本文整理汇总了Java中org.apache.hadoop.hbase.rest.model.TableListModel.getObjectFromMessage方法的典型用法代码示例。如果您正苦于以下问题:Java TableListModel.getObjectFromMessage方法的具体用法?Java TableListModel.getObjectFromMessage怎么用?Java TableListModel.getObjectFromMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hbase.rest.model.TableListModel
的用法示例。
在下文中一共展示了TableListModel.getObjectFromMessage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTableList
import org.apache.hadoop.hbase.rest.model.TableListModel; //导入方法依赖的package包/类
/**
* @return string representing the cluster's version
* @throws IOException
* if the endpoint does not exist, there is a timeout, or some other
* general failure mode
*/
public TableListModel getTableList() throws IOException {
StringBuilder path = new StringBuilder();
path.append('/');
if (accessToken != null) {
path.append(accessToken);
path.append('/');
}
int code = 0;
for (int i = 0; i < maxRetries; i++) {
// Response response = client.get(path.toString(),
// Constants.MIMETYPE_XML);
Response response = client.get(path.toString(),
Constants.MIMETYPE_PROTOBUF);
code = response.getCode();
switch (code) {
case 200:
TableListModel t = new TableListModel();
return (TableListModel) t.getObjectFromMessage(response.getBody());
case 404:
throw new IOException("Table list not found");
case 509:
try {
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
throw (InterruptedIOException)new InterruptedIOException().initCause(e);
}
break;
default:
throw new IOException("get request to " + path.toString()
+ " request returned " + code);
}
}
throw new IOException("get request to " + path.toString()
+ " request timed out");
}
示例2: getTableList
import org.apache.hadoop.hbase.rest.model.TableListModel; //导入方法依赖的package包/类
/**
* @return string representing the cluster's version
* @throws IOEXception
* if the endpoint does not exist, there is a timeout, or some other
* general failure mode
*/
public TableListModel getTableList() throws IOException {
StringBuilder path = new StringBuilder();
path.append('/');
if (accessToken != null) {
path.append(accessToken);
path.append('/');
}
int code = 0;
for (int i = 0; i < maxRetries; i++) {
// Response response = client.get(path.toString(),
// Constants.MIMETYPE_XML);
Response response = client.get(path.toString(),
Constants.MIMETYPE_PROTOBUF);
code = response.getCode();
switch (code) {
case 200:
TableListModel t = new TableListModel();
return (TableListModel) t.getObjectFromMessage(response.getBody());
case 404:
throw new IOException("Table list not found");
case 509:
try {
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
}
break;
default:
throw new IOException("get request to " + path.toString()
+ " request returned " + code);
}
}
throw new IOException("get request to " + path.toString()
+ " request timed out");
}
示例3: getTableList
import org.apache.hadoop.hbase.rest.model.TableListModel; //导入方法依赖的package包/类
/**
* @return string representing the cluster's version
* @throws IOEXception
* if the endpoint does not exist, there is a timeout, or some other
* general failure mode
*/
public TableListModel getTableList() throws IOException {
StringBuilder path = new StringBuilder();
path.append('/');
if (accessToken != null) {
path.append(accessToken);
path.append('/');
}
int code = 0;
for (int i = 0; i < maxRetries; i++) {
// Response response = client.get(path.toString(),
// Constants.MIMETYPE_XML);
Response response = client.get(path.toString(),
Constants.MIMETYPE_PROTOBUF);
code = response.getCode();
switch (code) {
case 200:
TableListModel t = new TableListModel();
return (TableListModel) t.getObjectFromMessage(response.getBody());
case 404:
throw new IOException("Table list not found");
case 509:
try {
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
throw (InterruptedIOException)new InterruptedIOException().initCause(e);
}
break;
default:
throw new IOException("get request to " + path.toString()
+ " request returned " + code);
}
}
throw new IOException("get request to " + path.toString()
+ " request timed out");
}
示例4: testGetNamespaceTablesAndCannotDeleteNamespace
import org.apache.hadoop.hbase.rest.model.TableListModel; //导入方法依赖的package包/类
@Test
public void testGetNamespaceTablesAndCannotDeleteNamespace() throws IOException, JAXBException {
Admin admin = TEST_UTIL.getAdmin();
String nsName = "TestNamespacesInstanceResource5";
Response response;
// Create namespace via admin.
NamespaceDescriptor.Builder nsBuilder = NamespaceDescriptor.create(nsName);
NamespaceDescriptor nsd = nsBuilder.build();
nsd.setConfiguration("key1", "value1");
admin.createNamespace(nsd);
// Create two tables via admin.
HColumnDescriptor colDesc = new HColumnDescriptor("cf1");
TableName tn1 = TableName.valueOf(nsName + ":table1");
HTableDescriptor table = new HTableDescriptor(tn1);
table.addFamily(colDesc);
admin.createTable(table);
TableName tn2 = TableName.valueOf(nsName + ":table2");
table = new HTableDescriptor(tn2);
table.addFamily(colDesc);
admin.createTable(table);
Map<String, String> nsProperties = new HashMap<>();
nsProperties.put("key1", "value1");
List<String> nsTables = Arrays.asList("table1", "table2");
// Check get namespace properties as XML, JSON and Protobuf.
String namespacePath = "/namespaces/" + nsName;
response = client.get(namespacePath);
assertEquals(200, response.getCode());
response = client.get(namespacePath, Constants.MIMETYPE_XML);
assertEquals(200, response.getCode());
NamespacesInstanceModel model = fromXML(response.getBody());
checkNamespaceProperties(model.getProperties(), nsProperties);
response = client.get(namespacePath, Constants.MIMETYPE_JSON);
assertEquals(200, response.getCode());
model = jsonMapper.readValue(response.getBody(), NamespacesInstanceModel.class);
checkNamespaceProperties(model.getProperties(), nsProperties);
response = client.get(namespacePath, Constants.MIMETYPE_PROTOBUF);
assertEquals(200, response.getCode());
model.getObjectFromMessage(response.getBody());
checkNamespaceProperties(model.getProperties(), nsProperties);
// Check get namespace tables as XML, JSON and Protobuf.
namespacePath = "/namespaces/" + nsName + "/tables";
response = client.get(namespacePath);
assertEquals(200, response.getCode());
response = client.get(namespacePath, Constants.MIMETYPE_XML);
assertEquals(200, response.getCode());
TableListModel tablemodel = fromXML(response.getBody());
checkNamespaceTables(tablemodel.getTables(), nsTables);
response = client.get(namespacePath, Constants.MIMETYPE_JSON);
assertEquals(200, response.getCode());
tablemodel = jsonMapper.readValue(response.getBody(), TableListModel.class);
checkNamespaceTables(tablemodel.getTables(), nsTables);
response = client.get(namespacePath, Constants.MIMETYPE_PROTOBUF);
assertEquals(200, response.getCode());
tablemodel.setTables(new ArrayList<>());
tablemodel.getObjectFromMessage(response.getBody());
checkNamespaceTables(tablemodel.getTables(), nsTables);
// Check cannot delete namespace via REST because it contains tables.
response = client.delete(namespacePath);
namespacePath = "/namespaces/" + nsName;
assertEquals(503, response.getCode());
}