本文整理汇总了Java中org.apache.hadoop.hbase.rest.client.Response.getCode方法的典型用法代码示例。如果您正苦于以下问题:Java Response.getCode方法的具体用法?Java Response.getCode怎么用?Java Response.getCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hbase.rest.client.Response
的用法示例。
在下文中一共展示了Response.getCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fullTableScan
import org.apache.hadoop.hbase.rest.client.Response; //导入方法依赖的package包/类
private static int fullTableScan(ScannerModel model) throws IOException {
model.setBatch(100);
Response response = client.put("/" + TABLE + "/scanner",
Constants.MIMETYPE_PROTOBUF, model.createProtobufOutput());
assertEquals(response.getCode(), 201);
String scannerURI = response.getLocation();
assertNotNull(scannerURI);
int count = 0;
while (true) {
response = client.get(scannerURI, Constants.MIMETYPE_PROTOBUF);
assertTrue(response.getCode() == 200 || response.getCode() == 204);
if (response.getCode() == 200) {
assertEquals(Constants.MIMETYPE_PROTOBUF, response.getHeader("content-type"));
CellSetModel cellSet = new CellSetModel();
cellSet.getObjectFromMessage(response.getBody());
Iterator<RowModel> rows = cellSet.getRows().iterator();
while (rows.hasNext()) {
RowModel row = rows.next();
Iterator<CellModel> cells = row.getCells().iterator();
while (cells.hasNext()) {
cells.next();
count++;
}
}
} else {
break;
}
}
// delete the scanner
response = client.delete(scannerURI);
assertEquals(response.getCode(), 200);
return count;
}
示例2: test
import org.apache.hadoop.hbase.rest.client.Response; //导入方法依赖的package包/类
public String test() throws JRException {
try {
if (client != null) {
Response response = client.get("/");
if (response.getCode() < 400) {
return "Connected successfully.";
}
}
} catch (Exception e) {
throw new JRException(e);
}
throw new JRException("Couldn't connect to HBase.");
}