com.hubspot.singularity.config.SingularityConfiguration Maven / Gradle / Ivy
package com.hubspot.singularity.config;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import javax.validation.Valid;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Optional;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import com.hubspot.singularity.RequestType;
import com.hubspot.singularity.SlavePlacement;
import io.dropwizard.Configuration;
import io.dropwizard.db.DataSourceFactory;
@JsonIgnoreProperties(ignoreUnknown = true)
public class SingularityConfiguration extends Configuration {
private boolean allowRequestsWithoutOwners = true;
private boolean allowTestResourceCalls = false;
private long askDriverToKillTasksAgainAfterMillis = TimeUnit.MINUTES.toMillis(5);
private long cacheOffersForMillis = TimeUnit.MINUTES.toMillis(1);
private int offerCacheSize = 125;
private boolean cacheOffers = false;
private long cacheForWebForMillis = TimeUnit.SECONDS.toMillis(30);
private int cacheTasksMaxSize = 5000;
private int cacheTasksInitialSize = 100;
private long cacheTasksForMillis = TimeUnit.DAYS.toMillis(1);
private int cacheDeploysMaxSize = 2000;
private int cacheDeploysInitialSize = 100;
private long cacheDeploysForMillis = TimeUnit.DAYS.toMillis(5);
private long cacheStateForMillis = TimeUnit.SECONDS.toMillis(30);
private long checkDeploysEverySeconds = 5;
private long checkAutoSpreadAllSlavesEverySeconds = 30;
private long checkNewTasksEverySeconds = 5;
private long checkExpiringUserActionEveryMillis = TimeUnit.SECONDS.toMillis(45);
private int checkNewTasksScheduledThreads = 3;
private long checkReconcileWhenRunningEveryMillis = TimeUnit.SECONDS.toMillis(30);
private long checkJobsEveryMillis = TimeUnit.MINUTES.toMillis(10);
private long checkSchedulerEverySeconds = 5;
private long checkWebhooksEveryMillis = TimeUnit.SECONDS.toMillis(10);
private long checkUsageEveryMillis = TimeUnit.MINUTES.toMillis(1);
private long checkMesosMasterHeartbeatEverySeconds = 20;
private long maxMissedMesosMasterHeartbeats = 3;
private int maxConcurrentUsageCollections = 15;
private boolean shuffleTasksForOverloadedSlaves = false; // recommended 'true' when oversubscribing cpu for larger clusters
private int maxTasksToShuffleTotal = 6; // Do not allow more than this many shuffle cleanups at once cluster-wide
private int maxTasksToShufflePerHost = 2;
private List doNotShuffleRequests = new ArrayList<>();
private int minutesBeforeNewTaskEligibleForShuffle = 15;
private long cleanUsageEveryMillis = TimeUnit.MINUTES.toMillis(5);
private int numUsageToKeep = 15;
private long cleanupEverySeconds = 5;
private long checkQueuedMailsEveryMillis = TimeUnit.SECONDS.toMillis(15);
private boolean ldapCacheEnabled = true;
private long ldapCacheSize = 100;
private long ldapCacheExpireMillis = TimeUnit.MINUTES.toMillis(1);
private long closeWaitSeconds = 5;
private String commonHostnameSuffixToOmit;
private boolean compressLargeDataObjects = true;
private long considerTaskHealthyAfterRunningForSeconds = 5;
private int cooldownAfterFailures = 3;
private double cooldownAfterPctOfInstancesFail = 1.0;
private long cooldownExpiresAfterMinutes = 15;
private long cooldownMinScheduleSeconds = 120;
@JsonProperty("database")
private DataSourceFactory databaseConfiguration;
@Min(value = 1, message = "Must be positive and non-zero")
private int defaultBounceExpirationMinutes = 60;
@NotNull
private SlavePlacement defaultSlavePlacement = SlavePlacement.GREEDY;
@Min(value = 0, message = "Must be non-negative")
private double placementLeniency = 0.09d;
private boolean defaultValueForKillTasksOfPausedRequests = true;
private int defaultDeployStepWaitTimeMs = 0;
private int defaultDeployMaxTaskRetries = 0;
private long deleteDeploysFromZkWhenNoDatabaseAfterHours = TimeUnit.DAYS.toHours(14);
private Optional maxStaleDeploysPerRequestInZkWhenNoDatabase = Optional.absent();
private long deleteDeadSlavesAfterHours = TimeUnit.DAYS.toHours(7);
private long deleteStaleRequestsFromZkWhenNoDatabaseAfterHours = TimeUnit.DAYS.toHours(14);
private Optional maxRequestsWithHistoryInZkWhenNoDatabase = Optional.absent();
private long deleteTasksFromZkWhenNoDatabaseAfterHours = TimeUnit.DAYS.toHours(7);
private Optional maxStaleTasksPerRequestInZkWhenNoDatabase = Optional.absent();
private long deleteUndeliverableWebhooksAfterHours = TimeUnit.DAYS.toHours(7);
private long deltaAfterWhichTasksAreLateMillis = TimeUnit.SECONDS.toMillis(30);
private long deployHealthyBySeconds = 120;
private int dispatchTaskShellCommandsEverySeconds = 5;
private long debugCuratorCallOverBytes = 25000;
private long debugCuratorCallOverMillis = 250;
@Deprecated
private boolean enableCorsFilter = false;
private CorsConfiguration cors = new CorsConfiguration();
private int healthcheckIntervalSeconds = 5;
private int healthcheckStartThreads = 3;
private int healthcheckTimeoutSeconds = 5;
private Optional startupDelaySeconds = Optional.absent();
private int startupTimeoutSeconds = 45;
private int startupIntervalSeconds = 2;
private Optional healthcheckMaxRetries = Optional.absent();
private Optional healthcheckMaxTotalTimeoutSeconds = Optional.absent();
private long killTaskIfNotHealthyAfterSeconds = 600;
@NotNull
private List healthcheckFailureStatusCodes = Collections.emptyList();
private String hostname;
private long killAfterTasksDoNotRunDefaultSeconds = 600;
private long killNonLongRunningTasksInCleanupAfterSeconds = TimeUnit.HOURS.toSeconds(24);
private int listenerThreadpoolSize = 3;
@JsonProperty("loadBalancerQueryParams")
private Map loadBalancerQueryParams;
private long loadBalancerRequestTimeoutMillis = 2000;
private long loadBalancerRemovalGracePeriodMillis = 0;
private String loadBalancerUri;
private boolean deleteRemovedRequestsFromLoadBalancer = false;
private Optional taskLabelForLoadBalancerUpstreamGroup = Optional.absent();
private int logFetchMaxThreads = 15;
private int maxDeployIdSize = 50;
private int maxHealthcheckResponseBodyBytes = 8192;
private int maxQueuedUpdatesPerWebhook = 50;
private int maxTasksPerOffer = 0;
private int maxTasksPerOfferPerRequest = 0;
private int maxRequestIdSize = 100;
private int maxUserIdSize = 100;
private boolean storeAllMesosTaskInfoForDebugging = false;
@JsonProperty("historyPurging")
@Valid
private HistoryPurgingConfiguration historyPurgingConfiguration = new HistoryPurgingConfiguration();
@JsonProperty("mesos")
@Valid
private MesosConfiguration mesosConfiguration;
@JsonProperty("network")
@Valid
private NetworkConfiguration networkConfiguration = new NetworkConfiguration();
private int newTaskCheckerBaseDelaySeconds = 1;
private long pendingDeployHoldTaskDuringDecommissionMillis = TimeUnit.MINUTES.toMillis(10);
private long persistHistoryEverySeconds = TimeUnit.HOURS.toSeconds(1);
private long reconcileSlavesEveryMinutes = TimeUnit.HOURS.toMinutes(1);
@JsonProperty("s3")
private S3Configuration s3Configuration;
private boolean sandboxDefaultsToTaskId = false;
private long sandboxHttpTimeoutMillis = TimeUnit.SECONDS.toMillis(2);
private long saveStateEverySeconds = 60;
@JsonProperty("sentry")
@Valid
private SentryConfiguration sentryConfiguration;
@JsonProperty("taskMetadata")
@Valid
private SingularityTaskMetadataConfiguration taskMetadataConfiguration = new SingularityTaskMetadataConfiguration();
@JsonProperty("smtp")
@Valid
private SMTPConfiguration smtpConfiguration;
private long startNewReconcileEverySeconds = TimeUnit.MINUTES.toSeconds(10);
@JsonProperty("ui")
@Valid
private UIConfiguration uiConfiguration = new UIConfiguration();
/** If true, the event system waits for all listeners having processed an event. */
private boolean waitForListeners = true;
private long warnIfScheduledJobIsRunningForAtLeastMillis = TimeUnit.DAYS.toMillis(1);
@JsonProperty("taskExecutionTimeLimitMillis")
private Optional taskExecutionTimeLimitMillis = Optional.absent();
private int warnIfScheduledJobIsRunningPastNextRunPct = 200;
private long zookeeperAsyncTimeout = 5000;
private int coreThreadpoolSize = 8;
private long threadpoolShutdownDelayInSeconds = 1;
private long taskPersistAfterStartupBufferMillis = TimeUnit.MINUTES.toMillis(1);
@Valid
@JsonProperty("customExecutor")
@NotNull
private CustomExecutorConfiguration customExecutorConfiguration = new CustomExecutorConfiguration();
private boolean createDeployIds = false;
@Min(4)
@Max(32)
private int deployIdLength = 8;
@JsonProperty("zookeeper")
@Valid
private ZooKeeperConfiguration zooKeeperConfiguration;
@JsonProperty("ldap")
@Valid
private LDAPConfiguration ldapConfiguration;
@JsonProperty("webhookAuth")
@Valid
private WebhookAuthConfiguration webhookAuthConfiguration = new WebhookAuthConfiguration();
private int maxConcurrentWebhooks = 100;
@JsonProperty("auth")
@NotNull
@Valid
private AuthConfiguration authConfiguration = new AuthConfiguration();
@NotNull
private Map> reserveSlavesWithAttributes = Collections.emptyMap();
@JsonProperty("graphite")
@NotNull
@Valid
private GraphiteConfiguration graphiteConfiguration = new GraphiteConfiguration();
private boolean taskHistoryQueryUsesZkFirst = false;
@JsonProperty("disasterDetection")
@NotNull
@Valid
private DisasterDetectionConfiguration disasterDetection = new DisasterDetectionConfiguration();
@Min(0)
@Max(1)
private double defaultTaskPriorityLevel = 0.3;
@NotNull
private Map defaultTaskPriorityLevelForRequestType = ImmutableMap.of(RequestType.WORKER, 0.5, RequestType.SERVICE, 0.7);
@Min(0)
private long checkPriorityKillsEveryMillis = TimeUnit.SECONDS.toMillis(30);
@Min(0)
@Max(5)
private double schedulerPriorityWeightFactor = 1.0;
private boolean rebalanceRacksOnScaleDown = false;
private boolean allowBounceToSameHost = false;
private int maxActiveOnDemandTasksPerRequest = 0;
private int maxDecommissioningSlaves = 2;
private boolean spreadAllSlavesEnabled = false;
private long delayPollersWhenDeltaOverMs = 15000;
private boolean delayOfferProcessingForLargeStatusUpdateDelta = true;
private int maxRunNowTaskLaunchDelayDays = 30;
private boolean allowDeployOfPausedRequests = false;
private Optional cpuHardLimit = Optional.absent();
// If cpuHardLimit is specified and a task is requesting a base cpu of > cpuHardLimit, that task's new hard limit is requested cpus * cpuHardLimitScaleFactor
private double cpuHardLimitScaleFactor = 1.25;
private Map preemptibleTasksOnlyMachineAttributes = Collections.emptyMap();
private long preemptibleTaskMaxExpectedRuntimeMs = 900000; // 15 minutes
private long maxSlaveUsageMetricAgeMs = 30000;
private boolean reCheckMetricsForLargeNewTaskCount = false;
public long getAskDriverToKillTasksAgainAfterMillis() {
return askDriverToKillTasksAgainAfterMillis;
}
public long getCacheStateForMillis() {
return cacheStateForMillis;
}
public long getDispatchTaskShellCommandsEverySeconds() {
return dispatchTaskShellCommandsEverySeconds;
}
public long getCheckDeploysEverySeconds() {
return checkDeploysEverySeconds;
}
public long getCheckAutoSpreadAllSlavesEverySeconds() {
return checkAutoSpreadAllSlavesEverySeconds;
}
public long getCheckNewTasksEverySeconds() {
return checkNewTasksEverySeconds;
}
public int getCheckNewTasksScheduledThreads() {
return checkNewTasksScheduledThreads;
}
public long getCheckReconcileWhenRunningEveryMillis() {
return checkReconcileWhenRunningEveryMillis;
}
public long getCheckJobsEveryMillis() {
return checkJobsEveryMillis;
}
public long getCheckSchedulerEverySeconds() {
return checkSchedulerEverySeconds;
}
public long getCheckWebhooksEveryMillis() {
return checkWebhooksEveryMillis;
}
public long getCleanupEverySeconds() {
return cleanupEverySeconds;
}
public long getCloseWaitSeconds() {
return closeWaitSeconds;
}
public Optional getCommonHostnameSuffixToOmit() {
return Optional.fromNullable(Strings.emptyToNull(commonHostnameSuffixToOmit));
}
public long getConsiderTaskHealthyAfterRunningForSeconds() {
return considerTaskHealthyAfterRunningForSeconds;
}
public int getCooldownAfterFailures() {
return cooldownAfterFailures;
}
public long getDebugCuratorCallOverBytes() {
return debugCuratorCallOverBytes;
}
public void setDebugCuratorCallOverBytes(long debugCuratorCallOverBytes) {
this.debugCuratorCallOverBytes = debugCuratorCallOverBytes;
}
public long getPendingDeployHoldTaskDuringDecommissionMillis() {
return pendingDeployHoldTaskDuringDecommissionMillis;
}
public long getCacheForWebForMillis() {
return cacheForWebForMillis;
}
public void setCacheForWebForMillis(long cacheForWebForMillis) {
this.cacheForWebForMillis = cacheForWebForMillis;
}
public void setPendingDeployHoldTaskDuringDecommissionMillis(long pendingDeployHoldTaskDuringDecommissionMillis) {
this.pendingDeployHoldTaskDuringDecommissionMillis = pendingDeployHoldTaskDuringDecommissionMillis;
}
public long getDebugCuratorCallOverMillis() {
return debugCuratorCallOverMillis;
}
public void setDebugCuratorCallOverMillis(long debugCuratorCallOverMillis) {
this.debugCuratorCallOverMillis = debugCuratorCallOverMillis;
}
public double getCooldownAfterPctOfInstancesFail() {
return cooldownAfterPctOfInstancesFail;
}
public long getCooldownExpiresAfterMinutes() {
return cooldownExpiresAfterMinutes;
}
public long getCooldownMinScheduleSeconds() {
return cooldownMinScheduleSeconds;
}
public int getCacheTasksMaxSize() {
return cacheTasksMaxSize;
}
public void setCacheTasksMaxSize(int cacheTasksMaxSize) {
this.cacheTasksMaxSize = cacheTasksMaxSize;
}
public int getCacheTasksInitialSize() {
return cacheTasksInitialSize;
}
public void setCacheTasksInitialSize(int cacheTasksInitialSize) {
this.cacheTasksInitialSize = cacheTasksInitialSize;
}
public int getCacheDeploysMaxSize() {
return cacheDeploysMaxSize;
}
public void setCacheDeploysMaxSize(int cacheDeploysMaxSize) {
this.cacheDeploysMaxSize = cacheDeploysMaxSize;
}
public int getCacheDeploysInitialSize() {
return cacheDeploysInitialSize;
}
public void setCacheDeploysInitialSize(int cacheDeploysInitialSize) {
this.cacheDeploysInitialSize = cacheDeploysInitialSize;
}
public long getCacheDeploysForMillis() {
return cacheDeploysForMillis;
}
public void setCacheDeploysForMillis(long cacheDeploysForMillis) {
this.cacheDeploysForMillis = cacheDeploysForMillis;
}
public int getCoreThreadpoolSize() {
return coreThreadpoolSize;
}
public CustomExecutorConfiguration getCustomExecutorConfiguration() {
return customExecutorConfiguration;
}
public Optional getDatabaseConfiguration() {
return Optional.fromNullable(databaseConfiguration);
}
public int getDefaultBounceExpirationMinutes() {
return defaultBounceExpirationMinutes;
}
public void setDefaultBounceExpirationMinutes(int defaultBounceExpirationMinutes) {
this.defaultBounceExpirationMinutes = defaultBounceExpirationMinutes;
}
public SlavePlacement getDefaultSlavePlacement() {
return defaultSlavePlacement;
}
public double getPlacementLeniency() {
return placementLeniency;
}
public int getDefaultDeployStepWaitTimeMs() {
return defaultDeployStepWaitTimeMs;
}
public void setDefaultDeployStepWaitTimeMs(int defaultDeployStepWaitTimeMs) {
this.defaultDeployStepWaitTimeMs = defaultDeployStepWaitTimeMs;
}
public int getDefaultDeployMaxTaskRetries() {
return defaultDeployMaxTaskRetries;
}
public boolean isLdapCacheEnabled() {
return ldapCacheEnabled;
}
public void setLdapCacheEnabled(boolean ldapCacheEnabled) {
this.ldapCacheEnabled = ldapCacheEnabled;
}
public long getLdapCacheSize() {
return ldapCacheSize;
}
public void setLdapCacheSize(long ldapCacheSize) {
this.ldapCacheSize = ldapCacheSize;
}
public long getLdapCacheExpireMillis() {
return ldapCacheExpireMillis;
}
public void setLdapCacheExpireMillis(long ldapCacheExpireMillis) {
this.ldapCacheExpireMillis = ldapCacheExpireMillis;
}
public void setDefaultDeployMaxTaskRetries(int defaultDeployMaxTaskRetries) {
this.defaultDeployMaxTaskRetries = defaultDeployMaxTaskRetries;
}
public long getDeleteDeploysFromZkWhenNoDatabaseAfterHours() {
return deleteDeploysFromZkWhenNoDatabaseAfterHours;
}
public long getDeleteStaleRequestsFromZkWhenNoDatabaseAfterHours() {
return deleteStaleRequestsFromZkWhenNoDatabaseAfterHours;
}
public long getDeleteTasksFromZkWhenNoDatabaseAfterHours() {
return deleteTasksFromZkWhenNoDatabaseAfterHours;
}
public long getDeleteUndeliverableWebhooksAfterHours() {
return deleteUndeliverableWebhooksAfterHours;
}
public long getDeltaAfterWhichTasksAreLateMillis() {
return deltaAfterWhichTasksAreLateMillis;
}
public long getDeployHealthyBySeconds() {
return deployHealthyBySeconds;
}
public int getDeployIdLength() {
return deployIdLength;
}
public int getHealthcheckIntervalSeconds() {
return healthcheckIntervalSeconds;
}
public int getHealthcheckStartThreads() {
return healthcheckStartThreads;
}
public int getHealthcheckTimeoutSeconds() {
return healthcheckTimeoutSeconds;
}
public Optional getHealthcheckMaxRetries() {
return healthcheckMaxRetries;
}
public Optional getHealthcheckMaxTotalTimeoutSeconds() {
return healthcheckMaxTotalTimeoutSeconds;
}
public long getKillTaskIfNotHealthyAfterSeconds() {
return killTaskIfNotHealthyAfterSeconds;
}
public Optional getHostname() {
return Optional.fromNullable(Strings.emptyToNull(hostname));
}
public long getKillAfterTasksDoNotRunDefaultSeconds() {
return killAfterTasksDoNotRunDefaultSeconds;
}
public long getKillNonLongRunningTasksInCleanupAfterSeconds() {
return killNonLongRunningTasksInCleanupAfterSeconds;
}
public long getLoadBalancerRemovalGracePeriodMillis() {
return loadBalancerRemovalGracePeriodMillis;
}
public void setLoadBalancerRemovalGracePeriodMillis(long loadBalancerRemovalGracePeriodMillis) {
this.loadBalancerRemovalGracePeriodMillis = loadBalancerRemovalGracePeriodMillis;
}
public long getDeleteDeadSlavesAfterHours() {
return deleteDeadSlavesAfterHours;
}
public void setDeleteDeadSlavesAfterHours(long deleteDeadSlavesAfterHours) {
this.deleteDeadSlavesAfterHours = deleteDeadSlavesAfterHours;
}
public int getListenerThreadpoolSize() {
return listenerThreadpoolSize;
}
public Optional