use of org.apache.hadoop.hbase.rest.model.TableModel in project hbase by apache.
the class TestNamespacesInstanceResource method checkNamespaceTables.
private void checkNamespaceTables(List<TableModel> namespaceTables, List<String> testTables) {
assertEquals(namespaceTables.size(), testTables.size());
for (TableModel namespaceTable : namespaceTables) {
String tableName = namespaceTable.getName();
assertTrue(testTables.contains(tableName));
}
}
use of org.apache.hadoop.hbase.rest.model.TableModel in project hbase by apache.
the class RootResource method getTableList.
private final TableListModel getTableList() throws IOException {
TableListModel tableList = new TableListModel();
TableName[] tableNames = servlet.getAdmin().listTableNames();
for (TableName name : tableNames) {
tableList.add(new TableModel(name.getNameAsString()));
}
return tableList;
}
use of org.apache.hadoop.hbase.rest.model.TableModel in project hbase by apache.
the class NamespacesInstanceResource method get.
/**
* Build a response for GET namespace description or GET list of namespace tables.
* @param context servlet context
* @param uriInfo (JAX-RS context variable) request URL
* @return A response containing NamespacesInstanceModel for a namespace descriptions and
* TableListModel for a list of namespace tables.
*/
@GET
@Produces({ MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF, MIMETYPE_PROTOBUF_IETF })
public Response get(@Context final ServletContext context, @Context final UriInfo uriInfo) {
if (LOG.isTraceEnabled()) {
LOG.trace("GET " + uriInfo.getAbsolutePath());
}
servlet.getMetrics().incrementRequests(1);
// Respond to list of namespace tables requests.
if (queryTables) {
TableListModel tableModel = new TableListModel();
try {
List<TableDescriptor> tables = servlet.getAdmin().listTableDescriptorsByNamespace(Bytes.toBytes(namespace));
for (TableDescriptor table : tables) {
tableModel.add(new TableModel(table.getTableName().getQualifierAsString()));
}
servlet.getMetrics().incrementSucessfulGetRequests(1);
return Response.ok(tableModel).build();
} catch (IOException e) {
servlet.getMetrics().incrementFailedGetRequests(1);
throw new RuntimeException("Cannot retrieve table list for '" + namespace + "'.");
}
}
// Respond to namespace description requests.
try {
NamespacesInstanceModel rowModel = new NamespacesInstanceModel(servlet.getAdmin(), namespace);
servlet.getMetrics().incrementSucessfulGetRequests(1);
return Response.ok(rowModel).build();
} catch (IOException e) {
servlet.getMetrics().incrementFailedGetRequests(1);
throw new RuntimeException("Cannot retrieve info for '" + namespace + "'.");
}
}
use of org.apache.hadoop.hbase.rest.model.TableModel in project hbase by apache.
the class TestTableResource method checkTableList.
private static void checkTableList(TableListModel model) {
boolean found = false;
Iterator<TableModel> tables = model.getTables().iterator();
assertTrue(tables.hasNext());
while (tables.hasNext()) {
TableModel table = tables.next();
if (table.getName().equals(TABLE.getNameAsString())) {
found = true;
break;
}
}
assertTrue(found);
}
Aggregations