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

com.hubspot.singularity.config.HistoryPurgingConfiguration Maven / Gradle / Ivy

There is a newer version: 1.5.0
Show newest version
package com.hubspot.singularity.config;

import com.google.common.base.Optional;

public class HistoryPurgingConfiguration {

  private int deleteTaskHistoryAfterDays = 365;

  private int deleteTaskHistoryAfterTasksPerRequest = 10000;

  private boolean deleteTaskHistoryBytesInsteadOfEntireRow = true;

  private int checkTaskHistoryEveryHours = 24;

  private boolean enabled = false;

  private Optional absentIfNotOverOne(int value) {
    if (value < 1) {
      return Optional.absent();
    }
    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 boolean isDeleteTaskHistoryBytesInsteadOfEntireRow() {
    return deleteTaskHistoryBytesInsteadOfEntireRow;
  }

  public void setDeleteTaskHistoryBytesInsteadOfEntireRow(boolean deleteTaskHistoryBytesInsteadOfEntireRow) {
    this.deleteTaskHistoryBytesInsteadOfEntireRow = deleteTaskHistoryBytesInsteadOfEntireRow;
  }

  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;
  }


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy