All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hubspot.singularity.SingularityDeploy Maven / Gradle / Ivy

The newest version!
package com.hubspot.singularity;

import static com.hubspot.singularity.JsonHelpers.copyOfList;
import static com.hubspot.singularity.JsonHelpers.copyOfSet;
import static com.hubspot.singularity.JsonHelpers.copyOfMap;

import java.util.List;
import java.util.Map;
import java.util.Set;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Optional;
import com.hubspot.deploy.ExecutorData;
import com.hubspot.mesos.Resources;
import com.hubspot.mesos.SingularityContainerInfo;
import com.wordnik.swagger.annotations.ApiModelProperty;

public class SingularityDeploy {

  private final String requestId;

  private final String id;

  private final Optional version;
  private final Optional timestamp;
  private final Optional> metadata;

  private final Optional containerInfo;

  private final Optional customExecutorCmd;
  private final Optional customExecutorId;
  private final Optional customExecutorSource;
  private final Optional customExecutorResources;
  private final Optional customExecutorUser;

  private final Optional resources;

  private final Optional command;
  private final Optional> arguments;
  private final Optional> env;
  private final Optional> uris;
  private final Optional executorData;
  private final Optional> labels;
  private final Optional>> taskLabels;
  private final Optional>> taskEnv;

  private final Optional healthcheckUri;
  private final Optional healthcheckIntervalSeconds;
  private final Optional healthcheckTimeoutSeconds;
  private final Optional healthcheckPortIndex;
  private final Optional skipHealthchecksOnDeploy;
  private final Optional healthcheckProtocol;

  private final Optional healthcheckMaxRetries;
  private final Optional healthcheckMaxTotalTimeoutSeconds;

  private final Optional deployHealthTimeoutSeconds;

  private final Optional considerHealthyAfterRunningForSeconds;

  private final Optional serviceBasePath;
  private final Optional> loadBalancerGroups;
  private final Optional loadBalancerPortIndex;
  private final Optional> loadBalancerOptions;
  private final Optional> loadBalancerDomains;
  private final Optional> loadBalancerAdditionalRoutes;
  private final Optional loadBalancerTemplate;

  private final Optional deployInstanceCountPerStep;
  private final Optional deployStepWaitTimeMs;
  private final Optional autoAdvanceDeploySteps;
  private final Optional maxTaskRetries;
  private final Optional shell;

  public static SingularityDeployBuilder newBuilder(String requestId, String id) {
    return new SingularityDeployBuilder(requestId, id);
  }

