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

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

The newest version!
package com.hubspot.singularity;

import java.util.Collections;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Objects;
import com.google.common.base.Optional;

public class SingularityDeployResult {

  private final DeployState deployState;
  private final Optional lbUpdate;
  private final Optional message;
  private final List deployFailures;
  private final long timestamp;

  public SingularityDeployResult(DeployState deployState) {
    this(deployState, Optional. absent(), Optional.absent(), Collections. emptyList(), System.currentTimeMillis());
  }

  public SingularityDeployResult(DeployState deployState, String message) {
    this(deployState, Optional.of(message), Optional.absent(), Collections. emptyList(), System.currentTimeMillis());
  }

  public SingularityDeployResult(DeployState deployState, Optional message, Optional lbUpdate) {
    this(deployState, message, lbUpdate, Collections. emptyList(), System.currentTimeMillis());
  }

  public SingularityDeployResult(DeployState deployState, SingularityLoadBalancerUpdate lbUpdate, List deployFailures) {
    this(deployState, Optional.of(String.format("Load balancer had state %s%s", lbUpdate.getLoadBalancerState(),
      lbUpdate.getMessage().isPresent() && lbUpdate.getMessage().get().length() > 0 ? String.format(" (%s)", lbUpdate.getMessage().get()) : "")), Optional.of(lbUpdate), deployFailures, System.currentTimeMillis());
  }

  @JsonCreator
  public SingularityDeployResult(@JsonProperty("deployState") DeployState deployState, @JsonProperty("message") Optional message, @JsonProperty("lbUpdate") Optional lbUpdate,
    @JsonProperty("deployFailures") List deployFailures, @JsonProperty("timestamp") long timestamp) {
    this.deployState = deployState;
    this.lbUpdate = lbUpdate;
    this.message = message;
    this.deployFailures = Objects.firstNonNull(deployFailures, Collections. emptyList());
    this.timestamp = timestamp;
  }

  public Optional getLbUpdate() {
    return lbUpdate;
  }

  public Optional getMessage() {
    return message;
  }

  public DeployState getDeployState() {
    return deployState;
  }

  public List getDeployFailures() {
    return deployFailures;
  }

  public long getTimestamp() {
    return timestamp;
  }

  @Override
  public String toString() {
    return "SingularityDeployResult [deployState=" + deployState + ", lbUpdate=" + lbUpdate + ", message=" + message + ", deployFailures=" + deployFailures + ", timestamp=" + timestamp + "]";
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy