com.hubspot.singularity.config.HistoryPurgingConfiguration Maven / Gradle / Ivy
package com.hubspot.singularity.config;
import java.util.Collections;
import java.util.Map;
import java.util.Optional;
public class HistoryPurgingConfiguration {
private int deleteTaskHistoryAfterDays = 0;
private int deleteTaskHistoryAfterTasksPerRequest = 0;
private int deleteTaskHistoryBytesAfterDays = 365;
private int deleteTaskHistoryBytesAfterTasksPerRequest = 10000;
private int checkTaskHistoryEveryHours = 24;
private boolean enabled = false;
private int purgeLimitPerQuery = 25000;
private int purgeStaleRequestIdsAfterDays = 7;
private int purgeRequestHistoryAfterDays = 365;
private int purgeDeployHistoryAfterDays = 365;
private Map requestOverrides = Collections.emptyMap();
private Optional absentIfNotOverOne(int value) {
if (value < 1) {
return Optional.empty();
}
return Optional.of(value);
}
public Optional getDeleteTaskHistoryAfterDays() {
return absentIfNotOverOne(deleteTaskHistoryAfterDays);
}
public void setDeleteTaskHistoryAfterDays(int deleteTaskHistoryAfterDays) {
this.deleteTaskHistoryAfterDays = deleteTaskHistoryAfterDays;
}
public Optional getDeleteTaskHistoryAfterTasksPerRequest() {
return absentIfNotOverOne(deleteTaskHistoryAfterTasksPerRequest);
}
public void setDeleteTaskHistoryAfterTasksPerRequest(
int deleteTaskHistoryAfterTasksPerRequest
) {
this.deleteTaskHistoryAfterTasksPerRequest = deleteTaskHistoryAfterTasksPerRequest;
}
public Optional getDeleteTaskHistoryBytesAfterDays() {
return absentIfNotOverOne(deleteTaskHistoryBytesAfterDays);
}
public void setDeleteTaskHistoryBytesAfterDays(int deleteTaskHistoryBytesAfterDays) {
this.deleteTaskHistoryBytesAfterDays = deleteTaskHistoryBytesAfterDays;
}
public Optional getDeleteTaskHistoryBytesAfterTasksPerRequest() {
return absentIfNotOverOne(deleteTaskHistoryBytesAfterTasksPerRequest);
}
public void setDeleteTaskHistoryBytesAfterTasksPerRequest(
int deleteTaskHistoryBytesAfterTasksPerRequest
) {
this.deleteTaskHistoryBytesAfterTasksPerRequest =
deleteTaskHistoryBytesAfterTasksPerRequest;
}
public int getCheckTaskHistoryEveryHours() {
return checkTaskHistoryEveryHours;
}
public void setCheckTaskHistoryEveryHours(int checkTaskHistoryEveryHours) {
this.checkTaskHistoryEveryHours = checkTaskHistoryEveryHours;
}
public boolean isEnabledAndValid() {
return (
enabled &&
checkTaskHistoryEveryHours > 0 &&
(
getDeleteTaskHistoryAfterDays().isPresent() ||
getDeleteTaskHistoryAfterTasksPerRequest().isPresent()
)
);
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
public Map getRequestOverrides() {
return requestOverrides;
}
public void setRequestOverrides(
Map requestOverrides
) {
this.requestOverrides = requestOverrides;
}
public int getPurgeLimitPerQuery() {
return purgeLimitPerQuery;
}
public void setPurgeLimitPerQuery(int purgeLimitPerQuery) {
this.purgeLimitPerQuery = purgeLimitPerQuery;
}
public int getPurgeStaleRequestIdsAfterDays() {
return purgeStaleRequestIdsAfterDays;
}
public void setPurgeStaleRequestIdsAfterDays(int purgeStaleRequestIdsAfterDays) {
this.purgeStaleRequestIdsAfterDays = purgeStaleRequestIdsAfterDays;
}
public int getPurgeRequestHistoryAfterDays() {
return purgeRequestHistoryAfterDays;
}
public void setPurgeRequestHistoryAfterDays(int purgeRequestHistoryAfterDays) {
this.purgeRequestHistoryAfterDays = purgeRequestHistoryAfterDays;
}
public int getPurgeDeployHistoryAfterDays() {
return purgeDeployHistoryAfterDays;
}
public void setPurgeDeployHistoryAfterDays(int purgeDeployHistoryAfterDays) {
this.purgeDeployHistoryAfterDays = purgeDeployHistoryAfterDays;
}
}