Skip to content

Commit

Permalink
Merge pull request #1850 from HubSpot/threadsafe-utilization-map
Browse files Browse the repository at this point in the history
Make requestUtilization map thread safe.
  • Loading branch information
ssalinas authored Sep 26, 2018
2 parents bb31baf + b1fb366 commit b8c5c42
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -49,7 +48,7 @@ public List<String> getBlacklist() {
return cache.getUnchecked(BLACKLIST_ROOT);
}

@NotNull private String getEmailPath(String email) {
private String getEmailPath(String email) {
return ZKPaths.makePath(BLACKLIST_ROOT, email);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -47,7 +48,7 @@ public class SingularityLeaderCache {
private Map<String, SingularitySlave> slaves;
private Map<String, SingularityRack> racks;
private Set<SingularityPendingTaskId> pendingTaskIdsToDelete;
private Map<String, RequestUtilization> requestUtilizations;
private ConcurrentMap<String, RequestUtilization> requestUtilizations;

private volatile boolean active;

Expand Down Expand Up @@ -117,7 +118,7 @@ public void stop() {
}

public void cacheRequestUtilizations(Map<String, RequestUtilization> requestUtilizations) {
this.requestUtilizations = new HashMap<>(requestUtilizations);
this.requestUtilizations = new ConcurrentHashMap<>(requestUtilizations);
}

public boolean active() {
Expand Down

0 comments on commit b8c5c42

Please # to comment.