Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Make requestUtilization map thread safe. #1850

Merged
merged 2 commits into from
Sep 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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