@Override public Map<String, Object> getHintsOnCluster(Cluster cluster, SecurityContext securityContext, Subject subject) { Map<String, Object> hintMap = new HashMap<>(); try (HBaseMetadataService hBaseMetadataService = HBaseMetadataService.newInstance(environmentService, cluster.getId(), securityContext, subject)) { hintMap.put(FIELD_NAME_TABLE, hBaseMetadataService.getHBaseTables().getTables()); } catch (ServiceNotFoundException e) { // we access it from mapping information so shouldn't be here throw new IllegalStateException("Service " + Constants.HBase.SERVICE_NAME + " in cluster " + cluster.getName() + " not found but mapping information exists."); } catch (ServiceConfigurationNotFoundException e) { // there's HBASE service but not enough configuration info. } catch (Exception e) { throw new RuntimeException(e); } return hintMap; }
@GET @Path("/clusters/{clusterId}/services/hbase/namespaces/{namespace}/tables") @Timed public Response getNamespaceTablesByClusterId(@PathParam("clusterId") Long clusterId, @PathParam("namespace") String namespace, @Context SecurityContext securityContext) throws Exception { SecurityUtil.checkPermissions(authorizer, securityContext, Cluster.NAMESPACE, clusterId, READ); try (HBaseMetadataService hbaseMetadataService = HBaseMetadataService .newInstance(environmentService, clusterId, securityContext, subject)) { return WSUtils.respondEntity(Subject.doAs(subject, (PrivilegedExceptionAction<Tables>)() -> hbaseMetadataService.getHBaseTables(namespace)), OK); } catch (EntityNotFoundException ex) { throw com.hortonworks.streamline.common.exception.service.exception.request.EntityNotFoundException.byId(ex.getMessage()); } } }