simonsssu commented on a change in pull request #1515:
URL: https://github.com/apache/iceberg/pull/1515#discussion_r502387801



##########
File path: 
flink/src/main/java/org/apache/iceberg/flink/sink/IcebergFilesCommitter.java
##########
@@ -103,10 +107,26 @@
   private static final ListStateDescriptor<SortedMap<Long, List<DataFile>>> 
STATE_DESCRIPTOR = buildStateDescriptor();
   private transient ListState<SortedMap<Long, List<DataFile>>> 
checkpointsState;
 
-  IcebergFilesCommitter(TableLoader tableLoader, Configuration hadoopConf, 
boolean replacePartitions) {
+  IcebergFilesCommitter(TableLoader tableLoader, Configuration hadoopConf, 
boolean replacePartitions,
+                        org.apache.flink.configuration.Configuration 
flinkConf) {
     this.tableLoader = tableLoader;
     this.hadoopConf = new SerializableConfiguration(hadoopConf);
     this.replacePartitions = replacePartitions;
+    this.flinkConf = flinkConf;
+    this.flushCommitInterval = 
flinkConf.getLong(FlinkSink.FLINK_ICEBERG_SINK_FLUSHINTERVAL,
+        FlinkSink.DEFAULT_FLINK_ICEBERG_SINK_FLUSHINTERVAL);
+  }
+
+  @Override
+  public void open() throws Exception {
+    super.open();
+    boolean isCheckpointEnabled = getRuntimeContext().isCheckpointingEnabled();
+    // If we don't enable checkpoint, we will use processingTimeSerice to do 
commit,
+    if (!isCheckpointEnabled) {
+      ProcessingTimeService processingTimeService = 
getRuntimeContext().getProcessingTimeService();
+      final long currentTimestamp = 
processingTimeService.getCurrentProcessingTime();
+      processingTimeService.registerTimer(currentTimestamp + 
flushCommitInterval, this);
+    }
   }
 
   @Override

Review comment:
       Yes initializeState will invoke even checkpoint disabled, and 
context.isRestored will be false.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to