本文整理汇总了Java中org.apache.hadoop.hbase.rest.client.Response类的典型用法代码示例。如果您正苦于以下问题:Java Response类的具体用法?Java Response怎么用?Java Response使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Response类属于org.apache.hadoop.hbase.rest.client包,在下文中一共展示了Response类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDeleteNonExistentColumn
import org.apache.hadoop.hbase.rest.client.Response; //导入依赖的package包/类
@Test
public void testDeleteNonExistentColumn() throws Exception {
Response response = putValueJson(TABLE, ROW_1, COLUMN_1, VALUE_1);
assertEquals(response.getCode(), 200);
response = checkAndDeleteJson(TABLE, ROW_1, COLUMN_1, VALUE_2);
assertEquals(304, response.getCode());
assertEquals(200, getValueJson(TABLE, ROW_1, COLUMN_1).getCode());
response = checkAndDeleteJson(TABLE, ROW_2, COLUMN_1, VALUE_2);
assertEquals(304, response.getCode());
assertEquals(200, getValueJson(TABLE, ROW_1, COLUMN_1).getCode());
response = checkAndDeleteJson(TABLE, ROW_1, "dummy", VALUE_1);
assertEquals(400, response.getCode());
assertEquals(200, getValueJson(TABLE, ROW_1, COLUMN_1).getCode());
response = checkAndDeleteJson(TABLE, ROW_1, "dummy:test", VALUE_1);
assertEquals(404, response.getCode());
assertEquals(200, getValueJson(TABLE, ROW_1, COLUMN_1).getCode());
response = checkAndDeleteJson(TABLE, ROW_1, "a:test", VALUE_1);
assertEquals(304, response.getCode());
assertEquals(200, getValueJson(TABLE, ROW_1, COLUMN_1).getCode());
}
示例2: testCannotDeleteDefaultAndHbaseNamespaces
import org.apache.hadoop.hbase.rest.client.Response; //导入依赖的package包/类
@Test
public void testCannotDeleteDefaultAndHbaseNamespaces() throws IOException {
String defaultPath = "/namespaces/default";
String hbasePath = "/namespaces/hbase";
Response response;
// Check that doesn't exist via non-REST call.
Admin admin = TEST_UTIL.getHBaseAdmin();
assertNotNull(findNamespace(admin, "default"));
assertNotNull(findNamespace(admin, "hbase"));
// Try (but fail) to delete namespaces via REST.
response = client.delete(defaultPath);
assertEquals(503, response.getCode());
response = client.delete(hbasePath);
assertEquals(503, response.getCode());
assertNotNull(findNamespace(admin, "default"));
assertNotNull(findNamespace(admin, "hbase"));
}
示例3: testMultiCellGetJSON
import org.apache.hadoop.hbase.rest.client.Response; //导入依赖的package包/类
@Test
public void testMultiCellGetJSON() throws IOException, JAXBException {
String row_5_url = "/" + TABLE + "/" + ROW_1 + "/" + COLUMN_1;
String row_6_url = "/" + TABLE + "/" + ROW_2 + "/" + COLUMN_2;
StringBuilder path = new StringBuilder();
path.append("/");
path.append(TABLE);
path.append("/multiget/?row=");
path.append(ROW_1);
path.append("&row=");
path.append(ROW_2);
client.post(row_5_url, Constants.MIMETYPE_BINARY, Bytes.toBytes(VALUE_1));
client.post(row_6_url, Constants.MIMETYPE_BINARY, Bytes.toBytes(VALUE_2));
Response response = client.get(path.toString(), Constants.MIMETYPE_JSON);
assertEquals(response.getCode(), 200);
assertEquals(Constants.MIMETYPE_JSON, response.getHeader("content-type"));
client.delete(row_5_url);
client.delete(row_6_url);
}
示例4: testMultiCellGetXML
import org.apache.hadoop.hbase.rest.client.Response; //导入依赖的package包/类
@Test
public void testMultiCellGetXML() throws IOException, JAXBException {
String row_5_url = "/" + TABLE + "/" + ROW_1 + "/" + COLUMN_1;
String row_6_url = "/" + TABLE + "/" + ROW_2 + "/" + COLUMN_2;
StringBuilder path = new StringBuilder();
path.append("/");
path.append(TABLE);
path.append("/multiget/?row=");
path.append(ROW_1);
path.append("&row=");
path.append(ROW_2);
client.post(row_5_url, Constants.MIMETYPE_BINARY, Bytes.toBytes(VALUE_1));
client.post(row_6_url, Constants.MIMETYPE_BINARY, Bytes.toBytes(VALUE_2));
Response response = client.get(path.toString(), Constants.MIMETYPE_XML);
assertEquals(response.getCode(), 200);
assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
client.delete(row_5_url);
client.delete(row_6_url);
}
示例5: testMultiCellGetJSONNotFound
import org.apache.hadoop.hbase.rest.client.Response; //导入依赖的package包/类
@Test
public void testMultiCellGetJSONNotFound() throws IOException, JAXBException {
String row_5_url = "/" + TABLE + "/" + ROW_1 + "/" + COLUMN_1;
StringBuilder path = new StringBuilder();
path.append("/");
path.append(TABLE);
path.append("/multiget/?row=");
path.append(ROW_1);
path.append("&row=");
path.append(ROW_2);
client.post(row_5_url, Constants.MIMETYPE_BINARY, Bytes.toBytes(VALUE_1));
Response response = client.get(path.toString(), Constants.MIMETYPE_JSON);
assertEquals(response.getCode(), 200);
ObjectMapper mapper = new JacksonProvider().locateMapper(CellSetModel.class,
MediaType.APPLICATION_JSON_TYPE);
CellSetModel cellSet = (CellSetModel) mapper.readValue(response.getBody(), CellSetModel.class);
assertEquals(1, cellSet.getRows().size());
assertEquals(ROW_1, Bytes.toString(cellSet.getRows().get(0).getKey()));
assertEquals(VALUE_1, Bytes.toString(cellSet.getRows().get(0).getCells().get(0).getValue()));
client.delete(row_5_url);
}
示例6: testSimpleScannerXMLWithLabelsThatReceivesNoData
import org.apache.hadoop.hbase.rest.client.Response; //导入依赖的package包/类
@Test
public void testSimpleScannerXMLWithLabelsThatReceivesNoData() throws IOException, JAXBException {
final int BATCH_SIZE = 5;
// new scanner
ScannerModel model = new ScannerModel();
model.setBatch(BATCH_SIZE);
model.addColumn(Bytes.toBytes(COLUMN_1));
model.addLabel(PUBLIC);
StringWriter writer = new StringWriter();
marshaller.marshal(model, writer);
byte[] body = Bytes.toBytes(writer.toString());
// recall previous put operation with read-only off
conf.set("hbase.rest.readonly", "false");
Response response = client.put("/" + TABLE + "/scanner", Constants.MIMETYPE_XML, body);
assertEquals(response.getCode(), 201);
String scannerURI = response.getLocation();
assertNotNull(scannerURI);
// get a cell set
response = client.get(scannerURI, Constants.MIMETYPE_XML);
// Respond with 204 as there are no cells to be retrieved
assertEquals(response.getCode(), 204);
assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
}
示例7: testSingleCellGetPutXML
import org.apache.hadoop.hbase.rest.client.Response; //导入依赖的package包/类
@Test
public void testSingleCellGetPutXML() throws IOException, JAXBException {
Response response = getValueXML(TABLE, ROW_1, COLUMN_1);
assertEquals(response.getCode(), 404);
response = putValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1);
assertEquals(response.getCode(), 200);
checkValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1);
response = putValueXML(TABLE, ROW_1, COLUMN_1, VALUE_2);
assertEquals(response.getCode(), 200);
checkValueXML(TABLE, ROW_1, COLUMN_1, VALUE_2);
response = checkAndPutValueXML(TABLE, ROW_1, COLUMN_1, VALUE_2, VALUE_3);
assertEquals(response.getCode(), 200);
checkValueXML(TABLE, ROW_1, COLUMN_1, VALUE_3);
response = checkAndDeleteXML(TABLE, ROW_1, COLUMN_1, VALUE_3);
assertEquals(response.getCode(), 200);
response = deleteRow(TABLE, ROW_1);
assertEquals(response.getCode(), 200);
}
示例8: testSingleCellGetPutPB
import org.apache.hadoop.hbase.rest.client.Response; //导入依赖的package包/类
@Test
public void testSingleCellGetPutPB() throws IOException, JAXBException {
Response response = getValuePB(TABLE, ROW_1, COLUMN_1);
assertEquals(response.getCode(), 404);
response = putValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1);
assertEquals(response.getCode(), 200);
checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1);
response = putValueXML(TABLE, ROW_1, COLUMN_1, VALUE_2);
assertEquals(response.getCode(), 200);
checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_2);
response = checkAndPutValuePB(TABLE, ROW_1, COLUMN_1, VALUE_2, VALUE_3);
assertEquals(response.getCode(), 200);
checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_3);
response = checkAndPutValueXML(TABLE, ROW_1, COLUMN_1, VALUE_3, VALUE_4);
assertEquals(response.getCode(), 200);
checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_4);
response = deleteRow(TABLE, ROW_1);
assertEquals(response.getCode(), 200);
}
示例9: testURLEncodedKey
import org.apache.hadoop.hbase.rest.client.Response; //导入依赖的package包/类
@Test
public void testURLEncodedKey() throws IOException, JAXBException {
String urlKey = "http://example.com/foo";
StringBuilder path = new StringBuilder();
path.append('/');
path.append(TABLE);
path.append('/');
path.append(URLEncoder.encode(urlKey, HConstants.UTF8_ENCODING));
path.append('/');
path.append(COLUMN_1);
Response response;
response = putValueXML(path.toString(), TABLE, urlKey, COLUMN_1,
VALUE_1);
assertEquals(response.getCode(), 200);
checkValueXML(path.toString(), TABLE, urlKey, COLUMN_1, VALUE_1);
}
示例10: testInvalidCheckParam
import org.apache.hadoop.hbase.rest.client.Response; //导入依赖的package包/类
@Test
public void testInvalidCheckParam() throws IOException, JAXBException {
CellSetModel cellSetModel = new CellSetModel();
RowModel rowModel = new RowModel(ROW_1);
rowModel.addCell(new CellModel(Bytes.toBytes(COLUMN_1),
Bytes.toBytes(VALUE_1)));
cellSetModel.addRow(rowModel);
StringWriter writer = new StringWriter();
xmlMarshaller.marshal(cellSetModel, writer);
final String path = "/" + TABLE + "/" + ROW_1 + "/" + COLUMN_1 + "?check=blah";
Response response = client.put(path, Constants.MIMETYPE_XML,
Bytes.toBytes(writer.toString()));
assertEquals(response.getCode(), 400);
}
示例11: testInvalidColumnPut
import org.apache.hadoop.hbase.rest.client.Response; //导入依赖的package包/类
@Test
public void testInvalidColumnPut() throws IOException, JAXBException {
String dummyColumn = "doesnot:exist";
CellSetModel cellSetModel = new CellSetModel();
RowModel rowModel = new RowModel(ROW_1);
rowModel.addCell(new CellModel(Bytes.toBytes(dummyColumn),
Bytes.toBytes(VALUE_1)));
cellSetModel.addRow(rowModel);
StringWriter writer = new StringWriter();
xmlMarshaller.marshal(cellSetModel, writer);
final String path = "/" + TABLE + "/" + ROW_1 + "/" + dummyColumn;
Response response = client.put(path, Constants.MIMETYPE_XML,
Bytes.toBytes(writer.toString()));
assertEquals(response.getCode(), 404);
}
示例12: testMetrics
import org.apache.hadoop.hbase.rest.client.Response; //导入依赖的package包/类
@Test
public void testMetrics() throws IOException, JAXBException {
final String path = "/" + TABLE + "/" + ROW_4 + "/" + COLUMN_1;
Response response = client.put(path, Constants.MIMETYPE_BINARY,
Bytes.toBytes(VALUE_4));
assertEquals(response.getCode(), 200);
Thread.yield();
response = client.get(path, Constants.MIMETYPE_JSON);
assertEquals(response.getCode(), 200);
assertEquals(Constants.MIMETYPE_JSON, response.getHeader("content-type"));
response = deleteRow(TABLE, ROW_4);
assertEquals(response.getCode(), 200);
UserProvider userProvider = UserProvider.instantiate(conf);
METRICS_ASSERT.assertCounterGt("requests", 2l,
RESTServlet.getInstance(conf, userProvider).getMetrics().getSource());
METRICS_ASSERT.assertCounterGt("successfulGet", 0l,
RESTServlet.getInstance(conf, userProvider).getMetrics().getSource());
METRICS_ASSERT.assertCounterGt("successfulPut", 0l,
RESTServlet.getInstance(conf, userProvider).getMetrics().getSource());
METRICS_ASSERT.assertCounterGt("successfulDelete", 0l,
RESTServlet.getInstance(conf, userProvider).getMetrics().getSource());
}
示例13: testGetStargateVersionText
import org.apache.hadoop.hbase.rest.client.Response; //导入依赖的package包/类
@Test
public void testGetStargateVersionText() throws IOException {
Response response = client.get("/version", Constants.MIMETYPE_TEXT);
assertTrue(response.getCode() == 200);
assertEquals(Constants.MIMETYPE_TEXT, response.getHeader("content-type"));
String body = Bytes.toString(response.getBody());
assertTrue(body.length() > 0);
assertTrue(body.contains(RESTServlet.VERSION_STRING));
assertTrue(body.contains(System.getProperty("java.vm.vendor")));
assertTrue(body.contains(System.getProperty("java.version")));
assertTrue(body.contains(System.getProperty("java.vm.version")));
assertTrue(body.contains(System.getProperty("os.name")));
assertTrue(body.contains(System.getProperty("os.version")));
assertTrue(body.contains(System.getProperty("os.arch")));
assertTrue(body.contains(ServletContainer.class.getPackage()
.getImplementationVersion()));
}
示例14: testScanningUnknownColumnJson
import org.apache.hadoop.hbase.rest.client.Response; //导入依赖的package包/类
@Test
public void testScanningUnknownColumnJson() throws IOException, JAXBException {
// Test scanning particular columns with limit.
StringBuilder builder = new StringBuilder();
builder.append("/*");
builder.append("?");
builder.append(Constants.SCAN_COLUMN + "=a:test");
Response response = client.get("/" + TABLE + builder.toString(),
Constants.MIMETYPE_JSON);
assertEquals(200, response.getCode());
assertEquals(Constants.MIMETYPE_JSON, response.getHeader("content-type"));
ObjectMapper mapper = new JacksonProvider().locateMapper(CellSetModel.class,
MediaType.APPLICATION_JSON_TYPE);
CellSetModel model = mapper.readValue(response.getStream(), CellSetModel.class);
int count = TestScannerResource.countCellSet(model);
assertEquals(0, count);
}
示例15: testSimpleFilter
import org.apache.hadoop.hbase.rest.client.Response; //导入依赖的package包/类
@Test
public void testSimpleFilter() throws IOException, JAXBException {
StringBuilder builder = new StringBuilder();
builder = new StringBuilder();
builder.append("/*");
builder.append("?");
builder.append(Constants.SCAN_COLUMN + "=" + COLUMN_1);
builder.append("&");
builder.append(Constants.SCAN_START_ROW + "=aaa");
builder.append("&");
builder.append(Constants.SCAN_END_ROW + "=aay");
builder.append("&");
builder.append(Constants.SCAN_FILTER + "=" + URLEncoder.encode("PrefixFilter('aab')", "UTF-8"));
Response response =
client.get("/" + TABLE + builder.toString(), Constants.MIMETYPE_XML);
assertEquals(200, response.getCode());
JAXBContext ctx = JAXBContext.newInstance(CellSetModel.class);
Unmarshaller ush = ctx.createUnmarshaller();
CellSetModel model = (CellSetModel) ush.unmarshal(response.getStream());
int count = TestScannerResource.countCellSet(model);
assertEquals(1, count);
assertEquals("aab", new String(model.getRows().get(0).getCells().get(0).getValue()));
}