Class CompactCoordinator
- java.lang.Object
-
- org.apache.flink.streaming.api.operators.AbstractStreamOperator<CompactorRequest>
-
- org.apache.flink.connector.file.sink.compactor.operator.CompactCoordinator
-
- All Implemented Interfaces:
Serializable
,CheckpointListener
,BoundedOneInput
,Input<CommittableMessage<FileSinkCommittable>>
,KeyContext
,KeyContextHandler
,OneInputStreamOperator<CommittableMessage<FileSinkCommittable>,CompactorRequest>
,StreamOperator<CompactorRequest>
,StreamOperatorStateHandler.CheckpointedStreamOperator
,YieldingOperator<CompactorRequest>
@Internal public class CompactCoordinator extends AbstractStreamOperator<CompactorRequest> implements OneInputStreamOperator<CommittableMessage<FileSinkCommittable>,CompactorRequest>, BoundedOneInput
Coordinator that coordinates file compaction for theFileSink
.All committable emitted from the writers are collected and packed into
CompactorRequest
s. TheFileCompactStrategy
defines when the requests can be fired. When a firing condition is met, the requests will be sent to theCompactorOperator
.The
CompactCoordinator
stores the non-fired committable as its state, and may emit a request at any time. ACompactorOperator
must ensure that the ownership of the committable in a compact request is successfully handed from the coordinator, before it can actually perform the compaction.- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.apache.flink.streaming.api.operators.AbstractStreamOperator
combinedWatermark, config, lastRecordAttributes1, lastRecordAttributes2, latencyStats, LOG, metrics, output, processingTimeService, stateHandler, stateKeySelector1, stateKeySelector2, timeServiceManager
-
-
Constructor Summary
Constructors Constructor Description CompactCoordinator(StreamOperatorParameters<CompactorRequest> parameters, FileCompactStrategy strategy, SimpleVersionedSerializer<FileSinkCommittable> committableSerializer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
endInput()
It is notified that no more data will arrive from the input.void
initializeState(StateInitializationContext context)
Stream operators with state which can be restored need to override this hook method.void
prepareSnapshotPreBarrier(long checkpointId)
This method is called when the operator should do a snapshot, before it emits its own checkpoint barrier.void
processElement(StreamRecord<CommittableMessage<FileSinkCommittable>> element)
Processes one element that arrived on this input of theMultipleInputStreamOperator
.void
snapshotState(StateSnapshotContext context)
Stream operators with state, which want to participate in a snapshot need to override this hook method.-
Methods inherited from class org.apache.flink.streaming.api.operators.AbstractStreamOperator
close, finish, getContainingTask, getCurrentKey, getExecutionConfig, getInternalTimerService, getKeyedStateBackend, getKeyedStateStore, getMetricGroup, getOperatorConfig, getOperatorID, getOperatorName, getOperatorStateBackend, getOrCreateKeyedState, getPartitionedState, getPartitionedState, getProcessingTimeService, getRuntimeContext, getStateKeySelector1, getStateKeySelector2, getTimeServiceManager, getUserCodeClassloader, hasKeyContext1, hasKeyContext2, initializeState, isAsyncStateProcessingEnabled, isUsingCustomRawKeyedState, notifyCheckpointAborted, notifyCheckpointComplete, open, processLatencyMarker, processLatencyMarker1, processLatencyMarker2, processRecordAttributes, processRecordAttributes1, processRecordAttributes2, processWatermark, processWatermark1, processWatermark2, processWatermarkStatus, processWatermarkStatus, processWatermarkStatus1, processWatermarkStatus2, reportOrForwardLatencyMarker, setCurrentKey, setKeyContextElement1, setKeyContextElement2, setMailboxExecutor, setProcessingTimeService, setup, snapshotState, useSplittableTimers
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.flink.api.common.state.CheckpointListener
notifyCheckpointAborted, notifyCheckpointComplete
-
Methods inherited from interface org.apache.flink.streaming.api.operators.Input
processLatencyMarker, processRecordAttributes, processWatermark, processWatermarkStatus
-
Methods inherited from interface org.apache.flink.streaming.api.operators.KeyContext
getCurrentKey, setCurrentKey
-
Methods inherited from interface org.apache.flink.streaming.api.operators.KeyContextHandler
hasKeyContext
-
Methods inherited from interface org.apache.flink.streaming.api.operators.OneInputStreamOperator
setKeyContextElement
-
Methods inherited from interface org.apache.flink.streaming.api.operators.StreamOperator
close, finish, getMetricGroup, getOperatorAttributes, getOperatorID, initializeState, open, setKeyContextElement1, setKeyContextElement2, snapshotState
-
-
-
-
Constructor Detail
-
CompactCoordinator
public CompactCoordinator(StreamOperatorParameters<CompactorRequest> parameters, FileCompactStrategy strategy, SimpleVersionedSerializer<FileSinkCommittable> committableSerializer)
-
-
Method Detail
-
processElement
public void processElement(StreamRecord<CommittableMessage<FileSinkCommittable>> element) throws Exception
Description copied from interface:Input
Processes one element that arrived on this input of theMultipleInputStreamOperator
. This method is guaranteed to not be called concurrently with other methods of the operator.- Specified by:
processElement
in interfaceInput<CommittableMessage<FileSinkCommittable>>
- Throws:
Exception
-
endInput
public void endInput() throws Exception
Description copied from interface:BoundedOneInput
It is notified that no more data will arrive from the input.WARNING: It is not safe to use this method to commit any transactions or other side effects! You can use this method to flush any buffered data that can later on be committed e.g. in a
CheckpointListener.notifyCheckpointComplete(long)
.NOTE: Given it is semantically very similar to the
StreamOperator.finish()
method. It might be dropped in favour of the other method at some point in time.- Specified by:
endInput
in interfaceBoundedOneInput
- Throws:
Exception
-
prepareSnapshotPreBarrier
public void prepareSnapshotPreBarrier(long checkpointId) throws Exception
Description copied from interface:StreamOperator
This method is called when the operator should do a snapshot, before it emits its own checkpoint barrier.This method is intended not for any actual state persistence, but only for emitting some data before emitting the checkpoint barrier. Operators that maintain some small transient state that is inefficient to checkpoint (especially when it would need to be checkpointed in a re-scalable way) but can simply be sent downstream before the checkpoint. An example are opportunistic pre-aggregation operators, which have small the pre-aggregation state that is frequently flushed downstream.
Important: This method should not be used for any actual state snapshot logic, because it will inherently be within the synchronous part of the operator's checkpoint. If heavy work is done within this method, it will affect latency and downstream checkpoint alignments.
- Specified by:
prepareSnapshotPreBarrier
in interfaceStreamOperator<CompactorRequest>
- Overrides:
prepareSnapshotPreBarrier
in classAbstractStreamOperator<CompactorRequest>
- Parameters:
checkpointId
- The ID of the checkpoint.- Throws:
Exception
- Throwing an exception here causes the operator to fail and go into recovery.
-
snapshotState
public void snapshotState(StateSnapshotContext context) throws Exception
Description copied from class:AbstractStreamOperator
Stream operators with state, which want to participate in a snapshot need to override this hook method.- Specified by:
snapshotState
in interfaceStreamOperatorStateHandler.CheckpointedStreamOperator
- Overrides:
snapshotState
in classAbstractStreamOperator<CompactorRequest>
- Parameters:
context
- context that provides information and means required for taking a snapshot- Throws:
Exception
-
initializeState
public void initializeState(StateInitializationContext context) throws Exception
Description copied from class:AbstractStreamOperator
Stream operators with state which can be restored need to override this hook method.- Specified by:
initializeState
in interfaceStreamOperatorStateHandler.CheckpointedStreamOperator
- Overrides:
initializeState
in classAbstractStreamOperator<CompactorRequest>
- Parameters:
context
- context that allows to register different states.- Throws:
Exception
-
-