本文整理匯總了Java中org.apache.hadoop.hbase.client.Admin.deleteNamespace方法的典型用法代碼示例。如果您正苦於以下問題:Java Admin.deleteNamespace方法的具體用法?Java Admin.deleteNamespace怎麽用?Java Admin.deleteNamespace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.hadoop.hbase.client.Admin
的用法示例。
在下文中一共展示了Admin.deleteNamespace方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: deleteNoBody
import org.apache.hadoop.hbase.client.Admin; //導入方法依賴的package包/類
/**
* Build a response for DELETE delete namespace.
* @param message value not used.
* @param headers value not used.
* @return response code.
*/
@DELETE
public Response deleteNoBody(final byte[] message,
final @Context UriInfo uriInfo, final @Context HttpHeaders headers) {
if (LOG.isDebugEnabled()) {
LOG.debug("DELETE " + uriInfo.getAbsolutePath());
}
if (servlet.isReadOnly()) {
servlet.getMetrics().incrementFailedDeleteRequests(1);
return Response.status(Response.Status.FORBIDDEN).type(MIMETYPE_TEXT)
.entity("Forbidden" + CRLF).build();
}
try{
Admin admin = servlet.getAdmin();
if (!doesNamespaceExist(admin, namespace)){
return Response.status(Response.Status.NOT_FOUND).type(MIMETYPE_TEXT).
entity("Namespace '" + namespace + "' does not exists. Cannot " +
"drop namespace.").build();
}
admin.deleteNamespace(namespace);
servlet.getMetrics().incrementSucessfulDeleteRequests(1);
return Response.ok().build();
} catch (IOException e) {
servlet.getMetrics().incrementFailedDeleteRequests(1);
return processException(e);
}
}
示例2: testNamespaceOperations
import org.apache.hadoop.hbase.client.Admin; //導入方法依賴的package包/類
@Test (timeout=180000)
public void testNamespaceOperations() throws Exception {
MiniHBaseCluster cluster = UTIL.getHBaseCluster();
String testNamespace = "observed_ns";
HMaster master = cluster.getMaster();
MasterCoprocessorHost host = master.getMasterCoprocessorHost();
CPMasterObserver cp = (CPMasterObserver)host.findCoprocessor(
CPMasterObserver.class.getName());
cp.enableBypass(false);
cp.resetStates();
// create a table
Admin admin = UTIL.getHBaseAdmin();
admin.createNamespace(NamespaceDescriptor.create(testNamespace).build());
assertTrue("Test namespace should be created", cp.wasCreateNamespaceCalled());
assertNotNull(admin.getNamespaceDescriptor(testNamespace));
assertTrue("Test namespace descriptor should have been called",
cp.wasGetNamespaceDescriptorCalled());
// turn off bypass, run the tests again
cp.enableBypass(true);
cp.resetStates();
admin.modifyNamespace(NamespaceDescriptor.create(testNamespace).build());
assertTrue("Test namespace should not have been modified",
cp.preModifyNamespaceCalledOnly());
assertNotNull(admin.getNamespaceDescriptor(testNamespace));
assertTrue("Test namespace descriptor should have been called",
cp.wasGetNamespaceDescriptorCalled());
admin.deleteNamespace(testNamespace);
assertTrue("Test namespace should not have been deleted", cp.preDeleteNamespaceCalledOnly());
assertNotNull(admin.getNamespaceDescriptor(testNamespace));
assertTrue("Test namespace descriptor should have been called",
cp.wasGetNamespaceDescriptorCalled());
cp.enableBypass(false);
cp.resetStates();
// delete table
admin.modifyNamespace(NamespaceDescriptor.create(testNamespace).build());
assertTrue("Test namespace should have been modified", cp.wasModifyNamespaceCalled());
admin.deleteNamespace(testNamespace);
assertTrue("Test namespace should have been deleted", cp.wasDeleteNamespaceCalled());
cp.enableBypass(true);
cp.resetStates();
admin.createNamespace(NamespaceDescriptor.create(testNamespace).build());
assertTrue("Test namespace should not be created", cp.preCreateNamespaceCalledOnly());
// turn on bypass, run the test
cp.enableBypass(true);
cp.resetStates();
admin.listNamespaceDescriptors();
assertTrue("post listNamespace should not have been called",
cp.preListNamespaceDescriptorsCalledOnly());
// turn off bypass, run the tests again
cp.enableBypass(false);
cp.resetStates();
admin.listNamespaceDescriptors();
assertTrue("post listNamespace should have been called",
cp.wasListNamespaceDescriptorsCalled());
}
示例3: testNamespaceListXMLandJSON
import org.apache.hadoop.hbase.client.Admin; //導入方法依賴的package包/類
@Test
public void testNamespaceListXMLandJSON() throws IOException, JAXBException {
String namespacePath = "/namespaces/";
NamespacesModel model;
Response response;
// Check that namespace does not yet exist via non-REST call.
Admin admin = TEST_UTIL.getHBaseAdmin();
assertFalse(doesNamespaceExist(admin, NAMESPACE1));
model = testNamespacesModel.buildTestModel();
testNamespacesModel.checkModel(model);
// Check that REST GET finds only default namespaces via XML and JSON responses.
response = client.get(namespacePath, Constants.MIMETYPE_XML);
assertEquals(200, response.getCode());
model = fromXML(response.getBody());
testNamespacesModel.checkModel(model, "hbase", "default");
response = client.get(namespacePath, Constants.MIMETYPE_JSON);
assertEquals(200, response.getCode());
model = testNamespacesModel.fromJSON(Bytes.toString(response.getBody()));
testNamespacesModel.checkModel(model, "hbase", "default");
// Create namespace and check that REST GET finds one additional namespace.
createNamespaceViaAdmin(admin, NAMESPACE1);
response = client.get(namespacePath, Constants.MIMETYPE_XML);
assertEquals(200, response.getCode());
model = fromXML(response.getBody());
testNamespacesModel.checkModel(model, NAMESPACE1, "hbase", "default");
response = client.get(namespacePath, Constants.MIMETYPE_JSON);
assertEquals(200, response.getCode());
model = testNamespacesModel.fromJSON(Bytes.toString(response.getBody()));
testNamespacesModel.checkModel(model, NAMESPACE1, "hbase", "default");
// Create another namespace and check that REST GET finds one additional namespace.
createNamespaceViaAdmin(admin, NAMESPACE2);
response = client.get(namespacePath, Constants.MIMETYPE_XML);
assertEquals(200, response.getCode());
model = fromXML(response.getBody());
testNamespacesModel.checkModel(model, NAMESPACE1, NAMESPACE2, "hbase", "default");
response = client.get(namespacePath, Constants.MIMETYPE_JSON);
assertEquals(200, response.getCode());
model = testNamespacesModel.fromJSON(Bytes.toString(response.getBody()));
testNamespacesModel.checkModel(model, NAMESPACE1, NAMESPACE2, "hbase", "default");
// Delete namespace and check that REST still finds correct namespaces.
admin.deleteNamespace(NAMESPACE1);
response = client.get(namespacePath, Constants.MIMETYPE_XML);
assertEquals(200, response.getCode());
model = fromXML(response.getBody());
testNamespacesModel.checkModel(model, NAMESPACE2, "hbase", "default");
response = client.get(namespacePath, Constants.MIMETYPE_JSON);
assertEquals(200, response.getCode());
model = testNamespacesModel.fromJSON(Bytes.toString(response.getBody()));
testNamespacesModel.checkModel(model, NAMESPACE2, "hbase", "default");
admin.deleteNamespace(NAMESPACE2);
}
示例4: testNamespaceListPBandDefault
import org.apache.hadoop.hbase.client.Admin; //導入方法依賴的package包/類
@Test
public void testNamespaceListPBandDefault() throws IOException, JAXBException {
String schemaPath = "/namespaces/";
NamespacesModel model;
Response response;
// Check that namespace does not yet exist via non-REST call.
Admin admin = TEST_UTIL.getHBaseAdmin();
assertFalse(doesNamespaceExist(admin, NAMESPACE1));
model = testNamespacesModel.buildTestModel();
testNamespacesModel.checkModel(model);
// Check that REST GET finds only default namespaces via PB and default Accept header.
response = client.get(schemaPath, Constants.MIMETYPE_PROTOBUF);
assertEquals(200, response.getCode());
model.getObjectFromMessage(response.getBody());
testNamespacesModel.checkModel(model, "hbase", "default");
response = client.get(schemaPath);
assertEquals(200, response.getCode());
// Create namespace and check that REST GET finds one additional namespace.
createNamespaceViaAdmin(admin, NAMESPACE1);
response = client.get(schemaPath, Constants.MIMETYPE_PROTOBUF);
assertEquals(200, response.getCode());
model.getObjectFromMessage(response.getBody());
testNamespacesModel.checkModel(model, NAMESPACE1, "hbase", "default");
response = client.get(schemaPath);
assertEquals(200, response.getCode());
// Create another namespace and check that REST GET finds one additional namespace.
createNamespaceViaAdmin(admin, NAMESPACE2);
response = client.get(schemaPath, Constants.MIMETYPE_PROTOBUF);
assertEquals(200, response.getCode());
model.getObjectFromMessage(response.getBody());
testNamespacesModel.checkModel(model, NAMESPACE1, NAMESPACE2, "hbase", "default");
response = client.get(schemaPath);
assertEquals(200, response.getCode());
// Delete namespace and check that REST GET still finds correct namespaces.
admin.deleteNamespace(NAMESPACE1);
response = client.get(schemaPath, Constants.MIMETYPE_PROTOBUF);
assertEquals(200, response.getCode());
model.getObjectFromMessage(response.getBody());
testNamespacesModel.checkModel(model, NAMESPACE2, "hbase", "default");
response = client.get(schemaPath);
assertEquals(200, response.getCode());
admin.deleteNamespace(NAMESPACE2);
}