use of com.hortonworks.streamline.streams.catalog.Topology in project streamline by hortonworks.
the class TopologyMetricsService method getTopNAndOtherComponentsLatency.
public List<Pair<String, Double>> getTopNAndOtherComponentsLatency(Topology topology, String asUser, int nOfTopN) throws IOException {
TopologyMetrics topologyMetrics = getTopologyMetricsInstance(topology);
Map<String, TopologyMetrics.ComponentMetric> metricsForTopology = topologyMetrics.getMetricsForTopology(CatalogToLayoutConverter.getTopologyLayout(topology), asUser);
List<Pair<String, Double>> topNAndOther = new ArrayList<>();
List<ImmutablePair<String, Double>> latencyOrderedComponents = metricsForTopology.entrySet().stream().map((x) -> new ImmutablePair<>(x.getValue().getComponentName(), x.getValue().getProcessedTime())).sorted((c1, c2) -> {
if (c2.getValue() == null) {
// assuming c1 is bigger
return -1;
} else {
return c2.getValue().compareTo(c1.getValue());
}
}).collect(toList());
latencyOrderedComponents.stream().limit(nOfTopN).forEachOrdered(topNAndOther::add);
double sumLatencyOthers = latencyOrderedComponents.stream().skip(nOfTopN).filter((x) -> x.getValue() != null).mapToDouble(Pair::getValue).sum();
topNAndOther.add(new ImmutablePair<>("Others", sumLatencyOthers));
return topNAndOther;
}
use of com.hortonworks.streamline.streams.catalog.Topology in project streamline by hortonworks.
the class NamespaceCatalogResourceTest method setupExpectationForSimulatingTopologyIsRunning.
private void setupExpectationForSimulatingTopologyIsRunning(final Long testNamespaceId, final Namespace testNamespace, final Collection<NamespaceServiceClusterMap> existingMappings) throws IOException {
List<Topology> topologies = createTestTopologies(testNamespaceId);
new Expectations() {
{
environmentService.getNamespace(testNamespaceId);
result = testNamespace;
environmentService.listServiceClusterMapping(testNamespaceId);
result = existingMappings;
catalogService.listTopologies();
result = topologies;
// assuming first topology is not running
topologyActionsService.getRuntimeTopologyId(topologies.get(0), anyString);
result = new TopologyNotAliveException("generated exception for purpose");
// and second topology is running now
topologyActionsService.getRuntimeTopologyId(topologies.get(1), anyString);
result = "dummy-storm-topology-id";
}
};
}
use of com.hortonworks.streamline.streams.catalog.Topology in project streamline by hortonworks.
the class NamespaceCatalogResourceTest method createTestTopologies.
private List<Topology> createTestTopologies(Long testNamespaceId) {
Topology topology1 = new Topology();
topology1.setId(1L);
topology1.setName("test-topology-1");
topology1.setNamespaceId(testNamespaceId);
topology1.setVersionId(1L);
Topology topology2 = new Topology();
topology2.setId(2L);
topology2.setName("test-topology-2");
topology2.setNamespaceId(testNamespaceId);
topology2.setVersionId(1L);
return Lists.newArrayList(topology1, topology2);
}
use of com.hortonworks.streamline.streams.catalog.Topology in project streamline by hortonworks.
the class TopologyEventSamplingResource method disableSampling.
@POST
@Path("/topologies/{topologyId}/component/{componentId}/sampling/disable")
@Timed
public Response disableSampling(@PathParam("topologyId") Long topologyId, @PathParam("componentId") Long componentId, @Context SecurityContext securityContext) throws Exception {
SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_SUPER_ADMIN, Topology.NAMESPACE, topologyId, READ, EXECUTE);
Topology topology = catalogService.getTopology(topologyId);
TopologyComponent topologyComponent = catalogService.getTopologyComponent(topologyId, componentId);
if (topology != null && topologyComponent != null) {
String asUser = WSUtils.getUserFromSecurityContext(securityContext);
boolean success = samplingService.disableSampling(topology, topologyComponent, asUser);
return WSUtils.respondEntity(SamplingResponse.of(topologyId).componentId(componentId).success(success).build(), OK);
}
throw EntityNotFoundException.byId(buildTopologyComponentId(topologyId, componentId));
}
use of com.hortonworks.streamline.streams.catalog.Topology in project streamline by hortonworks.
the class TopologyActionResource method resumeTopologyVersion.
@POST
@Path("/topologies/{topologyId}/versions/{versionId}/actions/resume")
@Timed
public Response resumeTopologyVersion(@PathParam("topologyId") Long topologyId, @PathParam("versionId") Long versionId, @Context SecurityContext securityContext) throws Exception {
SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_SUPER_ADMIN, NAMESPACE, topologyId, READ, EXECUTE);
Topology result = catalogService.getTopology(topologyId, versionId);
if (result != null) {
actionsService.resumeTopology(result, WSUtils.getUserFromSecurityContext(securityContext));
return WSUtils.respondEntity(result, OK);
}
throw EntityNotFoundException.byVersion(topologyId.toString(), versionId.toString());
}
Aggregations