Skip to content

Commit 3fd94e4

Browse files
committed
Fix[optimize network]:Fix ConcurrentModificationException problem.
1 parent 3b0dcd4 commit 3fd94e4

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

flink-shim/flink-shim-1.13/src/main/java/org/apache/flink/runtime/io/network/partition/PipelinedResultPartition.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.io.IOException;
2929
import java.util.HashMap;
3030
import java.util.Map;
31+
import java.util.concurrent.ConcurrentHashMap;
3132
import java.util.stream.IntStream;
3233

3334
import static org.apache.flink.util.Preconditions.checkArgument;
@@ -216,13 +217,13 @@ public void close() {
216217
asyncThread.interrupt();
217218
}
218219

219-
public void iniEnv(int numberOfChannels){
220-
bufferStatista = new HashMap<>(numberOfChannels);
220+
public void iniEnv(int numberOfChannels) {
221+
bufferStatista = new ConcurrentHashMap<>(numberOfChannels);
221222
asyncThread = new Thread(() -> {
222223
try {
223224
Long checkStartTime = System.currentTimeMillis();
224225
while (iniAsyncBackground) {
225-
if (System.currentTimeMillis() - checkStartTime > FLUSH_TIME){
226+
if (System.currentTimeMillis() - checkStartTime > FLUSH_TIME) {
226227
bufferStatista.clear();
227228
checkStartTime = System.currentTimeMillis();
228229
}
@@ -231,7 +232,7 @@ public void iniEnv(int numberOfChannels){
231232
bufferStatista.put(e,
232233
bufferStatista.getOrDefault(e, 0)
233234
+ Math.max(subpartitions[e].getBuffersInBacklog(), 1)));
234-
if (getBackPressuredTimeMsPerSecond().getValue() > ACTIVE_FLUSH_TASK_BACK_PRESSURED_TIME){
235+
if (getBackPressuredTimeMsPerSecond().getValue() > ACTIVE_FLUSH_TASK_BACK_PRESSURED_TIME) {
235236
flushStatista = true;
236237
}
237238
Thread.sleep(ACTIVE_FLUSH_TASK_BACK_PRESSURED_TIME);
@@ -245,7 +246,7 @@ public void iniEnv(int numberOfChannels){
245246

246247
public Map<Integer, Integer> getBufferStatista() {
247248
if (flushStatista) {
248-
return bufferStatista;
249+
return new HashMap<>(bufferStatista);
249250
}
250251
return null;
251252
}

0 commit comments

Comments
 (0)