Search in sources :

Example 1 with SimpleVersionedListState

use of org.apache.flink.streaming.api.operators.util.SimpleVersionedListState in project flink by apache.

the class CompactCoordinatorStateHandler method initializeState.

@Override
public void initializeState(StateInitializationContext context) throws Exception {
    super.initializeState(context);
    ListState<FileSinkCommittable> remainingCommittableState = new SimpleVersionedListState<>(context.getOperatorStateStore().getListState(REMAINING_COMMITTABLE_RAW_STATES_DESC), committableSerializer);
    Iterable<FileSinkCommittable> stateRemaining = remainingCommittableState.get();
    if (stateRemaining != null) {
        for (FileSinkCommittable committable : stateRemaining) {
            // all committable should be wrapped with a single request, since multiple files
            // compacting is not available now
            String bucketId = committable.getBucketId();
            CompactorRequest request = new CompactorRequest(bucketId);
            request.addToCompact(committable);
            output.collect(new StreamRecord<>(Either.Right(request)));
        }
    }
    // Remaining committable should be all emitted, and the state can be cleared. From now on
    // the operator is stateless, snapshotState is not necessary.
    remainingCommittableState.clear();
}
Also used : SimpleVersionedListState(org.apache.flink.streaming.api.operators.util.SimpleVersionedListState) FileSinkCommittable(org.apache.flink.connector.file.sink.FileSinkCommittable)

Aggregations

FileSinkCommittable (org.apache.flink.connector.file.sink.FileSinkCommittable)1 SimpleVersionedListState (org.apache.flink.streaming.api.operators.util.SimpleVersionedListState)1