Search in sources :

Example 16 with ConcurrentOperationException

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

the class VolumeTest method testCopyBaseImage.

@Test
public void testCopyBaseImage() {
    DataStore primaryStore = createPrimaryDataStore();
    primaryStoreId = primaryStore.getId();
    primaryStore = this.dataStoreMgr.getPrimaryDataStore(primaryStoreId);
    VolumeVO volume = createVolume(image.getId(), primaryStore.getId());
    VolumeInfo volInfo = this.volFactory.getVolume(volume.getId());
    AsyncCallFuture<VolumeApiResult> future = this.volumeService.createVolumeFromTemplateAsync(volInfo, this.primaryStoreId, this.templateFactory.getTemplate(this.image.getId(), DataStoreRole.Image));
    try {
        VolumeApiResult result = future.get();
        AssertJUnit.assertTrue(result.isSuccess());
        VolumeInfo newVol = result.getVolume();
        boolean res = this.volumeService.destroyVolume(newVol.getId());
        Assert.assertTrue(res);
        VolumeInfo vol = this.volFactory.getVolume(volume.getId());
        future = this.volumeService.expungeVolumeAsync(vol);
        result = future.get();
        Assert.assertTrue(result.isSuccess());
    } catch (InterruptedException e) {
        Assert.fail(e.toString());
    } catch (ExecutionException e) {
        Assert.fail(e.toString());
    } catch (ConcurrentOperationException e) {
        Assert.fail(e.toString());
    }
}
Also used : VolumeVO(com.cloud.storage.VolumeVO) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) VolumeInfo(org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo) VolumeApiResult(org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult) ExecutionException(java.util.concurrent.ExecutionException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) Test(org.testng.annotations.Test)

Example 17 with ConcurrentOperationException

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

the class VolumeTestVmware method testDeleteDisk.

