Search in sources :

Example 66 with OperationTimedoutException

use of com.cloud.exception.OperationTimedoutException in project cosmic by MissionCriticalCloud.

the class SecondaryStorageManagerImpl method startSecStorageVm.

@Override
public SecondaryStorageVmVO startSecStorageVm(final long secStorageVmId) {
    try {
        final SecondaryStorageVmVO secStorageVm = _secStorageVmDao.findById(secStorageVmId);
        _itMgr.advanceStart(secStorageVm.getUuid(), null, null);
        return _secStorageVmDao.findById(secStorageVm.getId());
    } catch (final InsufficientCapacityException | ResourceUnavailableException | OperationTimedoutException e) {
        logger.warn("Exception while trying to start secondary storage vm", e);
        return null;
    }
}
Also used : SecondaryStorageVmVO(com.cloud.vm.SecondaryStorageVmVO) OperationTimedoutException(com.cloud.exception.OperationTimedoutException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException)

Example 67 with OperationTimedoutException

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

the class StorageSystemDataMotionStrategy method performResignature.

private CopyCmdAnswer performResignature(DataObject dataObj, HostVO hostVO, boolean keepGrantedAccess) {
    long storagePoolId = dataObj.getDataStore().getId();
    DataStore dataStore = dataStoreMgr.getDataStore(storagePoolId, DataStoreRole.Primary);
    Map<String, String> details = getDetails(dataObj);
    ResignatureCommand command = new ResignatureCommand(details);
    ResignatureAnswer answer = null;
    try {
        _volumeService.grantAccess(dataObj, hostVO, dataStore);
        answer = (ResignatureAnswer) _agentMgr.send(hostVO.getId(), command);
    } catch (CloudRuntimeException | AgentUnavailableException | OperationTimedoutException ex) {
        keepGrantedAccess = false;
        String msg = "Failed to resign the DataObject with the following ID: " + dataObj.getId();
        LOGGER.warn(msg, ex);
        throw new CloudRuntimeException(msg + ex.getMessage());
    } finally {
        if (keepGrantedAccess == false) {
            _volumeService.revokeAccess(dataObj, hostVO, dataStore);
        }
    }
    if (answer == null || !answer.getResult()) {
        final String errMsg;
        if (answer != null && answer.getDetails() != null && !answer.getDetails().isEmpty()) {
            errMsg = answer.getDetails();
        } else {
            errMsg = "Unable to perform resignature operation in 'StorageSystemDataMotionStrategy.performResignature'";
        }
        throw new CloudRuntimeException(errMsg);
    }
    VolumeObjectTO newVolume = new VolumeObjectTO();
    newVolume.setSize(answer.getSize());
    newVolume.setPath(answer.getPath());
    newVolume.setFormat(answer.getFormat());
    return new CopyCmdAnswer(newVolume);
}
Also used : OperationTimedoutException(com.cloud.exception.OperationTimedoutException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) AgentUnavailableException(com.cloud.exception.AgentUnavailableException) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) ResignatureAnswer(org.apache.cloudstack.storage.command.ResignatureAnswer) VolumeObjectTO(org.apache.cloudstack.storage.to.VolumeObjectTO) ResignatureCommand(org.apache.cloudstack.storage.command.ResignatureCommand) CopyCmdAnswer(org.apache.cloudstack.storage.command.CopyCmdAnswer)

Example 68 with OperationTimedoutException

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

the class VirtualMachineManagerImpl method orchestrateStorageMigration.

