@Override public void close() { incomingOperator.doCleanup(); try { snapshotTimer.stop(); } catch (SchedulerException e) { LOG.error("Failed to stop snapshot timer", e); } }
@Override public void nextTuple() { incomingOperator.nextTuple(); if (LOG.isDebugEnabled()) { LOG.debug( "nextTuple({} {}[{}])", context.getTopologyId(), getName(), this.getTopologyContext().getThisTaskIndex()); } }
@Override public void open( @SuppressWarnings("rawtypes") Map stormConf, TopologyContext context, SpoutOutputCollector collector) { LOG.info( "open({}[{}]) TaskId: {}, ThisComponetTasks: {}, ThisWorkerTasks: {}", context.getThisComponentId(), context.getThisTaskIndex(), context.getThisTaskId(), context.getComponentTasks(context.getThisComponentId()), context.getThisWorkerTasks()); @SuppressWarnings("unchecked") GungnirConfig config = GungnirConfig.wrap((Map<String, Object>) stormConf.get(GUNGNIR_CONFIG)); topologyContext = context; if (config.getBoolean(TOPOLOGY_METRICS_ENABLED) && metricsMap != null) { for (Map.Entry<String, Metrics> entry : metricsMap.entrySet()) { topologyContext.registerMetric( entry.getKey(), entry.getValue(), config.getInteger(TOPOLOGY_METRICS_INTERVAL_SECS)); } } this.context.setComponent(this); incomingOperator.doPrepare(config, this.context); for (PartitionOperator partitionOperator : outgoingOperators) { SpoutDispatcher spoutDispatcher = new SpoutDispatcher(); spoutDispatcher.collector = collector; Dispatcher dispatcher = partitionOperator.getDispatcher(); if (dispatcher == null) { partitionOperator.setDispatcher(spoutDispatcher); } else if (dispatcher instanceof MultiDispatcher) { for (Dispatcher d : ((MultiDispatcher) dispatcher).getDispatchers()) { if (d instanceof FilterDispatcher) { ((FilterDispatcher) d).setDispatcher(spoutDispatcher); } } } else if (dispatcher instanceof FilterDispatcher) { ((FilterDispatcher) dispatcher).setDispatcher(spoutDispatcher); } } // TODO: parallelization // snapshotTimer = new SnapshotTimer(config.getInteger(COMPONENT_SNAPSHOT_QUEUE_SIZE), // config.getInteger(COMPONENT_SNAPSHOT_PARALLELISM)); snapshotTimer = new SnapshotTimer(getName() + "_" + topologyContext.getThisTaskIndex()); }