@Test
public void testDeleteDisk() {
    DataStore primaryStore = createPrimaryDataStore();
    primaryStoreId = primaryStore.getId();
    primaryStore = this.dataStoreMgr.getPrimaryDataStore(primaryStoreId);
    VolumeVO volume = createVolume(null, primaryStore.getId());
    VolumeInfo volInfo = this.volFactory.getVolume(volume.getId());
    AsyncCallFuture<VolumeApiResult> future = this.volumeService.createVolumeAsync(volInfo, primaryStore);
    try {
        VolumeApiResult result = future.get();
        VolumeInfo vol = result.getVolume();
        this.volumeService.destroyVolume(volInfo.getId());
        volInfo = this.volFactory.getVolume(vol.getId());
        this.volumeService.expungeVolumeAsync(volInfo);
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (ExecutionException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (ConcurrentOperationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : VolumeVO(com.cloud.storage.VolumeVO) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) VolumeInfo(org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo) VolumeApiResult(org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult) ExecutionException(java.util.concurrent.ExecutionException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) Test(org.testng.annotations.Test)

Example 18 with ConcurrentOperationException

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

the class HighAvailabilityManagerImpl method scheduleRestart.

@Override
public void scheduleRestart(VMInstanceVO vm, boolean investigate) {
    Long hostId = vm.getHostId();
    if (hostId == null) {
        try {
            s_logger.debug("Found a vm that is scheduled to be restarted but has no host id: " + vm);
            _itMgr.advanceStop(vm.getUuid(), true);
        } catch (ResourceUnavailableException e) {
            assert false : "How do we hit this when force is true?";
            throw new CloudRuntimeException("Caught exception even though it should be handled.", e);
        } catch (OperationTimedoutException e) {
            assert false : "How do we hit this when force is true?";
            throw new CloudRuntimeException("Caught exception even though it should be handled.", e);
        } catch (ConcurrentOperationException e) {
            assert false : "How do we hit this when force is true?";
            throw new CloudRuntimeException("Caught exception even though it should be handled.", e);
        }
    }
    if (vm.getHypervisorType() == HypervisorType.VMware || vm.getHypervisorType() == HypervisorType.Hyperv) {
        s_logger.info("Skip HA for VMware VM or Hyperv VM" + vm.getInstanceName());
        return;
    }
    if (!investigate) {
        if (s_logger.isDebugEnabled()) {
            s_logger.debug("VM does not require investigation so I'm marking it as Stopped: " + vm.toString());
        }
        AlertManager.AlertType alertType = AlertManager.AlertType.ALERT_TYPE_USERVM;
        if (VirtualMachine.Type.DomainRouter.equals(vm.getType())) {
            alertType = AlertManager.AlertType.ALERT_TYPE_DOMAIN_ROUTER;
        } else if (VirtualMachine.Type.ConsoleProxy.equals(vm.getType())) {
            alertType = AlertManager.AlertType.ALERT_TYPE_CONSOLE_PROXY;
        } else if (VirtualMachine.Type.SecondaryStorageVm.equals(vm.getType())) {
            alertType = AlertManager.AlertType.ALERT_TYPE_SSVM;
        }
        if (!(_forceHA || vm.isHaEnabled())) {
            String hostDesc = "id:" + vm.getHostId() + ", availability zone id:" + vm.getDataCenterId() + ", pod id:" + vm.getPodIdToDeployIn();
            _alertMgr.sendAlert(alertType, vm.getDataCenterId(), vm.getPodIdToDeployIn(), "VM (name: " + vm.getHostName() + ", id: " + vm.getId() + ") stopped unexpectedly on host " + hostDesc, "Virtual Machine " + vm.getHostName() + " (id: " + vm.getId() + ") running on host [" + vm.getHostId() + "] stopped unexpectedly.");
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("VM is not HA enabled so we're done.");
            }
        }
        try {
            _itMgr.advanceStop(vm.getUuid(), true);
            vm = _instanceDao.findByUuid(vm.getUuid());
        } catch (ResourceUnavailableException e) {
            assert false : "How do we hit this when force is true?";
            throw new CloudRuntimeException("Caught exception even though it should be handled.", e);
        } catch (OperationTimedoutException e) {
            assert false : "How do we hit this when force is true?";
            throw new CloudRuntimeException("Caught exception even though it should be handled.", e);
        } catch (ConcurrentOperationException e) {
            assert false : "How do we hit this when force is true?";
            throw new CloudRuntimeException("Caught exception even though it should be handled.", e);
        }
    }
    if (vm.getHypervisorType() == HypervisorType.VMware) {
        s_logger.info("Skip HA for VMware VM " + vm.getInstanceName());
        return;
    }
    List<HaWorkVO> items = _haDao.findPreviousHA(vm.getId());
    int timesTried = 0;
    for (HaWorkVO item : items) {
        if (timesTried < item.getTimesTried() && !item.canScheduleNew(_timeBetweenFailures)) {
            timesTried = item.getTimesTried();
            break;
        }
    }
    if (hostId == null) {
        hostId = vm.getLastHostId();
    }
    HaWorkVO work = new HaWorkVO(vm.getId(), vm.getType(), WorkType.HA, investigate ? Step.Investigating : Step.Scheduled, hostId != null ? hostId : 0L, vm.getState(), timesTried, vm.getUpdated());
    _haDao.persist(work);
    if (s_logger.isInfoEnabled()) {
        s_logger.info("Schedule vm for HA:  " + vm);
    }
    wakeupWorkers();
}
Also used : OperationTimedoutException(com.cloud.exception.OperationTimedoutException) AlertManager(com.cloud.alert.AlertManager) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException)

Example 19 with ConcurrentOperationException

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

the class VirtualNetworkApplianceManagerImpl method processConnect.

@Override
public void processConnect(final Host host, final StartupCommand cmd, final boolean forRebalance) throws ConnectionException {
    final List<DomainRouterVO> routers = _routerDao.listIsolatedByHostId(host.getId());
    for (DomainRouterVO router : routers) {
        if (router.isStopPending()) {
            s_logger.info("Stopping router " + router.getInstanceName() + " due to stop pending flag found!");
            final VirtualMachine.State state = router.getState();
            if (state != VirtualMachine.State.Stopped && state != VirtualMachine.State.Destroyed) {
                try {
                    stopRouter(router.getId(), false);
                } catch (final ResourceUnavailableException e) {
                    s_logger.warn("Fail to stop router " + router.getInstanceName(), e);
                    throw new ConnectionException(false, "Fail to stop router " + router.getInstanceName());
                } catch (final ConcurrentOperationException e) {
                    s_logger.warn("Fail to stop router " + router.getInstanceName(), e);
                    throw new ConnectionException(false, "Fail to stop router " + router.getInstanceName());
                }
            }
            router.setStopPending(false);
            router = _routerDao.persist(router);
        }
    }
}
Also used : ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) DomainRouterVO(com.cloud.vm.DomainRouterVO) ConnectionException(com.cloud.exception.ConnectionException) VirtualMachine(com.cloud.vm.VirtualMachine)