private void orchestrateStorageMigration(final String vmUuid, final StoragePool destPool) {
    final VMInstanceVO vm = _vmDao.findByUuid(vmUuid);
    if (destPool == null) {
        throw new CloudRuntimeException("Unable to migrate vm: missing destination storage pool");
    }
    try {
        stateTransitTo(vm, VirtualMachine.Event.StorageMigrationRequested, null);
    } catch (final NoTransitionException e) {
        s_logger.debug("Unable to migrate vm: " + e.toString());
        throw new CloudRuntimeException("Unable to migrate vm: " + e.toString());
    }
    final VirtualMachineProfile profile = new VirtualMachineProfileImpl(vm);
    boolean migrationResult = false;
    try {
        migrationResult = volumeMgr.storageMigration(profile, destPool);
        if (migrationResult) {
            if (destPool.getPodId() != null && !destPool.getPodId().equals(vm.getPodIdToDeployIn())) {
                final DataCenterDeployment plan = new DataCenterDeployment(vm.getDataCenterId(), destPool.getPodId(), null, null, null, null);
                final VirtualMachineProfileImpl vmProfile = new VirtualMachineProfileImpl(vm, null, null, null, null);
                _networkMgr.reallocate(vmProfile, plan);
            }
            //when start the vm next time, don;'t look at last_host_id, only choose the host based on volume/storage pool
            vm.setLastHostId(null);
            vm.setPodIdToDeployIn(destPool.getPodId());
            // unregister the VM from the source host and cleanup the associated VM files.
            if (vm.getHypervisorType().equals(HypervisorType.VMware)) {
                Long srcClusterId = null;
                Long srcHostId = vm.getHostId() != null ? vm.getHostId() : vm.getLastHostId();
                if (srcHostId != null) {
                    HostVO srcHost = _hostDao.findById(srcHostId);
                    srcClusterId = srcHost.getClusterId();
                }
                final Long destClusterId = destPool.getClusterId();
                if (srcClusterId != null && destClusterId != null && !srcClusterId.equals(destClusterId)) {
                    final String srcDcName = _clusterDetailsDao.getVmwareDcName(srcClusterId);
                    final String destDcName = _clusterDetailsDao.getVmwareDcName(destClusterId);
                    if (srcDcName != null && destDcName != null && !srcDcName.equals(destDcName)) {
                        s_logger.debug("Since VM's storage was successfully migrated across VMware Datacenters, unregistering VM: " + vm.getInstanceName() + " from source host: " + srcHostId);
                        final UnregisterVMCommand uvc = new UnregisterVMCommand(vm.getInstanceName());
                        uvc.setCleanupVmFiles(true);
                        try {
                            _agentMgr.send(srcHostId, uvc);
                        } catch (final AgentUnavailableException | OperationTimedoutException e) {
                            throw new CloudRuntimeException("Failed to unregister VM: " + vm.getInstanceName() + " from source host: " + srcHostId + " after successfully migrating VM's storage across VMware Datacenters");
                        }
                    }
                }
            }
        } else {
            s_logger.debug("Storage migration failed");
        }
    } catch (final ConcurrentOperationException e) {
        s_logger.debug("Failed to migration: " + e.toString());
        throw new CloudRuntimeException("Failed to migration: " + e.toString());
    } catch (final InsufficientVirtualNetworkCapacityException e) {
        s_logger.debug("Failed to migration: " + e.toString());
        throw new CloudRuntimeException("Failed to migration: " + e.toString());
    } catch (final InsufficientAddressCapacityException e) {
        s_logger.debug("Failed to migration: " + e.toString());
        throw new CloudRuntimeException("Failed to migration: " + e.toString());
    } catch (final InsufficientCapacityException e) {
        s_logger.debug("Failed to migration: " + e.toString());
        throw new CloudRuntimeException("Failed to migration: " + e.toString());
    } catch (final StorageUnavailableException e) {
        s_logger.debug("Failed to migration: " + e.toString());
        throw new CloudRuntimeException("Failed to migration: " + e.toString());
    } finally {
        try {
            stateTransitTo(vm, VirtualMachine.Event.AgentReportStopped, null);
        } catch (final NoTransitionException e) {
            s_logger.debug("Failed to change vm state: " + e.toString());
            throw new CloudRuntimeException("Failed to change vm state: " + e.toString());
        }
    }
}
Also used : OperationTimedoutException(com.cloud.exception.OperationTimedoutException) DataCenterDeployment(com.cloud.deploy.DataCenterDeployment) InsufficientAddressCapacityException(com.cloud.exception.InsufficientAddressCapacityException) UnregisterVMCommand(com.cloud.agent.api.UnregisterVMCommand) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) HostVO(com.cloud.host.HostVO) StorageUnavailableException(com.cloud.exception.StorageUnavailableException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) AgentUnavailableException(com.cloud.exception.AgentUnavailableException) NoTransitionException(com.cloud.utils.fsm.NoTransitionException) InsufficientVirtualNetworkCapacityException(com.cloud.exception.InsufficientVirtualNetworkCapacityException) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException)

Example 69 with OperationTimedoutException

use of com.cloud.exception.OperationTimedoutException in project cosmic by MissionCriticalCloud.

the class AgentAttache method send.

public Answer[] send(final Request req, final int wait) throws AgentUnavailableException, OperationTimedoutException {
    final SynchronousListener sl = new SynchronousListener(null);
    final long seq = req.getSequence();
    send(req, sl);
    try {
        for (int i = 0; i < 2; i++) {
            Answer[] answers = null;
            try {
                answers = sl.waitFor(wait);
            } catch (final InterruptedException e) {
                s_logger.debug(log(seq, "Interrupted"));
            }
            if (answers != null) {
                if (s_logger.isDebugEnabled()) {
                    new Response(req, answers).logD("Received: ", false);
                }
                return answers;
            }
            // Try it again.
            answers = sl.getAnswers();
            if (answers != null) {
                if (s_logger.isDebugEnabled()) {
                    new Response(req, answers).logD("Received after timeout: ", true);
                }
                _agentMgr.notifyAnswersToMonitors(_id, seq, answers);
                return answers;
            }
            final Long current = _currentSequence;
            if (current != null && seq != current) {
                if (s_logger.isDebugEnabled()) {
                    s_logger.debug(log(seq, "Waited too long."));
                }
                throw new OperationTimedoutException(req.getCommands(), _id, seq, wait, false);
            }
            if (s_logger.isDebugEnabled()) {
                s_logger.debug(log(seq, "Waiting some more time because this is the current command"));
            }
        }
        throw new OperationTimedoutException(req.getCommands(), _id, seq, wait * 2, true);
    } catch (final OperationTimedoutException e) {
        s_logger.warn(log(seq, "Timed out on " + req.toString()));
        cancel(seq);
        final Long current = _currentSequence;
        if (req.executeInSequence() && (current != null && current == seq)) {
            sendNext(seq);
        }
        throw e;
    } catch (final Exception e) {
        s_logger.warn(log(seq, "Exception while waiting for answer"), e);
        cancel(seq);
        final Long current = _currentSequence;
        if (req.executeInSequence() && (current != null && current == seq)) {
            sendNext(seq);
        }
        throw new OperationTimedoutException(req.getCommands(), _id, seq, wait, false);
    } finally {
        unregisterListener(seq);
    }
}
Also used : Response(com.cloud.agent.transport.Response) Answer(com.cloud.agent.api.Answer) OperationTimedoutException(com.cloud.exception.OperationTimedoutException) AgentUnavailableException(com.cloud.exception.AgentUnavailableException) OperationTimedoutException(com.cloud.exception.OperationTimedoutException)