  @JsonCreator
  public SingularityDeploy(@JsonProperty("requestId") String requestId,
      @JsonProperty("id") String id,
      @JsonProperty("command") Optional command,
      @JsonProperty("arguments") Optional> arguments,
      @JsonProperty("containerInfo") Optional containerInfo,
      @JsonProperty("customExecutorCmd") Optional customExecutorCmd,
      @JsonProperty("customExecutorId") Optional customExecutorId,
      @JsonProperty("customExecutorSource") Optional customExecutorSource,
      @JsonProperty("customExecutorResources") Optional customExecutorResources,
      @JsonProperty("customExecutorUser") Optional customExecutorUser,
      @JsonProperty("resources") Optional resources,
      @JsonProperty("env") Optional> env,
      @JsonProperty("taskEnv") Optional>> taskEnv,
      @JsonProperty("uris") Optional> uris,
      @JsonProperty("metadata") Optional> metadata,
      @JsonProperty("executorData") Optional executorData,
      @JsonProperty("version") Optional version,
      @JsonProperty("timestamp") Optional timestamp,
      @JsonProperty("labels") Optional> labels,
      @JsonProperty("taskLabels") Optional>> taskLabels,
      @JsonProperty("deployHealthTimeoutSeconds") Optional deployHealthTimeoutSeconds,
      @JsonProperty("healthcheckUri") Optional healthcheckUri,
      @JsonProperty("healthcheckIntervalSeconds") Optional healthcheckIntervalSeconds,
      @JsonProperty("healthcheckTimeoutSeconds") Optional healthcheckTimeoutSeconds,
      @JsonProperty("healthcheckPortIndex") Optional healthcheckPortIndex,
      @JsonProperty("healthcheckMaxRetries") Optional healthcheckMaxRetries,
      @JsonProperty("healthcheckMaxTotalTimeoutSeconds") Optional healthcheckMaxTotalTimeoutSeconds,
      @JsonProperty("serviceBasePath") Optional serviceBasePath,
      @JsonProperty("loadBalancerGroups") Optional> loadBalancerGroups,
      @JsonProperty("loadBalancerPortIndex") Optional loadBalancerPortIndex,
      @JsonProperty("considerHealthyAfterRunningForSeconds") Optional considerHealthyAfterRunningForSeconds,
      @JsonProperty("loadBalancerOptions") Optional> loadBalancerOptions,
      @JsonProperty("loadBalancerDomains") Optional> loadBalancerDomains,
      @JsonProperty("loadBalancerAdditionalRoutes") Optional> loadBalancerAdditionalRoutes,
      @JsonProperty("loadBalancerTemplate") Optional loadBalancerTemplate,
      @JsonProperty("skipHealthchecksOnDeploy") Optional skipHealthchecksOnDeploy,
      @JsonProperty("healthCheckProtocol") Optional healthcheckProtocol,
      @JsonProperty("deployInstanceCountPerStep") Optional deployInstanceCountPerStep,
      @JsonProperty("deployStepWaitTimeMs") Optional deployStepWaitTimeMs,
      @JsonProperty("autoAdvanceDeploySteps") Optional autoAdvanceDeploySteps,
      @JsonProperty("maxTaskRetries") Optional maxTaskRetries,
      @JsonProperty("shell") Optional shell) {
    this.requestId = requestId;

    this.command = command;
    this.arguments = arguments;
    this.resources = resources;

    this.containerInfo = containerInfo;

    this.customExecutorCmd = customExecutorCmd;
    this.customExecutorId = customExecutorId;
    this.customExecutorSource = customExecutorSource;
    this.customExecutorResources = customExecutorResources;
    this.customExecutorUser = customExecutorUser;

    this.metadata = metadata;
    this.version = version;
    this.id = id;
    this.timestamp = timestamp;
    this.env = env;
    this.taskEnv = taskEnv;
    this.uris = uris;
    this.executorData = executorData;
    this.labels = labels;
    this.taskLabels = taskLabels;

    this.healthcheckUri = healthcheckUri;
    this.healthcheckIntervalSeconds = healthcheckIntervalSeconds;
    this.healthcheckTimeoutSeconds = healthcheckTimeoutSeconds;
    this.healthcheckPortIndex = healthcheckPortIndex;
    this.skipHealthchecksOnDeploy = skipHealthchecksOnDeploy;
    this.healthcheckProtocol = healthcheckProtocol;

    this.healthcheckMaxRetries = healthcheckMaxRetries;
    this.healthcheckMaxTotalTimeoutSeconds = healthcheckMaxTotalTimeoutSeconds;

    this.considerHealthyAfterRunningForSeconds = considerHealthyAfterRunningForSeconds;

    this.deployHealthTimeoutSeconds = deployHealthTimeoutSeconds;

    this.serviceBasePath = serviceBasePath;
    this.loadBalancerGroups = loadBalancerGroups;
    this.loadBalancerPortIndex = loadBalancerPortIndex;
    this.loadBalancerOptions = loadBalancerOptions;
    this.loadBalancerDomains = loadBalancerDomains;
    this.loadBalancerAdditionalRoutes = loadBalancerAdditionalRoutes;
    this.loadBalancerTemplate = loadBalancerTemplate;

    this.deployInstanceCountPerStep = deployInstanceCountPerStep;
    this.deployStepWaitTimeMs = deployStepWaitTimeMs;
    this.autoAdvanceDeploySteps = autoAdvanceDeploySteps;
    this.maxTaskRetries = maxTaskRetries;
    this.shell = shell;
  }

