Search in sources :

Example 1 with StreamingEngineNotReachableException

use of com.hortonworks.streamline.common.exception.service.exception.server.StreamingEngineNotReachableException in project streamline by hortonworks.

the class TopologyCatalogResource method removeTopology.

@DELETE
@Path("/topologies/{topologyId}")
@Timed
public Response removeTopology(@PathParam("topologyId") Long topologyId, @javax.ws.rs.QueryParam("onlyCurrent") boolean onlyCurrent, @javax.ws.rs.QueryParam("force") boolean force, @Context SecurityContext securityContext) throws Exception {
    SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_SUPER_ADMIN, NAMESPACE, topologyId, DELETE);
    if (!force) {
        Topology result = catalogService.getTopology(topologyId);
        if (result == null) {
            throw EntityNotFoundException.byId(topologyId.toString());
        }
        String asUser = WSUtils.getUserFromSecurityContext(securityContext);
        try {
            String runtimeTopologyId = actionsService.getRuntimeTopologyId(result, asUser);
            if (StringUtils.isNotEmpty(runtimeTopologyId)) {
                throw BadRequestException.message("Can't remove topology while Topology is running - topology id: " + topologyId);
            }
        } catch (TopologyNotAliveException e) {
        // OK to continue
        } catch (StormNotReachableException | IOException e) {
            // users need to make a request with force parameter on
            throw new StreamingEngineNotReachableException(e.getMessage(), e);
        }
    }
    Response response;
    if (onlyCurrent) {
        response = removeCurrentTopologyVersion(topologyId);
    } else {
        response = removeAllTopologyVersions(topologyId);
    }
    SecurityUtil.removeAcl(authorizer, securityContext, NAMESPACE, topologyId);
    return response;
}
Also used : Response(javax.ws.rs.core.Response) StormNotReachableException(com.hortonworks.streamline.streams.storm.common.StormNotReachableException) TopologyNotAliveException(com.hortonworks.streamline.streams.exception.TopologyNotAliveException) Topology(com.hortonworks.streamline.streams.catalog.Topology) IOException(java.io.IOException) StreamingEngineNotReachableException(com.hortonworks.streamline.common.exception.service.exception.server.StreamingEngineNotReachableException) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) DELETE(com.hortonworks.streamline.streams.security.Permission.DELETE) Timed(com.codahale.metrics.annotation.Timed)

Aggregations

Timed (com.codahale.metrics.annotation.Timed)1 StreamingEngineNotReachableException (com.hortonworks.streamline.common.exception.service.exception.server.StreamingEngineNotReachableException)1 Topology (com.hortonworks.streamline.streams.catalog.Topology)1 TopologyNotAliveException (com.hortonworks.streamline.streams.exception.TopologyNotAliveException)1 DELETE (com.hortonworks.streamline.streams.security.Permission.DELETE)1 StormNotReachableException (com.hortonworks.streamline.streams.storm.common.StormNotReachableException)1 IOException (java.io.IOException)1 DELETE (javax.ws.rs.DELETE)1 Path (javax.ws.rs.Path)1 Response (javax.ws.rs.core.Response)1