zhangshenghang commented on code in PR #9961:
URL: https://github.com/apache/seatunnel/pull/9961#discussion_r2441844357
##########
seatunnel-connectors-v2/connector-milvus/src/main/java/org/apache/seatunnel/connectors/seatunnel/milvus/sink/MilvusSinkWriter.java:
##########
@@ -41,13 +47,29 @@ public class MilvusSinkWriter
private final MilvusBufferBatchWriter batchWriter;
private ReadonlyConfig config;
+ private final ScheduledExecutorService scheduler;
+
+ private final ReentrantLock lock = new ReentrantLock();
+
+ private final AtomicReference<Exception> exception = new
AtomicReference<>();
+
public MilvusSinkWriter(
Context context,
CatalogTable catalogTable,
ReadonlyConfig config,
List<MilvusSinkState> milvusSinkStates) {
this.batchWriter = new MilvusBufferBatchWriter(catalogTable, config);
this.config = config;
+ int batchInterval = config.get(MilvusSinkOptions.BATCH_INTERVAL);
+ this.scheduler = batchInterval > 0 ?
Executors.newSingleThreadScheduledExecutor() : null;
+ if (scheduler != null) {
+ log.info("create Milvus sink writer with batch interval: {}",
batchInterval);
+ scheduler.scheduleAtFixedRate(
+ new BatchWriterFlushRunnable(batchWriter),
+ 0,
+ batchInterval,
+ TimeUnit.MILLISECONDS);
+ }
Review Comment:
We do not recommend opening a separate thread to handle this issue. You can
solve this problem through prepareCommit()
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]