/** {@inheritDoc} */ @Override public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) { LOG.debug("Start to prepare storm output bolt."); outputCollector = collector; if (null != output.getConfig().get(StreamingConfig.STREAMING_STORM_COMMON_ISACK)) { needAck = Boolean.valueOf( output.getConfig().get(StreamingConfig.STREAMING_STORM_COMMON_ISACK).toString()); } try { output.initialize(); } catch (StreamingException e) { LOG.error("Failed to initialize output stream."); throw new RuntimeException("Failed to initialize output stream", e); } }
/** {@inheritDoc} */ @Override public void cleanup() { LOG.debug("Start to cleanup storm output bolt."); try { output.destroy(); } catch (StreamingException e) { LOG.error("Failed to destroy output."); throw new RuntimeException("Failed to destroy output", e); } }
/** {@inheritDoc} */ @Override public void execute(Tuple tuple) { LOG.debug("Start up to execute tuple."); String sourceStreamName = tuple.getSourceStreamId(); try { for (String streamName : output.getInputStream()) { if (sourceStreamName.equals(streamName)) { TupleEvent event = TupleTransform.tupeToEvent(tuple, output.getInputSchema().get(streamName)); output.execute(streamName, event); } } } catch (StreamingException e) { LOG.error("Failed to execute tuple."); throw new RuntimeException("Failed to execute tuple.", e); } if (needAck) { outputCollector.ack(tuple); } }
/** {@inheritDoc} */ @Override public Map<String, Object> getComponentConfiguration() { return output.getConfig(); }