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

io.dropwizard.health.conf.Schedule Maven / Gradle / Ivy

Go to download

Provides a health check implementation that performs ongoing monitoring of an application's dependencies and includes an endpoint that can be called by a load balancer to determine if the application is healthy and thus able to retrieve traffic.

The newest version!
package io.dropwizard.health.conf;

import com.fasterxml.jackson.annotation.JsonProperty;
import io.dropwizard.util.Duration;

import java.util.Objects;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

public class Schedule {

    @JsonProperty
    private Duration initialDelay = null;

    @NotNull
    @JsonProperty
    private Duration checkInterval = Duration.seconds(5);

    @NotNull
    @JsonProperty
    private Duration downtimeInterval = Duration.seconds(30);

    @Min(0)
    @JsonProperty
    private int failureAttempts = 3;

    @Min(0)
    @JsonProperty
    private int successAttempts = 2;

    public Duration getInitialDelay() {
        // default to checkInterval value
        return initialDelay == null ? getCheckInterval() : initialDelay;
    }

    public void setInitialDelay(Duration initialDelay) {
        this.initialDelay = initialDelay;
    }

    public Duration getCheckInterval() {
        return checkInterval;
    }

    public void setCheckInterval(final Duration checkInterval) {
        this.checkInterval = checkInterval;
    }

    public Duration getDowntimeInterval() {
        return downtimeInterval;
    }

    public void setDowntimeInterval(final Duration downtimeInterval) {
        this.downtimeInterval = downtimeInterval;
    }

    public int getFailureAttempts() {
        return failureAttempts;
    }

    public void setFailureAttempts(final int failureAttempts) {
        this.failureAttempts = failureAttempts;
    }

    public int getSuccessAttempts() {
        return successAttempts;
    }

    public void setSuccessAttempts(final int successAttempts) {
        this.successAttempts = successAttempts;
    }

    @Override
    public boolean equals(final Object o) {
        if (this == o) return true;
        if (!(o instanceof Schedule)) return false;
        final Schedule schedule = (Schedule) o;
        return failureAttempts == schedule.failureAttempts &&
                successAttempts == schedule.successAttempts &&
                Objects.equals(initialDelay, schedule.initialDelay) &&
                Objects.equals(checkInterval, schedule.checkInterval) &&
                Objects.equals(downtimeInterval, schedule.downtimeInterval);
    }

    @Override
    public int hashCode() {
        return Objects.hash(initialDelay, checkInterval, downtimeInterval, failureAttempts, successAttempts);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy