-
Notifications
You must be signed in to change notification settings - Fork 188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Overrides for run now requests #1650
Changes from 4 commits
4d1815c
edab7aa
27ddc68
3634f26
4bf55d2
cf38987
7db038c
f9d59e5
42fe3b6
6c0c836
4b1c9fa
d81a6a9
f3012b7
a049250
5a2e951
19267fb
03b9972
3110897
38554c0
547b834
19b385e
30a441e
28e9b53
097469d
bc231b2
15c44da
265f042
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package com.hubspot.singularity; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import com.google.common.base.Optional; | ||
import com.hubspot.mesos.Resources; | ||
|
||
public class SingularityPendingTaskBuilder { | ||
|
||
private SingularityPendingTaskId pendingTaskId; | ||
private Optional<List<String>> cmdLineArgsList; | ||
private Optional<String> user; | ||
private Optional<String> runId; | ||
private Optional<Boolean> skipHealthchecks; | ||
private Optional<String> message; | ||
private Optional<Resources> resources; | ||
private Map<String, String> envOverrides; | ||
private Optional<String> actionId; | ||
|
||
public SingularityPendingTaskBuilder() { | ||
this.pendingTaskId = null; | ||
this.cmdLineArgsList = Optional.absent(); | ||
this.user = Optional.absent(); | ||
this.runId = Optional.absent(); | ||
this.skipHealthchecks = Optional.absent(); | ||
this.message = Optional.absent(); | ||
this.resources = Optional.absent(); | ||
this.envOverrides = null; | ||
this.actionId = Optional.absent(); | ||
} | ||
|
||
public SingularityPendingTaskBuilder setPendingTaskId(SingularityPendingTaskId pendingTaskId) { | ||
this.pendingTaskId = pendingTaskId; | ||
return this; | ||
} | ||
|
||
|
||
public SingularityPendingTaskBuilder setCmdLineArgsList(List<String> cmdLineArgsList) { | ||
this.cmdLineArgsList = Optional.of(cmdLineArgsList); | ||
return this; | ||
} | ||
|
||
public SingularityPendingTaskBuilder setCmdLineArgsList(Optional<List<String>> cmdLineArgsList) { | ||
this.cmdLineArgsList = cmdLineArgsList; | ||
return this; | ||
} | ||
|
||
public SingularityPendingTaskBuilder setUser(String user) { | ||
this.user = Optional.of(user); | ||
return this; | ||
} | ||
|
||
|
||
public SingularityPendingTaskBuilder setRunId(String runId) { | ||
this.runId = Optional.of(runId); | ||
return this; | ||
} | ||
|
||
public SingularityPendingTaskBuilder setSkipHealthchecks(Boolean skipHealthchecks) { | ||
this.skipHealthchecks = Optional.of(skipHealthchecks); | ||
return this; | ||
} | ||
|
||
public SingularityPendingTaskBuilder setMessage(String message) { | ||
this.message = Optional.of(message); | ||
return this; | ||
} | ||
|
||
public SingularityPendingTaskBuilder setResources(Resources resources) { | ||
this.resources = Optional.of(resources); | ||
return this; | ||
} | ||
|
||
public SingularityPendingTaskBuilder setEnvOverrides(Map<String, String> envOverrides) { | ||
this.envOverrides = envOverrides; | ||
return this; | ||
} | ||
public SingularityPendingTaskBuilder setActionId(String actionId) { | ||
this.actionId = Optional.of(actionId); | ||
return this; | ||
} | ||
|
||
public SingularityPendingTask build() { | ||
return new SingularityPendingTask( | ||
pendingTaskId, cmdLineArgsList, user, runId, skipHealthchecks, message, resources, envOverrides, actionId | ||
); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package com.hubspot.singularity; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import com.google.common.base.Optional; | ||
import com.hubspot.mesos.Resources; | ||
import com.hubspot.singularity.api.SingularityRunNowRequest; | ||
|
||
public class SingularityRunNowRequestBuilder { | ||
private Optional<String> message; | ||
private Optional<String> runId; | ||
private Optional<List<String>> commandLineArgs; | ||
private Optional<Boolean> skipHealthchecks; | ||
private Optional<Resources> resources; | ||
private Map<String, String> envOverrides; | ||
private Optional<Long> runAt; | ||
|
||
public SingularityRunNowRequestBuilder() | ||
{ | ||
this.message = Optional.absent(); | ||
this.runId = Optional.absent(); | ||
this.commandLineArgs = Optional.absent(); | ||
this.skipHealthchecks = Optional.absent(); | ||
this.resources = Optional.absent(); | ||
this.envOverrides = null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. empty map instead of null here? |
||
this.runAt = Optional.absent(); | ||
} | ||
|
||
public SingularityRunNowRequestBuilder setMessage(String message) { | ||
this.message = Optional.of(message); | ||
return this; | ||
} | ||
|
||
public SingularityRunNowRequestBuilder setRunId(String runId) { | ||
this.runId = Optional.of(runId); | ||
return this; | ||
} | ||
|
||
public SingularityRunNowRequestBuilder setCommandLineArgs(List<String> commandLineArgs) { | ||
this.commandLineArgs = Optional.of(commandLineArgs); | ||
return this; | ||
} | ||
|
||
public SingularityRunNowRequestBuilder setSkipHealthchecks(Boolean skipHealthchecks) { | ||
this.skipHealthchecks = Optional.of(skipHealthchecks); | ||
return this; | ||
} | ||
|
||
public SingularityRunNowRequestBuilder setResources(Resources resources) { | ||
this.resources = Optional.of(resources); | ||
return this; | ||
} | ||
|
||
public SingularityRunNowRequestBuilder setEnvOverrides(Map<String, String> environmentVariables) { | ||
this.envOverrides = environmentVariables; | ||
return this; | ||
} | ||
|
||
public SingularityRunNowRequestBuilder setRunAt(Long runAt) { | ||
this.runAt = Optional.of(runAt); | ||
return this; | ||
} | ||
|
||
public SingularityRunNowRequest build() { | ||
return new SingularityRunNowRequest( | ||
message, skipHealthchecks, runId, commandLineArgs, resources, envOverrides, runAt); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same toString comment for this one |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
package com.hubspot.singularity.api; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
@@ -15,34 +17,38 @@ public class SingularityRunNowRequest { | |
private final Optional<List<String>> commandLineArgs; | ||
private final Optional<Boolean> skipHealthchecks; | ||
private final Optional<Resources> resources; | ||
private final Map<String, String> envOverrides; | ||
private final Optional<Long> runAt; | ||
|
||
public SingularityRunNowRequest( | ||
Optional<String> message, | ||
Optional<Boolean> skipHealthchecks, | ||
Optional<String> runId, | ||
Optional<List<String>> commandLineArgs, | ||
Optional<Resources> resources | ||
Optional<Resources> resources, | ||
Map<String, String> envOverrides | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Quick note here, we don't want to modify existing constructor signatures for classes in a |
||
) { | ||
this(message, skipHealthchecks, runId, commandLineArgs, resources, Optional.<Long>absent()); | ||
this(message, skipHealthchecks, runId, commandLineArgs, resources, envOverrides, Optional.<Long>absent()); | ||
} | ||
|
||
@JsonCreator | ||
public SingularityRunNowRequest(@JsonProperty("message") Optional<String> message, | ||
@JsonProperty("skipHealthchecks") Optional<Boolean> skipHealthchecks, | ||
@JsonProperty("runId") Optional<String> runId, | ||
@JsonProperty("commandLineArgs") Optional<List<String>> commandLineArgs, | ||
public SingularityRunNowRequest(@JsonProperty("setMessage") Optional<String> message, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmmm...think that was my improper use of Intellij's refactoring tools. Going to need to be more careful of that in the future. |
||
@JsonProperty("setSkipHealthchecks") Optional<Boolean> skipHealthchecks, | ||
@JsonProperty("setRunId") Optional<String> runId, | ||
@JsonProperty("setCommandLineArgs") Optional<List<String>> commandLineArgs, | ||
@JsonProperty("resources") Optional<Resources> resources, | ||
@JsonProperty("runAt") Optional<Long> runAt) { | ||
@JsonProperty("setEnvOverrides") Map<String, String> envOverrides, | ||
@JsonProperty("setRunAt") Optional<Long> runAt) { | ||
this.message = message; | ||
this.commandLineArgs = commandLineArgs; | ||
this.runId = runId; | ||
this.skipHealthchecks = skipHealthchecks; | ||
this.resources = resources; | ||
this.envOverrides = envOverrides == null ? Collections.emptyMap() : envOverrides; | ||
this.runAt = runAt; | ||
} | ||
|
||
@ApiModelProperty(required=false, value="A message to show to users about why this action was taken") | ||
@ApiModelProperty(required=false, value="A setMessage to show to users about why this action was taken") | ||
public Optional<String> getMessage() { | ||
return message; | ||
} | ||
|
@@ -62,11 +68,16 @@ public Optional<Boolean> getSkipHealthchecks() { | |
return skipHealthchecks; | ||
} | ||
|
||
@ApiModelProperty(required=false, value="Override the resources from the active deploy for this run") | ||
@ApiModelProperty(required=false, value="Override the setResources from the active deploy for this run") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. similar comment here, don't want to rename these to |
||
public Optional<Resources> getResources() { | ||
return resources; | ||
} | ||
|
||
@ApiModelProperty(required=false, value="Override the environment variables for launched tasks") | ||
public Map<String, String> getEnvOverrides() { | ||
return envOverrides; | ||
} | ||
|
||
@ApiModelProperty(required=false, value="Schedule this task to run at a specified time") | ||
public Optional<Long> getRunAt() { | ||
return runAt; | ||
|
@@ -80,6 +91,7 @@ public String toString() { | |
", commandLineArgs=" + commandLineArgs + | ||
", skipHealthchecks=" + skipHealthchecks + | ||
", resources=" + resources + | ||
", envOverrides=" + envOverrides + | ||
", runAt=" + runAt + | ||
'}'; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to add a toString on these. Ends up being helpful for debugging later if we ever have to log it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to know :)