public int getDelaySeconds(Object[] args) { if (oldStatus != null && oldStatus.getDelaySecs() > 0) { return oldStatus.getDelaySecs(); } Integer delaySecs = DelayStatusTransitionCallback.DEFAULT_DELAY_SECONDS; if (args == null || args.length == 0 || args[0] == null) { Map<?, ?> map = null; try { map = StormConfig.read_nimbus_topology_conf(data.getConf(), topologyid); delaySecs = JStormUtils.parseInt( map.get(Config.TOPOLOGY_MESSAGE_TIMEOUT_SECS), DEFAULT_DELAY_SECONDS); } catch (Exception e) { LOG.info("Failed to get topology configuration " + topologyid); } } else { delaySecs = JStormUtils.parseInt(args[0]); } if (delaySecs == null || delaySecs <= 0) { delaySecs = DelayStatusTransitionCallback.DEFAULT_DELAY_SECONDS; } return delaySecs; }
@Override public <T> Object execute(T... args) { LOG.info("Begin to remove topology: " + topologyid); try { StormBase stormBase = data.getStormClusterState().storm_base(topologyid, null); if (stormBase == null) { LOG.info("Topology " + topologyid + " has been removed "); return null; } data.getStormClusterState().remove_storm(topologyid); LOG.info("Successfully removed ZK items topology: " + topologyid); } catch (Exception e) { // TODO Auto-generated catch block LOG.warn("Failed to remove StormBase " + topologyid + " from ZK", e); } return null; }
@Override public <T> Object execute(T... args) { int delaySecs = getDelaySeconds(args); LOG.info("Delaying event " + newType + " for " + delaySecs + " secs for " + topologyid); data.getScheduExec() .schedule( new DelayEventRunnable(data, topologyid, nextAction), delaySecs, TimeUnit.SECONDS); return new StormStatus(delaySecs, newType); }