use of com.hortonworks.streamline.streams.catalog.Topology in project streamline by hortonworks.
the class MetricsResource method getTopologyMetricsById.
@GET
@Path("/topologies/{id}")
@Timed
public Response getTopologyMetricsById(@PathParam("id") Long id, @Context SecurityContext securityContext) throws Exception {
SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, id, READ);
Topology topology = catalogService.getTopology(id);
if (topology != null) {
String asUser = WSUtils.getUserFromSecurityContext(securityContext);
Map<String, TopologyMetrics.ComponentMetric> topologyMetrics = metricsService.getTopologyMetrics(topology, asUser);
return WSUtils.respondEntity(topologyMetrics, OK);
}
throw EntityNotFoundException.byId(id.toString());
}
use of com.hortonworks.streamline.streams.catalog.Topology in project streamline by hortonworks.
the class MetricsResource method getTopologyMetricsViaTimeSeriesById.
@GET
@Path("/topologies/{id}/timeseries")
@Timed
public Response getTopologyMetricsViaTimeSeriesById(@PathParam("id") Long id, @QueryParam("from") Long from, @QueryParam("to") Long to, @Context SecurityContext securityContext) throws Exception {
SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, id, READ);
assertTimeRange(from, to);
Topology topology = catalogService.getTopology(id);
if (topology != null) {
String asUser = WSUtils.getUserFromSecurityContext(securityContext);
TopologyTimeSeriesMetrics.TimeSeriesComponentMetric topologyMetrics = metricsService.getTopologyStats(topology, from, to, asUser);
return WSUtils.respondEntity(topologyMetrics, OK);
}
throw EntityNotFoundException.byId(id.toString());
}
use of com.hortonworks.streamline.streams.catalog.Topology in project streamline by hortonworks.
the class MetricsResource method getComponentStats.
@GET
@Path("/topologies/{id}/components/all/component_stats")
@Timed
public Response getComponentStats(@PathParam("id") Long id, @QueryParam("from") Long from, @QueryParam("to") Long to, @Context SecurityContext securityContext) throws Exception {
SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, id, READ);
assertTimeRange(from, to);
Topology topology = catalogService.getTopology(id);
if (topology != null) {
List<TopologyComponent> topologyComponents = new ArrayList<>();
List<com.hortonworks.registries.common.QueryParam> queryParams = new ArrayList<>();
queryParams.add(new com.hortonworks.registries.common.QueryParam("topologyId", String.valueOf(topology.getId())));
queryParams.add(new com.hortonworks.registries.common.QueryParam("versionId", String.valueOf(topology.getVersionId())));
topologyComponents.addAll(catalogService.listTopologySources(queryParams));
topologyComponents.addAll(catalogService.listTopologyProcessors(queryParams));
topologyComponents.addAll(catalogService.listTopologySinks(queryParams));
Map<String, TopologyTimeSeriesMetrics.TimeSeriesComponentMetric> topologyMetrics = ParallelStreamUtil.execute(() -> topologyComponents.parallelStream().map(c -> {
try {
String asUser = WSUtils.getUserFromSecurityContext(securityContext);
return Pair.of(c, metricsService.getComponentStats(topology, c, from, to, asUser));
} catch (IOException e) {
throw new RuntimeException(e);
}
}).collect(toMap(m -> m.getKey().getId().toString(), m -> m.getValue())), forkJoinPool);
return WSUtils.respondEntity(topologyMetrics, OK);
}
throw EntityNotFoundException.byId(id.toString());
}
use of com.hortonworks.streamline.streams.catalog.Topology in project streamline by hortonworks.
the class StreamCatalogService method removeTopology.
public Topology removeTopology(Long topologyId, Long versionId, boolean recurse) {
Topology topology = new Topology();
topology.setId(topologyId);
topology.setVersionId(versionId);
if (recurse) {
try {
removeTopologyDependencies(topology.getId(), topology.getVersionId());
} catch (Exception ex) {
LOG.error("Got exception while removing topology dependencies", ex);
throw new RuntimeException(ex);
}
}
Topology removedTopology = dao.remove(topology.getStorableKey());
removeTopologyVersionInfo(versionId);
return removedTopology;
}
use of com.hortonworks.streamline.streams.catalog.Topology in project streamline by hortonworks.
the class StreamCatalogServiceTest method testListTopologiesProvidesVersionedTimestamp_STREAMLINE_526.
@Test
public void testListTopologiesProvidesVersionedTimestamp_STREAMLINE_526() {
List<Topology> topologies = new ArrayList<>();
topologies.add(createTopology(1L));
topologies.add(createTopology(2L));
topologies.add(createTopology(3L));
List<TopologyVersion> versions = topologies.stream().map(x -> createTopologyVersionInfo(x.getId(), x.getId())).collect(Collectors.toList());
new Expectations() {
{
dao.find(withEqual(new Topology().getNameSpace()), withAny(new ArrayList<>()));
result = topologies;
dao.find(withEqual(new TopologyVersion().getNameSpace()), withAny(new ArrayList<>()));
result = versions;
dao.get(withEqual(new StorableKey(versions.get(0).getNameSpace(), versions.get(0).getPrimaryKey())));
result = versions.get(0);
dao.get(withEqual(new StorableKey(versions.get(1).getNameSpace(), versions.get(1).getPrimaryKey())));
result = versions.get(1);
dao.get(withEqual(new StorableKey(versions.get(2).getNameSpace(), versions.get(2).getPrimaryKey())));
result = versions.get(2);
}
};
Collection<Topology> result = streamCatalogService.listTopologies();
assertTrue(result.size() > 0);
assertFalse(result.stream().anyMatch(x -> x.getVersionTimestamp() == null));
}
Aggregations