Search in sources :

Example 1 with TableModel

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));
    }
}
Also used : TableModel(org.apache.hadoop.hbase.rest.model.TableModel)

Example 2 with TableModel

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;
}
Also used : TableName(org.apache.hadoop.hbase.TableName) TableListModel(org.apache.hadoop.hbase.rest.model.TableListModel) TableModel(org.apache.hadoop.hbase.rest.model.TableModel)

Example 3 with TableModel

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 + "'.");
    }
}
Also used : TableListModel(org.apache.hadoop.hbase.rest.model.TableListModel) NamespacesInstanceModel(org.apache.hadoop.hbase.rest.model.NamespacesInstanceModel) IOException(java.io.IOException) TableDescriptor(org.apache.hadoop.hbase.client.TableDescriptor) TableModel(org.apache.hadoop.hbase.rest.model.TableModel) Produces(org.apache.hbase.thirdparty.javax.ws.rs.Produces) GET(org.apache.hbase.thirdparty.javax.ws.rs.GET)

Example 4 with TableModel

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);
}
Also used : TableModel(org.apache.hadoop.hbase.rest.model.TableModel)

Aggregations

TableModel (org.apache.hadoop.hbase.rest.model.TableModel)4 TableListModel (org.apache.hadoop.hbase.rest.model.TableListModel)2 IOException (java.io.IOException)1 TableName (org.apache.hadoop.hbase.TableName)1 TableDescriptor (org.apache.hadoop.hbase.client.TableDescriptor)1 NamespacesInstanceModel (org.apache.hadoop.hbase.rest.model.NamespacesInstanceModel)1 GET (org.apache.hbase.thirdparty.javax.ws.rs.GET)1 Produces (org.apache.hbase.thirdparty.javax.ws.rs.Produces)1