diff --git a/Docs/about/requests-and-deploys.md b/Docs/about/requests-and-deploys.md
index 84b0cff160..b6032bfefa 100644
--- a/Docs/about/requests-and-deploys.md
+++ b/Docs/about/requests-and-deploys.md
@@ -36,6 +36,7 @@ Now you want `TestService` to actually run. To do this, you need to create a `De
"resources": {
"cpus":1,
"memoryMb":128,
+ "diskMb": 1024,
"numPorts":2
},
"command":"java -Ddw.server.applicationConnectors[0].port=$PORT0 -Ddw.server.adminConnectors[0].port=$PORT1 -jar singularitytest-1.0-SNAPSHOT.jar server example.yml",
diff --git a/Docs/getting-started/install.md b/Docs/getting-started/install.md
index 4149a57c7c..c7614d5c1d 100644
--- a/Docs/getting-started/install.md
+++ b/Docs/getting-started/install.md
@@ -66,6 +66,7 @@ mesos:
master: http://[mesos master hostname]/api/v1/scheduler
defaultCpus: 1
defaultMemory: 128
+ defaultDisk: 1024
frameworkName: Singularity
frameworkId: Singularity
frameworkFailoverTimeout: 1000000
diff --git a/Docs/reference/configuration.md b/Docs/reference/configuration.md
index a5915e5156..036eb4485f 100644
--- a/Docs/reference/configuration.md
+++ b/Docs/reference/configuration.md
@@ -176,6 +176,7 @@ These settings should live under the "mesos" field inside the root configuration
|-----------|---------|-------------|------|
| defaultCpus | 1 | Number of CPUs to request for a task if none are specified | int |
| defaultMemory | 64 | MB of memory to request for a task if none is specified | int |
+| defaultDisk | 1024 | MB of disk to request for a task if none is specified | int |
| maxNumInstancesPerRequest | 25 | Max instances (tasks) to allow for a request (requests using over this will return a 400) | int |
| maxNumCpusPerInstance | 50 | Max number of CPUs allowed on a given task | int |
| maxNumCpusPerRequest | 900 | Max number of CPUs allowed for a given request (cpus per task * task instance) | int |
diff --git a/SingularityBase/pom.xml b/SingularityBase/pom.xml
index 5c8f2fa8dd..7f24886428 100644
--- a/SingularityBase/pom.xml
+++ b/SingularityBase/pom.xml
@@ -41,11 +41,6 @@
jackson-datatype-guava
-
- org.apache.mesos
- mesos
-
-
org.apache.commons
commons-lang3
diff --git a/SingularityBase/src/main/java/com/hubspot/mesos/JavaUtils.java b/SingularityBase/src/main/java/com/hubspot/mesos/JavaUtils.java
index c2315afad0..aae04c2aaf 100644
--- a/SingularityBase/src/main/java/com/hubspot/mesos/JavaUtils.java
+++ b/SingularityBase/src/main/java/com/hubspot/mesos/JavaUtils.java
@@ -202,12 +202,4 @@ public static ThreadPoolExecutor newFixedTimingOutThreadPool(int maxThreads, lon
public static String getReplaceHyphensWithUnderscores(String string) {
return string.replace("-", "_");
}
-
- public static final Optional getUserEmail(Optional user) {
- if (user.isPresent()) {
- return user.get().getEmail();
- } else {
- return Optional.absent();
- }
- }
}
diff --git a/SingularityBase/src/main/java/com/hubspot/mesos/SingularityVolume.java b/SingularityBase/src/main/java/com/hubspot/mesos/SingularityVolume.java
index 8536577ffd..af0dce2d82 100644
--- a/SingularityBase/src/main/java/com/hubspot/mesos/SingularityVolume.java
+++ b/SingularityBase/src/main/java/com/hubspot/mesos/SingularityVolume.java
@@ -2,8 +2,6 @@
import java.util.Objects;
-import org.apache.mesos.v1.Protos;
-
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Optional;
@@ -23,19 +21,6 @@ public SingularityVolume(
this.mode = Optional.fromNullable(mode);
}
- @Deprecated
- public SingularityVolume(String containerPath, Optional hostPath, Optional mode) {
- this(containerPath, hostPath, convertedMode(mode));
- }
-
- private static SingularityDockerVolumeMode convertedMode(Optional mode) {
- if (mode.isPresent()) {
- return SingularityDockerVolumeMode.valueOf(mode.get().toString());
- } else {
- return null;
- }
- }
-
public String getContainerPath() {
return containerPath;
}
diff --git a/SingularityBase/src/main/java/com/hubspot/mesos/json/SingularityMesosOfferObject.java b/SingularityBase/src/main/java/com/hubspot/mesos/json/SingularityMesosOfferObject.java
deleted file mode 100644
index 0d8643a805..0000000000
--- a/SingularityBase/src/main/java/com/hubspot/mesos/json/SingularityMesosOfferObject.java
+++ /dev/null
@@ -1,168 +0,0 @@
-package com.hubspot.mesos.json;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.mesos.v1.Protos.AgentID;
-import org.apache.mesos.v1.Protos.Attribute;
-import org.apache.mesos.v1.Protos.ExecutorID;
-import org.apache.mesos.v1.Protos.FrameworkID;
-import org.apache.mesos.v1.Protos.Offer;
-import org.apache.mesos.v1.Protos.OfferID;
-import org.apache.mesos.v1.Protos.Resource;
-import org.apache.mesos.v1.Protos.URL;
-
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-/*
- * Mirrors the mesos Offer object, with the exception that slaveId can be read into agentId
- */
-public class SingularityMesosOfferObject {
- private final List attributes;
- private final List executorIds;
- private final URL url;
- private final AgentID agentId;
- private final AgentID slaveId;
- private final FrameworkID frameworkId;
- private final String hostname;
- private final List resources;
- private final OfferID id;
-
- public static final SingularityMesosOfferObject fromProtos(Offer offer) {
- return new SingularityMesosOfferObject(
- offer.getAttributesList(),
- offer.getExecutorIdsList(),
- offer.getUrl(),
- offer.getAgentId(),
- null,
- offer.getFrameworkId(),
- offer.getHostname(),
- offer.getResourcesList(),
- offer.getId()
- );
- }
-
- @JsonCreator
- public SingularityMesosOfferObject(@JsonProperty("attributes") List attributes,
- @JsonProperty("executorIds") List executorIds,
- @JsonProperty("url") URL url,
- @JsonProperty("agentId") AgentID agentId,
- @JsonProperty("slaveId") AgentID slaveId,
- @JsonProperty("frameworkId") FrameworkID frameworkId,
- @JsonProperty("hostname") String hostname,
- @JsonProperty("resources") List resources,
- @JsonProperty("id") OfferID id) {
- this.attributes = attributes;
- this.executorIds = executorIds;
- this.url = url;
- this.agentId = agentId != null ? agentId : slaveId;
- this.slaveId = agentId != null ? agentId : slaveId;
- this.frameworkId = frameworkId;
- this.hostname = hostname;
- this.resources = resources;
- this.id = id;
- }
-
- public SingularityMesosOfferObject sizeOptimized() {
- return new SingularityMesosOfferObject(attributes, Collections.emptyList(), url, agentId, null, frameworkId, hostname, Collections.emptyList(), id);
- }
-
- public List getAttributes() {
- return attributes;
- }
-
- public List getExecutorIds() {
- return executorIds;
- }
-
- public URL getUrl() {
- return url;
- }
-
- public AgentID getAgentId() {
- return agentId;
- }
-
- public AgentID getSlaveId() {
- return slaveId;
- }
-
- public FrameworkID getFrameworkId() {
- return frameworkId;
- }
-
- public String getHostname() {
- return hostname;
- }
-
- public List getResources() {
- return resources;
- }
-
- public OfferID getId() {
- return id;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- SingularityMesosOfferObject that = (SingularityMesosOfferObject) o;
-
- if (attributes != null ? !attributes.equals(that.attributes) : that.attributes != null) {
- return false;
- }
- if (executorIds != null ? !executorIds.equals(that.executorIds) : that.executorIds != null) {
- return false;
- }
- if (url != null ? !url.equals(that.url) : that.url != null) {
- return false;
- }
- if (agentId != null ? !agentId.equals(that.agentId) : that.agentId != null) {
- return false;
- }
- if (frameworkId != null ? !frameworkId.equals(that.frameworkId) : that.frameworkId != null) {
- return false;
- }
- if (hostname != null ? !hostname.equals(that.hostname) : that.hostname != null) {
- return false;
- }
- if (resources != null ? !resources.equals(that.resources) : that.resources != null) {
- return false;
- }
- return id != null ? id.equals(that.id) : that.id == null;
- }
-
- @Override
- public int hashCode() {
- int result = attributes != null ? attributes.hashCode() : 0;
- result = 31 * result + (executorIds != null ? executorIds.hashCode() : 0);
- result = 31 * result + (url != null ? url.hashCode() : 0);
- result = 31 * result + (agentId != null ? agentId.hashCode() : 0);
- result = 31 * result + (frameworkId != null ? frameworkId.hashCode() : 0);
- result = 31 * result + (hostname != null ? hostname.hashCode() : 0);
- result = 31 * result + (resources != null ? resources.hashCode() : 0);
- result = 31 * result + (id != null ? id.hashCode() : 0);
- return result;
- }
-
- @Override
- public String toString() {
- return "SingularityMesosOfferObject{" +
- "attributes=" + attributes +
- ", executorIds=" + executorIds +
- ", url=" + url +
- ", agentId=" + agentId +
- ", frameworkId=" + frameworkId +
- ", hostname='" + hostname + '\'' +
- ", resources=" + resources +
- ", id=" + id +
- '}';
- }
-}
diff --git a/SingularityBase/src/main/java/com/hubspot/mesos/json/SingularityMesosTaskObject.java b/SingularityBase/src/main/java/com/hubspot/mesos/json/SingularityMesosTaskObject.java
deleted file mode 100644
index cf832b7a16..0000000000
--- a/SingularityBase/src/main/java/com/hubspot/mesos/json/SingularityMesosTaskObject.java
+++ /dev/null
@@ -1,237 +0,0 @@
-package com.hubspot.mesos.json;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.mesos.v1.Protos.AgentID;
-import org.apache.mesos.v1.Protos.CommandInfo;
-import org.apache.mesos.v1.Protos.ContainerInfo;
-import org.apache.mesos.v1.Protos.DiscoveryInfo;
-import org.apache.mesos.v1.Protos.ExecutorInfo;
-import org.apache.mesos.v1.Protos.HealthCheck;
-import org.apache.mesos.v1.Protos.KillPolicy;
-import org.apache.mesos.v1.Protos.Labels;
-import org.apache.mesos.v1.Protos.Resource;
-import org.apache.mesos.v1.Protos.TaskID;
-import org.apache.mesos.v1.Protos.TaskInfo;
-
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.google.common.base.Optional;
-
-/*
- * Mimics the TaskInfo object from mesos, with the addition that we can read
- * AgentID from either a field named slaveId or a field named agentId for
- * better backwards compatibility
- */
-public class SingularityMesosTaskObject {
- private final TaskID taskId;
- private final Optional executor;
- private final Optional labels;
- private final AgentID agentId;
- private final AgentID slaveId;
- private final List resources;
- private final Optional command;
- private final Optional container;
- private final Optional discovery;
- private final Optional healthCheck;
- private final Optional killPolicy;
- private final String name;
-
- public static SingularityMesosTaskObject fromProtos(TaskInfo taskInfo) {
- return new SingularityMesosTaskObject(
- taskInfo.getTaskId(),
- taskInfo.hasExecutor() ? Optional.of(taskInfo.getExecutor()) : Optional.absent(),
- taskInfo.hasLabels() ? Optional.of(taskInfo.getLabels()) : Optional.absent(),
- taskInfo.getAgentId(),
- null,
- taskInfo.getResourcesList(),
- taskInfo.hasCommand() ? Optional.of(taskInfo.getCommand()) : Optional.absent(),
- taskInfo.hasContainer() ? Optional.of(taskInfo.getContainer()) : Optional.absent(),
- taskInfo.hasDiscovery() ? Optional.of(taskInfo.getDiscovery()) : Optional.absent(),
- taskInfo.hasHealthCheck() ? Optional.of(taskInfo.getHealthCheck()) : Optional.absent(),
- taskInfo.hasKillPolicy() ? Optional.of(taskInfo.getKillPolicy()) : Optional.absent(),
- taskInfo.getName()
- );
- }
-
- @JsonCreator
- public SingularityMesosTaskObject(@JsonProperty("taskId") TaskID taskId,
- @JsonProperty("executor") Optional executor,
- @JsonProperty("labels") Optional labels,
- @JsonProperty("agentId") AgentID agentId,
- @JsonProperty("slaveId") AgentID slaveId,
- @JsonProperty("resources") List resources,
- @JsonProperty("command") Optional command,
- @JsonProperty("container") Optional container,
- @JsonProperty("discovery") Optional discovery,
- @JsonProperty("healthCheck") Optional healthCheck,
- @JsonProperty("killPolicy") Optional killPolicy,
- @JsonProperty("name") String name) {
- this.taskId = taskId;
- this.executor = executor;
- this.labels = labels;
- this.agentId = agentId != null ? agentId : slaveId;
- this.slaveId = agentId != null ? agentId : slaveId;
- this.resources = resources != null ? resources : Collections.emptyList();
- this.command = command;
- this.container = container;
- this.discovery = discovery;
- this.healthCheck = healthCheck;
- this.killPolicy = killPolicy;
- this.name = name;
- }
-
- public TaskID getTaskId() {
- return taskId;
- }
-
- public ExecutorInfo getExecutor() {
- return executor.orNull();
- }
-
- public boolean hasExecutor() {
- return executor.isPresent();
- }
-
- public Labels getLabels() {
- return labels.orNull();
- }
-
- public boolean hasLabels() {
- return labels.isPresent();
- }
-
- public AgentID getAgentId() {
- return agentId;
- }
-
- public AgentID getSlaveId() {
- return slaveId;
- }
-
- public List getResources() {
- return resources;
- }
-
- public CommandInfo getCommand() {
- return command.orNull();
- }
-
- public boolean hasCommand() {
- return command.isPresent();
- }
-
- public ContainerInfo getContainer() {
- return container.orNull();
- }
-
- public boolean hasContainer() {
- return container.isPresent();
- }
-
- public DiscoveryInfo getDiscovery() {
- return discovery.orNull();
- }
-
- public boolean hasDiscovery() {
- return discovery.isPresent();
- }
-
- public HealthCheck getHealthCheck() {
- return healthCheck.orNull();
- }
-
- public boolean hasHealthCheck() {
- return healthCheck.isPresent();
- }
-
- public KillPolicy getKillPolicy() {
- return killPolicy.orNull();
- }
-
- public boolean hasKillPolicy() {
- return killPolicy.isPresent();
- }
-
- public String getName() {
- return name;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- SingularityMesosTaskObject that = (SingularityMesosTaskObject) o;
-
- if (taskId != null ? !taskId.equals(that.taskId) : that.taskId != null) {
- return false;
- }
- if (executor != null ? !executor.equals(that.executor) : that.executor != null) {
- return false;
- }
- if (labels != null ? !labels.equals(that.labels) : that.labels != null) {
- return false;
- }
- if (agentId != null ? !agentId.equals(that.agentId) : that.agentId != null) {
- return false;
- }
- if (resources != null ? !resources.equals(that.resources) : that.resources != null) {
- return false;
- }
- if (command != null ? !command.equals(that.command) : that.command != null) {
- return false;
- }
- if (container != null ? !container.equals(that.container) : that.container != null) {
- return false;
- }
- if (discovery != null ? !discovery.equals(that.discovery) : that.discovery != null) {
- return false;
- }
- if (healthCheck != null ? !healthCheck.equals(that.healthCheck) : that.healthCheck != null) {
- return false;
- }
- if (killPolicy != null ? !killPolicy.equals(that.killPolicy) : that.killPolicy != null) {
- return false;
- }
- return name != null ? name.equals(that.name) : that.name == null;
- }
-
- @Override
- public int hashCode() {
- int result = taskId != null ? taskId.hashCode() : 0;
- result = 31 * result + (executor != null ? executor.hashCode() : 0);
- result = 31 * result + (labels != null ? labels.hashCode() : 0);
- result = 31 * result + (agentId != null ? agentId.hashCode() : 0);
- result = 31 * result + (resources != null ? resources.hashCode() : 0);
- result = 31 * result + (command != null ? command.hashCode() : 0);
- result = 31 * result + (container != null ? container.hashCode() : 0);
- result = 31 * result + (discovery != null ? discovery.hashCode() : 0);
- result = 31 * result + (healthCheck != null ? healthCheck.hashCode() : 0);
- result = 31 * result + (killPolicy != null ? killPolicy.hashCode() : 0);
- result = 31 * result + (name != null ? name.hashCode() : 0);
- return result;
- }
-
- @Override
- public String toString() {
- return "SingularityMesosTaskObject{" +
- "taskId=" + taskId +
- ", executor=" + executor +
- ", labels=" + labels +
- ", agentId=" + agentId +
- ", resources=" + resources +
- ", command=" + command +
- ", container=" + container +
- ", discovery=" + discovery +
- ", healthCheck=" + healthCheck +
- ", killPolicy=" + killPolicy +
- ", name='" + name + '\'' +
- '}';
- }
-}
diff --git a/SingularityBase/src/main/java/com/hubspot/mesos/json/SingularityMesosTaskStatusObject.java b/SingularityBase/src/main/java/com/hubspot/mesos/json/SingularityMesosTaskStatusObject.java
deleted file mode 100644
index 50520d2d33..0000000000
--- a/SingularityBase/src/main/java/com/hubspot/mesos/json/SingularityMesosTaskStatusObject.java
+++ /dev/null
@@ -1,201 +0,0 @@
-package com.hubspot.mesos.json;
-
-import org.apache.mesos.v1.Protos.AgentID;
-import org.apache.mesos.v1.Protos.ContainerStatus;
-import org.apache.mesos.v1.Protos.ExecutorID;
-import org.apache.mesos.v1.Protos.Labels;
-import org.apache.mesos.v1.Protos.TaskID;
-import org.apache.mesos.v1.Protos.TaskState;
-import org.apache.mesos.v1.Protos.TaskStatus;
-import org.apache.mesos.v1.Protos.TaskStatus.Reason;
-import org.apache.mesos.v1.Protos.TaskStatus.Source;
-import org.apache.mesos.v1.Protos.TimeInfo;
-
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.google.common.base.Optional;
-
-public class SingularityMesosTaskStatusObject {
- private final Optional agentId;
- private final Optional slaveId;
- private final Optional containerStatus;
- private final Optional executorId;
- private final Optional healthy;
- private final Optional labels;
- private final Optional message;
- private final Optional reason;
- private final Optional source;
- private final Optional state;
- private final Optional taskId;
- private final Optional timestamp;
- private final Optional unreachableTime;
-
- @JsonCreator
- public SingularityMesosTaskStatusObject(@JsonProperty("agentId") Optional agentId,
- @JsonProperty("slaveId") Optional slaveId,
- @JsonProperty("containerStatus") Optional containerStatus,
- @JsonProperty("executorID") Optional executorId,
- @JsonProperty("healthy") Optional healthy,
- @JsonProperty("labels") Optional labels,
- @JsonProperty("message") Optional message,
- @JsonProperty("reason") Optional reason,
- @JsonProperty("source") Optional source,
- @JsonProperty("state") Optional state,
- @JsonProperty("taskId") Optional taskId,
- @JsonProperty("timestamp") Optional timestamp,
- @JsonProperty("unreachableTime") Optional unreachableTime) {
- this.agentId = agentId.or(slaveId);
- this.slaveId = agentId.or(slaveId);
- this.containerStatus = containerStatus;
- this.executorId = executorId;
- this.healthy = healthy;
- this.labels = labels;
- this.message = message;
- this.reason = reason;
- this.source = source;
- this.state = state;
- this.taskId = taskId;
- this.timestamp = timestamp;
- this.unreachableTime = unreachableTime;
- }
-
- public static SingularityMesosTaskStatusObject fromProtos(TaskStatus status) {
- return new SingularityMesosTaskStatusObject(
- status.hasAgentId() ? Optional.of(status.getAgentId()) : Optional.absent(),
- status.hasAgentId() ? Optional.of(status.getAgentId()) : Optional.absent(),
- status.hasContainerStatus() ? Optional.of(status.getContainerStatus()) : Optional.absent(),
- status.hasExecutorId() ? Optional.of(status.getExecutorId()) : Optional.absent(),
- status.hasHealthy() ? Optional.of(status.getHealthy()) : Optional.absent(),
- status.hasLabels() ? Optional.of(status.getLabels()) : Optional.absent(),
- status.hasMessage() ? Optional.of(status.getMessage()) : Optional.absent(),
- status.hasReason() ? Optional.of(status.getReason()) : Optional.absent(),
- status.hasSource() ? Optional.of(status.getSource()) : Optional.absent(),
- status.hasState() ? Optional.of(status.getState()) : Optional.absent(),
- status.hasTaskId() ? Optional.of(status.getTaskId()) : Optional.absent(),
- status.hasTimestamp() ? Optional.of(status.getTimestamp()) : Optional.absent(),
- status.hasUnreachableTime() ? Optional.of(status.getUnreachableTime()) : Optional.absent()
- );
- }
-
- public AgentID getAgentId() {
- return agentId.orNull();
- }
-
- public boolean hasAgentId() {
- return agentId.isPresent();
- }
-
- public AgentID getSlaveId() {
- return slaveId.orNull();
- }
- public boolean hasSlaveId() {
- return slaveId.isPresent();
- }
-
- public ContainerStatus getContainerStatus() {
- return containerStatus.orNull();
- }
-
- public boolean hasContainerStatus() {
- return containerStatus.isPresent();
- }
-
- public ExecutorID getExecutorId() {
- return executorId.orNull();
- }
-
- public boolean hasExecutorId() {
- return executorId.isPresent();
- }
-
- public Boolean getHealthy() {
- return healthy.orNull();
- }
-
- public boolean hasHealthy() {
- return healthy.isPresent();
- }
-
- public Labels getLabels() {
- return labels.orNull();
- }
-
- public boolean hasLabels() {
- return labels.isPresent();
- }
-
- public String getMessage() {
- return message.orNull();
- }
-
- public boolean hasMessage() {
- return message.isPresent();
- }
-
- public Reason getReason() {
- return reason.orNull();
- }
-
- public boolean hasReason() {
- return reason.isPresent();
- }
-
- public Source getSource() {
- return source.orNull();
- }
-
- public boolean hasSource() {
- return source.isPresent();
- }
-
- public TaskState getState() {
- return state.orNull();
- }
-
- public boolean hasState() {
- return state.isPresent();
- }
-
- public TaskID getTaskId() {
- return taskId.orNull();
- }
-
- public boolean hasTaskId() {
- return taskId.isPresent();
- }
-
- public Double getTimestamp() {
- return timestamp.orNull();
- }
-
- public boolean hasTimestamp() {
- return timestamp.isPresent();
- }
-
- public TimeInfo getUnreachableTime() {
- return unreachableTime.orNull();
- }
-
- public boolean hasUnreachableTime() {
- return unreachableTime.isPresent();
- }
-
- @Override
- public String toString() {
- return "SingularityMesosTaskStatusObject{" +
- "agentId=" + agentId +
- ", slaveId=" + slaveId +
- ", containerStatus=" + containerStatus +
- ", executorId=" + executorId +
- ", healthy=" + healthy +
- ", labels=" + labels +
- ", message=" + message +
- ", reason=" + reason +
- ", source=" + source +
- ", state=" + state +
- ", taskId=" + taskId +
- ", timestamp=" + timestamp +
- ", unreachableTime=" + unreachableTime +
- '}';
- }
-}
diff --git a/SingularityBase/src/main/java/com/hubspot/mesos/protos/MesosExecutorInfo.java b/SingularityBase/src/main/java/com/hubspot/mesos/protos/MesosExecutorInfo.java
new file mode 100644
index 0000000000..0fe76b6ca4
--- /dev/null
+++ b/SingularityBase/src/main/java/com/hubspot/mesos/protos/MesosExecutorInfo.java
@@ -0,0 +1,67 @@
+package com.hubspot.mesos.protos;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.Optional;
+
+public class MesosExecutorInfo {
+ private final Optional executorId;
+ private final Map allOtherFields;
+
+ @JsonCreator
+ public MesosExecutorInfo(@JsonProperty("executorId") Optional executorId) {
+ this.executorId = executorId;
+ this.allOtherFields = new HashMap<>();
+ }
+
+ public MesosStringValue getExecutorId() {
+ return executorId.orNull();
+ }
+
+ public boolean hasExecutorId() {
+ return executorId.isPresent();
+ }
+
+ // Unknown fields
+ @JsonAnyGetter
+ public Map getUnknownFields() {
+ return allOtherFields;
+ }
+
+ @JsonAnySetter
+ public void setUnknownFields(String name, Object value) {
+ allOtherFields.put(name, value);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof MesosExecutorInfo) {
+ final MesosExecutorInfo that = (MesosExecutorInfo) obj;
+ return Objects.equals(this.executorId, that.executorId) &&
+ Objects.equals(this.allOtherFields, that.allOtherFields);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(executorId, allOtherFields);
+ }
+
+ @Override
+ public String toString() {
+ return "MesosExecutorInfo{" +
+ "executorId=" + executorId +
+ ", allOtherFields=" + allOtherFields +
+ '}';
+ }
+}
diff --git a/SingularityBase/src/main/java/com/hubspot/mesos/protos/MesosLabels.java b/SingularityBase/src/main/java/com/hubspot/mesos/protos/MesosLabels.java
new file mode 100644
index 0000000000..c0878deead
--- /dev/null
+++ b/SingularityBase/src/main/java/com/hubspot/mesos/protos/MesosLabels.java
@@ -0,0 +1,44 @@
+package com.hubspot.mesos.protos;
+
+import java.util.List;
+import java.util.Objects;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class MesosLabels {
+ private final List labels;
+
+ @JsonCreator
+ public MesosLabels(@JsonProperty("labels") List labels) {
+ this.labels = labels;
+ }
+
+ public List getLabels() {
+ return labels;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof MesosLabels) {
+ final MesosLabels that = (MesosLabels) obj;
+ return Objects.equals(this.labels, that.labels);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(labels);
+ }
+
+ @Override
+ public String toString() {
+ return "MesosLabels{" +
+ "labels=" + labels +
+ '}';
+ }
+}
diff --git a/SingularityBase/src/main/java/com/hubspot/mesos/protos/MesosOfferObject.java b/SingularityBase/src/main/java/com/hubspot/mesos/protos/MesosOfferObject.java
new file mode 100644
index 0000000000..1af025a366
--- /dev/null
+++ b/SingularityBase/src/main/java/com/hubspot/mesos/protos/MesosOfferObject.java
@@ -0,0 +1,109 @@
+package com.hubspot.mesos.protos;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/*
+ * Mirrors the mesos Offer object, with the exception that slaveId can be read into agentId
+ */
+public class MesosOfferObject {
+ private final MesosStringValue agentId;
+ private final MesosStringValue slaveId;
+ private final MesosStringValue frameworkId;
+ private final String hostname;
+ private final MesosStringValue id;
+ private final Map allOtherFields;
+
+ @JsonCreator
+ public MesosOfferObject(@JsonProperty("agentId") MesosStringValue agentId,
+ @JsonProperty("slaveId") MesosStringValue slaveId,
+ @JsonProperty("frameworkId") MesosStringValue frameworkId,
+ @JsonProperty("hostname") String hostname,
+ @JsonProperty("id") MesosStringValue id) {
+ this.agentId = agentId != null ? agentId : slaveId;
+ this.slaveId = agentId != null ? agentId : slaveId;
+ this.frameworkId = frameworkId;
+ this.hostname = hostname;
+ this.id = id;
+ this.allOtherFields = new HashMap<>();
+ }
+
+ @JsonIgnore
+ public MesosOfferObject sizeOptimized() {
+ MesosOfferObject optimized = new MesosOfferObject(agentId, null, frameworkId, hostname, id);
+ optimized.setAllOtherFields("url", allOtherFields.get("url"));
+ return optimized;
+ }
+
+ public MesosStringValue getAgentId() {
+ return agentId;
+ }
+
+ public MesosStringValue getSlaveId() {
+ return slaveId;
+ }
+
+ public MesosStringValue getFrameworkId() {
+ return frameworkId;
+ }
+
+ public String getHostname() {
+ return hostname;
+ }
+
+ public MesosStringValue getId() {
+ return id;
+ }
+
+ // Unknown fields
+ @JsonAnyGetter
+ public Map getAllOtherFields() {
+ return allOtherFields;
+ }
+
+ @JsonAnySetter
+ public void setAllOtherFields(String name, Object value) {
+ allOtherFields.put(name, value);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof MesosOfferObject) {
+ final MesosOfferObject that = (MesosOfferObject) obj;
+ return Objects.equals(this.agentId, that.agentId) &&
+ Objects.equals(this.slaveId, that.slaveId) &&
+ Objects.equals(this.frameworkId, that.frameworkId) &&
+ Objects.equals(this.hostname, that.hostname) &&
+ Objects.equals(this.id, that.id) &&
+ Objects.equals(this.allOtherFields, that.allOtherFields);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(agentId, slaveId, frameworkId, hostname, id, allOtherFields);
+ }
+
+ @Override
+ public String toString() {
+ return "MesosOfferObject{" +
+ "agentId=" + agentId +
+ ", slaveId=" + slaveId +
+ ", frameworkId=" + frameworkId +
+ ", hostname='" + hostname + '\'' +
+ ", id=" + id +
+ ", allOtherFields=" + allOtherFields +
+ '}';
+ }
+}
diff --git a/SingularityBase/src/main/java/com/hubspot/mesos/protos/MesosParameter.java b/SingularityBase/src/main/java/com/hubspot/mesos/protos/MesosParameter.java
new file mode 100644
index 0000000000..a9972c9a03
--- /dev/null
+++ b/SingularityBase/src/main/java/com/hubspot/mesos/protos/MesosParameter.java
@@ -0,0 +1,64 @@
+package com.hubspot.mesos.protos;
+
+import java.util.Objects;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.Optional;
+
+public class MesosParameter {
+ private final Optional key;
+ private final Optional value;
+
+ @JsonCreator
+ public MesosParameter(@JsonProperty("key") Optional key,
+ @JsonProperty("value") Optional value) {
+ this.key = key;
+ this.value = value;
+ }
+
+ public String getKey() {
+ return key.orNull();
+ }
+
+ @JsonIgnore
+ public boolean hasKey() {
+ return key.isPresent();
+ }
+
+ public String getValue() {
+ return value.orNull();
+ }
+
+ @JsonIgnore
+ public boolean hasValue() {
+ return value.isPresent();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof MesosParameter) {
+ final MesosParameter that = (MesosParameter) obj;
+ return Objects.equals(this.key, that.key) &&
+ Objects.equals(this.value, that.value);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(key, value);
+ }
+
+ @Override
+ public String toString() {
+ return "MesosKeyValueObject{" +
+ "key=" + key +
+ ", value=" + value +
+ '}';
+ }
+}
diff --git a/SingularityBase/src/main/java/com/hubspot/mesos/protos/MesosResourceObject.java b/SingularityBase/src/main/java/com/hubspot/mesos/protos/MesosResourceObject.java
new file mode 100644
index 0000000000..f73fd227de
--- /dev/null
+++ b/SingularityBase/src/main/java/com/hubspot/mesos/protos/MesosResourceObject.java
@@ -0,0 +1,70 @@
+package com.hubspot.mesos.protos;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.Optional;
+
+public class MesosResourceObject {
+ private final Optional name;
+ private final Map allOtherFields;
+
+ @JsonCreator
+
+ public MesosResourceObject(@JsonProperty("name") Optional name) {
+ this.name = name;
+ this.allOtherFields = new HashMap<>();
+ }
+
+ public String getName() {
+ return name.orNull();
+ }
+
+ @JsonIgnore
+ public boolean hasName() {
+ return name.isPresent();
+ }
+
+ // Unknown fields
+ @JsonAnyGetter
+ public Map getUnknownFields() {
+ return allOtherFields;
+ }
+
+ @JsonAnySetter
+ public void setUnknownFields(String name, Object value) {
+ allOtherFields.put(name, value);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof MesosResourceObject) {
+ final MesosResourceObject that = (MesosResourceObject) obj;
+ return Objects.equals(this.name, that.name) &&
+ Objects.equals(this.allOtherFields, that.allOtherFields);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(name, allOtherFields);
+ }
+
+ @Override
+ public String toString() {
+ return "MesosResourceObject{" +
+ "name=" + name +
+ ", allOtherFields=" + allOtherFields +
+ '}';
+ }
+}
diff --git a/SingularityBase/src/main/java/com/hubspot/mesos/protos/MesosStringValue.java b/SingularityBase/src/main/java/com/hubspot/mesos/protos/MesosStringValue.java
new file mode 100644
index 0000000000..6a4eaca139
--- /dev/null
+++ b/SingularityBase/src/main/java/com/hubspot/mesos/protos/MesosStringValue.java
@@ -0,0 +1,43 @@
+package com.hubspot.mesos.protos;
+
+import java.util.Objects;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class MesosStringValue {
+ private final String value;
+
+ @JsonCreator
+ public MesosStringValue(@JsonProperty("value") String value) {
+ this.value = value;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof MesosStringValue) {
+ final MesosStringValue that = (MesosStringValue) obj;
+ return Objects.equals(this.value, that.value);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(value);
+ }
+
+ @Override
+ public String toString() {
+ return "SingularityMesosIdObject{" +
+ "value='" + value + '\'' +
+ '}';
+ }
+}
diff --git a/SingularityBase/src/main/java/com/hubspot/mesos/protos/MesosTaskObject.java b/SingularityBase/src/main/java/com/hubspot/mesos/protos/MesosTaskObject.java
new file mode 100644
index 0000000000..c6fc1d0518
--- /dev/null
+++ b/SingularityBase/src/main/java/com/hubspot/mesos/protos/MesosTaskObject.java
@@ -0,0 +1,128 @@
+package com.hubspot.mesos.protos;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.Optional;
+
+/*
+ * Mimics the TaskInfo object from mesos, with the addition that we can read
+ * AgentID from either a field named slaveId or a field named agentId for
+ * better backwards compatibility
+ */
+public class MesosTaskObject {
+ private final MesosStringValue taskId;
+ private final Optional executor;
+ private final MesosLabels labels;
+ private final MesosStringValue agentId;
+ private final MesosStringValue slaveId;
+ private final List resources;
+ private final String name;
+ private final Map allOtherFields;
+
+ @JsonCreator
+ public MesosTaskObject(@JsonProperty("taskId") MesosStringValue taskId,
+ @JsonProperty("executor") Optional executor,
+ @JsonProperty("labels") MesosLabels labels,
+ @JsonProperty("agentId") MesosStringValue agentId,
+ @JsonProperty("slaveId") MesosStringValue slaveId,
+ @JsonProperty("resources") List resources,
+ @JsonProperty("name") String name) {
+ this.taskId = taskId;
+ this.executor = executor;
+ this.labels = labels;
+ this.agentId = agentId != null ? agentId : slaveId;
+ this.slaveId = agentId != null ? agentId : slaveId;
+ this.resources = resources != null ? resources : Collections.emptyList();
+ this.name = name;
+ this.allOtherFields = new HashMap<>();
+ }
+
+ public MesosStringValue getTaskId() {
+ return taskId;
+ }
+
+ public MesosExecutorInfo getExecutor() {
+ return executor.orNull();
+ }
+
+ public boolean hasExecutor() {
+ return executor.isPresent();
+ }
+
+ public MesosLabels getLabels() {
+ return labels;
+ }
+
+ public MesosStringValue getAgentId() {
+ return agentId;
+ }
+
+ public MesosStringValue getSlaveId() {
+ return slaveId;
+ }
+
+ public List getResources() {
+ return resources;
+ }
+
+ // Unknown fields
+ @JsonAnyGetter
+ public Map getAllOtherFields() {
+ return allOtherFields;
+ }
+
+ @JsonAnySetter
+ public void setAllOtherFields(String name, Object value) {
+ allOtherFields.put(name, value);
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof MesosTaskObject) {
+ final MesosTaskObject that = (MesosTaskObject) obj;
+ return Objects.equals(this.taskId, that.taskId) &&
+ Objects.equals(this.executor, that.executor) &&
+ Objects.equals(this.labels, that.labels) &&
+ Objects.equals(this.agentId, that.agentId) &&
+ Objects.equals(this.slaveId, that.slaveId) &&
+ Objects.equals(this.resources, that.resources) &&
+ Objects.equals(this.name, that.name) &&
+ Objects.equals(this.allOtherFields, that.allOtherFields);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(taskId, executor, labels, agentId, slaveId, resources, name, allOtherFields);
+ }
+
+ @Override
+ public String toString() {
+ return "MesosTaskObject{" +
+ "taskId=" + taskId +
+ ", executor=" + executor +
+ ", labels=" + labels +
+ ", agentId=" + agentId +
+ ", slaveId=" + slaveId +
+ ", resources=" + resources +
+ ", name='" + name + '\'' +
+ ", allOtherFields=" + allOtherFields +
+ '}';
+ }
+}
diff --git a/SingularityBase/src/main/java/com/hubspot/mesos/protos/MesosTaskState.java b/SingularityBase/src/main/java/com/hubspot/mesos/protos/MesosTaskState.java
new file mode 100644
index 0000000000..0e5763c975
--- /dev/null
+++ b/SingularityBase/src/main/java/com/hubspot/mesos/protos/MesosTaskState.java
@@ -0,0 +1,7 @@
+package com.hubspot.mesos.protos;
+
+public enum MesosTaskState {
+ TASK_DROPPED, TASK_ERROR, TASK_FAILED, TASK_FINISHED, TASK_GONE,
+ TASK_GONE_BY_OPERATOR, TASK_KILLED, TASK_KILLING, TASK_LOST,
+ TASK_RUNNING, TASK_STAGING, TASK_STARTING, TASK_UNKNOWN, TASK_UNREACHABLE
+}
diff --git a/SingularityBase/src/main/java/com/hubspot/mesos/protos/MesosTaskStatusObject.java b/SingularityBase/src/main/java/com/hubspot/mesos/protos/MesosTaskStatusObject.java
new file mode 100644
index 0000000000..9568888531
--- /dev/null
+++ b/SingularityBase/src/main/java/com/hubspot/mesos/protos/MesosTaskStatusObject.java
@@ -0,0 +1,132 @@
+package com.hubspot.mesos.protos;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.Optional;
+
+public class MesosTaskStatusObject {
+ private final Optional agentId;
+ private final Optional slaveId;
+ private final Optional healthy;
+ private final Optional message;
+ private final Optional reason;
+ private final Optional state;
+ private final Optional taskId;
+ private final Optional timestamp;
+ private final Map allOtherFields;
+
+ @JsonCreator
+ public MesosTaskStatusObject(@JsonProperty("agentId") Optional agentId,
+ @JsonProperty("slaveId") Optional slaveId,
+ @JsonProperty("healthy") Optional healthy,
+ @JsonProperty("message") Optional message,
+ @JsonProperty("reason") Optional reason,
+ @JsonProperty("state") Optional state,
+ @JsonProperty("taskId") Optional taskId,
+ @JsonProperty("timestamp") Optional timestamp) {
+ this.agentId = agentId.or(slaveId);
+ this.slaveId = agentId.or(slaveId);
+ this.healthy = healthy;
+ this.message = message;
+ this.reason = reason;
+ this.state = state;
+ this.taskId = taskId;
+ this.timestamp = timestamp;
+ this.allOtherFields = new HashMap<>();
+ }
+
+ public MesosStringValue getAgentId() {
+ return agentId.orNull();
+ }
+
+ public boolean hasAgentId() {
+ return agentId.isPresent();
+ }
+
+ public MesosStringValue getSlaveId() {
+ return slaveId.orNull();
+ }
+
+ public boolean hasSlaveId() {
+ return slaveId.isPresent();
+ }
+
+ public Boolean getHealthy() {
+ return healthy.orNull();
+ }
+
+ public boolean hasHealthy() {
+ return healthy.isPresent();
+ }
+
+ public String getMessage() {
+ return message.orNull();
+ }
+
+ public boolean hasMessage() {
+ return message.isPresent();
+ }
+
+ public MesosTaskStatusReason getReason() {
+ return reason.orNull();
+ }
+
+ public boolean hasReason() {
+ return reason.isPresent();
+ }
+
+ public MesosTaskState getState() {
+ return state.orNull();
+ }
+
+ public boolean hasState() {
+ return state.isPresent();
+ }
+
+ public MesosStringValue getTaskId() {
+ return taskId.orNull();
+ }
+
+ public boolean hasTaskId() {
+ return taskId.isPresent();
+ }
+
+ public Double getTimestamp() {
+ return timestamp.orNull();
+ }
+
+ public boolean hasTimestamp() {
+ return timestamp.isPresent();
+ }
+
+ // Unknown fields
+ @JsonAnyGetter
+ public Map getAllOtherFields() {
+ return allOtherFields;
+ }
+
+ @JsonAnySetter
+ public void setAllOtherFields(String name, Object value) {
+ allOtherFields.put(name, value);
+ }
+
+
+ @Override
+ public String toString() {
+ return "SingularityMesosTaskStatusObject{" +
+ "agentId=" + agentId +
+ ", slaveId=" + slaveId +
+ ", healthy=" + healthy +
+ ", message=" + message +
+ ", reason=" + reason +
+ ", state=" + state +
+ ", taskId=" + taskId +
+ ", timestamp=" + timestamp +
+ '}';
+ }
+}
diff --git a/SingularityBase/src/main/java/com/hubspot/mesos/protos/MesosTaskStatusReason.java b/SingularityBase/src/main/java/com/hubspot/mesos/protos/MesosTaskStatusReason.java
new file mode 100644
index 0000000000..3494dce8f6
--- /dev/null
+++ b/SingularityBase/src/main/java/com/hubspot/mesos/protos/MesosTaskStatusReason.java
@@ -0,0 +1,12 @@
+package com.hubspot.mesos.protos;
+
+public enum MesosTaskStatusReason {
+ REASON_COMMAND_EXECUTOR_FAILED, REASON_CONTAINER_LAUNCH_FAILED, REASON_CONTAINER_LIMITATION, REASON_CONTAINER_LIMITATION_DISK,
+ REASON_CONTAINER_LIMITATION_MEMORY, REASON_CONTAINER_PREEMPTED, REASON_CONTAINER_UPDATE_FAILED, REASON_EXECUTOR_REGISTRATION_TIMEOUT,
+ REASON_EXECUTOR_REREGISTRATION_TIMEOUT, REASON_EXECUTOR_TERMINATED, REASON_EXECUTOR_UNREGISTERED, REASON_FRAMEWORK_REMOVED, REASON_GC_ERROR,
+ REASON_INVALID_FRAMEWORKID, REASON_INVALID_OFFERS, REASON_IO_SWITCHBOARD_EXITED, REASON_MASTER_DISCONNECTED, REASON_RECONCILIATION,
+ REASON_RESOURCES_UNKNOWN, REASON_SLAVE_DISCONNECTED, REASON_SLAVE_REMOVED, REASON_SLAVE_REMOVED_BY_OPERATOR, REASON_SLAVE_RESTARTED,
+ REASON_SLAVE_UNKNOWN, REASON_TASK_CHECK_STATUS_UPDATED, REASON_TASK_GROUP_INVALID, REASON_TASK_GROUP_UNAUTHORIZED,
+ REASON_TASK_HEALTH_CHECK_STATUS_UPDATED, REASON_TASK_INVALID, REASON_TASK_KILLED_DURING_LAUNCH, REASON_TASK_UNAUTHORIZED,
+ REASON_TASK_UNKNOWN
+}
diff --git a/SingularityBase/src/main/java/com/hubspot/singularity/ExtendedTaskState.java b/SingularityBase/src/main/java/com/hubspot/singularity/ExtendedTaskState.java
index 48c6ecd626..4b4fe437b7 100644
--- a/SingularityBase/src/main/java/com/hubspot/singularity/ExtendedTaskState.java
+++ b/SingularityBase/src/main/java/com/hubspot/singularity/ExtendedTaskState.java
@@ -1,44 +1,23 @@
package com.hubspot.singularity;
-import java.util.Map;
-
-import org.apache.mesos.v1.Protos.TaskState;
-
import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Maps;
+import com.hubspot.mesos.protos.MesosTaskState;
public enum ExtendedTaskState {
- TASK_LAUNCHED("launched", false, Optional.absent()), TASK_STAGING("staging", false, Optional.of(TaskState.TASK_STAGING)),
- TASK_STARTING("starting", false, Optional.of(TaskState.TASK_STARTING)), TASK_RUNNING("running", false, Optional.of(TaskState.TASK_RUNNING)),
- TASK_CLEANING("cleaning", false, Optional.absent()), TASK_KILLING("killing", false, Optional.of(TaskState.TASK_KILLING)), TASK_FINISHED("finished", true, Optional.of(TaskState.TASK_FINISHED)),
- TASK_FAILED("failed", true, Optional.of(TaskState.TASK_FAILED)), TASK_KILLED("killed", true, Optional.of(TaskState.TASK_KILLED)),
- TASK_LOST("lost", true, Optional.of(TaskState.TASK_LOST)), TASK_LOST_WHILE_DOWN("lost", true, Optional.absent()), TASK_ERROR("error", true, Optional.of(TaskState.TASK_ERROR)),
- TASK_DROPPED("dropped", true, Optional.of(TaskState.TASK_DROPPED)), TASK_GONE("gone", true, Optional.of(TaskState.TASK_GONE)), TASK_UNREACHABLE("unreachable", true, Optional.of(TaskState.TASK_UNREACHABLE)),
- TASK_GONE_BY_OPERATOR("goneByOperator", true, Optional.of(TaskState.TASK_GONE_BY_OPERATOR)), TASK_UNKNOWN("dropped", true, Optional.of(TaskState.TASK_UNKNOWN));
-
- private static final Map map;
- static {
- map = Maps.newHashMapWithExpectedSize(ExtendedTaskState.values().length);
- for (ExtendedTaskState extendedTaskState : ExtendedTaskState.values()) {
- if (extendedTaskState.toTaskState().isPresent()) {
- map.put(extendedTaskState.toTaskState().get(), extendedTaskState);
- }
- }
-
- for (TaskState t : TaskState.values()) {
- if (map.get(t) == null) {
- throw new IllegalStateException("No ExtendedTaskState provided for TaskState " + t + ", you probably have incompatible versions of Mesos and Singularity.");
- }
- }
- }
+ TASK_LAUNCHED("launched", false, Optional.absent()), TASK_STAGING("staging", false, Optional.of(MesosTaskState.TASK_STAGING)),
+ TASK_STARTING("starting", false, Optional.of(MesosTaskState.TASK_STARTING)), TASK_RUNNING("running", false, Optional.of(MesosTaskState.TASK_RUNNING)),
+ TASK_CLEANING("cleaning", false, Optional.absent()), TASK_KILLING("killing", false, Optional.of(MesosTaskState.TASK_KILLING)), TASK_FINISHED("finished", true, Optional.of(MesosTaskState.TASK_FINISHED)),
+ TASK_FAILED("failed", true, Optional.of(MesosTaskState.TASK_FAILED)), TASK_KILLED("killed", true, Optional.of(MesosTaskState.TASK_KILLED)),
+ TASK_LOST("lost", true, Optional.of(MesosTaskState.TASK_LOST)), TASK_LOST_WHILE_DOWN("lost", true, Optional.absent()), TASK_ERROR("error", true, Optional.of(MesosTaskState.TASK_ERROR)),
+ TASK_DROPPED("dropped", true, Optional.of(MesosTaskState.TASK_DROPPED)), TASK_GONE("gone", true, Optional.of(MesosTaskState.TASK_GONE)), TASK_UNREACHABLE("unreachable", true, Optional.of(MesosTaskState.TASK_UNREACHABLE)),
+ TASK_GONE_BY_OPERATOR("goneByOperator", true, Optional.of(MesosTaskState.TASK_GONE_BY_OPERATOR)), TASK_UNKNOWN("dropped", true, Optional.of(MesosTaskState.TASK_UNKNOWN));
private final String displayName;
private final boolean isDone;
- private final Optional taskState;
+ private final Optional taskState;
- ExtendedTaskState(String displayName, boolean isDone, Optional taskState) {
+ ExtendedTaskState(String displayName, boolean isDone, Optional taskState) {
this.displayName = displayName;
this.isDone = isDone;
this.taskState = taskState;
@@ -60,14 +39,7 @@ public boolean isSuccess() {
return this == TASK_FINISHED;
}
- public Optional toTaskState() {
+ public Optional toTaskState() {
return taskState;
}
-
- public static ExtendedTaskState fromTaskState(TaskState taskState) {
- ExtendedTaskState extendedTaskState = map.get(taskState);
- Preconditions.checkArgument(extendedTaskState != null, "No ExtendedTaskState for TaskState %s", taskState);
- return extendedTaskState;
- }
-
}
diff --git a/SingularityBase/src/main/java/com/hubspot/singularity/SingularityRequest.java b/SingularityBase/src/main/java/com/hubspot/singularity/SingularityRequest.java
index 4c22e545d5..e1b3f24090 100644
--- a/SingularityBase/src/main/java/com/hubspot/singularity/SingularityRequest.java
+++ b/SingularityBase/src/main/java/com/hubspot/singularity/SingularityRequest.java
@@ -61,6 +61,7 @@ public class SingularityRequest {
private final Optional maxTasksPerOffer;
private final Optional allowBounceToSameHost;
+ @Deprecated
private final Optional dataCenter;
@JsonCreator
@@ -361,7 +362,8 @@ public Optional getTaskPriorityLevel() {
return taskPriorityLevel;
}
- @ApiModelProperty(required=false, value="When using the cluster coordinator, the data center associated with this request")
+ @Deprecated
+ @ApiModelProperty(required=false, value="the data center associated with this request")
public Optional getDataCenter() {
return dataCenter;
}
diff --git a/SingularityBase/src/main/java/com/hubspot/singularity/SingularityRequestBuilder.java b/SingularityBase/src/main/java/com/hubspot/singularity/SingularityRequestBuilder.java
index 93194c7853..f2a08522cd 100644
--- a/SingularityBase/src/main/java/com/hubspot/singularity/SingularityRequestBuilder.java
+++ b/SingularityBase/src/main/java/com/hubspot/singularity/SingularityRequestBuilder.java
@@ -51,6 +51,7 @@ public class SingularityRequestBuilder {
private Optional taskPriorityLevel;
private Optional maxTasksPerOffer;
private Optional allowBounceToSameHost;
+ @Deprecated
private Optional dataCenter;
public SingularityRequestBuilder(String id, RequestType requestType) {
@@ -357,10 +358,12 @@ public SingularityRequestBuilder setAllowBounceToSameHost(Optional allo
return this;
}
+ @Deprecated
public Optional getDataCenter() {
return dataCenter;
}
+ @Deprecated
public SingularityRequestBuilder setDataCenter(Optional dataCenter) {
this.dataCenter = dataCenter;
return this;
diff --git a/SingularityBase/src/main/java/com/hubspot/singularity/SingularitySlaveUsage.java b/SingularityBase/src/main/java/com/hubspot/singularity/SingularitySlaveUsage.java
index f6e328f38c..60407be5b7 100644
--- a/SingularityBase/src/main/java/com/hubspot/singularity/SingularitySlaveUsage.java
+++ b/SingularityBase/src/main/java/com/hubspot/singularity/SingularitySlaveUsage.java
@@ -9,7 +9,7 @@
public class SingularitySlaveUsage {
public enum ResourceUsageType {
- CPU_USED, MEMORY_BYTES_USED, CPU_FREE, MEMORY_BYTES_FREE
+ CPU_USED, MEMORY_BYTES_USED, DISK_BYTES_USED, CPU_FREE, MEMORY_BYTES_FREE, DISK_BYTES_FREE
}
public static final long BYTES_PER_MEGABYTE = 1000L * 1000L;
diff --git a/SingularityBase/src/main/java/com/hubspot/singularity/SingularityTask.java b/SingularityBase/src/main/java/com/hubspot/singularity/SingularityTask.java
index 4aa7e89930..795eb0da2e 100644
--- a/SingularityBase/src/main/java/com/hubspot/singularity/SingularityTask.java
+++ b/SingularityBase/src/main/java/com/hubspot/singularity/SingularityTask.java
@@ -3,48 +3,38 @@
import java.util.Collections;
import java.util.List;
-import org.apache.mesos.v1.Protos.AgentID;
-import org.apache.mesos.v1.Protos.TaskInfo;
-
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
-import com.hubspot.mesos.MesosUtils;
-import com.hubspot.mesos.json.SingularityMesosOfferObject;
-import com.hubspot.mesos.json.SingularityMesosTaskObject;
+import com.hubspot.mesos.protos.MesosStringValue;
+import com.hubspot.mesos.protos.MesosOfferObject;
+import com.hubspot.mesos.protos.MesosTaskObject;
import com.wordnik.swagger.annotations.ApiModelProperty;
public class SingularityTask extends SingularityTaskIdHolder {
private final SingularityTaskRequest taskRequest;
- private final List offers;
- /*
- * Only used when we first send this task to mesos. This should not be saved to JSON
- * A subset of this information which we have greater control over is saved in the
- * SingularityMesosTaskObject
- */
- private final TaskInfo mesosTaskProtos;
- private final SingularityMesosTaskObject mesosTask;
+ private final List offers;
+ private final MesosTaskObject mesosTask;
private final Optional rackId;
- public SingularityTask(SingularityTaskRequest taskRequest, SingularityTaskId taskId, List offers, TaskInfo mesosTaskProtos, SingularityMesosTaskObject task, Optional rackId) {
- this(taskRequest, taskId, null, offers, mesosTaskProtos, task, rackId);
- }
-
- public SingularityTask(SingularityTaskRequest taskRequest, SingularityTaskId taskId, List offers, SingularityMesosTaskObject task, Optional rackId) {
- this(taskRequest, taskId, null, offers, null, task, rackId);
+ public SingularityTask(SingularityTaskRequest taskRequest, SingularityTaskId taskId, List offers, MesosTaskObject task, Optional rackId) {
+ this(taskRequest, taskId, null, offers, task, rackId);
}
@JsonCreator
- public SingularityTask(@JsonProperty("taskRequest") SingularityTaskRequest taskRequest, @JsonProperty("taskId") SingularityTaskId taskId, @JsonProperty("offer") SingularityMesosOfferObject offer, @JsonProperty("offers") List offers,
- @JsonProperty("mesosTaskProtos") TaskInfo mesosTaskProtos, @JsonProperty("mesosTask") SingularityMesosTaskObject task, @JsonProperty("rackId") Optional rackId) {
+ public SingularityTask(@JsonProperty("taskRequest") SingularityTaskRequest taskRequest,
+ @JsonProperty("taskId") SingularityTaskId taskId,
+ @JsonProperty("offer") MesosOfferObject offer,
+ @JsonProperty("offers") List offers,
+ @JsonProperty("mesosTask") MesosTaskObject task,
+ @JsonProperty("rackId") Optional rackId) {
super(taskId);
Preconditions.checkArgument(offer != null || offers != null, "Must specify at least one of offer / offers");
this.taskRequest = taskRequest;
this.mesosTask = task;
- this.mesosTaskProtos = mesosTaskProtos;
this.rackId = rackId;
if (offers != null) {
this.offers = offers;
@@ -62,41 +52,26 @@ public SingularityTaskRequest getTaskRequest() {
*/
@Deprecated
@ApiModelProperty(hidden=true)
- public SingularityMesosOfferObject getOffer() {
+ public MesosOfferObject getOffer() {
return offers.get(0);
}
@ApiModelProperty(hidden=true)
- public List getOffers() {
+ public List getOffers() {
return offers;
}
@ApiModelProperty(hidden=true)
- public SingularityMesosTaskObject getMesosTask() {
+ public MesosTaskObject getMesosTask() {
return mesosTask;
}
- @JsonIgnore
- public TaskInfo getMesosTaskProtos() {
- return mesosTaskProtos;
- }
-
public Optional getRackId() {
return rackId;
}
@JsonIgnore
- public Optional getPortByIndex(int index) {
- List ports = MesosUtils.getAllPorts(mesosTask.getResources());
- if (index >= ports.size() || index < 0) {
- return Optional.absent();
- } else {
- return Optional.of(ports.get(index));
- }
- }
-
- @JsonIgnore
- public AgentID getAgentId() {
+ public MesosStringValue getAgentId() {
return offers.get(0).getAgentId();
}
@@ -109,8 +84,8 @@ public String getHostname() {
public String toString() {
return "SingularityTask{" +
"taskRequest=" + taskRequest +
- ", offer=" + MesosUtils.formatForLogging(offers) +
- ", mesosTask=" + MesosUtils.formatForLogging(mesosTask) +
+ ", offer=" + offers +
+ ", mesosTask=" + mesosTask +
", rackId=" + rackId +
'}';
}
diff --git a/SingularityBase/src/main/java/com/hubspot/singularity/SingularityTaskStatusHolder.java b/SingularityBase/src/main/java/com/hubspot/singularity/SingularityTaskStatusHolder.java
index 26b31451ab..16e6613d57 100644
--- a/SingularityBase/src/main/java/com/hubspot/singularity/SingularityTaskStatusHolder.java
+++ b/SingularityBase/src/main/java/com/hubspot/singularity/SingularityTaskStatusHolder.java
@@ -3,19 +3,18 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Optional;
-import com.hubspot.mesos.MesosUtils;
-import com.hubspot.mesos.json.SingularityMesosTaskStatusObject;
+import com.hubspot.mesos.protos.MesosTaskStatusObject;
public class SingularityTaskStatusHolder {
- private final Optional taskStatus;
+ private final Optional taskStatus;
private final SingularityTaskId taskId;
private final long serverTimestamp;
private final String serverId;
private final Optional slaveId;
@JsonCreator
- public SingularityTaskStatusHolder(@JsonProperty("taskId") SingularityTaskId taskId, @JsonProperty("taskStatus") Optional taskStatus, @JsonProperty("serverTimestamp") long serverTimestamp, @JsonProperty("serverId") String serverId, @JsonProperty("slaveId") Optional slaveId) {
+ public SingularityTaskStatusHolder(@JsonProperty("taskId") SingularityTaskId taskId, @JsonProperty("taskStatus") Optional taskStatus, @JsonProperty("serverTimestamp") long serverTimestamp, @JsonProperty("serverId") String serverId, @JsonProperty("slaveId") Optional slaveId) {
this.taskId = taskId;
this.taskStatus = taskStatus;
this.serverTimestamp = serverTimestamp;
@@ -23,7 +22,7 @@ public SingularityTaskStatusHolder(@JsonProperty("taskId") SingularityTaskId tas
this.slaveId = slaveId;
}
- public Optional getTaskStatus() {
+ public Optional getTaskStatus() {
return taskStatus;
}
@@ -46,7 +45,7 @@ public Optional getSlaveId() {
@Override
public String toString() {
return "SingularityTaskStatusHolder{" +
- "taskStatus=" + MesosUtils.formatForLogging(taskStatus) +
+ "taskStatus=" + taskStatus +
", taskId=" + taskId +
", serverTimestamp=" + serverTimestamp +
", serverId='" + serverId + '\'' +
diff --git a/SingularityBase/src/main/java/com/hubspot/singularity/SingularityUser.java b/SingularityBase/src/main/java/com/hubspot/singularity/SingularityUser.java
index 4089e7c282..62c4416267 100644
--- a/SingularityBase/src/main/java/com/hubspot/singularity/SingularityUser.java
+++ b/SingularityBase/src/main/java/com/hubspot/singularity/SingularityUser.java
@@ -2,6 +2,8 @@
import static com.google.common.collect.ImmutableSet.copyOf;
+import java.security.Principal;
+import java.util.Collections;
import java.util.Objects;
import java.util.Set;
@@ -9,26 +11,38 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Optional;
-public class SingularityUser {
+public class SingularityUser implements Principal {
private final String id;
private final Optional name;
private final Optional email;
private final Set groups;
+ private final boolean authenticated;
+
+ public static SingularityUser DEFAULT_USER = new SingularityUser("singularity", Optional.absent(), Optional.absent(), Collections.emptySet(), false);
+
+ public SingularityUser(String id, Optional name, Optional email, Set groups) {
+ this(id, name, email, groups, true);
+ }
@JsonCreator
- public SingularityUser(@JsonProperty("id") String id, @JsonProperty("name") Optional name, @JsonProperty("email") Optional email, @JsonProperty("groups") Set groups) {
+ public SingularityUser(@JsonProperty("id") String id,
+ @JsonProperty("name") Optional name,
+ @JsonProperty("email") Optional email,
+ @JsonProperty("groups") Set groups,
+ @JsonProperty("authenticated") boolean authenticated) {
this.id = id;
this.name = name;
this.email = email;
this.groups = copyOf(groups);
+ this.authenticated = authenticated;
}
public String getId() {
return id;
}
- public Optional getName() {
- return name;
+ public String getName() {
+ return name.or(id);
}
public Optional getEmail() {
@@ -39,33 +53,39 @@ public Set getGroups() {
return groups;
}
- @Override
- public String toString() {
- return "SingularityUser{" +
- "id='" + id + '\'' +
- ", name=" + name +
- ", email=" + email +
- ", groups=" + groups +
- '}';
+ public boolean isAuthenticated() {
+ return authenticated;
}
@Override
- public boolean equals(Object o) {
- if (this == o) {
+ public boolean equals(Object obj) {
+ if (this == obj) {
return true;
}
- if (o == null || getClass() != o.getClass()) {
- return false;
+ if (obj instanceof SingularityUser) {
+ final SingularityUser that = (SingularityUser) obj;
+ return Objects.equals(this.authenticated, that.authenticated) &&
+ Objects.equals(this.id, that.id) &&
+ Objects.equals(this.name, that.name) &&
+ Objects.equals(this.email, that.email) &&
+ Objects.equals(this.groups, that.groups);
}
- SingularityUser that = (SingularityUser) o;
- return Objects.equals(id, that.id) &&
- Objects.equals(name, that.name) &&
- Objects.equals(email, that.email) &&
- Objects.equals(groups, that.groups);
+ return false;
}
@Override
public int hashCode() {
- return Objects.hash(id, name, email, groups);
+ return Objects.hash(id, name, email, groups, authenticated);
+ }
+
+ @Override
+ public String toString() {
+ return "SingularityUser{" +
+ "id='" + id + '\'' +
+ ", name=" + name +
+ ", email=" + email +
+ ", groups=" + groups +
+ ", authenticated=" + authenticated +
+ '}';
}
}
diff --git a/SingularityClient/src/main/java/com/hubspot/singularity/client/SingularityClient.java b/SingularityClient/src/main/java/com/hubspot/singularity/client/SingularityClient.java
index 90d9eedde4..3c8a6b62c3 100644
--- a/SingularityClient/src/main/java/com/hubspot/singularity/client/SingularityClient.java
+++ b/SingularityClient/src/main/java/com/hubspot/singularity/client/SingularityClient.java
@@ -104,7 +104,8 @@ public class SingularityClient {
private static final String BASE_API_FORMAT = "%s://%s/%s";
- private static final String AUTH_CHECK_FORMAT = "%s/auth/%s/auth-check/%s";
+ private static final String AUTH_CHECK_FORMAT = "%s/auth/%s/auth-check";
+ private static final String AUTH_CHECK_USER_FORMAT = AUTH_CHECK_FORMAT + "/%s";
private static final String STATE_FORMAT = "%s/state";
private static final String TASK_RECONCILIATION_FORMAT = STATE_FORMAT + "/task-reconciliation";
@@ -1446,7 +1447,27 @@ public void deletePriorityFreeze() {
* true if the user is authorized for scope, false otherwise
*/
public boolean isUserAuthorized(String requestId, String userId, SingularityAuthorizationScope scope) {
- final Function requestUri = (host) -> String.format(AUTH_CHECK_FORMAT, getApiBase(host), requestId, userId);
+ final Function requestUri = (host) -> String.format(AUTH_CHECK_USER_FORMAT, getApiBase(host), requestId, userId);
+ Map params = Collections.singletonMap("scope", scope.name());
+ HttpResponse response = executeGetSingleWithParams(requestUri, "auth check", "", Optional.of(params));
+ return response.isSuccess();
+ }
+
+ /**
+ * Check if the current client's user is authorized for the specified scope on the specified request
+ *
+ * @param requestId
+ * The request to check authorization on
+ * @param userId
+ * The user whose authorization will be checked
+ * @param scope
+ * The scope to check that `user` has
+ *
+ * @return
+ * true if the user is authorized for scope, false otherwise
+ */
+ public boolean isUserAuthorized(String requestId, SingularityAuthorizationScope scope) {
+ final Function requestUri = (host) -> String.format(AUTH_CHECK_FORMAT, getApiBase(host), requestId);
Map params = Collections.singletonMap("scope", scope.name());
HttpResponse response = executeGetSingleWithParams(requestUri, "auth check", "", Optional.of(params));
return response.isSuccess();
diff --git a/SingularityClusterCoordinator/.blazar.yaml b/SingularityClusterCoordinator/.blazar.yaml
deleted file mode 100644
index 0748966170..0000000000
--- a/SingularityClusterCoordinator/.blazar.yaml
+++ /dev/null
@@ -1,3 +0,0 @@
-env:
- MAVEN_ARGS: "-T 8 -Dsingularity.jar.name.format=\\${project.artifactId} -Dgpg.skip=true -DforkCount=2C"
- SET_VERSION_OVERRIDE: "0.18.0-$GIT_BRANCH-SNAPSHOT"
diff --git a/SingularityClusterCoordinator/.build-executable b/SingularityClusterCoordinator/.build-executable
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/SingularityClusterCoordinator/pom.xml b/SingularityClusterCoordinator/pom.xml
deleted file mode 100644
index 4ae4d34375..0000000000
--- a/SingularityClusterCoordinator/pom.xml
+++ /dev/null
@@ -1,133 +0,0 @@
-
-
- 4.0.0
-
-
- com.hubspot
- Singularity
- 0.18.0-SNAPSHOT
-
-
- SingularityClusterCoordinator
-
-
- com.hubspot.singularity.SingularityClusterCoordinator
-
-
-
-
- com.hubspot
- SingularityBase
-
-
-
- com.hubspot
- SingularityServiceBase
-
-
-
- com.hubspot
- SingularityClient
-
-
-
- com.hubspot.dropwizard
- dropwizard-guicier
-
-
-
- io.dropwizard
- dropwizard-core
-
-
-
- io.dropwizard
- dropwizard-lifecycle
-
-
-
- io.dropwizard
- dropwizard-assets
-
-
-
- com.hubspot
- HorizonCore
-
-
-
- com.hubspot
- HorizonNing
-
-
-
- io.dropwizard
- dropwizard-views
-
-
-
- io.dropwizard.metrics
- metrics-healthchecks
-
-
-
- com.fasterxml.jackson.datatype
- jackson-datatype-guava
-
-
-
- com.fasterxml.jackson.core
- jackson-core
-
-
-
- javax.validation
- validation-api
-
-
-
- com.fasterxml.jackson.core
- jackson-databind
-
-
-
- com.google.inject
- guice
-
-
-
- javax.ws.rs
- javax.ws.rs-api
-
-
-
- com.fasterxml.jackson.core
- jackson-annotations
-
-
-
- org.hibernate
- hibernate-validator
-
-
-
- com.hubspot.jackson
- jackson-datatype-protobuf
-
-
-
- com.google.guava
- guava
-
-
-
- javax.servlet
- javax.servlet-api
-
-
-
- org.slf4j
- slf4j-api
-
-
-
diff --git a/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/CoordinatorDropwizardHealthcheck.java b/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/CoordinatorDropwizardHealthcheck.java
deleted file mode 100644
index f905ef7e61..0000000000
--- a/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/CoordinatorDropwizardHealthcheck.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.hubspot.singularity;
-
-import com.codahale.metrics.health.HealthCheck;
-import com.google.inject.Inject;
-import com.hubspot.singularity.config.ClusterCoordinatorConfiguration;
-
-public class CoordinatorDropwizardHealthcheck extends HealthCheck {
- private final ClusterCoordinatorConfiguration configuration;
-
- @Inject
- public CoordinatorDropwizardHealthcheck(ClusterCoordinatorConfiguration configuration) {
- this.configuration = configuration;
- }
-
- @Override
- protected Result check() throws Exception {
- if (configuration.getDataCenters().isEmpty()) {
- return Result.unhealthy("No configured data centers");
- } else {
- return Result.healthy("Valid data centers", configuration.getDataCenters());
- }
- }
-}
diff --git a/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/SingularityClusterCoordinator.java b/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/SingularityClusterCoordinator.java
deleted file mode 100644
index 044c88a441..0000000000
--- a/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/SingularityClusterCoordinator.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package com.hubspot.singularity;
-
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.datatype.guava.GuavaModule;
-import com.hubspot.dropwizard.guicier.GuiceBundle;
-import com.hubspot.jackson.datatype.protobuf.ProtobufModule;
-import com.hubspot.singularity.config.ClusterCoordinatorConfiguration;
-
-import io.dropwizard.Application;
-import io.dropwizard.assets.AssetsBundle;
-import io.dropwizard.setup.Bootstrap;
-import io.dropwizard.setup.Environment;
-import io.dropwizard.views.ViewBundle;
-
-public class SingularityClusterCoordinator extends Application {
- @Override
- public void initialize(final Bootstrap bootstrap) {
-
- final GuiceBundle guiceBundle = GuiceBundle.defaultBuilder(ClusterCoordinatorConfiguration.class)
- .modules(new SingularityClusterCoordinatorModule())
- .build();
- bootstrap.addBundle(guiceBundle);
-
- bootstrap.addBundle(new ViewBundle<>());
- bootstrap.addBundle(new AssetsBundle("/assets/static/", "/static/"));
- bootstrap.addBundle(new AssetsBundle("/assets/api-docs/", "/api-docs/", "index.html", "api-docs"));
-
- bootstrap.getObjectMapper().registerModule(new ProtobufModule());
- bootstrap.getObjectMapper().registerModule(new GuavaModule());
- bootstrap.getObjectMapper().setSerializationInclusion(Include.NON_NULL);
- bootstrap.getObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- }
-
- @Override
- public void run(final ClusterCoordinatorConfiguration configuration, final Environment environment) throws Exception {}
-
- public static void main(final String[] args) throws Exception {
- try {
- new SingularityClusterCoordinator().run(args);
- } catch (final Throwable t) {
- t.printStackTrace();
- System.exit(1);
- }
- }
-}
diff --git a/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/SingularityClusterCoordinatorModule.java b/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/SingularityClusterCoordinatorModule.java
deleted file mode 100644
index 563e6eb55e..0000000000
--- a/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/SingularityClusterCoordinatorModule.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package com.hubspot.singularity;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.inject.Binder;
-import com.google.inject.Scopes;
-import com.hubspot.dropwizard.guicier.DropwizardAwareModule;
-import com.hubspot.mesos.JavaUtils;
-import com.hubspot.singularity.config.ClusterCoordinatorConfiguration;
-import com.hubspot.singularity.proxy.SingularityClusterCoodinatorResourcesModule;
-
-public class SingularityClusterCoordinatorModule extends DropwizardAwareModule {
-
- @Override
- public void configure(Binder binder) {
- binder.bind(ObjectMapper.class).toInstance(JavaUtils.newObjectMapper());
- binder.bind(CoordinatorDropwizardHealthcheck.class).in(Scopes.SINGLETON);
- binder.install(new SingularityClusterCoodinatorResourcesModule(getConfiguration()));
- }
-}
diff --git a/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/config/ClusterCoordinatorConfiguration.java b/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/config/ClusterCoordinatorConfiguration.java
deleted file mode 100644
index 4bd54e44e7..0000000000
--- a/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/config/ClusterCoordinatorConfiguration.java
+++ /dev/null
@@ -1,174 +0,0 @@
-package com.hubspot.singularity.config;
-
-import java.util.List;
-
-import javax.validation.Valid;
-
-import org.hibernate.validator.constraints.NotEmpty;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.google.common.base.Optional;
-import com.hubspot.singularity.SingularityClientCredentials;
-
-import io.dropwizard.Configuration;
-
-public class ClusterCoordinatorConfiguration extends Configuration {
- /*
- * List of possible Singularity clusters. The first in the list will be considered the default
- */
- @NotEmpty
- private List dataCenters;
-
- @JsonProperty("ui")
- @Valid
- private UIConfiguration uiConfiguration = new UIConfiguration();
-
- private Optional defaultClientCredentials;
-
- private boolean errorOnDataCenterNotSpecified = false;
-
- // Settings to inform the ui
- private Integer defaultMemory = 64;
- private Integer defaultCpus = 1;
- private Integer slaveHttpPort = 5051;
- private Optional slaveHttpsPort = Optional.absent();
- private int bounceExpirationMinutes = 60;
- private long healthcheckIntervalSeconds = 5;
- private long healthcheckTimeoutSeconds = 5;
- private Optional healthcheckMaxRetries = Optional.absent();
- private int startupTimeoutSeconds = 45;
- private boolean loadBalancingEnabled = false;
- private Optional commonHostnameSuffixToOmit = Optional.absent();
- private Integer warnIfScheduledJobIsRunningPastNextRunPct = 200;
-
-
-
- public List getDataCenters() {
- return dataCenters;
- }
-
- public void setDataCenters(List dataCenters) {
- this.dataCenters = dataCenters;
- }
-
- public UIConfiguration getUiConfiguration() {
- return uiConfiguration;
- }
-
- public void setUiConfiguration(UIConfiguration uiConfiguration) {
- this.uiConfiguration = uiConfiguration;
- }
-
- public Integer getDefaultMemory() {
- return defaultMemory;
- }
-
- public void setDefaultMemory(Integer defaultMemory) {
- this.defaultMemory = defaultMemory;
- }
-
- public Integer getDefaultCpus() {
- return defaultCpus;
- }
-
- public void setDefaultCpus(Integer defaultCpus) {
- this.defaultCpus = defaultCpus;
- }
-
- public Integer getSlaveHttpPort() {
- return slaveHttpPort;
- }
-
- public void setSlaveHttpPort(Integer slaveHttpPort) {
- this.slaveHttpPort = slaveHttpPort;
- }
-
- public Optional getSlaveHttpsPort() {
- return slaveHttpsPort;
- }
-
- public void setSlaveHttpsPort(Optional slaveHttpsPort) {
- this.slaveHttpsPort = slaveHttpsPort;
- }
-
- public int getBounceExpirationMinutes() {
- return bounceExpirationMinutes;
- }
-
- public void setBounceExpirationMinutes(int bounceExpirationMinutes) {
- this.bounceExpirationMinutes = bounceExpirationMinutes;
- }
-
- public long getHealthcheckIntervalSeconds() {
- return healthcheckIntervalSeconds;
- }
-
- public void setHealthcheckIntervalSeconds(long healthcheckIntervalSeconds) {
- this.healthcheckIntervalSeconds = healthcheckIntervalSeconds;
- }
-
- public long getHealthcheckTimeoutSeconds() {
- return healthcheckTimeoutSeconds;
- }
-
- public void setHealthcheckTimeoutSeconds(long healthcheckTimeoutSeconds) {
- this.healthcheckTimeoutSeconds = healthcheckTimeoutSeconds;
- }
-
- public Optional getHealthcheckMaxRetries() {
- return healthcheckMaxRetries;
- }
-
- public void setHealthcheckMaxRetries(Optional healthcheckMaxRetries) {
- this.healthcheckMaxRetries = healthcheckMaxRetries;
- }
-
- public int getStartupTimeoutSeconds() {
- return startupTimeoutSeconds;
- }
-
- public void setStartupTimeoutSeconds(int startupTimeoutSeconds) {
- this.startupTimeoutSeconds = startupTimeoutSeconds;
- }
-
- public boolean isLoadBalancingEnabled() {
- return loadBalancingEnabled;
- }
-
- public void setLoadBalancingEnabled(boolean loadBalancingEnabled) {
- this.loadBalancingEnabled = loadBalancingEnabled;
- }
-
- public Optional getCommonHostnameSuffixToOmit() {
- return commonHostnameSuffixToOmit;
- }
-
- public void setCommonHostnameSuffixToOmit(Optional commonHostnameSuffixToOmit) {
- this.commonHostnameSuffixToOmit = commonHostnameSuffixToOmit;
- }
-
- public Integer getWarnIfScheduledJobIsRunningPastNextRunPct() {
- return warnIfScheduledJobIsRunningPastNextRunPct;
- }
-
- public void setWarnIfScheduledJobIsRunningPastNextRunPct(Integer warnIfScheduledJobIsRunningPastNextRunPct) {
- this.warnIfScheduledJobIsRunningPastNextRunPct = warnIfScheduledJobIsRunningPastNextRunPct;
- }
-
- public Optional getDefaultClientCredentials() {
- return defaultClientCredentials;
- }
-
- public void setDefaultClientCredentials(Optional defaultClientCredentials) {
- this.defaultClientCredentials = defaultClientCredentials;
- }
-
- public boolean isErrorOnDataCenterNotSpecified() {
- return errorOnDataCenterNotSpecified;
- }
-
- public ClusterCoordinatorConfiguration setErrorOnDataCenterNotSpecified(boolean errorOnDataCenterNotSpecified) {
- this.errorOnDataCenterNotSpecified = errorOnDataCenterNotSpecified;
- return this;
- }
-}
diff --git a/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/config/DataCenter.java b/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/config/DataCenter.java
deleted file mode 100644
index 75bd160474..0000000000
--- a/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/config/DataCenter.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package com.hubspot.singularity.config;
-
-import java.util.List;
-
-import javax.validation.constraints.NotNull;
-
-import org.hibernate.validator.constraints.NotEmpty;
-
-import com.google.common.base.Optional;
-import com.hubspot.singularity.SingularityClientCredentials;
-
-public class DataCenter {
- @NotNull
- private String name;
- @NotEmpty
- private List hosts;
- @NotNull
- private String contextPath;
- // http or https
- private String scheme = "http";
-
- private Optional clientCredentials = Optional.absent();
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public List getHosts() {
- return hosts;
- }
-
- public void setHosts(List hosts) {
- this.hosts = hosts;
- }
-
- public String getContextPath() {
- return contextPath;
- }
-
- public void setContextPath(String contextPath) {
- this.contextPath = contextPath;
- }
-
- public String getScheme() {
- return scheme;
- }
-
- public void setScheme(String scheme) {
- this.scheme = scheme;
- }
-
- public Optional getClientCredentials() {
- return clientCredentials;
- }
-
- public void setClientCredentials(Optional clientCredentials) {
- this.clientCredentials = clientCredentials;
- }
-
- @Override
- public String toString() {
- return "DataCenter{" +
- "name='" + name + '\'' +
- ", hosts=" + hosts +
- ", contextPath='" + contextPath + '\'' +
- ", scheme='" + scheme + '\'' +
- ", clientCredentials=" + clientCredentials +
- '}';
- }
-}
diff --git a/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/exceptions/DataCenterConflictException.java b/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/exceptions/DataCenterConflictException.java
deleted file mode 100644
index 9c08fd4f75..0000000000
--- a/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/exceptions/DataCenterConflictException.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.hubspot.singularity.exceptions;
-
-import javax.ws.rs.WebApplicationException;
-
-public class DataCenterConflictException extends WebApplicationException {
- public DataCenterConflictException(String message) {
- super(message, 409);
- }
-}
diff --git a/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/exceptions/DataCenterNotFoundException.java b/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/exceptions/DataCenterNotFoundException.java
deleted file mode 100644
index e003980199..0000000000
--- a/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/exceptions/DataCenterNotFoundException.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.hubspot.singularity.exceptions;
-
-import javax.ws.rs.WebApplicationException;
-
-public class DataCenterNotFoundException extends WebApplicationException {
- public DataCenterNotFoundException(String message, int status) {
- super(message, status);
- }
-}
diff --git a/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/exceptions/NotImplemenedException.java b/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/exceptions/NotImplemenedException.java
deleted file mode 100644
index c8a71b6260..0000000000
--- a/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/exceptions/NotImplemenedException.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.hubspot.singularity.exceptions;
-
-import javax.ws.rs.WebApplicationException;
-
-public class NotImplemenedException extends WebApplicationException {
- public NotImplemenedException() {
- super("Not Implemented", 500);
- }
-}
diff --git a/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/proxy/AuthResource.java b/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/proxy/AuthResource.java
deleted file mode 100644
index 075fe7a15b..0000000000
--- a/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/proxy/AuthResource.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.hubspot.singularity.proxy;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import com.google.common.base.Optional;
-import com.google.inject.Inject;
-import com.hubspot.singularity.SingularityAuthorizationScope;
-import com.hubspot.singularity.config.ApiPaths;
-
-@Path(ApiPaths.AUTH_RESOURCE_PATH)
-@Produces({ MediaType.APPLICATION_JSON })
-public class AuthResource extends ProxyResource {
-
- @Inject
- public AuthResource() {}
-
- @GET
- @Path("/user")
- public Response getUser(@Context HttpServletRequest request) {
- return routeToDefaultDataCenter(request);
- }
-
- @GET
- @Path("/{requestId}/auth-check/{userId}")
- public Response checkReadOnlyAuth(@Context HttpServletRequest request, @PathParam("requestId") String requestId, @PathParam("userId") String userId, @QueryParam("scope") Optional scope) {
- return routeToDefaultDataCenter(request);
- }
-}
diff --git a/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/proxy/DataCenterLocator.java b/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/proxy/DataCenterLocator.java
deleted file mode 100644
index d9700ef5ef..0000000000
--- a/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/proxy/DataCenterLocator.java
+++ /dev/null
@@ -1,206 +0,0 @@
-package com.hubspot.singularity.proxy;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Random;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.stream.Collectors;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableMap;
-import com.google.inject.Inject;
-import com.hubspot.singularity.SingularityRequestGroup;
-import com.hubspot.singularity.SingularityRequestParent;
-import com.hubspot.singularity.SingularitySlave;
-import com.hubspot.singularity.client.SingularityClient;
-import com.hubspot.singularity.config.ClusterCoordinatorConfiguration;
-import com.hubspot.singularity.config.DataCenter;
-import com.hubspot.singularity.exceptions.DataCenterNotFoundException;
-
-import io.dropwizard.lifecycle.Managed;
-
-public class DataCenterLocator implements Managed {
- private static final Logger LOG = LoggerFactory.getLogger(DataCenterLocator.class);
-
- private final ClusterCoordinatorConfiguration configuration;
- private final Map dataCenters;
- private final Map clients;
-
- private final Random random = new Random();
-
- private final Map> requestIdsByDataCenter = new ConcurrentHashMap<>();
- private final Map> requestGroupsByDataCenter = new ConcurrentHashMap<>();
- private final Map> slaveIdsByDataCenter = new ConcurrentHashMap<>();
- private final Map> hostnamesByDataCenter = new ConcurrentHashMap<>();
- private final Map> rackIdsByDataCenter = new ConcurrentHashMap<>();
-
-
- @Inject
- public DataCenterLocator(ClusterCoordinatorConfiguration configuration, Map clients) {
- this.configuration = configuration;
- this.clients = clients;
-
- ImmutableMap.Builder builder = ImmutableMap.builder();
- configuration.getDataCenters().forEach((dc) -> builder.put(dc.getName(), dc));
- this.dataCenters = builder.build();
- }
-
- String getHost(DataCenter dataCenter) {
- return dataCenter.getHosts().get(random.nextInt(dataCenter.getHosts().size()));
- }
-
- DataCenter getDataCenterForRequest(String requestId, boolean isGetRequest) {
- for (Map.Entry entry : dataCenters.entrySet()) {
- if (requestIdsByDataCenter.get(entry.getKey()).contains(requestId)) {
- return entry.getValue();
- }
- }
-
- // Not found, try each one
- for (Map.Entry entry : dataCenters.entrySet()) {
- SingularityClient client = clients.get(entry.getKey());
- Optional maybeRequest = client.getSingularityRequest(requestId);
- if (maybeRequest.isPresent()) {
- requestIdsByDataCenter.get(entry.getKey()).add(maybeRequest.get().getRequest().getId());
- return entry.getValue();
- }
- }
- throw new DataCenterNotFoundException(String.format("Could not find requestId '%s' in any data center", requestId), isGetRequest ? 404 :500);
- }
-
- Optional getMaybeDataCenterForRequest(String requestId, boolean isGetRequest) {
- try {
- return Optional.of(getDataCenterForRequest(requestId, isGetRequest));
- } catch (DataCenterNotFoundException nfe) {
- return Optional.absent();
- }
- }
-
- DataCenter getDataCenterForRequestGroup(String requestGroupId, boolean isGetRequest) {
- for (Map.Entry entry : dataCenters.entrySet()) {
- if (requestGroupsByDataCenter.get(entry.getKey()).contains(requestGroupId)) {
- return entry.getValue();
- }
- }
-
- // Not found, try each one
- for (Map.Entry entry : dataCenters.entrySet()) {
- SingularityClient client = clients.get(entry.getKey());
- Optional maybeRequestGroup = client.getRequestGroup(requestGroupId);
- if (maybeRequestGroup.isPresent()) {
- requestGroupsByDataCenter.get(entry.getKey()).add(maybeRequestGroup.get().getId());
- return entry.getValue();
- }
- }
- throw new DataCenterNotFoundException(String.format("Could not find requestGroupId '%s' in any data center", requestGroupId), isGetRequest ? 404 :500);
- }
-
- DataCenter getDataCenterForSlaveId(String slaveId, boolean isGetRequest) {
- for (Map.Entry entry : dataCenters.entrySet()) {
- if (slaveIdsByDataCenter.get(entry.getKey()).contains(slaveId)) {
- return entry.getValue();
- }
- }
-
- // Not found, try each one
- for (Map.Entry entry : dataCenters.entrySet()) {
- SingularityClient client = clients.get(entry.getKey());
- Optional maybeSlave = client.getSlave(slaveId);
- if (maybeSlave.isPresent()) {
- slaveIdsByDataCenter.get(entry.getKey()).add(maybeSlave.get().getId());
- hostnamesByDataCenter.get(entry.getKey()).add(maybeSlave.get().getHost());
- rackIdsByDataCenter.get(entry.getKey()).add(maybeSlave.get().getRackId());
- return entry.getValue();
- }
- }
- throw new DataCenterNotFoundException(String.format("Could not find slaveId '%s' in any data center", slaveId), isGetRequest ? 404 :500);
- }
-
- DataCenter getDataCenterForSlaveHostname(String hostname, boolean isGetRequest) {
- for (Map.Entry entry : dataCenters.entrySet()) {
- if (hostnamesByDataCenter.get(entry.getKey()).contains(hostname)) {
- return entry.getValue();
- }
- }
-
- // Not found, try each one
- for (Map.Entry entry : dataCenters.entrySet()) {
- SingularityClient client = clients.get(entry.getKey());
- Collection slaves = client.getSlaves(Optional.absent());
- for (SingularitySlave slave : slaves) {
- if (slave.getHost().equals(hostname)) {
- slaveIdsByDataCenter.get(entry.getKey()).add(slave.getId());
- hostnamesByDataCenter.get(entry.getKey()).add(slave.getHost());
- rackIdsByDataCenter.get(entry.getKey()).add(slave.getRackId());
- return entry.getValue();
- }
- }
- }
- throw new DataCenterNotFoundException(String.format("Could not find slave with hostname '%s' in any data center", hostname), isGetRequest ? 404 :500);
- }
-
- DataCenter getDataCenterForRackId(String rackId, boolean isGetRequest) {
- for (Map.Entry entry : dataCenters.entrySet()) {
- if (rackIdsByDataCenter.get(entry.getKey()).contains(rackId)) {
- return entry.getValue();
- }
- }
-
- // Not found, try each one
- for (Map.Entry entry : dataCenters.entrySet()) {
- SingularityClient client = clients.get(entry.getKey());
- Collection slaves = client.getSlaves(Optional.absent());
- for (SingularitySlave slave : slaves) {
- if (slave.getRackId().equals(rackId)) {
- slaveIdsByDataCenter.get(entry.getKey()).add(slave.getId());
- hostnamesByDataCenter.get(entry.getKey()).add(slave.getHost());
- rackIdsByDataCenter.get(entry.getKey()).add(slave.getRackId());
- return entry.getValue();
- }
- }
- }
- throw new DataCenterNotFoundException(String.format("Could not find rack with id '%s' in any data center", rackId), isGetRequest ? 404 :500);
- }
-
- DataCenter getDataCenter(String name) {
- if (dataCenters.containsKey(name)) {
- return dataCenters.get(name);
- } else {
- throw new DataCenterNotFoundException(String.format("No known data center with name: %s", name), 404);
- }
- }
-
- @Override
- public void start() {
- loadData();
- }
-
- private void loadData() {
- configuration.getDataCenters().forEach((dc) -> {
- SingularityClient singularityClient = clients.get(dc.getName());
-
- Collection requestParents = singularityClient.getSingularityRequests();
- requestIdsByDataCenter.put(dc.getName(), requestParents.stream().map((r) -> r.getRequest().getId()).collect(Collectors.toSet()));
- LOG.info("Loaded {} requests for data center {}", requestParents.size(), dc.getName());
-
- Collection slaves = singularityClient.getSlaves(Optional.absent());
- Set rackIds = slaves.stream().map(SingularitySlave::getRackId).collect(Collectors.toSet());
- rackIdsByDataCenter.put(dc.getName(), new HashSet<>(rackIds));
- slaveIdsByDataCenter.put(dc.getName(), slaves.stream().map(SingularitySlave::getId).collect(Collectors.toSet()));
- hostnamesByDataCenter.put(dc.getName(), slaves.stream().map(SingularitySlave::getHost).collect(Collectors.toSet()));
- LOG.info("Loaded {} slaves for data center {}", slaves.size(), dc.getName());
-
- Collection requestGroups = singularityClient.getRequestGroups();
- requestGroupsByDataCenter.put(dc.getName(), requestGroups.stream().map(SingularityRequestGroup::getId).collect(Collectors.toSet()));
- LOG.info("Loaded {} request groups for data center {}", requestGroups.size(), dc.getName());
- });
- }
-
- @Override
- public void stop() {}
-}
diff --git a/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/proxy/DeployResource.java b/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/proxy/DeployResource.java
deleted file mode 100644
index 848ee9e376..0000000000
--- a/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/proxy/DeployResource.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package com.hubspot.singularity.proxy;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import com.google.inject.Inject;
-import com.hubspot.singularity.SingularityUpdatePendingDeployRequest;
-import com.hubspot.singularity.api.SingularityDeployRequest;
-import com.hubspot.singularity.config.ApiPaths;
-
-@Path(ApiPaths.DEPLOY_RESOURCE_PATH)
-@Produces({ MediaType.APPLICATION_JSON })
-public class DeployResource extends ProxyResource {
-
- @Inject
- public DeployResource() {}
-
- @GET
- @Path("/pending")
- public Response getPendingDeploys(@Context HttpServletRequest request) {
- return getMergedListResult(request);
- }
-
- @POST
- @Consumes({ MediaType.APPLICATION_JSON })
- public Response deploy(@Context HttpServletRequest request, SingularityDeployRequest deployRequest) {
- return routeByRequestId(request, deployRequest.getDeploy().getRequestId(), deployRequest);
- }
-
- @DELETE
- @Path("/deploy/{deployId}/request/{requestId}")
- public Response cancelDeploy(@Context HttpServletRequest request, @PathParam("requestId") String requestId, @PathParam("deployId") String deployId) {
- return routeByRequestId(request, requestId);
- }
-
- @POST
- @Path("/update")
- public Response updatePendingDeploy(@Context HttpServletRequest request, SingularityUpdatePendingDeployRequest updateRequest) {
- return routeByRequestId(request, updateRequest.getRequestId(), updateRequest);
- }
-}
diff --git a/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/proxy/DisastersResource.java b/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/proxy/DisastersResource.java
deleted file mode 100644
index 49e8e3f836..0000000000
--- a/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/proxy/DisastersResource.java
+++ /dev/null
@@ -1,105 +0,0 @@
-package com.hubspot.singularity.proxy;
-
-import java.util.List;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-
-import com.google.common.base.Optional;
-import com.google.inject.Inject;
-import com.hubspot.singularity.SingularityAction;
-import com.hubspot.singularity.SingularityDisabledAction;
-import com.hubspot.singularity.SingularityDisasterType;
-import com.hubspot.singularity.SingularityDisastersData;
-import com.hubspot.singularity.SingularityTaskCredits;
-import com.hubspot.singularity.api.SingularityDisabledActionRequest;
-import com.hubspot.singularity.config.ApiPaths;
-import com.hubspot.singularity.exceptions.NotImplemenedException;
-
-@Path(ApiPaths.DISASTERS_RESOURCE_PATH)
-@Produces({ MediaType.APPLICATION_JSON })
-public class DisastersResource extends ProxyResource {
-
- @Inject
- public DisastersResource() {}
-
- @GET
- @Path("/stats")
- public SingularityDisastersData disasterStats(@Context HttpServletRequest request) {
- throw new NotImplemenedException();
- }
-
- @GET
- @Path("/active")
- public List activeDisasters(@Context HttpServletRequest request) {
- throw new NotImplemenedException();
- }
-
- @POST
- @Path("/disable")
- public void disableAutomatedDisasterCreation(@Context HttpServletRequest request) {
- throw new NotImplemenedException();
- }
-
- @POST
- @Path("/enable")
- public void enableAutomatedDisasterCreation(@Context HttpServletRequest request) {
- throw new NotImplemenedException();
- }
-
- @DELETE
- @Path("/active/{type}")
- public void removeDisaster(@Context HttpServletRequest request, @PathParam("type") SingularityDisasterType type) {
- throw new NotImplemenedException();
- }
-
- @POST
- @Path("/active/{type}")
- public void newDisaster(@Context HttpServletRequest request, @PathParam("type") SingularityDisasterType type) {
- throw new NotImplemenedException();
- }
-
- @GET
- @Path("/disabled-actions")
- public List disabledActions(@Context HttpServletRequest request) {
- throw new NotImplemenedException();
- }
-
- @POST
- @Path("/disabled-actions/{action}")
- public void disableAction(@Context HttpServletRequest request, @PathParam("action") SingularityAction action, SingularityDisabledActionRequest disabledActionRequest) {
- throw new NotImplemenedException();
- }
-
- @DELETE
- @Path("/disabled-actions/{action}")
- public void enableAction(@Context HttpServletRequest request, @PathParam("action") SingularityAction action) {
- throw new NotImplemenedException();
- }
-
- @POST
- @Path("/task-credits")
- public void addTaskCredits(@Context HttpServletRequest request, @QueryParam("credits") Optional credits) throws Exception {
- throw new NotImplemenedException();
- }
-
- @DELETE
- @Path("/task-credits")
- public void disableTaskCredits(@Context HttpServletRequest request) throws Exception {
- throw new NotImplemenedException();
- }
-
- @GET
- @Path("/task-credits")
- public SingularityTaskCredits getTaskCreditData(@Context HttpServletRequest request) throws Exception {
- throw new NotImplemenedException();
- }
-}
diff --git a/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/proxy/HistoryResource.java b/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/proxy/HistoryResource.java
deleted file mode 100644
index 6e4897020a..0000000000
--- a/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/proxy/HistoryResource.java
+++ /dev/null
@@ -1,145 +0,0 @@
-package com.hubspot.singularity.proxy;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import com.google.common.base.Optional;
-import com.google.inject.Inject;
-import com.hubspot.singularity.SingularityTaskId;
-import com.hubspot.singularity.config.ApiPaths;
-
-// Omits some or all @QueryParam annotated args, will be copied from request context
-@Path(ApiPaths.HISTORY_RESOURCE_PATH)
-@Produces({ MediaType.APPLICATION_JSON })
-public class HistoryResource extends ProxyResource {
-
- @Inject
- public HistoryResource() {}
-
- @GET
- @Path("/task/{taskId}")
- public Response getHistoryForTask(@Context HttpServletRequest request, @PathParam("taskId") String taskId) {
- SingularityTaskId parsedId = SingularityTaskId.valueOf(taskId);
- return routeByRequestId(request, parsedId.getRequestId());
- }
-
-
- @GET
- @Path("/request/{requestId}/tasks/active")
- public Response getTaskHistoryForRequest(@Context HttpServletRequest request, @PathParam("requestId") String requestId) {
- return routeByRequestId(request, requestId);
- }
-
- @GET
- @Path("/request/{requestId}/deploy/{deployId}")
- public Response getDeploy(@Context HttpServletRequest request, @PathParam("requestId") String requestId, @PathParam("deployId") String deployId) {
- return routeByRequestId(request, requestId);
- }
-
- @GET
- @Path("/request/{requestId}/deploy/{deployId}/tasks/active")
- public Response getActiveDeployTasks(@Context HttpServletRequest request, @PathParam("requestId") String requestId, @PathParam("deployId") String deployId) {
- return routeByRequestId(request, requestId);
- }
-
- @GET
- @Path("/request/{requestId}/deploy/{deployId}/tasks/inactive")
- public Response getInactiveDeployTasks(@Context HttpServletRequest request, @PathParam("requestId") String requestId, @PathParam("deployId") String deployId) {
- return routeByRequestId(request, requestId);
- }
-
- @GET
- @Path("/request/{requestId}/deploy/{deployId}/tasks/inactive/withmetadata")
- public Response getInactiveDeployTasksWithMetadata(
- @Context HttpServletRequest request, @PathParam("requestId") String requestId, @PathParam("deployId") String deployId) {
- return routeByRequestId(request, requestId);
- }
-
- @GET
- @Path("/tasks")
- public Response getTaskHistory(
- @Context HttpServletRequest request, @QueryParam("requestId") Optional requestId, @QueryParam("deployId") Optional deployId,
- @QueryParam("runId") Optional runId, @QueryParam("host") Optional host) {
- // TODO - what if requestId not present?
- return routeByRequestId(request, requestId.or(""));
- }
-
- @GET
- @Path("/tasks/withmetadata")
- public Response getTaskHistoryWithMetadata(
- @Context HttpServletRequest request, @QueryParam("requestId") Optional requestId, @QueryParam("deployId") Optional deployId,
- @QueryParam("runId") Optional runId, @QueryParam("host") Optional host) {
- // TODO - what if requestId not present?
- return routeByRequestId(request, requestId.or(""));
- }
-
- @GET
- @Path("/request/{requestId}/tasks")
- public Response getTaskHistoryForRequest(
- @Context HttpServletRequest request, @PathParam("requestId") String requestId, @QueryParam("deployId") Optional deployId,
- @QueryParam("runId") Optional runId, @QueryParam("host") Optional host) {
- return routeByRequestId(request, requestId);
- }
-
- @GET
- @Path("/request/{requestId}/tasks/withmetadata")
- public Response getTaskHistoryForRequestWithMetadata(
- @Context HttpServletRequest request, @PathParam("requestId") String requestId, @QueryParam("deployId") Optional deployId,
- @QueryParam("runId") Optional runId, @QueryParam("host") Optional host) {
- return routeByRequestId(request, requestId);
- }
-
- @GET
- @Path("/request/{requestId}/run/{runId}")
- public Response getTaskHistoryForRequestAndRunId(
- @Context HttpServletRequest request, @PathParam("requestId") String requestId, @PathParam("runId") String runId) {
- return routeByRequestId(request, requestId);
- }
-
- @GET
- @Path("/request/{requestId}/deploys")
- public Response getDeploys(
- @Context HttpServletRequest request, @PathParam("requestId") String requestId) {
- return routeByRequestId(request, requestId);
- }
-
- @GET
- @Path("/request/{requestId}/deploys/withmetadata")
- public Response getDeploysWithMetadata(
- @Context HttpServletRequest request, @PathParam("requestId") String requestId) {
- return routeByRequestId(request, requestId);
- }
-
- @GET
- @Path("/request/{requestId}/requests")
- public Response getRequestHistoryForRequest(
- @Context HttpServletRequest request, @PathParam("requestId") String requestId) {
- return routeByRequestId(request, requestId);
- }
-
- @GET
- @Path("/request/{requestId}/requests/withmetadata")
- public Response getRequestHistoryForRequestWithMetadata(
- @Context HttpServletRequest request, @PathParam("requestId") String requestId) {
- return routeByRequestId(request, requestId);
- }
-
- @GET
- @Path("/requests/search")
- public Response getRequestHistoryForRequestLike(@Context HttpServletRequest request, @QueryParam("requestIdLike") String requestIdLike) {
- return getMergedListResult(request);
- }
-
- @GET
- @Path("/request/{requestId}/command-line-args")
- public Response getRecentCommandLineArgs(@Context HttpServletRequest request, @PathParam("requestId") String requestId) {
- return getMergedListResult(request);
- }
-}
diff --git a/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/proxy/InactiveSlaveResource.java b/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/proxy/InactiveSlaveResource.java
deleted file mode 100644
index f98a121f8d..0000000000
--- a/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/proxy/InactiveSlaveResource.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package com.hubspot.singularity.proxy;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import com.google.inject.Inject;
-import com.hubspot.singularity.config.ApiPaths;
-
-@Path(ApiPaths.INACTIVE_SLAVES_RESOURCE_PATH)
-@Produces({ MediaType.APPLICATION_JSON })
-public class InactiveSlaveResource extends ProxyResource {
-
- @Inject
- public InactiveSlaveResource() {}
-
- @GET
- public Response getInactiveSlaves(@Context HttpServletRequest request) {
- return getMergedListResult(request);
- }
-
- @POST
- public Response deactivateSlave(@Context HttpServletRequest request, @QueryParam("host") String host) {
- return routeByHostname(request, host);
- }
-
- @DELETE
- public Response reactivateSlave(@Context HttpServletRequest request, @QueryParam("host") String host) {
- return routeByHostname(request, host);
- }
-}
diff --git a/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/proxy/PriorityResource.java b/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/proxy/PriorityResource.java
deleted file mode 100644
index 74d5b97917..0000000000
--- a/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/proxy/PriorityResource.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.hubspot.singularity.proxy;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-
-import com.google.common.base.Optional;
-import com.google.inject.Inject;
-import com.hubspot.singularity.SingularityPriorityFreezeParent;
-import com.hubspot.singularity.api.SingularityPriorityFreeze;
-import com.hubspot.singularity.config.ApiPaths;
-import com.hubspot.singularity.exceptions.NotImplemenedException;
-
-@Path(ApiPaths.PRIORITY_RESOURCE_PATH)
-@Produces({ MediaType.APPLICATION_JSON })
-public class PriorityResource extends ProxyResource {
-
- @Inject
- public PriorityResource() {}
-
- @GET
- @Path("/freeze")
- public Optional getActivePriorityFreeze(@Context HttpServletRequest request) {
- throw new NotImplemenedException();
- }
-
- @DELETE
- @Path("/freeze")
- public void deleteActivePriorityFreeze(@Context HttpServletRequest request) {
- throw new NotImplemenedException();
- }
-
- @POST
- @Path("/freeze")
- public SingularityPriorityFreezeParent createPriorityFreeze(@Context HttpServletRequest request, SingularityPriorityFreeze priorityFreezeRequest) {
- throw new NotImplemenedException();
- }
-}
diff --git a/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/proxy/ProxyResource.java b/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/proxy/ProxyResource.java
deleted file mode 100644
index 7b6db2c99f..0000000000
--- a/SingularityClusterCoordinator/src/main/java/com/hubspot/singularity/proxy/ProxyResource.java
+++ /dev/null
@@ -1,323 +0,0 @@
-package com.hubspot.singularity.proxy;
-
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeoutException;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.ResponseBuilder;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.common.base.Throwables;
-import com.google.common.collect.Lists;
-import com.google.inject.Inject;
-import com.google.inject.name.Named;
-import com.hubspot.horizon.AsyncHttpClient;
-import com.hubspot.horizon.Header;
-import com.hubspot.horizon.HttpRequest;
-import com.hubspot.horizon.HttpRequest.Method;
-import com.hubspot.horizon.HttpResponse;
-import com.hubspot.singularity.config.ApiPaths;
-import com.hubspot.singularity.config.ClusterCoordinatorConfiguration;
-import com.hubspot.singularity.config.DataCenter;
-
-import io.dropwizard.server.SimpleServerFactory;
-
-public class ProxyResource {
- private static final Logger LOG = LoggerFactory.getLogger(ProxyResource.class);
-
- private AsyncHttpClient httpClient;
- protected ClusterCoordinatorConfiguration configuration;
- private ObjectMapper objectMapper;
- protected DataCenterLocator dataCenterLocator;
- private String contextPath;
-
- public ProxyResource() {}
-
- @Inject
- void injectProxyDeps(ClusterCoordinatorConfiguration configuration,
- @Named(SingularityClusterCoodinatorResourcesModule.ASYNC_HTTP_CLIENT) AsyncHttpClient httpClient,
- ObjectMapper objectMapper,
- DataCenterLocator dataCenterLocator) {
- this.configuration = configuration;
- this.httpClient = httpClient;
- this.objectMapper = objectMapper;
- this.dataCenterLocator = dataCenterLocator;
- String baseContextPath = ((SimpleServerFactory) configuration.getServerFactory()).getApplicationContextPath();
- if (baseContextPath.startsWith("/")) {
- baseContextPath = baseContextPath.substring(1, baseContextPath.length());
- }
- if (baseContextPath.endsWith("/")) {
- baseContextPath = baseContextPath.substring(0, baseContextPath.length() -1);
- }
- this.contextPath = baseContextPath + ApiPaths.API_BASE_PATH;
- }
-
- /*
- * For items where the dataCenter is part of the object, or where a full list is desired.
- * Collect and merge results from each configured dataCenter
- */
- public Response getMergedListResult(HttpServletRequest request) {
- return getMergedListResult(request, null);
- }
-
- public Response getMergedListResult(HttpServletRequest request, T body) {
- List headers = getHeaders(request);
- List params = getParams(request);
-
- // TODO - parallelize
- List