@@ -125,8 +125,6 @@ class PlanetaryEngine<K, V> {
125
125
private final IdleWindowScaner idleWindowScaner ;
126
126
private volatile boolean stop = false ;
127
127
128
- private long lastCommit = 0 ;
129
- private int commitInterval = 10 * 1000 ;
130
128
private final HashSet <MessageQueue > mq2Commit = new HashSet <>();
131
129
132
130
@@ -147,14 +145,15 @@ public PlanetaryEngine(DefaultLitePullConsumer unionConsumer, DefaultMQProducer
147
145
}
148
146
});
149
147
Integer idleTime = (Integer ) WorkerThread .this .properties .getOrDefault (StreamConfig .IDLE_TIME_TO_FIRE_WINDOW , 2000 );
148
+ int commitInterval = (Integer ) WorkerThread .this .properties .getOrDefault (StreamConfig .COMMIT_STATE_INTERNAL_MS , 2 * 1000 );
150
149
this .idleWindowScaner = new IdleWindowScaner (idleTime , executor );
151
150
WorkerThread .this .executor .scheduleAtFixedRate (() -> {
152
151
try {
153
152
doCommit (mq2Commit );
154
153
} catch (Throwable t ) {
155
154
logger .error ("commit offset and state error." , t );
156
155
}
157
- }, 10 , 10 , TimeUnit .SECONDS );
156
+ }, 1000 , commitInterval , TimeUnit .MILLISECONDS );
158
157
}
159
158
160
159
@@ -227,15 +226,15 @@ void runInLoop() throws Throwable {
227
226
}
228
227
229
228
void doCommit (HashSet <MessageQueue > set ) throws Throwable {
230
- if (( System . currentTimeMillis () - lastCommit > commitInterval ) && set .size () != 0 ) {
229
+ if (set != null && set .size () != 0 ) {
231
230
232
231
this .stateStore .persist (set );
233
232
this .unionConsumer .commit (set , true );
234
233
235
234
for (MessageQueue messageQueue : set ) {
236
235
logger .debug ("committed messageQueue: [{}]" , messageQueue );
237
236
}
238
- lastCommit = System . currentTimeMillis ();
237
+
239
238
set .clear ();
240
239
}
241
240
}
0 commit comments