  public SingularityDeployBuilder toBuilder() {
    return new SingularityDeployBuilder(requestId, id)
    .setCommand(command)
    .setArguments(copyOfList(arguments))
    .setResources(resources)
    .setContainerInfo(containerInfo)
    .setCustomExecutorCmd(customExecutorCmd)
    .setCustomExecutorId(customExecutorId)
    .setCustomExecutorSource(customExecutorSource)
    .setCustomExecutorResources(customExecutorResources)
    .setCustomExecutorUser(customExecutorUser)
    .setHealthcheckUri(healthcheckUri)
    .setHealthcheckIntervalSeconds(healthcheckIntervalSeconds)
    .setHealthcheckTimeoutSeconds(healthcheckTimeoutSeconds)
    .setHealthcheckPortIndex(healthcheckPortIndex)
    .setSkipHealthchecksOnDeploy(skipHealthchecksOnDeploy)
    .setHealthcheckProtocol(healthcheckProtocol)
    .setHealthcheckMaxRetries(healthcheckMaxRetries)
    .setHealthcheckMaxTotalTimeoutSeconds(healthcheckMaxTotalTimeoutSeconds)
    .setConsiderHealthyAfterRunningForSeconds(considerHealthyAfterRunningForSeconds)
    .setDeployHealthTimeoutSeconds(deployHealthTimeoutSeconds)
    .setServiceBasePath(serviceBasePath)
    .setLoadBalancerGroups(copyOfSet(loadBalancerGroups))
    .setLoadBalancerPortIndex(loadBalancerPortIndex)
    .setLoadBalancerOptions(copyOfMap(loadBalancerOptions))
    .setLoadBalancerDomains(copyOfSet(loadBalancerDomains))
    .setLoadBalancerAdditionalRoutes(copyOfList(loadBalancerAdditionalRoutes))
    .setLoadBalancerTemplate(loadBalancerTemplate)
    .setMetadata(copyOfMap(metadata))
    .setVersion(version)
    .setTimestamp(timestamp)
    .setEnv(copyOfMap(env))
    .setTaskEnv(taskEnv)
    .setUris(copyOfList(uris))
    .setExecutorData(executorData)
    .setLabels(labels)
    .setTaskLabels(taskLabels)
    .setDeployInstanceCountPerStep(deployInstanceCountPerStep)
    .setDeployStepWaitTimeMs(deployStepWaitTimeMs)
    .setAutoAdvanceDeploySteps(autoAdvanceDeploySteps)
    .setMaxTaskRetries(maxTaskRetries)
    .setShell(shell);
  }

  @ApiModelProperty(required=false, value="Number of seconds that Singularity waits for this service to become healthy (for it to download artifacts, start running, and optionally pass healthchecks.)")
  public Optional getDeployHealthTimeoutSeconds() {
    return deployHealthTimeoutSeconds;
  }

  @ApiModelProperty(required=true, value="Singularity Request Id which is associated with this deploy.")
  public String getRequestId() {
    return requestId;
  }

  @ApiModelProperty(required=true, value="Singularity deploy id.")
  public String getId() {
    return id;
  }

  @ApiModelProperty(required=false, value="Deploy version")
  public Optional getVersion() {
    return version;
  }

  @ApiModelProperty(required=false, value="Deploy timestamp.")
  public Optional getTimestamp() {
    return timestamp;
  }

  @ApiModelProperty(required=false, value="Map of metadata key/value pairs associated with the deployment.")
  public Optional> getMetadata() {
    return metadata;
  }

  @ApiModelProperty(required=false, value="Container information for deployment into a container.", dataType="SingularityContainerInfo")
  public Optional getContainerInfo() {
    return containerInfo;
  }

  @ApiModelProperty(required=false, value="Custom Mesos executor", dataType= "string")
  public Optional getCustomExecutorCmd() {
    return customExecutorCmd;
  }

  @ApiModelProperty(required=false, value="Custom Mesos executor id.")
  public Optional getCustomExecutorId() {
    return customExecutorId;
  }

  @ApiModelProperty(required=false, value="Custom Mesos executor source.")
  public Optional getCustomExecutorSource() { return customExecutorSource; }

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

