Skip to content

Commit

Permalink
take a list of string values for each reserved attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
ssalinas committed Dec 10, 2015
1 parent ff0328e commit 836f127
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
@@ -1,6 +1,7 @@
package com.hubspot.singularity.config;

import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

Expand Down Expand Up @@ -204,7 +205,7 @@ public class SingularityConfiguration extends Configuration {
private AuthConfiguration authConfiguration = new AuthConfiguration();

@NotNull
private Map<String, String> reserveSlavesWithAttributes = Collections.emptyMap();
private Map<String, List<String>> reserveSlavesWithAttributes = Collections.emptyMap();

@JsonProperty("graphite")
@NotNull
Expand Down Expand Up @@ -834,11 +835,11 @@ public void setHistoryPurgingConfiguration(HistoryPurgingConfiguration historyPu
this.historyPurgingConfiguration = historyPurgingConfiguration;
}

public Map<String, String> getReserveSlavesWithAttributes() {
public Map<String, List<String>> getReserveSlavesWithAttributes() {
return reserveSlavesWithAttributes;
}

public void setReserveSlavesWithAttrbiutes(Map<String, String> reserveSlavesWithAttributes) {
public void setReserveSlavesWithAttrbiutes(Map<String, List<String>> reserveSlavesWithAttributes) {
this.reserveSlavesWithAttributes = reserveSlavesWithAttributes;
}

Expand Down
@@ -1,6 +1,7 @@
package com.hubspot.singularity.mesos;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.inject.Singleton;
Expand Down Expand Up @@ -95,9 +96,11 @@ public Map<String, String> getTextAttributes(Offer offer) {
public Map<String, String> reservedSlaveAttributes(Offer offer) {
Map<String, String> reservedAttributes = new HashMap<>();
Map<String, String> offerTextAttributes = getTextAttributes(offer);
for (Map.Entry<String, String> entry : configuration.getReserveSlavesWithAttributes().entrySet()) {
if (offerTextAttributes.containsKey(entry.getKey()) && offerTextAttributes.get(entry.getKey()).equals(entry.getValue())) {
reservedAttributes.put(entry.getKey(), entry.getValue());
for (Map.Entry<String, List<String>> entry : configuration.getReserveSlavesWithAttributes().entrySet()) {
for (String attr : entry.getValue()) {
if (offerTextAttributes.containsKey(entry.getKey()) && offerTextAttributes.get(entry.getKey()).equals(attr)) {
reservedAttributes.put(entry.getKey(), attr);
}
}
}
return reservedAttributes;
Expand Down

0 comments on commit 836f127

Please sign in to comment.