/** * @return List of storm topologies as returned by Storm's REST API */ public StormTopologies getTopologies() throws IOException, PrivilegedActionException { return executeSecure(() -> { final Map<String, ?> jsonAsMap = JsonClientUtil.getEntity(httpClient.target(tplgySumUrl), Map.class); List<String> topologies = Collections.emptyList(); if (jsonAsMap != null) { final List<Map<String, String>> topologiesSummary = (List<Map<String, String>>) jsonAsMap.get(STORM_REST_API_TOPOLOGIES_KEY); if (topologiesSummary != null) { topologies = new ArrayList<>(topologiesSummary.size()); for (Map<String, String> tpSum : topologiesSummary) { topologies.add(tpSum.get(STORM_REST_API_TOPOLOGY_ID_KEY)); } } } return new StormTopologies(topologies, getSecurity()); } ); }
public Security getSecurity() throws IOException { return new Security(securityContext, new Authorizer(false), getPrincipals(), getKeytabs()); } }
public Principals getPrincipals() throws IOException { return Principals.fromAmbariConfig(stormEnvConfig, getServiceToComponent()); }
@Override public Security getSecurity(Cluster cluster, SecurityContext securityContext, Subject subject) { try { StormMetadataService sms = new StormMetadataService .Builder(environmentService, cluster.getId(), securityContext, subject).build(); return sms.getSecurity(); } catch (Exception e) { throw new RuntimeException(e); } }
@GET @Path("/clusters/{clusterId}/services/storm/topologies") @Timed public Response getTopologiesByClusterId(@PathParam("clusterId") Long clusterId, @Context SecurityContext securityContext) { SecurityUtil.checkPermissions(authorizer, securityContext, Cluster.NAMESPACE, clusterId, READ); try { StormMetadataService stormMetadataService = new StormMetadataService .Builder(environmentService, clusterId, securityContext, subject).build(); return WSUtils.respondEntity(stormMetadataService.getTopologies(), OK); } catch (EntityNotFoundException | IOException | PrivilegedActionException ex) { throw com.hortonworks.streamline.common.exception.service.exception.request.EntityNotFoundException.byId(ex.getMessage()); } }
@GET @Path("/clusters/{clusterId}/services/storm/mainpage/url") @Timed public Response getMainPageByClusterId(@PathParam("clusterId") Long clusterId, @Context SecurityContext securityContext) { SecurityUtil.checkPermissions(authorizer, securityContext, Cluster.NAMESPACE, clusterId, READ); try { StormMetadataService stormMetadataService = new StormMetadataService .Builder(environmentService, clusterId, securityContext, subject).build(); return WSUtils.respondEntity(Collections.singletonMap("url", stormMetadataService.getMainPageUrl()), OK); } catch (EntityNotFoundException ex) { throw com.hortonworks.streamline.common.exception.service.exception.request.EntityNotFoundException.byId(ex.getMessage()); } } }
public StormMetadataService build() throws ServiceNotFoundException, ServiceComponentNotFoundException { return new StormMetadataService(newHttpClient(), getTopologySummaryRestUrl(), getMainPageUrl(), securityContext, getServiceConfig(AMBARI_JSON_CONFIG_STORM_ENV), subject, getComponent(AMBARI_JSON_COMPONENT_STORM_NIMBUS), getComponentProcesses(AMBARI_JSON_COMPONENT_STORM_NIMBUS), getComponent(AMBARI_JSON_COMPONENT_STORM_UI_SERVER), getComponentProcesses(AMBARI_JSON_COMPONENT_STORM_UI_SERVER)); }