Example 70 with OperationTimedoutException

use of com.cloud.exception.OperationTimedoutException in project cosmic by MissionCriticalCloud.

the class AgentManagerImpl method easySend.

@Override
public Answer easySend(final Long hostId, final Command cmd) {
    try {
        final Host h = _hostDao.findById(hostId);
        if (h == null || h.getRemoved() != null) {
            s_logger.debug("Host with id " + hostId + " doesn't exist");
            return null;
        }
        final Status status = h.getStatus();
        if (!status.equals(Status.Up) && !status.equals(Status.Connecting)) {
            s_logger.debug("Can not send command " + cmd + " due to Host " + hostId + " is not up");
            return null;
        }
        final Answer answer = send(hostId, cmd);
        if (answer == null) {
            s_logger.warn("send returns null answer");
            return null;
        }
        if (s_logger.isDebugEnabled() && answer.getDetails() != null) {
            s_logger.debug("Details from executing " + cmd.getClass() + ": " + answer.getDetails());
        }
        return answer;
    } catch (final AgentUnavailableException e) {
        s_logger.warn(e.getMessage());
        return null;
    } catch (final OperationTimedoutException e) {
        s_logger.warn("Operation timed out: " + e.getMessage());
        return null;
    } catch (final Exception e) {
        s_logger.warn("Exception while sending", e);
        return null;
    }
}
Also used : Status(com.cloud.host.Status) UnsupportedAnswer(com.cloud.agent.api.UnsupportedAnswer) AgentControlAnswer(com.cloud.agent.api.AgentControlAnswer) Answer(com.cloud.agent.api.Answer) PingAnswer(com.cloud.agent.api.PingAnswer) ReadyAnswer(com.cloud.agent.api.ReadyAnswer) StartupAnswer(com.cloud.agent.api.StartupAnswer) OperationTimedoutException(com.cloud.exception.OperationTimedoutException) AgentUnavailableException(com.cloud.exception.AgentUnavailableException) Host(com.cloud.host.Host) ConnectionException(com.cloud.exception.ConnectionException) NoTransitionException(com.cloud.utils.fsm.NoTransitionException) AgentUnavailableException(com.cloud.exception.AgentUnavailableException) TaskExecutionException(com.cloud.utils.exception.TaskExecutionException) OperationTimedoutException(com.cloud.exception.OperationTimedoutException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ConfigurationException(javax.naming.ConfigurationException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ClosedChannelException(java.nio.channels.ClosedChannelException) HypervisorVersionChangedException(com.cloud.utils.exception.HypervisorVersionChangedException) NioConnectionException(com.cloud.utils.exception.NioConnectionException) UnsupportedVersionException(com.cloud.exception.UnsupportedVersionException)

Aggregations

OperationTimedoutException (com.cloud.exception.OperationTimedoutException)131 AgentUnavailableException (com.cloud.exception.AgentUnavailableException)108 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)73 Answer (com.cloud.agent.api.Answer)50 HostVO (com.cloud.host.HostVO)45 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)31 ArrayList (java.util.ArrayList)27 Commands (com.cloud.agent.manager.Commands)26 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)23 AgentControlAnswer (com.cloud.agent.api.AgentControlAnswer)22 NoTransitionException (com.cloud.utils.fsm.NoTransitionException)22 UnPlugNicAnswer (com.cloud.agent.api.UnPlugNicAnswer)21 PlugNicAnswer (com.cloud.agent.api.PlugNicAnswer)19 CheckVirtualMachineAnswer (com.cloud.agent.api.CheckVirtualMachineAnswer)18 RestoreVMSnapshotAnswer (com.cloud.agent.api.RestoreVMSnapshotAnswer)17 StartAnswer (com.cloud.agent.api.StartAnswer)17 GuestOSVO (com.cloud.storage.GuestOSVO)17 VMSnapshotVO (com.cloud.vm.snapshot.VMSnapshotVO)16 Host (com.cloud.host.Host)15 UserVmVO (com.cloud.vm.UserVmVO)15