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();
  }
  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;
  }