remove a warning from agent

remove a warning from agent
This commit is contained in:
coderfengyun 2014-08-29 08:58:42 +08:00
parent ccc212b13f
commit 77168b6ac7
1 changed files with 60 additions and 56 deletions

View File

@ -68,91 +68,95 @@ public class HBasePlugin {
} catch (Exception ex) {
Logger.getLogger(HBasePlugin.class).info(ex, ex);
return new HBaseReturn(false);
}
}
}
@Behavior(value = "Query", type = BehaviorType.USER_BEHAVIOR)
public HBaseReturn query(
@Parameter(value = "key", type = SupportTypes.Field) String key) {
try {
try {
Filter filter = new SingleColumnValueFilter(Bytes.toBytes("key1"),
Bytes.toBytes("key1"), CompareOp.EQUAL, Bytes.toBytes(key));
Bytes.toBytes("key1"), CompareOp.EQUAL, Bytes.toBytes(key));
Scan s = new Scan();
s.setFilter(filter);
ResultScanner resultScanner = this.tableUnderTest.getScanner(s);
for (Result r : resultScanner) {
System.out.println("get the row key:" + new String(r.getRow()));
}
return new HBaseReturn(true);
return new HBaseReturn(true);
} catch (Exception ex) {
Logger.getLogger(HBasePlugin.class).info(ex, ex);
return new HBaseReturn(false);
}
}
}
/**
* get style, read according to rowKey
*
* @param rowkey
* @throws IOException
* @return
*/
@SuppressWarnings("deprecation")
@Behavior(value = "Get", type = BehaviorType.USER_BEHAVIOR)
public HBaseReturn get(@Parameter(value = "rowkey", type = SupportTypes.Field) String rowkey) {
try {
public HBaseReturn get(
@Parameter(value = "rowkey", type = SupportTypes.Field) String rowkey) {
try {
Get g = new Get(Bytes.toBytes(rowkey));
Result r = tableUnderTest.get(g);
for(KeyValue kv : r.raw()){
Result r = tableUnderTest.get(g);
for (KeyValue kv : r.raw()) {
System.out.println("column: " + new String(kv.getRow()));
System.out.println("value: " + new String(kv.getValue()));
}
}
return new HBaseReturn(true);
} catch (IOException ex) {
Logger.getLogger(HBasePlugin.class).info(ex, ex);
Logger.getLogger(HBasePlugin.class).info(ex, ex);
return new HBaseReturn(false);
}
}
}
/**
* Perform a range scan for a set of records in the database.
*
* @param startkey
* The record key of the first record to read.
* @param recordcount
* The number of records to read
* @return
*/
@SuppressWarnings("deprecation")
@Behavior(value = "Scan", type = BehaviorType.USER_BEHAVIOR)
public HBaseReturn scan(
@Parameter(value = "startkey", type = SupportTypes.Field) String startkey,
@Parameter(value = "recordcount", type = SupportTypes.Field) String recordcount) {
Scan s = new Scan(Bytes.toBytes(startkey));
Integer count = Integer.getInteger(recordcount);
s.setCaching(count);
ResultScanner scanner = null;
try {
scanner = tableUnderTest.getScanner(s);
int numResults = 0;
for (Result rr = scanner.next(); rr != null; rr = scanner.next()) {
for (KeyValue kv : rr.raw()) {
System.out.println("result: key =" + kv.getQualifier()
+ " value = " + kv.getValue());
}
numResults++;
if (numResults >= count) {
break;
}
}
} catch (IOException e) {
Logger.getLogger(HBasePlugin.class).info(e, e);
return new HBaseReturn(false);
} finally {
scanner.close();
}
return new HBaseReturn(true);
}
/**
* Perform a range scan for a set of records in the database.
* @param startkey The record key of the first record to read.
* @param recordcount The number of records to read
* @return
*/
@Behavior(value = "Scan", type = BehaviorType.USER_BEHAVIOR)
public HBaseReturn scan(@Parameter(value = "startkey", type = SupportTypes.Field) String startkey,
@Parameter(value = "recordcount", type = SupportTypes.Field) String recordcount)
{
Scan s = new Scan(Bytes.toBytes(startkey));
Integer count = Integer.getInteger(recordcount);
s.setCaching(count);
ResultScanner scanner = null;
try {
scanner = tableUnderTest.getScanner(s);
int numResults = 0;
for (Result rr = scanner.next(); rr != null; rr = scanner.next())
{
String key = Bytes.toString(rr.getRow());
for (KeyValue kv : rr.raw()) {
System.out.println("result: key =" + kv.getQualifier() + " value = " + kv.getValue());
}
numResults++;
if (numResults >= count)
{
break;
}
}
}catch (IOException e) {
Logger.getLogger(HBasePlugin.class).info(e, e);
return new HBaseReturn(false);
}finally {
scanner.close();
}
return new HBaseReturn(true);
}
}