예제 #1
0
  @Override
  public void restoreState(StreamTaskState taskState, long recoveryTimestamp) throws Exception {
    super.restoreState(taskState, recoveryTimestamp);

    final ClassLoader userClassloader = getUserCodeClassloader();

    @SuppressWarnings("unchecked")
    StateHandle<DataInputView> inputState =
        (StateHandle<DataInputView>) taskState.getOperatorState();
    DataInputView in = inputState.getState(userClassloader);

    int numKeys = in.readInt();
    this.windows = new HashMap<>(numKeys);
    this.processingTimeTimers = new HashMap<>();
    this.watermarkTimers = new HashMap<>();

    for (int i = 0; i < numKeys; i++) {
      int numWindows = in.readInt();
      for (int j = 0; j < numWindows; j++) {
        Context context = new Context(in, userClassloader);
        Map<W, Context> keyWindows = windows.get(context.key);
        if (keyWindows == null) {
          keyWindows = new HashMap<>(numWindows);
          windows.put(context.key, keyWindows);
        }
        keyWindows.put(context.window, context);
      }
    }
  }
예제 #2
0
  @Override
  public void restoreState(StreamTaskState taskState, long recoveryTimestamp) throws Exception {
    super.restoreState(taskState, recoveryTimestamp);

    final ClassLoader userClassloader = getUserCodeClassloader();

    @SuppressWarnings("unchecked")
    StateHandle<DataInputView> inputState =
        (StateHandle<DataInputView>) taskState.getOperatorState();
    DataInputView in = inputState.getState(userClassloader);

    restoreTimers(in);
  }
예제 #3
0
  /**
   * Notification on completed checkpoints
   *
   * @param checkpointId The ID of the checkpoint that has been completed.
   * @throws Exception
   */
  @Override
  public void commitCheckpoint(long checkpointId, String stateName, StateHandle<Serializable> state)
      throws Exception {
    LOG.info("Commit checkpoint {}", checkpointId);

    long[] checkpointOffsets;

    checkpointOffsets = (long[]) state.getState();

    if (LOG.isInfoEnabled()) {
      LOG.info("Committing offsets {} to ZooKeeper", Arrays.toString(checkpointOffsets));
    }

    setOffsetsInZooKeeper(checkpointOffsets);
  }