public void invokeUserFunction(String componentTypeName, StreamInvokable<OUT> userInvokable) throws IOException, InterruptedException { if (LOG.isDebugEnabled()) { LOG.debug( componentTypeName + " " + streamComponent.getName() + " invoked with instance id " + streamComponent.getInstanceID()); } initializeOutputSerializers(); try { streamComponent.invokeUserFunction(userInvokable); } catch (Exception e) { flushOutputs(); throw new RuntimeException(e); } if (LOG.isDebugEnabled()) { LOG.debug( componentTypeName + " " + streamComponent.getName() + " invoke finished with instance id " + streamComponent.getInstanceID()); } flushOutputs(); }
public OutputHandler(AbstractStreamComponent streamComponent) { this.streamComponent = streamComponent; this.outputs = new LinkedList<RecordWriter<SerializationDelegate<StreamRecord<OUT>>>>(); this.configuration = new StreamConfig(streamComponent.getTaskConfiguration()); try { setConfigOutputs(); } catch (StreamComponentException e) { throw new StreamComponentException( "Cannot register outputs for " + streamComponent.getClass().getSimpleName(), e); } }
private StreamCollector<OUT> setCollector() { if (streamComponent.configuration.getDirectedEmit()) { OutputSelector<OUT> outputSelector = streamComponent.configuration.getOutputSelector(); collector = new DirectedStreamCollector<OUT>( streamComponent.getInstanceID(), outSerializationDelegate, outputSelector); } else { collector = new StreamCollector<OUT>(streamComponent.getInstanceID(), outSerializationDelegate); } return collector; }
void setPartitioner( int outputNumber, List<RecordWriter<SerializationDelegate<StreamRecord<OUT>>>> outputs) { StreamPartitioner<OUT> outputPartitioner = null; try { outputPartitioner = configuration.getPartitioner(outputNumber); } catch (Exception e) { throw new StreamComponentException( "Cannot deserialize partitioner for " + streamComponent.getName() + " with " + outputNumber + " outputs", e); } RecordWriter<SerializationDelegate<StreamRecord<OUT>>> output; if (bufferTimeout > 0) { output = new StreamRecordWriter<SerializationDelegate<StreamRecord<OUT>>>( streamComponent, outputPartitioner, bufferTimeout); } else { output = new RecordWriter<SerializationDelegate<StreamRecord<OUT>>>( streamComponent, outputPartitioner); } outputs.add(output); List<String> outputName = configuration.getOutputName(outputNumber); if (collector != null) { collector.addOutput(output, outputName); } if (LOG.isTraceEnabled()) { LOG.trace( "Partitioner set: " + outputPartitioner.getClass().getSimpleName() + " with " + outputNumber + " outputs"); } }