private void killTopologyIfRunning(TopologyContext context, TopologyLayout layout) { try { TopologyActions.Status engineStatus = context.getTopologyActions().status(layout, context.getAsUser()); if (!engineStatus.getStatus().equals(TopologyActions.Status.STATUS_UNKNOWN)) { invokeKill(context); } } catch (Exception e) { LOG.debug("Not able to get running status of topology '{}'", context.getTopology().getName()); } } };
@Override public void deploy(TopologyContext context) throws Exception { try { context.setCurrentAction("Setting up cluster artifacts"); Topology topology = context.getTopology(); TopologyActions topologyActions = context.getTopologyActions(); context.getTopologyActionsService().setUpClusterArtifacts(topology, topologyActions); context.setState(TOPOLOGY_STATE_CLUSTER_ARTIFACTS_SETUP); context.setCurrentAction("Cluster artifacts set up"); } catch (Exception ex) { LOG.error("Error while setting up cluster artifacts", ex); context.setState(TOPOLOGY_STATE_DEPLOYMENT_FAILED); context.setCurrentAction("Cluster artifacts set up failed due to: " + ex); throw new IgnoreTransactionRollbackException(ex); } } };
@Override public void deploy(TopologyContext context) throws Exception { try { context.setCurrentAction("Validating topology DAG"); TopologyDag dag = context.getTopology().getTopologyDag(); context.getTopologyActionsService().ensureValid(dag); context.setState(TOPOLOGY_STATE_DAG_VALIDATED); context.setCurrentAction("Topology DAG validated"); } catch (Exception ex) { context.setState(TOPOLOGY_STATE_DEPLOYMENT_FAILED); context.setCurrentAction("Topology DAG validation failed due to: " + ex); throw new IgnoreTransactionRollbackException(ex); } } };
private static void invokeKill(TopologyContext context) throws Exception { Topology topology = context.getTopology(); TopologyActions topologyActions = context.getTopologyActions(); topologyActions.kill(CatalogToLayoutConverter.getTopologyLayout(topology), context.getAsUser()); LOG.debug("Killed topology '{}'", topology.getName()); } }
@Override public void deploy(TopologyContext context) throws Exception { try { context.setCurrentAction("Setting up extra jars"); Topology topology = context.getTopology(); TopologyActions topologyActions = context.getTopologyActions(); String mavenArtifacts = context.getTopologyActionsService().setUpExtraJars(topology, topologyActions); context.setMavenArtifacts(mavenArtifacts); context.setState(TOPOLOGY_STATE_EXTRA_JARS_SETUP); context.setCurrentAction("Extra jars set up"); } catch (Exception ex) { LOG.error("Error while setting up extra jars", ex); context.setState(TOPOLOGY_STATE_DEPLOYMENT_FAILED); context.setCurrentAction("Extra jars setup failed due to: " + ex); throw new IgnoreTransactionRollbackException(ex); } } };
@Override public void deploy(TopologyContext context) throws Exception { try { context.setCurrentAction("Constructing topology DAG"); Topology topology = context.getTopology(); TopologyDag dag = context.getTopologyActionsService().getTopologyDagBuilder().getDag(topology); topology.setTopologyDag(dag); context.setState(TOPOLOGY_STATE_DAG_CONSTRUCTED); context.setCurrentAction("DAG constructed"); } catch (Exception ex) { context.setState(TOPOLOGY_STATE_DEPLOYMENT_FAILED); context.setCurrentAction("Topology DAG construction failed due to: " + ex); throw new IgnoreTransactionRollbackException(ex); } } };
@Override public void suspend(TopologyContext context) throws Exception { try { context.setCurrentAction("Suspending topology"); Topology topology = context.getTopology(); TopologyActions topologyActions = context.getTopologyActions(); topologyActions.suspend(CatalogToLayoutConverter.getTopologyLayout(topology), context.getAsUser()); context.setState(TOPOLOGY_STATE_SUSPENDED); context.setCurrentAction("Topology suspended"); } catch (Exception ex) { LOG.error("Error while trying to suspend the topology", ex); context.setCurrentAction("Suspending the topology failed due to: " + ex); throw new IgnoreTransactionRollbackException(ex); } } };
@Override public void resume(TopologyContext context) throws Exception { try { context.setCurrentAction("Resuming topology"); Topology topology = context.getTopology(); TopologyActions topologyActions = context.getTopologyActions(); topologyActions.resume(CatalogToLayoutConverter.getTopologyLayout(topology), context.getAsUser()); context.setState(TOPOLOGY_STATE_DEPLOYED); context.setCurrentAction("Topology resumed"); } catch (Exception ex) { LOG.error("Error while trying to resume the topology", ex); context.setCurrentAction("Resuming the topology failed due to: " + ex); throw new IgnoreTransactionRollbackException(ex); } } };
@Override public void deploy(TopologyContext context) throws Exception { TopologyActions topologyActions = context.getTopologyActions(); Topology topology = context.getTopology(); TopologyDag dag = topology.getTopologyDag(); TopologyLayout layout = CatalogToLayoutConverter.getTopologyLayout(topology, dag); if (dag == null) { throw new IllegalStateException("Topology dag not set up"); } try { context.setCurrentAction("Submitting topology to streaming engine"); String mavenArtifacts = context.getMavenArtifacts(); topologyActions.deploy(layout, mavenArtifacts, context, context.getAsUser()); context.setState(TOPOLOGY_STATE_DEPLOYED); context.setCurrentAction("Topology deployed"); } catch (Exception ex) { LOG.error("Error while trying to deploy the topology in the streaming engine", ex); LOG.error("Trying to kill any running instance of topology '{}'", context.getTopology().getName()); killTopologyIfRunning(context, layout); context.setState(TOPOLOGY_STATE_DEPLOYMENT_FAILED); context.setCurrentAction("Topology submission failed due to: " + ex); throw new IgnoreTransactionRollbackException(ex); } }