@GET @Path("/clusters/{clusterId}/services/hive/databases/{dbName}/tables") @Timed public Response getDatabaseTablesByClusterId(@PathParam("clusterId") Long clusterId, @PathParam("dbName") String dbName, @Context SecurityContext securityContext) throws Exception { SecurityUtil.checkPermissions(authorizer, securityContext, Cluster.NAMESPACE, clusterId, READ); try(final HiveMetadataService hiveMetadataService = HiveMetadataService.newInstance(environmentService, clusterId, securityContext, subject)) { return WSUtils.respondEntity(hiveMetadataService.getHiveTables(dbName), OK); } catch (EntityNotFoundException ex) { throw com.hortonworks.streamline.common.exception.service.exception.request.EntityNotFoundException.byId(ex.getMessage()); } } }
@GET @Path("/clusters/{clusterId}/services/hive/databases") @Timed public Response getDatabasesByClusterId(@PathParam("clusterId") Long clusterId, @Context SecurityContext securityContext) throws Exception { SecurityUtil.checkPermissions(authorizer, securityContext, Cluster.NAMESPACE, clusterId, READ); try(final HiveMetadataService hiveMetadataService = HiveMetadataService.newInstance(environmentService, clusterId, securityContext, subject)) { return WSUtils.respondEntity(hiveMetadataService.getHiveDatabases(), OK); } catch (EntityNotFoundException ex) { throw com.hortonworks.streamline.common.exception.service.exception.request.EntityNotFoundException.byId(ex.getMessage()); } }
/** * Creates secure {@link HiveMetadataService}, which delegates to {@link HiveMetaStoreClient} instantiated with * default {@link HiveConf}, and {@code hivemetastore-site.xml} and {@code hive-site.xml} properties overridden * with the config for the cluster imported in the service pool (either manually or using Ambari) */ public static HiveMetadataService newInstance(EnvironmentService environmentService, Long clusterId, SecurityContext securityContext, Subject subject) throws MetaException, IOException, EntityNotFoundException, PrivilegedActionException { return newInstance(overrideConfig(environmentService, clusterId), securityContext, subject, getHiveMetastoreComponent(environmentService, clusterId), getHiveMetastores(environmentService, clusterId)); }