Example 20 with ConcurrentOperationException

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

the class VirtualNetworkApplianceManagerImpl method recoverRedundantNetwork.

// Ensure router status is update to date before execute this function. The
// function would try best to recover all routers except MASTER
protected void recoverRedundantNetwork(final DomainRouterVO masterRouter, final DomainRouterVO backupRouter) {
    if (masterRouter.getState() == VirtualMachine.State.Running && backupRouter.getState() == VirtualMachine.State.Running) {
        final HostVO masterHost = _hostDao.findById(masterRouter.getHostId());
        final HostVO backupHost = _hostDao.findById(backupRouter.getHostId());
        if (masterHost.getState() == Status.Up && backupHost.getState() == Status.Up) {
            final String title = "Reboot " + backupRouter.getInstanceName() + " to ensure redundant virtual routers work";
            if (s_logger.isDebugEnabled()) {
                s_logger.debug(title);
            }
            _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_DOMAIN_ROUTER, backupRouter.getDataCenterId(), backupRouter.getPodIdToDeployIn(), title, title);
            try {
                rebootRouter(backupRouter.getId(), true);
            } catch (final ConcurrentOperationException e) {
                s_logger.warn("Fail to reboot " + backupRouter.getInstanceName(), e);
            } catch (final ResourceUnavailableException e) {
                s_logger.warn("Fail to reboot " + backupRouter.getInstanceName(), e);
            } catch (final InsufficientCapacityException e) {
                s_logger.warn("Fail to reboot " + backupRouter.getInstanceName(), e);
            }
        }
    }
}
Also used : ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) HostVO(com.cloud.host.HostVO) ManagementServerHostVO(com.cloud.cluster.ManagementServerHostVO)

Aggregations

ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)153 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)96 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)80 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)71 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)46 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)43 ServerApiException (org.apache.cloudstack.api.ServerApiException)32 Account (com.cloud.user.Account)24 NoTransitionException (com.cloud.utils.fsm.NoTransitionException)23 InsufficientAddressCapacityException (com.cloud.exception.InsufficientAddressCapacityException)21 DB (com.cloud.utils.db.DB)21 AsyncJobExecutionContext (org.apache.cloudstack.framework.jobs.AsyncJobExecutionContext)20 VmWorkJobVO (org.apache.cloudstack.framework.jobs.impl.VmWorkJobVO)20 OperationTimedoutException (com.cloud.exception.OperationTimedoutException)17 ConfigurationException (javax.naming.ConfigurationException)17 ArrayList (java.util.ArrayList)16 ActionEvent (com.cloud.event.ActionEvent)14 NetworkRuleConflictException (com.cloud.exception.NetworkRuleConflictException)14 UserVm (com.cloud.uservm.UserVm)14 ManagementServerException (com.cloud.exception.ManagementServerException)13