Search in sources :

Example 51 with StorageUnavailableException

use of com.cloud.exception.StorageUnavailableException in project cloudstack by apache.

the class SnapshotManagerImpl method sendToPool.

@Override
public Answer sendToPool(Volume vol, Command cmd) {
    StoragePool pool = (StoragePool) dataStoreMgr.getPrimaryDataStore(vol.getPoolId());
    long[] hostIdsToTryFirst = null;
    Long vmHostId = getHostIdForSnapshotOperation(vol);
    if (vmHostId != null) {
        hostIdsToTryFirst = new long[] { vmHostId };
    }
    List<Long> hostIdsToAvoid = new ArrayList<Long>();
    for (int retry = _totalRetries; retry >= 0; retry--) {
        try {
            Pair<Long, Answer> result = _storageMgr.sendToPool(pool, hostIdsToTryFirst, hostIdsToAvoid, cmd);
            if (result.second().getResult()) {
                return result.second();
            }
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("The result for " + cmd.getClass().getName() + " is " + result.second().getDetails() + " through " + result.first());
            }
            hostIdsToAvoid.add(result.first());
        } catch (StorageUnavailableException e1) {
            s_logger.warn("Storage unavailable ", e1);
            return null;
        }
        try {
            Thread.sleep(_pauseInterval * 1000);
        } catch (InterruptedException e) {
            s_logger.debug("[ignored] interupted while retry cmd.");
        }
        s_logger.debug("Retrying...");
    }
    s_logger.warn("After " + _totalRetries + " retries, the command " + cmd.getClass().getName() + " did not succeed.");
    return null;
}
Also used : Answer(com.cloud.agent.api.Answer) StoragePool(com.cloud.storage.StoragePool) StorageUnavailableException(com.cloud.exception.StorageUnavailableException) ArrayList(java.util.ArrayList) EndPoint(org.apache.cloudstack.engine.subsystem.api.storage.EndPoint)

Example 52 with StorageUnavailableException

use of com.cloud.exception.StorageUnavailableException in project cloudstack by apache.

the class StorageManagerImpl method sendToPool.

@Override
public Pair<Long, Answer[]> sendToPool(StoragePool pool, long[] hostIdsToTryFirst, List<Long> hostIdsToAvoid, Commands cmds) throws StorageUnavailableException {
    List<Long> hostIds = getUpHostsInPool(pool.getId());
    Collections.shuffle(hostIds);
    if (hostIdsToTryFirst != null) {
        for (int i = hostIdsToTryFirst.length - 1; i >= 0; i--) {
            if (hostIds.remove(hostIdsToTryFirst[i])) {
                hostIds.add(0, hostIdsToTryFirst[i]);
            }
        }
    }
    if (hostIdsToAvoid != null) {
        hostIds.removeAll(hostIdsToAvoid);
    }
    if (hostIds == null || hostIds.isEmpty()) {
        throw new StorageUnavailableException("Unable to send command to the pool " + pool.getId() + " due to there is no enabled hosts up in this cluster", pool.getId());
    }
    for (Long hostId : hostIds) {
        try {
            List<Answer> answers = new ArrayList<Answer>();
            Command[] cmdArray = cmds.toCommands();
            for (Command cmd : cmdArray) {
                long targetHostId = _hvGuruMgr.getGuruProcessedCommandTargetHost(hostId, cmd);
                answers.add(_agentMgr.send(targetHostId, cmd));
            }
            return new Pair<Long, Answer[]>(hostId, answers.toArray(new Answer[answers.size()]));
        } catch (AgentUnavailableException e) {
            s_logger.debug("Unable to send storage pool command to " + pool + " via " + hostId, e);
        } catch (OperationTimedoutException e) {
            s_logger.debug("Unable to send storage pool command to " + pool + " via " + hostId, e);
        }
    }
    throw new StorageUnavailableException("Unable to send command to the pool ", pool.getId());
}
Also used : OperationTimedoutException(com.cloud.exception.OperationTimedoutException) ArrayList(java.util.ArrayList) EndPoint(org.apache.cloudstack.engine.subsystem.api.storage.EndPoint) ModifyStoragePoolAnswer(com.cloud.agent.api.ModifyStoragePoolAnswer) GetVolumeStatsAnswer(com.cloud.agent.api.GetVolumeStatsAnswer) Answer(com.cloud.agent.api.Answer) SyncVolumePathAnswer(org.apache.cloudstack.storage.command.SyncVolumePathAnswer) GetStoragePoolCapabilitiesAnswer(com.cloud.agent.api.GetStoragePoolCapabilitiesAnswer) GetStorageStatsAnswer(com.cloud.agent.api.GetStorageStatsAnswer) StorageUnavailableException(com.cloud.exception.StorageUnavailableException) GetStorageStatsCommand(com.cloud.agent.api.GetStorageStatsCommand) GetVolumeStatsCommand(com.cloud.agent.api.GetVolumeStatsCommand) Command(com.cloud.agent.api.Command) CheckDataStoreStoragePolicyComplainceCommand(org.apache.cloudstack.storage.command.CheckDataStoreStoragePolicyComplainceCommand) GetStoragePoolCapabilitiesCommand(com.cloud.agent.api.GetStoragePoolCapabilitiesCommand) SyncVolumePathCommand(org.apache.cloudstack.storage.command.SyncVolumePathCommand) ModifyStoragePoolCommand(com.cloud.agent.api.ModifyStoragePoolCommand) DeleteStoragePoolCommand(com.cloud.agent.api.DeleteStoragePoolCommand) DettachCommand(org.apache.cloudstack.storage.command.DettachCommand) AgentUnavailableException(com.cloud.exception.AgentUnavailableException) Pair(com.cloud.utils.Pair)

Aggregations

StorageUnavailableException (com.cloud.exception.StorageUnavailableException)52 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)26 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)21 DB (com.cloud.utils.db.DB)16 ExecutionException (java.util.concurrent.ExecutionException)15 NoTransitionException (com.cloud.utils.fsm.NoTransitionException)14 ArrayList (java.util.ArrayList)13 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)12 StoragePool (com.cloud.storage.StoragePool)12 Pair (com.cloud.utils.Pair)11 Answer (com.cloud.agent.api.Answer)10 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)10 HypervisorType (com.cloud.hypervisor.Hypervisor.HypervisorType)9 ConfigurationException (javax.naming.ConfigurationException)9 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)8 DiskOffering (com.cloud.offering.DiskOffering)8 VolumeVO (com.cloud.storage.VolumeVO)8 ExecutionException (com.cloud.utils.exception.ExecutionException)8 StoragePoolVO (org.apache.cloudstack.storage.datastore.db.StoragePoolVO)8 AgentUnavailableException (com.cloud.exception.AgentUnavailableException)7