  @Deprecated
  @ApiModelProperty(required=false, value="User to run custom executor as")
  public Optional getCustomExecutorUser() {
    return customExecutorUser;
  }

  @ApiModelProperty(required=false, value="Resources required for this deploy.", dataType="com.hubspot.mesos.Resources")
  public Optional getResources() {
    return resources;
  }

  @ApiModelProperty(required=false, value="Command to execute for this deployment.")
  public Optional getCommand() {
    return command;
  }

  @ApiModelProperty(required=false, value="Command arguments.")
  public Optional> getArguments() {
    return arguments;
  }

  @ApiModelProperty(required=false, value="Map of environment variable definitions.")
  public Optional> getEnv() {
    return env;
  }

  @ApiModelProperty(required=false, value="Map of environment variable overrides for specific task instances.")
  public Optional>> getTaskEnv() {
    return taskEnv;
  }

  @ApiModelProperty(required=false, value="List of URIs to download before executing the deploy command.")
  public Optional> getUris() {
    return uris;
  }

  @ApiModelProperty(required=false, value="Executor specific information")
  public Optional getExecutorData() {
    return executorData;
  }

  @ApiModelProperty(required=false, value="Deployment Healthcheck URI, if specified will be called after TASK_RUNNING.")
  public Optional getHealthcheckUri() {
    return healthcheckUri;
  }

  @ApiModelProperty(required=false, value="Healthcheck protocol - HTTP or HTTPS")
  public Optional getHealthcheckProtocol() {
    return healthcheckProtocol;
  }

  @ApiModelProperty(required=false, value="Time to wait after a failed healthcheck to try again in seconds.")
  public Optional getHealthcheckIntervalSeconds() {
    return healthcheckIntervalSeconds;
  }

  @ApiModelProperty(required=false, value="Single healthcheck HTTP timeout in seconds.")
  public Optional getHealthcheckTimeoutSeconds() {
    return healthcheckTimeoutSeconds;
  }

  @ApiModelProperty(required=false, value="Perform healthcheck on this dynamically allocated port (e.g. 0 for first port), defaults to first port")
  public Optional getHealthcheckPortIndex() {
    return healthcheckPortIndex;
  }

  @ApiModelProperty(required=false, value="The base path for the API exposed by the deploy. Used in conjunction with the Load balancer API.")
  public Optional getServiceBasePath() {
    return serviceBasePath;
  }

  @ApiModelProperty(required=false, value="Number of seconds that a service must be healthy to consider the deployment to be successful.")
  public Optional getConsiderHealthyAfterRunningForSeconds() {
    return considerHealthyAfterRunningForSeconds;
  }

  @ApiModelProperty(required=false, value="List of load balancer groups associated with this deployment.")
  public Optional> getLoadBalancerGroups() {
    return loadBalancerGroups;
  }

  @ApiModelProperty(required=false, value="Send this port to the load balancer api (e.g. 0 for first port), defaults to first port")
  public Optional getLoadBalancerPortIndex() {
    return loadBalancerPortIndex;
  }

  @ApiModelProperty(required=false, value="Map (Key/Value) of options for the load balancer.")
  public Optional> getLoadBalancerOptions() {
    return loadBalancerOptions;
  }

  @ApiModelProperty(required=false, value="List of domains to host this service on, for use with the load balancer api")
  public Optional> getLoadBalancerDomains() {
    return loadBalancerDomains;
  }

  @ApiModelProperty(required=false, value="Additional routes besides serviceBasePath used by this service")
  public Optional> getLoadBalancerAdditionalRoutes() {
    return loadBalancerAdditionalRoutes;
  }

  @ApiModelProperty(required=false, value="Name of load balancer template to use if not using the default template")
  public Optional getLoadBalancerTemplate() {
    return loadBalancerTemplate;
  }

  @ApiModelProperty(required=false, value="Labels for all tasks associated with this deploy")
  public Optional> getLabels() {
    return labels;
  }

  @ApiModelProperty(required=false, value="Labels for specific tasks associated with this deploy, indexed by instance number")
  public Optional>> getTaskLabels() {
    return taskLabels;
  }

