@Override
  protected void run() throws Exception {
    // cache some references on the stack, to make the code more JIT friendly
    final OneInputStreamOperator<IN, OUT> operator = this.headOperator;
    final StreamInputProcessor<IN> inputProcessor = this.inputProcessor;
    final Object lock = getCheckpointLock();

    while (running && inputProcessor.processInput(operator, lock)) {
      checkTimerException();
    }
  }
  @Override
  public void init() throws Exception {
    StreamConfig configuration = getConfiguration();

    TypeSerializer<IN> inSerializer = configuration.getTypeSerializerIn1(getUserCodeClassLoader());
    int numberOfInputs = configuration.getNumberOfInputs();

    if (numberOfInputs > 0) {
      InputGate[] inputGates = getEnvironment().getAllInputGates();
      inputProcessor =
          new StreamInputProcessor<IN>(
              inputGates,
              inSerializer,
              getCheckpointBarrierListener(),
              configuration.getCheckpointMode(),
              getEnvironment().getIOManager(),
              getExecutionConfig().areTimestampsEnabled());

      // make sure that stream tasks report their I/O statistics
      AccumulatorRegistry registry = getEnvironment().getAccumulatorRegistry();
      AccumulatorRegistry.Reporter reporter = registry.getReadWriteReporter();
      inputProcessor.setReporter(reporter);
    }
  }
 @Override
 protected void cleanup() throws Exception {
   inputProcessor.cleanup();
 }