Search in sources :

Example 1 with SingularityAction

use of com.hubspot.singularity.SingularityAction in project Singularity by HubSpot.

the class DisasterManager method addDisabledActionsForDisasters.

public void addDisabledActionsForDisasters(List<SingularityDisasterType> newActiveDisasters) {
    boolean automaticallyClearable = true;
    for (SingularityDisasterType disasterType : newActiveDisasters) {
        if (!disasterType.isAutomaticallyClearable()) {
            automaticallyClearable = false;
            break;
        }
    }
    String message = String.format("Active disasters detected: (%s)%s", newActiveDisasters, automaticallyClearable ? "" : ", action must be re-enabled by an admin user");
    Optional<Long> expiresAt = Optional.absent();
    if (automaticallyClearable) {
        expiresAt = Optional.of(System.currentTimeMillis() + configuration.getDisasterDetection().getDefaultDisabledActionExpiration());
    }
    for (SingularityAction action : configuration.getDisasterDetection().getDisableActionsOnDisaster()) {
        disable(action, Optional.of(message), Optional.<SingularityUser>absent(), automaticallyClearable, expiresAt);
    }
}
Also used : SingularityAction(com.hubspot.singularity.SingularityAction) SingularityDisasterType(com.hubspot.singularity.SingularityDisasterType)

Aggregations

SingularityAction (com.hubspot.singularity.SingularityAction)1 SingularityDisasterType (com.hubspot.singularity.SingularityDisasterType)1