Search in sources :

Example 1 with CheckVMActivityOnStoragePoolCommand

use of com.cloud.agent.api.CheckVMActivityOnStoragePoolCommand 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)

Aggregations

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 HACheckerException (org.apache.cloudstack.ha.provider.HACheckerException)1