Skip to content

Commit

Permalink
Merge branch 'master' of github.com:HubSpot/Singularity
Browse files Browse the repository at this point in the history
  • Loading branch information
ssalinas committed Mar 30, 2015
2 parents 57fdc92 + d6bbc02 commit 9214895
Show file tree
Hide file tree
Showing 87 changed files with 1,565 additions and 472 deletions.
10 changes: 10 additions & 0 deletions SingularityBase/src/main/java/com/hubspot/mesos/Resources.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,17 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

import static com.google.common.base.Preconditions.checkNotNull;

public class Resources {
public static Resources add(Resources a, Resources b) {
checkNotNull(a, "first argument of Resources.add() is null");
checkNotNull(b, "second argument of Resources.add() is null");

return new Resources(a.getCpus() + b.getCpus(), a.getMemoryMb() + b.getMemoryMb(), a.getNumPorts() + b.getNumPorts());
}

public static final Resources EMPTY_RESOURCES = new Resources(0, 0, 0);

private final double cpus;
private final double memoryMb;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public class SingularityDeploy {
private final Optional<String> customExecutorCmd;
private final Optional<String> customExecutorId;
private final Optional<String> customExecutorSource;
private final Optional<Resources> customExecutorResources;

private final Optional<Resources> resources;

private final Optional<String> command;
Expand Down Expand Up @@ -63,6 +65,7 @@ public SingularityDeploy(@JsonProperty("requestId") String requestId,
@JsonProperty("customExecutorCmd") Optional<String> customExecutorCmd,
@JsonProperty("customExecutorId") Optional<String> customExecutorId,
@JsonProperty("customExecutorSource") Optional<String> customExecutorSource,
@JsonProperty("customExecutorResources") Optional<Resources> customExecutorResources,
@JsonProperty("resources") Optional<Resources> resources,
@JsonProperty("env") Optional<Map<String, String>> env,
@JsonProperty("uris") Optional<List<String>> uris,
Expand Down Expand Up @@ -90,6 +93,7 @@ public SingularityDeploy(@JsonProperty("requestId") String requestId,
this.customExecutorCmd = customExecutorCmd;
this.customExecutorId = customExecutorId;
this.customExecutorSource = customExecutorSource;
this.customExecutorResources = customExecutorResources;

this.metadata = metadata;
this.version = version;
Expand Down Expand Up @@ -190,6 +194,11 @@ public Optional<String> getCustomExecutorId() {
@ApiModelProperty(required=false, value="Custom Mesos executor source.")
public Optional<String> getCustomExecutorSource() { return customExecutorSource; }

@ApiModelProperty(required=false, value="Resources to allocate for custom mesos executor")
public Optional<Resources> getCustomExecutorResources() {
return customExecutorResources;
}

@ApiModelProperty(required=false, value="Resources required for this deploy.", dataType="com.hubspot.mesos.Resources")
public Optional<Resources> getResources() {
return resources;
Expand Down Expand Up @@ -272,6 +281,7 @@ public String toString() {
", customExecutorCmd=" + customExecutorCmd +
", customExecutorId=" + customExecutorId +
", customExecutorSource=" + customExecutorSource +
", customExecutorResources=" + customExecutorResources +
", resources=" + resources +
", command=" + command +
", arguments=" + arguments +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public class SingularityDeployBuilder {
private Optional<String> customExecutorCmd;
private Optional<String> customExecutorId;
private Optional<String> customExecutorSource;
private Optional<Resources> customExecutorResources;

private Optional<Resources> resources;

private Optional<String> command;
Expand Down Expand Up @@ -54,6 +56,7 @@ public SingularityDeployBuilder(String requestId, String id) {
this.customExecutorCmd = Optional.absent();
this.customExecutorId = Optional.absent();
this.customExecutorSource = Optional.absent();
this.customExecutorResources = Optional.absent();
this.resources = Optional.absent();
this.command = Optional.absent();
this.arguments = Optional.absent();
Expand All @@ -72,7 +75,7 @@ public SingularityDeployBuilder(String requestId, String id) {
}

public SingularityDeploy build() {
return new SingularityDeploy(requestId, id, command, arguments, containerInfo, customExecutorCmd, customExecutorId, customExecutorSource, resources, env, uris, metadata, executorData, version, timestamp, deployHealthTimeoutSeconds, healthcheckUri, healthcheckIntervalSeconds,
return new SingularityDeploy(requestId, id, command, arguments, containerInfo, customExecutorCmd, customExecutorId, customExecutorSource, customExecutorResources, resources, env, uris, metadata, executorData, version, timestamp, deployHealthTimeoutSeconds, healthcheckUri, healthcheckIntervalSeconds,
healthcheckTimeoutSeconds, serviceBasePath, loadBalancerGroups, considerHealthyAfterRunningForSeconds, loadBalancerOptions, skipHealthchecksOnDeploy);
}

Expand Down Expand Up @@ -161,6 +164,15 @@ public SingularityDeployBuilder setCustomExecutorSource(Optional<String> customE
return this;
}

public Optional<Resources> getCustomExecutorResources() {
return customExecutorResources;
}

public SingularityDeployBuilder setCustomExecutorResources(Optional<Resources> customExecutorResources) {
this.customExecutorResources = customExecutorResources;
return this;
}

public Optional<Long> getDeployHealthTimeoutSeconds() {
return deployHealthTimeoutSeconds;
}
Expand Down Expand Up @@ -299,6 +311,7 @@ public String toString() {
", customExecutorCmd=" + customExecutorCmd +
", customExecutorId=" + customExecutorId +
", customExecutorSource=" + customExecutorSource +
", customExecutorResources=" + customExecutorResources +
", resources=" + resources +
", command=" + command +
", arguments=" + arguments +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public class SingularityRequest {
private final Optional<Long> killOldNonLongRunningTasksAfterMillis;
private final Optional<Long> scheduledExpectedRuntimeMillis;

private final Optional<Long> waitAtLeastMillisAfterTaskFinishesForReschedule;

//"use requestType instead"
@Deprecated
private final Optional<Boolean> daemon;
Expand All @@ -42,7 +44,8 @@ public SingularityRequest(@JsonProperty("id") String id, @JsonProperty("requestT
@JsonProperty("rackSensitive") Optional<Boolean> rackSensitive, @JsonProperty("loadBalanced") Optional<Boolean> loadBalanced,
@JsonProperty("killOldNonLongRunningTasksAfterMillis") Optional<Long> killOldNonLongRunningTasksAfterMillis, @JsonProperty("scheduleType") Optional<ScheduleType> scheduleType,
@JsonProperty("quartzSchedule") Optional<String> quartzSchedule, @JsonProperty("rackAffinity") Optional<List<String>> rackAffinity,
@JsonProperty("slavePlacement") Optional<SlavePlacement> slavePlacement, @JsonProperty("scheduledExpectedRuntimeMillis") Optional<Long> scheduledExpectedRuntimeMillis) {
@JsonProperty("slavePlacement") Optional<SlavePlacement> slavePlacement, @JsonProperty("scheduledExpectedRuntimeMillis") Optional<Long> scheduledExpectedRuntimeMillis,
@JsonProperty("waitAtLeastMillisAfterTaskFinishesForReschedule") Optional<Long> waitAtLeastMillisAfterTaskFinishesForReschedule) {
this.id = id;
this.owners = owners;
this.numRetriesOnFailure = numRetriesOnFailure;
Expand All @@ -57,6 +60,7 @@ public SingularityRequest(@JsonProperty("id") String id, @JsonProperty("requestT
this.rackAffinity = rackAffinity;
this.slavePlacement = slavePlacement;
this.scheduledExpectedRuntimeMillis = scheduledExpectedRuntimeMillis;
this.waitAtLeastMillisAfterTaskFinishesForReschedule = waitAtLeastMillisAfterTaskFinishesForReschedule;

if (requestType == null) {
this.requestType = RequestType.fromDaemonAndScheduleAndLoadBalanced(schedule, daemon, loadBalanced);
Expand All @@ -77,6 +81,7 @@ public SingularityRequestBuilder toBuilder() {
.setScheduleType(scheduleType)
.setQuartzSchedule(quartzSchedule)
.setRackAffinity(copyOfList(rackAffinity))
.setWaitAtLeastMillisAfterTaskFinishesForReschedule(waitAtLeastMillisAfterTaskFinishesForReschedule)
.setSlavePlacement(slavePlacement)
.setScheduledExpectedRuntimeMillis(scheduledExpectedRuntimeMillis);
}
Expand Down Expand Up @@ -202,12 +207,16 @@ public ScheduleType getScheduleTypeSafe() {
return scheduleType.or(ScheduleType.CRON);
}

public Optional<Long> getWaitAtLeastMillisAfterTaskFinishesForReschedule() {
return waitAtLeastMillisAfterTaskFinishesForReschedule;
}

@Override
public String toString() {
return "SingularityRequest [id=" + id + ", requestType=" + requestType + ", owners=" + owners + ", numRetriesOnFailure=" + numRetriesOnFailure + ", schedule=" + schedule + ", quartzSchedule="
+ quartzSchedule + ", scheduleType=" + scheduleType + ", killOldNonLongRunningTasksAfterMillis=" + killOldNonLongRunningTasksAfterMillis + ", scheduledExpectedRuntimeMillis="
+ scheduledExpectedRuntimeMillis + ", daemon=" + daemon + ", instances=" + instances + ", rackSensitive=" + rackSensitive + ", rackAffinity=" + rackAffinity + ", slavePlacement="
+ slavePlacement + ", loadBalanced=" + loadBalanced + "]";
+ scheduledExpectedRuntimeMillis + ", waitAtLeastMillisAfterTaskFinishesForReschedule=" + waitAtLeastMillisAfterTaskFinishesForReschedule + ", daemon=" + daemon + ", instances=" + instances
+ ", rackSensitive=" + rackSensitive + ", rackAffinity=" + rackAffinity + ", slavePlacement=" + slavePlacement + ", loadBalanced=" + loadBalanced + "]";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class SingularityRequestBuilder {
private Optional<Long> killOldNonLongRunningTasksAfterMillis;
private Optional<Long> scheduledExpectedRuntimeMillis;

private Optional<Long> waitAtLeastMillisAfterTaskFinishesForReschedule;

@Deprecated
// use requestType
Expand Down Expand Up @@ -52,7 +53,7 @@ public SingularityRequestBuilder(String id, RequestType requestType) {

public SingularityRequest build() {
return new SingularityRequest(id, requestType, owners, numRetriesOnFailure, schedule, daemon, instances, rackSensitive, loadBalanced, killOldNonLongRunningTasksAfterMillis, scheduleType, quartzSchedule,
rackAffinity, slavePlacement, scheduledExpectedRuntimeMillis);
rackAffinity, slavePlacement, scheduledExpectedRuntimeMillis, waitAtLeastMillisAfterTaskFinishesForReschedule);
}

public Optional<Boolean> getLoadBalanced() {
Expand Down Expand Up @@ -182,12 +183,21 @@ public RequestType getRequestType() {
return requestType;
}

public Optional<Long> getWaitAtLeastMillisAfterTaskFinishesForReschedule() {
return waitAtLeastMillisAfterTaskFinishesForReschedule;
}

public SingularityRequestBuilder setWaitAtLeastMillisAfterTaskFinishesForReschedule(Optional<Long> waitAtLeastMillisAfterTaskFinishesForReschedule) {
this.waitAtLeastMillisAfterTaskFinishesForReschedule = waitAtLeastMillisAfterTaskFinishesForReschedule;
return this;
}

@Override
public String toString() {
return "SingularityRequestBuilder [id=" + id + ", requestType=" + requestType + ", owners=" + owners + ", numRetriesOnFailure=" + numRetriesOnFailure + ", schedule=" + schedule
+ ", quartzSchedule=" + quartzSchedule + ", scheduleType=" + scheduleType + ", killOldNonLongRunningTasksAfterMillis=" + killOldNonLongRunningTasksAfterMillis
+ ", scheduledExpectedRuntimeMillis=" + scheduledExpectedRuntimeMillis + ", daemon=" + daemon + ", instances=" + instances + ", rackSensitive=" + rackSensitive + ", rackAffinity="
+ rackAffinity + ", slavePlacement=" + slavePlacement + ", loadBalanced=" + loadBalanced + "]";
+ ", scheduledExpectedRuntimeMillis=" + scheduledExpectedRuntimeMillis + ", waitAtLeastMillisAfterTaskFinishesForReschedule=" + waitAtLeastMillisAfterTaskFinishesForReschedule + ", daemon="
+ daemon + ", instances=" + instances + ", rackSensitive=" + rackSensitive + ", rackAffinity=" + rackAffinity + ", slavePlacement=" + slavePlacement + ", loadBalanced=" + loadBalanced + "]";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public SingularityTaskHistoryUpdate(@JsonProperty("taskId") SingularityTaskId ta
@Override
public int compareTo(SingularityTaskHistoryUpdate o) {
return ComparisonChain.start()
.compare(timestamp, o.getTimestamp())
.compare(taskState.ordinal(), o.getTaskState().ordinal())
.compare(timestamp, o.getTimestamp())
.compare(o.getTaskId().getId(), getTaskId().getId())
.result();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.hubspot.singularity.api;

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.hubspot.singularity.SingularityDeploy;
Expand Down Expand Up @@ -32,6 +33,11 @@ public Optional<Boolean> getUnpauseOnSuccessfulDeploy() {
return unpauseOnSuccessfulDeploy;
}

@JsonIgnore
public boolean isUnpauseOnSuccessfulDeploy() {
return unpauseOnSuccessfulDeploy.or(Boolean.FALSE);
}

@ApiModelProperty(required=true, value="The Singularity deploy object")
public SingularityDeploy getDeploy() {
return deploy;
Expand Down
Loading

0 comments on commit 9214895

Please sign in to comment.