Search in sources :

Example 1 with HACheckerException

use of org.apache.cloudstack.ha.provider.HACheckerException in project cloudstack by apache.

the class KVMHostActivityChecker method verifyActivityOfStorageOnHost.

protected boolean verifyActivityOfStorageOnHost(HashMap<StoragePool, List<Volume>> poolVolMap, StoragePool pool, Host agent, DateTime suspectTime, boolean activityStatus) throws HACheckerException, IllegalStateException {
    List<Volume> volume_list = poolVolMap.get(pool);
    final CheckVMActivityOnStoragePoolCommand cmd = new CheckVMActivityOnStoragePoolCommand(agent, pool, volume_list, suspectTime);
    LOG.debug(String.format("Checking VM activity for %s on storage pool [%s].", agent.toString(), pool.getId()));
    try {
        Answer answer = storageManager.sendToPool(pool, getNeighbors(agent), cmd);
        if (answer != null) {
            activityStatus = !answer.getResult();
            LOG.debug(String.format("%s %s activity on storage pool [%s]", agent.toString(), activityStatus ? "has" : "does not have", pool.getId()));
        } else {
            String message = String.format("Did not get a valid response for VM activity check for %s on storage pool [%s].", agent.toString(), pool.getId());
            LOG.debug(message);
            throw new IllegalStateException(message);
        }
    } catch (StorageUnavailableException e) {
        String message = String.format("Storage [%s] is unavailable to do the check, probably the %s is not reachable.", pool.getId(), agent.toString());
        LOG.warn(message, e);
        throw new HACheckerException(message, e);
    }
    return activityStatus;
}
Also used : Answer(com.cloud.agent.api.Answer) StorageUnavailableException(com.cloud.exception.StorageUnavailableException) Volume(com.cloud.storage.Volume) HACheckerException(org.apache.cloudstack.ha.provider.HACheckerException) CheckVMActivityOnStoragePoolCommand(com.cloud.agent.api.CheckVMActivityOnStoragePoolCommand)

Example 2 with HACheckerException

use of org.apache.cloudstack.ha.provider.HACheckerException 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

HACheckerException (org.apache.cloudstack.ha.provider.HACheckerException)2 Answer (com.cloud.agent.api.Answer)1 CheckVMActivityOnStoragePoolCommand (com.cloud.agent.api.CheckVMActivityOnStoragePoolCommand)1 StorageUnavailableException (com.cloud.exception.StorageUnavailableException)1 Volume (com.cloud.storage.Volume)1 HAConfig (org.apache.cloudstack.ha.HAConfig)1 HAResourceCounter (org.apache.cloudstack.ha.HAResourceCounter)1