コード例 #1
0
ファイル: StreamTask.java プロジェクト: naveenmadhire/flink
  public void restoreStateLazy() throws Exception {
    if (lazyRestoreState != null) {
      LOG.info("Restoring checkpointed state to task {}", getName());

      try {
        final StreamOperator<?>[] allOperators = operatorChain.getAllOperators();
        final StreamTaskState[] states = lazyRestoreState.getState(userClassLoader);

        // be GC friendly
        lazyRestoreState = null;

        for (int i = 0; i < states.length; i++) {
          StreamTaskState state = states[i];
          StreamOperator<?> operator = allOperators[i];

          if (state != null && operator != null) {
            LOG.debug("Task {} in chain ({}) has checkpointed state", i, getName());
            operator.restoreState(state);
          } else if (operator != null) {
            LOG.debug("Task {} in chain ({}) does not have checkpointed state", i, getName());
          }
        }
      } catch (Exception e) {
        throw new Exception("Could not restore checkpointed state to operators and functions", e);
      }
    }
  }