  @ApiModelProperty(required=false, value="Allows skipping of health checks when deploying.")
  public Optional getSkipHealthchecksOnDeploy() {
    return skipHealthchecksOnDeploy;
  }

  @ApiModelProperty(required=false, value="Maximum number of times to retry an individual healthcheck before failing the deploy.")
  public Optional getHealthcheckMaxRetries() {
    return healthcheckMaxRetries;
  }

  @ApiModelProperty(required=false, value="Maximum amount of time to wait before failing a deploy for healthchecks to pass.")
  public Optional getHealthcheckMaxTotalTimeoutSeconds() {
    return healthcheckMaxTotalTimeoutSeconds;
  }

  @ApiModelProperty(required=false, value="deploy this many instances at a time")
  public Optional getDeployInstanceCountPerStep() {
    return deployInstanceCountPerStep;
  }

  @ApiModelProperty(required=false, value="wait this long between deploy steps")
  public Optional getDeployStepWaitTimeMs() {
    return deployStepWaitTimeMs;
  }

  @ApiModelProperty(required=false, value="automatically advance to the next target instance count after `deployStepWaitTimeMs` seconds")
  public Optional getAutoAdvanceDeploySteps() {
    return autoAdvanceDeploySteps;
  }

  @ApiModelProperty(required=false, value="allowed at most this many failed tasks to be retried before failing the deploy")
  public Optional getMaxTaskRetries() {
    return maxTaskRetries;
  }

  @ApiModelProperty(required=false, value="Override the shell property on the mesos task")
  public Optional getShell() {
    return shell;
  }

  @Override
  public String toString() {
    return "SingularityDeploy{" +
      "requestId='" + requestId + '\'' +
      ", id='" + id + '\'' +
      ", version=" + version +
      ", timestamp=" + timestamp +
      ", metadata=" + metadata +
      ", containerInfo=" + containerInfo +
      ", customExecutorCmd=" + customExecutorCmd +
      ", customExecutorId=" + customExecutorId +
      ", customExecutorSource=" + customExecutorSource +
      ", customExecutorResources=" + customExecutorResources +
      ", customExecutorUser=" + customExecutorUser +
      ", resources=" + resources +
      ", command=" + command +
      ", arguments=" + arguments +
      ", env=" + env +
      ", taskEnv=" + taskEnv +
      ", uris=" + uris +
      ", executorData=" + executorData +
      ", healthcheckUri=" + healthcheckUri +
      ", healthcheckIntervalSeconds=" + healthcheckIntervalSeconds +
      ", healthcheckTimeoutSeconds=" + healthcheckTimeoutSeconds +
      ", healthcheckPortIndex=" + healthcheckPortIndex +
      ", skipHealthchecksOnDeploy=" + skipHealthchecksOnDeploy +
      ", healthcheckProtocol=" + healthcheckProtocol +
      ", healthcheckMaxRetries=" + healthcheckMaxRetries +
      ", healthcheckMaxTotalTimeoutSeconds=" + healthcheckMaxTotalTimeoutSeconds +
      ", deployHealthTimeoutSeconds=" + deployHealthTimeoutSeconds +
      ", considerHealthyAfterRunningForSeconds=" + considerHealthyAfterRunningForSeconds +
      ", serviceBasePath=" + serviceBasePath +
      ", loadBalancerGroups=" + loadBalancerGroups +
      ", loadBalancerPortIndex=" + loadBalancerPortIndex +
      ", loadBalancerOptions=" + loadBalancerOptions +
      ", loadBalancerDomain=" + loadBalancerDomains +
      ", loadBalancerAdditionalRoutes=" + loadBalancerAdditionalRoutes +
      ", loadBalancerTemplate=" + loadBalancerTemplate +
      ", labels=" + labels +
      ", taskLabels=" + taskLabels +
      ", deployInstanceCountPerStep=" + deployInstanceCountPerStep +
      ", deployStepWaitTimeMs=" + deployStepWaitTimeMs +
      ", autoAdvanceDeploySteps=" + autoAdvanceDeploySteps +
      ", maxTaskRetries=" + maxTaskRetries +
      '}';
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy