Search in sources :

Example 1 with HAConfig

use of org.apache.cloudstack.ha.HAConfig in project cloudstack by apache.

the class FenceTask method processResult.

public void processResult(boolean result, Throwable e) {
    final HAConfig haConfig = getHaConfig();
    final HAResourceCounter counter = haManager.getHACounter(haConfig.getResourceId(), haConfig.getResourceType());
    if (result) {
        counter.resetRecoveryCounter();
        haManager.transitionHAState(HAConfig.Event.Fenced, haConfig);
        getHaProvider().fenceSubResources(getResource());
        getHaProvider().enableMaintenance(getResource());
    }
    getHaProvider().sendAlert(getResource(), HAConfig.HAState.Fencing);
}
Also used : HAConfig(org.apache.cloudstack.ha.HAConfig) HAResourceCounter(org.apache.cloudstack.ha.HAResourceCounter)

Example 2 with HAConfig

use of org.apache.cloudstack.ha.HAConfig in project cloudstack by apache.

the class RecoveryTask method processResult.

public void processResult(boolean result, Throwable e) {
    final HAConfig haConfig = getHaConfig();
    final HAResourceCounter counter = haManager.getHACounter(haConfig.getResourceId(), haConfig.getResourceType());
    counter.incrRecoveryCounter();
    counter.resetActivityCounter();
    if (result) {
        haManager.transitionHAState(HAConfig.Event.Recovered, haConfig);
        getHaProvider().fenceSubResources(getResource());
    }
    getHaProvider().sendAlert(getResource(), HAConfig.HAState.Recovering);
}
Also used : HAConfig(org.apache.cloudstack.ha.HAConfig) HAResourceCounter(org.apache.cloudstack.ha.HAResourceCounter)

Example 3 with HAConfig

use of org.apache.cloudstack.ha.HAConfig in project cloudstack by apache.

the class ListHostHAResourcesCmd method setupResponse.

private void setupResponse(final List<HAConfig> hostHAConfigList) {
    final ListResponse<HostHAResponse> response = new ListResponse<>();
    final List<HostHAResponse> hostHAResponses = new ArrayList<>();
    for (final HAConfig config : hostHAConfigList) {
        final Host host = _resourceService.getHost(config.getResourceId());
        if (host == null) {
            continue;
        }
        final HostHAResponse hostHAResponse = new HostHAResponse();
        hostHAResponse.setId(host.getUuid());
        hostHAResponse.setEnabled(config.isEnabled());
        hostHAResponse.setHaState(config.getState());
        hostHAResponse.setProvider(config.getHaProvider());
        hostHAResponses.add(hostHAResponse);
    }
    response.setResponses(hostHAResponses);
    response.setResponseName(getCommandName());
    setResponseObject(response);
}
Also used : ListResponse(org.apache.cloudstack.api.response.ListResponse) HAConfig(org.apache.cloudstack.ha.HAConfig) ArrayList(java.util.ArrayList) HostHAResponse(org.apache.cloudstack.api.response.HostHAResponse) Host(com.cloud.host.Host)

Example 4 with HAConfig

use of org.apache.cloudstack.ha.HAConfig in project cloudstack by apache.

the class HealthCheckTask method processResult.

public void processResult(boolean result, Throwable e) {
    final HAConfig haConfig = getHaConfig();
    final HAResourceCounter counter = haManager.getHACounter(haConfig.getResourceId(), haConfig.getResourceType());
    if (result) {
        haManager.transitionHAState(HAConfig.Event.HealthCheckPassed, haConfig);
        if (haConfig.getState() == HAConfig.HAState.Fenced) {
            haManager.disableHA(haConfig.getResourceId(), haConfig.getResourceType());
        }
        counter.resetSuspectTimestamp();
        counter.resetActivityCounter();
        counter.resetRecoveryCounter();
    } else {
        haManager.transitionHAState(HAConfig.Event.HealthCheckFailed, haConfig);
        counter.markResourceSuspected();
    }
}
Also used : HAConfig(org.apache.cloudstack.ha.HAConfig) HAResourceCounter(org.apache.cloudstack.ha.HAResourceCounter)

Example 5 with HAConfig

use of org.apache.cloudstack.ha.HAConfig in project cloudstack by apache.

the class ActivityCheckTask method processResult.

public synchronized void processResult(boolean result, Throwable t) {
    final HAConfig haConfig = getHaConfig();
    final HAResourceCounter counter = haManager.getHACounter(haConfig.getResourceId(), haConfig.getResourceType());
    if (t != null && t instanceof HACheckerException) {
        haManager.transitionHAState(HAConfig.Event.Ineligible, getHaConfig());
        counter.resetActivityCounter();
        return;
    }
    counter.incrActivityCounter(!result);
    if (counter.getActivityCheckCounter() < maxActivityChecks) {
        haManager.transitionHAState(HAConfig.Event.TooFewActivityCheckSamples, haConfig);
        return;
    }
    if (counter.hasActivityThresholdExceeded(activityCheckFailureRatio)) {
        haManager.transitionHAState(HAConfig.Event.ActivityCheckFailureOverThresholdRatio, haConfig);
    } else {
        if (haManager.transitionHAState(HAConfig.Event.ActivityCheckFailureUnderThresholdRatio, haConfig)) {
            counter.markResourceDegraded();
        }
    }
    counter.resetActivityCounter();
}
Also used : HAConfig(org.apache.cloudstack.ha.HAConfig) HACheckerException(org.apache.cloudstack.ha.provider.HACheckerException) HAResourceCounter(org.apache.cloudstack.ha.HAResourceCounter)

Aggregations

HAConfig (org.apache.cloudstack.ha.HAConfig)5 HAResourceCounter (org.apache.cloudstack.ha.HAResourceCounter)4 Host (com.cloud.host.Host)1 ArrayList (java.util.ArrayList)1 HostHAResponse (org.apache.cloudstack.api.response.HostHAResponse)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1 HACheckerException (org.apache.cloudstack.ha.provider.HACheckerException)1