Search in sources :

Example 11 with Topology

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());
}
Also used : TopologyActions(com.hortonworks.streamline.streams.actions.TopologyActions) Topology(com.hortonworks.streamline.streams.catalog.Topology) Path(javax.ws.rs.Path) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET)

Example 12 with Topology

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());
}
Also used : LogSearchCriteria(com.hortonworks.streamline.streams.logsearch.LogSearchCriteria) Topology(com.hortonworks.streamline.streams.catalog.Topology) Path(javax.ws.rs.Path) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET)

Example 13 with Topology

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());
}
Also used : Topology(com.hortonworks.streamline.streams.catalog.Topology) TopologyTestRunCase(com.hortonworks.streamline.streams.catalog.TopologyTestRunCase) TopologyTestRunCaseSource(com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSource) TopologyTestRunHistory(com.hortonworks.streamline.streams.catalog.TopologyTestRunHistory) SchemaValidationFailedException(com.hortonworks.streamline.common.exception.SchemaValidationFailedException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Timed(com.codahale.metrics.annotation.Timed)

Example 14 with Topology

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());
    }
}
Also used : TopologyComponent(com.hortonworks.streamline.streams.catalog.TopologyComponent) Topology(com.hortonworks.streamline.streams.catalog.Topology) Path(javax.ws.rs.Path) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET)

Example 15 with Topology

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());
    }
}
Also used : TopologyComponent(com.hortonworks.streamline.streams.catalog.TopologyComponent) Topology(com.hortonworks.streamline.streams.catalog.Topology) Collectors.toMap(java.util.stream.Collectors.toMap) Map(java.util.Map) Path(javax.ws.rs.Path) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET)

Aggregations

Topology (com.hortonworks.streamline.streams.catalog.Topology)67 Timed (com.codahale.metrics.annotation.Timed)39 Path (javax.ws.rs.Path)27 GET (javax.ws.rs.GET)17 IOException (java.io.IOException)12 TopologyActions (com.hortonworks.streamline.streams.actions.TopologyActions)9 TopologyTestRunHistory (com.hortonworks.streamline.streams.catalog.TopologyTestRunHistory)9 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)8 TopologyTestRunCase (com.hortonworks.streamline.streams.catalog.TopologyTestRunCase)8 List (java.util.List)8 Map (java.util.Map)8 POST (javax.ws.rs.POST)8 Expectations (mockit.Expectations)8 Test (org.junit.Test)7 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)6 TopologyComponent (com.hortonworks.streamline.streams.catalog.TopologyComponent)6 TopologyTestRunCaseSource (com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSource)6 ArrayList (java.util.ArrayList)6 StreamCatalogService (com.hortonworks.streamline.streams.catalog.service.StreamCatalogService)5 Collections (java.util.Collections)5