use of org.apache.hbase.thirdparty.javax.ws.rs.GET 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 + "'.");
}
}
Aggregations