use of com.hortonworks.streamline.streams.catalog.Topology in project streamline by hortonworks.
the class TopologyLoggingResource method getLogLevel.
@GET
@Path("/topologies/{topologyId}/logconfig")
@Timed
public Response getLogLevel(@PathParam("topologyId") Long topologyId, @Context SecurityContext securityContext) throws Exception {
SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, NAMESPACE, topologyId, READ);
Topology topology = catalogService.getTopology(topologyId);
if (topology != null) {
TopologyActions.LogLevelInformation logInfo = actionsService.getLogLevel(topology, WSUtils.getUserFromSecurityContext(securityContext));
LogLevelResponse response;
if (logInfo != null) {
response = LogLevelResponse.succeed().of(logInfo).build();
} else {
response = LogLevelResponse.fail().build();
}
return WSUtils.respondEntity(response, OK);
}
throw EntityNotFoundException.byId(topologyId.toString());
}
use of com.hortonworks.streamline.streams.catalog.Topology in project streamline by hortonworks.
the class TopologyLoggingResource method searchTopologyLogs.
@GET
@Path("/topologies/{topologyId}/logs")
@Timed
public Response searchTopologyLogs(@PathParam("topologyId") Long topologyId, @QueryParam("componentName") List<String> componentNames, @QueryParam("logLevel") List<String> logLevels, @QueryParam("searchString") String searchString, @QueryParam("from") Long from, @QueryParam("to") Long to, @QueryParam("start") Integer start, @QueryParam("limit") Integer limit, @QueryParam("ascending") Boolean ascending, @Context SecurityContext securityContext) {
SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, NAMESPACE, topologyId, READ);
Topology topology = catalogService.getTopology(topologyId);
if (topology != null) {
if (from == null) {
throw BadRequestException.missingParameter("from");
}
if (to == null) {
throw BadRequestException.missingParameter("to");
}
LogSearchCriteria criteria = new LogSearchCriteria(String.valueOf(topologyId), componentNames, logLevels, searchString, from, to, start, limit, ascending);
return WSUtils.respondEntity(logSearchService.search(topology, criteria), OK);
}
throw EntityNotFoundException.byId(topologyId.toString());
}
use of com.hortonworks.streamline.streams.catalog.Topology in project streamline by hortonworks.
the class TopologyTestRunResource method testRunTopology.
@POST
@Path("/topologies/{topologyId}/actions/testrun")
@Timed
public Response testRunTopology(@Context UriInfo urlInfo, @PathParam("topologyId") Long topologyId, TopologyTestRunParam topologyTestRunParam, @Context SecurityContext securityContext) throws Exception {
SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, EXECUTE);
Topology result = catalogService.getTopology(topologyId);
if (result != null) {
Long testCaseId = topologyTestRunParam.getTestCaseId();
Long durationSecs = topologyTestRunParam.getDurationSecs();
if (testCaseId == null) {
throw BadRequestException.missingParameter("testCaseId");
}
TopologyTestRunCase testCase = catalogService.getTopologyTestRunCase(topologyId, testCaseId);
if (testCase == null) {
throw EntityNotFoundException.byName("topology " + topologyId + " / topology test case " + testCaseId);
}
Collection<TopologyTestRunCaseSource> testCaseSources = catalogService.listTopologyTestRunCaseSource(testCaseId);
if (testCaseSources != null) {
for (TopologyTestRunCaseSource source : testCaseSources) {
try {
doValidationForTestRunCaseSource(topologyId, testCaseId, source);
} catch (SchemaValidationFailedException e) {
throw handleSchemaValidationFailedException(topologyId, source, e);
}
}
}
TopologyTestRunHistory history = actionsService.testRunTopology(result, testCase, durationSecs);
return WSUtils.respondEntity(history, OK);
}
throw EntityNotFoundException.byName("topology " + topologyId.toString());
}
use of com.hortonworks.streamline.streams.catalog.Topology in project streamline by hortonworks.
the class MetricsResource method getCompleteLatency.
@GET
@Path("/topologies/{id}/components/{topologyComponentId}/complete_latency")
@Timed
public Response getCompleteLatency(@PathParam("id") Long id, @PathParam("topologyComponentId") Long topologyComponentId, @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);
TopologyComponent topologyComponent = catalogService.getTopologyComponent(id, topologyComponentId);
if (topology != null && topologyComponent != null) {
String asUser = WSUtils.getUserFromSecurityContext(securityContext);
Map<Long, Double> metrics = metricsService.getCompleteLatency(topology, topologyComponent, from, to, asUser);
return WSUtils.respondEntity(metrics, OK);
} else if (topology == null) {
throw EntityNotFoundException.byId("Topology: " + id.toString());
} else {
// topologyComponent == null
throw EntityNotFoundException.byId("TopologyComponent: " + id.toString());
}
}
use of com.hortonworks.streamline.streams.catalog.Topology in project streamline by hortonworks.
the class MetricsResource method getKafkaTopicOffsets.
@GET
@Path("/topologies/{id}/components/{topologyComponentId}/kafka_topic_offsets")
@Timed
public Response getKafkaTopicOffsets(@PathParam("id") Long id, @PathParam("topologyComponentId") Long topologyComponentId, @QueryParam("from") Long from, @QueryParam("to") Long to, @Context SecurityContext securityContext) throws IOException {
SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, id, READ);
assertTimeRange(from, to);
Topology topology = catalogService.getTopology(id);
TopologyComponent topologyComponent = catalogService.getTopologyComponent(id, topologyComponentId);
if (topology != null && topologyComponent != null) {
String asUser = WSUtils.getUserFromSecurityContext(securityContext);
Map<String, Map<Long, Double>> metrics = metricsService.getKafkaTopicOffsets(topology, topologyComponent, from, to, asUser);
return WSUtils.respondEntity(metrics, OK);
} else if (topology == null) {
throw EntityNotFoundException.byId("Topology: " + id.toString());
} else {
// topologyComponent == null
throw EntityNotFoundException.byId("TopologyComponent: " + id.toString());
}
}
Aggregations