Search in sources :

Example 61 with Topology

use of com.hortonworks.streamline.streams.catalog.Topology in project streamline by hortonworks.

the class TopologyActionResource method validateTopologyVersion.

@POST
@Path("/topologies/{topologyId}/versions/{versionId}/actions/validate")
@Timed
public Response validateTopologyVersion(@PathParam("topologyId") Long topologyId, @PathParam("versionId") Long versionId, @Context SecurityContext securityContext) {
    SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_SUPER_ADMIN, NAMESPACE, topologyId, READ, EXECUTE);
    Topology result = catalogService.getTopology(topologyId, versionId);
    if (result != null) {
        // catalogService.validateTopology(SCHEMA, topologyId);
        return WSUtils.respondEntity(result, OK);
    }
    throw EntityNotFoundException.byVersion(topologyId.toString(), versionId.toString());
}
Also used : Topology(com.hortonworks.streamline.streams.catalog.Topology) Timed(com.codahale.metrics.annotation.Timed)

Example 62 with Topology

use of com.hortonworks.streamline.streams.catalog.Topology in project streamline by hortonworks.

the class TopologyActionResource method killTopology.

@POST
@Path("/topologies/{topologyId}/actions/kill")
@Timed
public Response killTopology(@PathParam("topologyId") Long topologyId, @Context SecurityContext securityContext) throws Exception {
    SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_SUPER_ADMIN, NAMESPACE, topologyId, READ, EXECUTE);
    Topology result = catalogService.getTopology(topologyId);
    if (result != null) {
        actionsService.killTopology(result, WSUtils.getUserFromSecurityContext(securityContext));
        return WSUtils.respondEntity(result, OK);
    }
    throw EntityNotFoundException.byId(topologyId.toString());
}
Also used : Topology(com.hortonworks.streamline.streams.catalog.Topology) Timed(com.codahale.metrics.annotation.Timed)

Example 63 with Topology

use of com.hortonworks.streamline.streams.catalog.Topology in project streamline by hortonworks.

the class TopologyActionResource method suspendTopology.

@POST
@Path("/topologies/{topologyId}/actions/suspend")
@Timed
public Response suspendTopology(@PathParam("topologyId") Long topologyId, @Context SecurityContext securityContext) throws Exception {
    SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_SUPER_ADMIN, NAMESPACE, topologyId, READ, EXECUTE);
    Topology result = catalogService.getTopology(topologyId);
    if (result != null) {
        actionsService.suspendTopology(result, WSUtils.getUserFromSecurityContext(securityContext));
        return WSUtils.respondEntity(result, OK);
    }
    throw EntityNotFoundException.byId(topologyId.toString());
}
Also used : Topology(com.hortonworks.streamline.streams.catalog.Topology) Timed(com.codahale.metrics.annotation.Timed)

Example 64 with Topology

use of com.hortonworks.streamline.streams.catalog.Topology in project streamline by hortonworks.

the class TopologyActionResource method killTopologyVersion.

@POST
@Path("/topologies/{topologyId}/versions/{versionId}/actions/kill")
@Timed
public Response killTopologyVersion(@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.killTopology(result, WSUtils.getUserFromSecurityContext(securityContext));
        return WSUtils.respondEntity(result, OK);
    }
    throw EntityNotFoundException.byVersion(topologyId.toString(), versionId.toString());
}
Also used : Topology(com.hortonworks.streamline.streams.catalog.Topology) Timed(com.codahale.metrics.annotation.Timed)

Example 65 with Topology

use of com.hortonworks.streamline.streams.catalog.Topology in project streamline by hortonworks.

the class TopologyLoggingResource method configureLogLevel.

@POST
@Path("/topologies/{topologyId}/logconfig")
@Timed
public Response configureLogLevel(@PathParam("topologyId") Long topologyId, @QueryParam("targetLogLevel") TopologyActions.LogLevel targetLogLevel, @QueryParam("durationSecs") int durationSecs, @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.configureLogLevel(topology, targetLogLevel, durationSecs, 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) POST(javax.ws.rs.POST) Timed(com.codahale.metrics.annotation.Timed)

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