@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()); } } }
private String getTopologySummaryRestUrl() throws ServiceNotFoundException, ServiceComponentNotFoundException { final HostPort hostPort = getHostPort(); String url = "http://" + hostPort.toString() + (urlRelativePath.startsWith("/") ? urlRelativePath : "/" + urlRelativePath); if (SecurityUtil.isKerberosAuthenticated(securityContext)) { url += "?" + STORM_REST_API_DO_AS_USER_QUERY_PARAM + "=" + securityContext.getUserPrincipal().getName(); } return url; }
/** * @return If storm view is configured it returns its URL, otherwise it returns the URL of the Storm UI */ private String getMainPageUrl() throws ServiceNotFoundException, ServiceComponentNotFoundException { final ServiceConfiguration stormViewConfiguration = getServiceConfig(SERVICE_STORM_VIEW); String url = null; if (stormViewConfiguration != null) { try { Map<String, String> confMap = stormViewConfiguration.getConfigurationMap(); url = confMap.get(STORM_VIEW_CONFIGURATION_KEY_STORM_VIEW_URL); } catch (IOException e) { // fail back } } if (url != null) { return url; } else { // just use Storm UI HostPort hostPort = getHostPort(); return "http://" + hostPort.toString(); } }
@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()); } }
@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); } }
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)); }