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

@ -92,16 +92,19 @@ public class HBasePlugin {
/** /**
* get style, read according to rowKey * get style, read according to rowKey
*
* @param rowkey * @param rowkey
* @throws IOException * @throws IOException
* @return * @return
*/ */
@SuppressWarnings("deprecation")
@Behavior(value = "Get", type = BehaviorType.USER_BEHAVIOR) @Behavior(value = "Get", type = BehaviorType.USER_BEHAVIOR)
public HBaseReturn get(@Parameter(value = "rowkey", type = SupportTypes.Field) String rowkey) { public HBaseReturn get(
@Parameter(value = "rowkey", type = SupportTypes.Field) String rowkey) {
try { try {
Get g = new Get(Bytes.toBytes(rowkey)); Get g = new Get(Bytes.toBytes(rowkey));
Result r = tableUnderTest.get(g); Result r = tableUnderTest.get(g);
for(KeyValue kv : r.raw()){ for (KeyValue kv : r.raw()) {
System.out.println("column: " + new String(kv.getRow())); System.out.println("column: " + new String(kv.getRow()));
System.out.println("value: " + new String(kv.getValue())); System.out.println("value: " + new String(kv.getValue()));
} }
@ -112,47 +115,48 @@ public class HBasePlugin {
} }
} }
/**
* 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")
* 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) @Behavior(value = "Scan", type = BehaviorType.USER_BEHAVIOR)
public HBaseReturn scan(@Parameter(value = "startkey", type = SupportTypes.Field) String startkey, public HBaseReturn scan(
@Parameter(value = "recordcount", type = SupportTypes.Field) String recordcount) @Parameter(value = "startkey", type = SupportTypes.Field) String startkey,
{ @Parameter(value = "recordcount", type = SupportTypes.Field) String recordcount) {
Scan s = new Scan(Bytes.toBytes(startkey)); Scan s = new Scan(Bytes.toBytes(startkey));
Integer count = Integer.getInteger(recordcount); Integer count = Integer.getInteger(recordcount);
s.setCaching(count); s.setCaching(count);
ResultScanner scanner = null; ResultScanner scanner = null;
try { try {
scanner = tableUnderTest.getScanner(s); scanner = tableUnderTest.getScanner(s);
int numResults = 0; int numResults = 0;
for (Result rr = scanner.next(); rr != null; rr = scanner.next()) for (Result rr = scanner.next(); rr != null; rr = scanner.next()) {
{
String key = Bytes.toString(rr.getRow()); for (KeyValue kv : rr.raw()) {
for (KeyValue kv : rr.raw()) { System.out.println("result: key =" + kv.getQualifier()
System.out.println("result: key =" + kv.getQualifier() + " value = " + kv.getValue()); + " value = " + kv.getValue());
} }
numResults++; numResults++;
if (numResults >= count) if (numResults >= count) {
{ break;
break; }
} }
}
}catch (IOException e) { } catch (IOException e) {
Logger.getLogger(HBasePlugin.class).info(e, e); Logger.getLogger(HBasePlugin.class).info(e, e);
return new HBaseReturn(false); return new HBaseReturn(false);
}finally { } finally {
scanner.close(); scanner.close();
} }
return new HBaseReturn(true); return new HBaseReturn(true);
} }
} }