use of org.apache.flink.connector.file.sink.compactor.operator.CompactorOperatorFactory in project flink by apache.
the class FileSink method addPreCommitTopology.
@Override
public DataStream<CommittableMessage<FileSinkCommittable>> addPreCommitTopology(DataStream<CommittableMessage<FileSinkCommittable>> committableStream) {
FileCompactStrategy strategy = bucketsBuilder.getCompactStrategy();
if (strategy == null) {
// not enabled, handlers will be added to process the remaining states of the compact
// coordinator and the compactor operators.
SingleOutputStreamOperator<Either<CommittableMessage<FileSinkCommittable>, CompactorRequest>> coordinatorOp = committableStream.forward().transform("CompactorCoordinator", new EitherTypeInfo<>(committableStream.getType(), new CompactorRequestTypeInfo(bucketsBuilder::getCommittableSerializer)), new CompactCoordinatorStateHandlerFactory(bucketsBuilder::getCommittableSerializer)).setParallelism(committableStream.getParallelism()).uid("FileSinkCompactorCoordinator");
return coordinatorOp.forward().transform("CompactorOperator", committableStream.getType(), new CompactorOperatorStateHandlerFactory(bucketsBuilder::getCommittableSerializer, bucketsBuilder::createBucketWriter)).setParallelism(committableStream.getParallelism()).uid("FileSinkCompactorOperator");
}
// explicitly rebalance here is required, or the partitioner will be forward, which is in
// fact the partitioner from the writers to the committers
SingleOutputStreamOperator<CompactorRequest> coordinatorOp = committableStream.rebalance().transform("CompactorCoordinator", new CompactorRequestTypeInfo(bucketsBuilder::getCommittableSerializer), new CompactCoordinatorFactory(strategy, bucketsBuilder::getCommittableSerializer)).setParallelism(1).uid("FileSinkCompactorCoordinator");
// parallelism of the compactors is not configurable at present, since it must be identical
// to that of the committers, or the committable summary and the committables may be
// distributed to different committers, which will cause a failure
TypeInformation<CommittableMessage<FileSinkCommittable>> committableType = committableStream.getType();
return coordinatorOp.transform("CompactorOperator", committableType, new CompactorOperatorFactory(strategy, bucketsBuilder.getFileCompactor(), bucketsBuilder::getCommittableSerializer, bucketsBuilder::createBucketWriter)).setParallelism(committableStream.getParallelism()).uid("FileSinkCompactorOperator");
}
Aggregations