当前位置: 首页>>代码示例>>Java>>正文


Java TableListModel.getObjectFromMessage方法代码示例

本文整理汇总了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");
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:44,代码来源:RemoteAdmin.java

示例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");
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:43,代码来源:RemoteAdmin.java

示例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");
}
 
开发者ID:shenli-uiuc,项目名称:PyroDB,代码行数:44,代码来源:RemoteAdmin.java

示例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());
}
 
开发者ID:apache,项目名称:hbase,代码行数:74,代码来源:TestNamespacesInstanceResource.java


注:本文中的org.apache.hadoop.hbase.rest.model.TableListModel.getObjectFromMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。