From 854c83b767cafbdc4b6ac86f3344cd4da1d053c0 Mon Sep 17 00:00:00 2001 From: Gowtam Lal Date: Thu, 13 Sep 2018 11:57:02 -0400 Subject: [PATCH 1/2] Make this map thread safe. --- .../singularity/scheduler/SingularityLeaderCache.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/SingularityService/src/main/java/com/hubspot/singularity/scheduler/SingularityLeaderCache.java b/SingularityService/src/main/java/com/hubspot/singularity/scheduler/SingularityLeaderCache.java index 9ddfaeb013..885ebdab5c 100644 --- a/SingularityService/src/main/java/com/hubspot/singularity/scheduler/SingularityLeaderCache.java +++ b/SingularityService/src/main/java/com/hubspot/singularity/scheduler/SingularityLeaderCache.java @@ -9,6 +9,7 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import java.util.function.Function; import java.util.stream.Collectors; @@ -47,7 +48,7 @@ public class SingularityLeaderCache { private Map slaves; private Map racks; private Set pendingTaskIdsToDelete; - private Map requestUtilizations; + private ConcurrentMap requestUtilizations; private volatile boolean active; @@ -117,7 +118,7 @@ public void stop() { } public void cacheRequestUtilizations(Map requestUtilizations) { - this.requestUtilizations = new HashMap<>(requestUtilizations); + this.requestUtilizations = new ConcurrentHashMap<>(requestUtilizations); } public boolean active() { From b1fb3662dddb856c186e6c706872b7b07fccbc2c Mon Sep 17 00:00:00 2001 From: Gowtam Lal Date: Thu, 13 Sep 2018 12:04:51 -0400 Subject: [PATCH 2/2] This annotation isn't useful here. --- .../com/hubspot/singularity/data/NotificationsManager.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/SingularityService/src/main/java/com/hubspot/singularity/data/NotificationsManager.java b/SingularityService/src/main/java/com/hubspot/singularity/data/NotificationsManager.java index cae9735320..c422eed9f2 100644 --- a/SingularityService/src/main/java/com/hubspot/singularity/data/NotificationsManager.java +++ b/SingularityService/src/main/java/com/hubspot/singularity/data/NotificationsManager.java @@ -5,7 +5,6 @@ import org.apache.curator.framework.CuratorFramework; import org.apache.curator.utils.ZKPaths; -import org.jetbrains.annotations.NotNull; import com.codahale.metrics.MetricRegistry; import com.google.common.cache.CacheBuilder; @@ -49,7 +48,7 @@ public List getBlacklist() { return cache.getUnchecked(BLACKLIST_ROOT); } - @NotNull private String getEmailPath(String email) { + private String getEmailPath(String email) { return ZKPaths.makePath(BLACKLIST_ROOT, email); } }