Skip to content

Commit 2292f08

Browse files
author
Fabricio Duarte
committed
Avoid possible race condition in task submission and clean-up
1 parent 25d2e33 commit 2292f08

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/StorageOrchestrator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public class StorageOrchestrator extends ManagerBase implements StorageOrchestra
111111

112112
Integer numConcurrentCopyTasksPerSSVM = 2;
113113

114-
private final Map<Long, ThreadPoolExecutor> zoneExecutorMap = new ConcurrentHashMap<>();
114+
private final Map<Long, ThreadPoolExecutor> zoneExecutorMap = new HashMap<>();
115115

116116
@Override
117117
public String getConfigComponentName() {
@@ -357,7 +357,7 @@ protected Map<Long, Pair<Long, Long>> migrateAway(
357357
return storageCapacities;
358358
}
359359

360-
protected <T> Future<T> submit(Long zoneId, Callable<T> task) {
360+
protected synchronized <T> Future<T> submit(Long zoneId, Callable<T> task) {
361361
if (!zoneExecutorMap.containsKey(zoneId)) {
362362
zoneExecutorMap.put(zoneId, new ThreadPoolExecutor(numConcurrentCopyTasksPerSSVM , numConcurrentCopyTasksPerSSVM,
363363
30, TimeUnit.MINUTES, new MigrateBlockingQueue<>(numConcurrentCopyTasksPerSSVM)));

0 commit comments

Comments
 (0)