use of com.hortonworks.streamline.streams.storm.common.StormNotReachableException in project streamline by hortonworks.
the class CatalogResourceUtil method enrichTopology.
static TopologyDashboardResponse enrichTopology(Topology topology, String asUser, Integer latencyTopN, EnvironmentService environmentService, TopologyActionsService actionsService, TopologyMetricsService metricsService, StreamCatalogService catalogService) {
LOG.debug("[START] enrichTopology - topology id: {}", topology.getId());
Stopwatch stopwatch = Stopwatch.createStarted();
try {
if (latencyTopN == null) {
latencyTopN = DEFAULT_N_OF_TOP_N_LATENCY;
}
TopologyDashboardResponse detailedResponse;
String namespaceName = null;
Namespace namespace = environmentService.getNamespace(topology.getNamespaceId());
if (namespace != null) {
namespaceName = namespace.getName();
}
try {
String runtimeTopologyId = actionsService.getRuntimeTopologyId(topology, asUser);
TopologyMetrics.TopologyMetric topologyMetric = metricsService.getTopologyMetric(topology, asUser);
List<Pair<String, Double>> latenciesTopN = metricsService.getTopNAndOtherComponentsLatency(topology, asUser, latencyTopN);
detailedResponse = new TopologyDashboardResponse(topology, TopologyRunningStatus.RUNNING, namespaceName);
detailedResponse.setRuntime(new TopologyRuntimeResponse(runtimeTopologyId, topologyMetric, latenciesTopN));
} catch (TopologyNotAliveException e) {
LOG.debug("Topology {} is not alive", topology.getId());
detailedResponse = new TopologyDashboardResponse(topology, TopologyRunningStatus.NOT_RUNNING, namespaceName);
catalogService.getTopologyState(topology.getId()).ifPresent(state -> {
if (TopologyStateFactory.getInstance().getTopologyState(state.getName()) == TopologyStates.TOPOLOGY_STATE_DEPLOYED) {
try {
LOG.info("Force killing streamline topology since its not alive in the cluster");
actionsService.killTopology(topology, asUser);
} catch (Exception ex) {
LOG.error("Error trying to kill topology", ex);
}
}
});
} catch (StormNotReachableException | IOException e) {
LOG.error("Storm is not reachable or fail to operate", e);
detailedResponse = new TopologyDashboardResponse(topology, TopologyRunningStatus.UNKNOWN, namespaceName);
} catch (Exception e) {
LOG.error("Unhandled exception occurs while operate with Storm", e);
detailedResponse = new TopologyDashboardResponse(topology, TopologyRunningStatus.UNKNOWN, namespaceName);
}
LOG.debug("[END] enrichTopology - topology id: {}, elapsed: {} ms", topology.getId(), stopwatch.elapsed(TimeUnit.MILLISECONDS));
return detailedResponse;
} finally {
stopwatch.stop();
}
}
use of com.hortonworks.streamline.streams.storm.common.StormNotReachableException 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;
}
Aggregations