Changed exception code to give the scope of the problem

This commit is contained in:
Alex Huang 2010-12-20 12:19:35 -08:00
parent 724b8d80bd
commit 356526db83
24 changed files with 785 additions and 1086 deletions

View File

@ -30,10 +30,14 @@ public class AgentUnavailableException extends ResourceUnavailableException {
private static final long serialVersionUID = SerialVersionUID.AgentUnavailableException;
public AgentUnavailableException(String msg, long agentId) {
super("Host " + agentId + ": " + msg, Host.class, agentId);
this(msg, agentId, null);
}
public AgentUnavailableException(long agentId) {
this("Unable to reach host.", agentId);
}
public AgentUnavailableException(String msg, long agentId, Throwable cause) {
super("Host " + agentId + ": " + msg, Host.class, agentId, cause);
}
}

View File

@ -18,28 +18,19 @@
package com.cloud.exception;
import com.cloud.utils.SerialVersionUID;
import com.cloud.utils.exception.CloudRuntimeException;
public class ResourceUnavailableException extends CloudRuntimeException {
public class ResourceUnavailableException extends Exception {
private static final long serialVersionUID = SerialVersionUID.ResourceUnavailableException;
Class<?> _scope;
long _id;
public ResourceUnavailableException(String msg) {
super(msg);
}
public ResourceUnavailableException(String msg, Throwable cause) {
super(msg, cause);
}
public ResourceUnavailableException(String msg, Class<?> scope, long resourceId) {
this(msg, scope, resourceId, null);
}
public ResourceUnavailableException(String msg, Class<?> scope, long resourceId, Throwable cause) {
super(msg, cause);
super(new StringBuilder("Resource [").append(scope).append(":").append(resourceId).append("] is unreachable: ").append(msg).toString(), cause);
_scope = scope;
_id = resourceId;
}

View File

@ -30,15 +30,18 @@ import com.cloud.utils.SerialVersionUID;
public class StorageUnavailableException extends ResourceUnavailableException {
private static final long serialVersionUID = SerialVersionUID.StorageUnavailableException;
public StorageUnavailableException(String msg) {
super(msg);
}
public StorageUnavailableException(String msg, long poolId) {
this(msg, poolId, null);
}
public StorageUnavailableException(String msg, long poolId, Throwable cause) {
super(msg, StoragePool.class, poolId, cause);
this(msg, StoragePool.class, poolId, cause);
}
public StorageUnavailableException(String msg, Class<?> scope, long resourceId) {
this(msg, scope, resourceId, null);
}
public StorageUnavailableException(String msg, Class<?> scope, long resourceId, Throwable th) {
super(msg, scope, resourceId, th);
}
}

View File

@ -26,8 +26,8 @@ import com.cloud.api.commands.CreateRemoteAccessVpnCmd;
import com.cloud.api.commands.DeleteRemoteAccessVpnCmd;
import com.cloud.api.commands.DisassociateIPAddrCmd;
import com.cloud.api.commands.ListNetworksCmd;
import com.cloud.api.commands.RestartNetworkCmd;
import com.cloud.api.commands.RemoveVpnUserCmd;
import com.cloud.api.commands.RestartNetworkCmd;
import com.cloud.exception.AccountLimitException;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientAddressCapacityException;
@ -87,7 +87,7 @@ public interface NetworkService {
List<? extends Network> searchForNetworks(ListNetworksCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
boolean deleteNetwork(long networkId) throws InvalidParameterValueException, PermissionDeniedException;
boolean restartNetwork(RestartNetworkCmd cmd) throws ConcurrentOperationException;
boolean restartNetwork(RestartNetworkCmd cmd) throws ConcurrentOperationException, ResourceUnavailableException;
int getActiveNicsInNetwork(long networkId);
}

View File

@ -29,8 +29,9 @@ public interface NetworkElement extends Adapter {
* @param config fully specified network configuration.
* @param offering network offering that originated the network configuration.
* @return true if network configuration is now usable; false if not; null if not handled by this element.
* @throws InsufficientNetworkCapacityException TODO
*/
boolean implement(Network network, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException;
boolean implement(Network network, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
/**
* Prepare for a nic to be added into this network.
@ -44,7 +45,7 @@ public interface NetworkElement extends Adapter {
* @throws ResourceUnavailableException
* @throws InsufficientNetworkCapacityException
*/
boolean prepare(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientNetworkCapacityException;
boolean prepare(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
/**
* A nic is released from this network.

View File

@ -1,195 +0,0 @@
/**
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
*
* This software is licensed under the GNU General Public License v3 or later.
*
* It is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.cloud.async.executor;
import java.util.List;
import org.apache.log4j.Logger;
import com.cloud.agent.api.Answer;
import com.cloud.api.BaseCmd;
import com.cloud.async.AsyncJobManager;
import com.cloud.async.AsyncJobResult;
import com.cloud.async.AsyncJobVO;
import com.cloud.configuration.ResourceCount.ResourceType;
import com.cloud.event.EventTypes;
import com.cloud.event.EventVO;
import com.cloud.serializer.GsonHelper;
import com.cloud.server.ManagementServer;
import com.cloud.storage.Volume.VolumeType;
import com.cloud.storage.VolumeVO;
import com.cloud.utils.db.DB;
import com.cloud.utils.db.Transaction;
import com.cloud.vm.UserVmVO;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachine.Event;
import com.google.gson.Gson;
public class DestroyVMExecutor extends VMOperationExecutor {
public static final Logger s_logger = Logger.getLogger(DestroyVMExecutor.class.getName());
@Override
public boolean execute() {
Gson gson = GsonHelper.getBuilder().create();
AsyncJobManager asyncMgr = getAsyncJobMgr();
AsyncJobVO job = getJob();
VMOperationParam param = gson.fromJson(job.getCmdInfo(), VMOperationParam.class);
ManagementServer managementServer = asyncMgr.getExecutorContext().getManagementServer();
OperationResponse response;
/*
if(getSyncSource() == null) {
asyncMgr.syncAsyncJobExecution(job.getId(), "UserVM", param.getVmId());
return true;
// always true if it does not have sync-source
} else {
managementServer.saveStartedEvent(param.getUserId(), param.getAccountId(), EventTypes.EVENT_VM_DESTROY, "Destroying VM " +param.getVmId(), param.getEventId());
asyncMgr.updateAsyncJobAttachment(job.getId(), "vm_instance", param.getVmId());
response = asyncMgr.getExecutorContext().getVmMgr().executeDestroyVM(this, param);
UserVmVO vm = managementServer.findUserVMInstanceById(param.getVmId());
String params = "id="+vm.getId() + "\nvmName=" + vm.getName() + "\nsoId=" + vm.getServiceOfferingId() + "\ntId=" + vm.getTemplateId() + "\ndcId=" + vm.getDataCenterId();
if (OperationResponse.STATUS_SUCCEEDED == response.getResultCode() ){
managementServer.saveEvent(param.getUserId(), param.getAccountId(), EventVO.LEVEL_INFO, EventTypes.EVENT_VM_DESTROY, "Successfully destroyed VM instance : " + param.getVmId(), params, param.getEventId());
return true;
}else if (OperationResponse.STATUS_FAILED == response.getResultCode()){
managementServer.saveEvent(param.getUserId(), param.getAccountId(), EventVO.LEVEL_ERROR, EventTypes.EVENT_VM_DESTROY, "Failed to stop VM instance : " + response.getResultDescription(), params, param.getEventId());
return true;
}
}
*/
return false;
}
@Override
@DB
public void processAnswer(VMOperationListener listener, long agentId, long seq, Answer answer) {
UserVmVO vm = listener.getVm();
VMOperationParam param = listener.getParam();
AsyncJobManager asyncMgr = getAsyncJobMgr();
ManagementServer managementServer = asyncMgr.getExecutorContext().getManagementServer();
String params = "id="+vm.getId() + "\nvmName=" + vm.getName() + "\nsoId=" + vm.getServiceOfferingId() + "\ntId=" + vm.getTemplateId() + "\ndcId=" + vm.getDataCenterId();
if(s_logger.isDebugEnabled())
s_logger.debug("Execute asynchronize destroy VM command: received stop-VM answer, " + vm.getHostId() + "-" + seq);
boolean stopped = false;
if(answer != null && answer.getResult())
stopped = true;
try {
if(stopped) {
asyncMgr.getExecutorContext().getVmMgr().completeStopCommand(param.getUserId(), vm, Event.OperationSucceeded, param.getChildEventId());
// completeStopCommand will log the stop event, if we log it here we will end up with duplicated stop event
Transaction txn = Transaction.currentTxn();
txn.start();
asyncMgr.getExecutorContext().getAccountMgr().decrementResourceCount(vm.getAccountId(), ResourceType.user_vm);
if (!asyncMgr.getExecutorContext().getItMgr().stateTransitTo(vm, VirtualMachine.Event.DestroyRequested, vm.getHostId())) {
s_logger.debug("Unable to destroy the vm because it is not in the correct state: " + vm.toString());
txn.rollback();
// managementServer.saveEvent(param.getUserId(), param.getAccountId(), EventVO.LEVEL_ERROR, EventTypes.EVENT_VM_DESTROY,
// "Failed to stop VM instance : " + vm.getName(), params, param.getEventId());
asyncMgr.completeAsyncJob(getJob().getId(),
AsyncJobResult.STATUS_FAILED, 0, "Unable to destroy the vm because it is not in the correct state");
return;
}
asyncMgr.getExecutorContext().getVmMgr().cleanNetworkRules(param.getUserId(), vm.getId());
// Mark the VM's root disk as destroyed
List<VolumeVO> volumes = asyncMgr.getExecutorContext().getVolumeDao().findByInstanceAndType(vm.getId(), VolumeType.ROOT);
for (VolumeVO volume : volumes) {
asyncMgr.getExecutorContext().getStorageMgr().destroyVolume(volume);
}
// Mark the VM's data disks as detached
volumes = asyncMgr.getExecutorContext().getVolumeDao().findByInstanceAndType(vm.getId(), VolumeType.DATADISK);
for (VolumeVO volume : volumes) {
asyncMgr.getExecutorContext().getVolumeDao().detachVolume(volume.getId());
}
// managementServer.saveEvent(param.getUserId(), vm.getAccountId(), EventVO.LEVEL_INFO, EventTypes.EVENT_VM_DESTROY,
// "Successfully destroyed VM instance : " + vm.getName(), params, param.getEventId());
txn.commit();
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_SUCCEEDED, 0, "success");
} else {
asyncMgr.getExecutorContext().getItMgr().stateTransitTo(vm, Event.OperationFailed, vm.getHostId());
asyncMgr.completeAsyncJob(getJob().getId(),
AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR, "Agent failed to stop VM: " + vm.getName());
// managementServer.saveEvent(param.getUserId(), vm.getAccountId(), EventVO.LEVEL_ERROR, EventTypes.EVENT_VM_STOP,
// "failed to stop VM instance : " + vm.getName(), params, param.getChildEventId());
// managementServer.saveEvent(param.getUserId(), param.getAccountId(), EventVO.LEVEL_ERROR, EventTypes.EVENT_VM_DESTROY,
// "failed to stop VM instance : " + vm.getName(), params, param.getEventId());
}
} catch(Exception e) {
s_logger.error("Unexpected exception " + e.getMessage(), e);
} finally {
asyncMgr.releaseSyncSource(this);
}
}
@Override
public void processDisconnect(VMOperationListener listener, long agentId) {
if(s_logger.isDebugEnabled())
s_logger.debug("Execute asynchronize destroy VM command: agent " + agentId + " disconnected");
processDisconnectAndTimeout(listener, "agent is disconnected");
}
@Override
public void processTimeout(VMOperationListener listener, long agentId, long seq) {
if(s_logger.isDebugEnabled())
s_logger.debug("Execute asynchronize destroy VM command: timed out, " + agentId + "-" + seq);
processDisconnectAndTimeout(listener, "operation timed out");
}
private void processDisconnectAndTimeout(VMOperationListener listener, String resultMessage) {
UserVmVO vm = listener.getVm();
VMOperationParam param = listener.getParam();
AsyncJobManager asyncMgr = getAsyncJobMgr();
EventVO event = new EventVO();
event.setUserId(param.getUserId());
event.setAccountId(vm.getAccountId());
event.setType(EventTypes.EVENT_VM_DESTROY);
event.setParameters("id="+vm.getId() + "\nvmName=" + vm.getName() + "\nsoId=" + vm.getServiceOfferingId() + "\ntId=" + vm.getTemplateId() + "\ndcId=" + vm.getDataCenterId());
event.setDescription("failed to stop VM instance : " + vm.getName() + " due to " + resultMessage);
event.setLevel(EventVO.LEVEL_ERROR);
boolean jobStatusUpdated = false;
try {
asyncMgr.completeAsyncJob(getJob().getId(),
AsyncJobResult.STATUS_FAILED, 0, resultMessage);
jobStatusUpdated = true;
asyncMgr.getExecutorContext().getEventDao().persist(event);
} catch (Exception e) {
if(!jobStatusUpdated)
asyncMgr.completeAsyncJob(getJob().getId(),
AsyncJobResult.STATUS_FAILED, 0, resultMessage);
s_logger.error("Unexpected exception " + e.getMessage(), e);
} finally {
asyncMgr.releaseSyncSource(this);
}
}
}

View File

@ -703,12 +703,6 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
} catch (InsufficientCapacityException e) {
s_logger.warn("InsufficientCapacity", e);
throw new CloudRuntimeException("Insufficient capacity exception", e);
} catch (StorageUnavailableException e) {
s_logger.warn("Unable to contact storage", e);
throw new CloudRuntimeException("Unable to contact storage", e);
} catch (ResourceUnavailableException e) {
s_logger.warn("Unable to contact resource", e);
throw new CloudRuntimeException("Unable to contact resource", e);
}
Map<String, Object> context = new HashMap<String, Object>();

View File

@ -47,6 +47,7 @@ import com.cloud.exception.AgentUnavailableException;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.OperationTimedoutException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.exception.StorageUnavailableException;
import com.cloud.ha.HaWorkVO.WorkType;
import com.cloud.ha.dao.HighAvailabilityDao;
@ -65,7 +66,6 @@ import com.cloud.utils.component.ComponentLocator;
import com.cloud.utils.component.Inject;
import com.cloud.utils.concurrency.NamedThreadFactory;
import com.cloud.utils.db.GlobalLock;
import com.cloud.utils.exception.ExecutionException;
import com.cloud.vm.State;
import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.VirtualMachine;
@ -457,7 +457,7 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager {
s_logger.warn("Unable to restart " + vm.toString() + " due to " + e.getMessage());
_alertMgr.sendAlert(alertType, vm.getDataCenterId(), vm.getPodId(), "Unable to restart " + vm.getName() + " which was running on host " + hostDesc, "Insufficient capacity to restart VM, name: " + vm.getName() + ", id: " + vmId + " which was running on host " + hostDesc);
return null;
} catch (final StorageUnavailableException e) {
} catch (final ResourceUnavailableException e) {
s_logger.warn("Unable to restart " + vm.toString() + " due to " + e.getMessage());
_alertMgr.sendAlert(alertType, vm.getDataCenterId(), vm.getPodId(), "Unable to restart " + vm.getName() + " which was running on host " + hostDesc, "The Storage is unavailable for trying to restart VM, name: " + vm.getName() + ", id: " + vmId + " which was running on host " + hostDesc);
return null;
@ -465,10 +465,6 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager {
s_logger.warn("Unable to restart " + vm.toString() + " due to " + e.getMessage());
_alertMgr.sendAlert(alertType, vm.getDataCenterId(), vm.getPodId(), "Unable to restart " + vm.getName() + " which was running on host " + hostDesc, "The Storage is unavailable for trying to restart VM, name: " + vm.getName() + ", id: " + vmId + " which was running on host " + hostDesc);
return null;
} catch (ExecutionException e) {
s_logger.warn("Unable to restart " + vm.toString() + " due to " + e.getMessage());
_alertMgr.sendAlert(alertType, vm.getDataCenterId(), vm.getPodId(), "Unable to restart " + vm.getName() + " which was running on host " + hostDesc, "The Storage is unavailable for trying to restart VM, name: " + vm.getName() + ", id: " + vmId + " which was running on host " + hostDesc);
return null;
}
}

View File

@ -25,17 +25,14 @@ import com.cloud.deploy.DeploymentPlan;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InsufficientNetworkCapacityException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.addr.PublicIp;
import com.cloud.network.rules.FirewallRule;
import com.cloud.network.rules.FirewallRuleVO;
import com.cloud.offerings.NetworkOfferingVO;
import com.cloud.service.ServiceOfferingVO;
import com.cloud.user.Account;
import com.cloud.user.AccountVO;
import com.cloud.utils.Pair;
import com.cloud.utils.net.Ip;
import com.cloud.vm.DomainRouterVO;
import com.cloud.vm.Nic;
import com.cloud.vm.NicProfile;
@ -110,7 +107,7 @@ public interface NetworkManager extends NetworkService {
void allocate(VirtualMachineProfile<? extends VMInstanceVO> vm, List<Pair<NetworkVO, NicProfile>> networks) throws InsufficientCapacityException, ConcurrentOperationException;
void prepare(VirtualMachineProfile<? extends VMInstanceVO> profile, DeployDestination dest, ReservationContext context) throws InsufficientNetworkCapacityException, ConcurrentOperationException, ResourceUnavailableException;
void prepare(VirtualMachineProfile<? extends VMInstanceVO> profile, DeployDestination dest, ReservationContext context) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException;
void release(VirtualMachineProfile<? extends VMInstanceVO> vmProfile);
List<? extends Nic> getNics (VirtualMachine vm);

View File

@ -80,7 +80,6 @@ import com.cloud.exception.AgentUnavailableException;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InsufficientNetworkCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.OperationTimedoutException;
import com.cloud.exception.PermissionDeniedException;
@ -1015,7 +1014,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
@DB
protected Pair<NetworkGuru, NetworkVO> implementNetwork(long networkId, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientAddressCapacityException {
protected Pair<NetworkGuru, NetworkVO> implementNetwork(long networkId, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
Transaction.currentTxn();
Pair<NetworkGuru, NetworkVO> implemented = new Pair<NetworkGuru, NetworkVO>(null, null);
@ -1045,20 +1044,19 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
network.setDns1(result.getDns1());
network.setDns2(result.getDns2());
network.setMode(result.getMode());
network.setState(Network.State.Implemented);
network.setReservationId(context.getReservationId());
network.setState(Network.State.Implementing);
_networksDao.update(networkId, network);
for (NetworkElement element : _networkElements) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Asking " + element.getName() + " to implmenet " + network);
}
try {
element.implement(network, offering, dest, context);
} catch (InsufficientCapacityException e) {
throw new ResourceUnavailableException("Unable to start domain router for this VM", e);
}
element.implement(network, offering, dest, context);
}
network.setState(Network.State.Implemented);
_networksDao.update(network.getId(), network);
implemented.set(guru, network);
return implemented;
} finally {
@ -1070,7 +1068,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
@Override
public void prepare(VirtualMachineProfile<? extends VMInstanceVO> vmProfile, DeployDestination dest, ReservationContext context) throws InsufficientNetworkCapacityException, ConcurrentOperationException, ResourceUnavailableException {
public void prepare(VirtualMachineProfile<? extends VMInstanceVO> vmProfile, DeployDestination dest, ReservationContext context) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException {
List<NicVO> nics = _nicDao.listBy(vmProfile.getId());
for (NicVO nic : nics) {
Pair<NetworkGuru, NetworkVO> implemented = implementNetwork(nic.getNetworkId(), dest, context);
@ -2054,7 +2052,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
@Override
public boolean restartNetwork(RestartNetworkCmd cmd) throws ConcurrentOperationException{
public boolean restartNetwork(RestartNetworkCmd cmd) throws ConcurrentOperationException, ResourceUnavailableException {
//This method reapplies Ip addresses, LoadBalancer and PortForwarding rules
String accountName = cmd.getAccountName();
long domainId = cmd.getDomainId();

View File

@ -27,7 +27,6 @@ import com.cloud.dc.DataCenter;
import com.cloud.deploy.DeployDestination;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InsufficientNetworkCapacityException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.Network;
import com.cloud.network.NetworkManager;
@ -72,21 +71,16 @@ public class DhcpElement extends AdapterBase implements NetworkElement {
}
@Override
public boolean implement(Network guestConfig, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException {
if (canHandle(offering.getGuestIpType(), dest)) {
DomainRouterVO router = _routerMgr.deployDhcp(guestConfig, dest, context.getAccount());
if (router == null) {
throw new ResourceUnavailableException("Unable to deploy the router for " + guestConfig);
}
return true;
} else {
public boolean implement(Network guestConfig, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws ResourceUnavailableException, ConcurrentOperationException, InsufficientCapacityException {
if (!canHandle(offering.getGuestIpType(), dest)) {
return false;
}
_routerMgr.deployDhcp(guestConfig, dest, context.getAccount());
return true;
}
@Override
public boolean prepare(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientNetworkCapacityException, ResourceUnavailableException {
public boolean prepare(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
if (canHandle(config.getGuestType(), dest)) {
if (vm.getType() != VirtualMachine.Type.User) {

View File

@ -29,7 +29,6 @@ import com.cloud.dc.dao.DataCenterDao;
import com.cloud.deploy.DeployDestination;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InsufficientNetworkCapacityException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.LoadBalancerVO;
import com.cloud.network.Network;
@ -50,6 +49,7 @@ import com.cloud.offerings.dao.NetworkOfferingDao;
import com.cloud.uservm.UserVm;
import com.cloud.utils.component.AdapterBase;
import com.cloud.utils.component.Inject;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.vm.DomainRouterVO;
import com.cloud.vm.NicProfile;
import com.cloud.vm.ReservationContext;
@ -83,21 +83,17 @@ public class DomainRouterElement extends AdapterBase implements NetworkElement {
}
@Override
public boolean implement(Network guestConfig, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException {
if (canHandle(offering.getGuestIpType(), dest.getDataCenter())) {
DomainRouterVO router = _routerMgr.deployVirtualRouter(guestConfig, dest, context.getAccount());
if (router == null) {
throw new ResourceUnavailableException("Unable to deploy the router for " + guestConfig);
}
return true;
} else {
public boolean implement(Network guestConfig, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws ResourceUnavailableException, ConcurrentOperationException, InsufficientCapacityException {
if (!canHandle(offering.getGuestIpType(), dest.getDataCenter())) {
return false;
}
_routerMgr.deployVirtualRouter(guestConfig, dest, context.getAccount());
return true;
}
@Override
public boolean prepare(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientNetworkCapacityException, ResourceUnavailableException {
public boolean prepare(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
if (canHandle(config.getGuestType(), dest.getDataCenter())) {
if (vm.getType() != VirtualMachine.Type.User) {
return false;
@ -136,7 +132,7 @@ public class DomainRouterElement extends AdapterBase implements NetworkElement {
DomainRouterVO router = _routerDao.findByNetworkConfiguration(networkId);
if (router == null) {
s_logger.warn("Unable to apply firewall rules, virtual router doesn't exist in the network " + config.getId());
throw new ResourceUnavailableException("Unable to apply firewall rules");
throw new CloudRuntimeException("Unable to apply firewall rules");
}
if (router.getState() == State.Running || router.getState() == State.Starting) {
@ -163,7 +159,7 @@ public class DomainRouterElement extends AdapterBase implements NetworkElement {
return true;
} else {
s_logger.warn("Unable to apply firewall rules, virtual router is not in the right state " + router.getState());
throw new ResourceUnavailableException("Unable to apply firewall rules, domR is not in right state " + router.getState());
throw new CloudRuntimeException("Unable to apply firewall rules, domR is not in right state " + router.getState());
}
}
return false;

View File

@ -22,9 +22,9 @@ import java.util.Map;
import com.cloud.api.commands.UpgradeRouterCmd;
import com.cloud.deploy.DeployDestination;
import com.cloud.exception.AgentUnavailableException;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InsufficientNetworkCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.exception.ResourceUnavailableException;
@ -33,7 +33,6 @@ import com.cloud.network.PublicIpAddress;
import com.cloud.network.RemoteAccessVpnVO;
import com.cloud.network.VpnUserVO;
import com.cloud.network.rules.FirewallRule;
import com.cloud.service.ServiceOfferingVO;
import com.cloud.user.Account;
import com.cloud.uservm.UserVm;
import com.cloud.utils.component.Manager;
@ -92,9 +91,9 @@ public interface DomainRouterManager extends Manager {
DomainRouterVO getRouter(long accountId, long zoneId);
DomainRouterVO getRouter(String publicIpAddress);
DomainRouterVO deployVirtualRouter(Network guestConfig, DeployDestination dest, Account owner) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException;
VirtualRouter deployVirtualRouter(Network guestNetwork, DeployDestination dest, Account owner) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException;
DomainRouterVO deployDhcp(Network guestConfig, DeployDestination dest, Account owner) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException;
VirtualRouter deployDhcp(Network guestNetwork, DeployDestination dest, Account owner) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException;
RemoteAccessVpnVO startRemoteAccessVpn(RemoteAccessVpnVO vpnVO) throws ResourceUnavailableException;
@ -102,11 +101,11 @@ public interface DomainRouterManager extends Manager {
boolean deleteRemoteAccessVpn(RemoteAccessVpnVO vpnVO);
DomainRouterVO addVirtualMachineIntoNetwork(Network config, NicProfile nic, VirtualMachineProfile<UserVm> vm, DeployDestination dest, ReservationContext context, Boolean startDhcp) throws ConcurrentOperationException, InsufficientNetworkCapacityException, ResourceUnavailableException;
VirtualRouter addVirtualMachineIntoNetwork(Network config, NicProfile nic, VirtualMachineProfile<UserVm> vm, DeployDestination dest, ReservationContext context, Boolean startDhcp) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException;
boolean associateIP (Network network, List<? extends PublicIpAddress> ipAddress);
boolean associateIP (Network network, List<? extends PublicIpAddress> ipAddress) throws ResourceUnavailableException;
boolean applyLBRules(Network network, List<? extends FirewallRule> rules);
boolean applyPortForwardingRules(Network network, List<? extends FirewallRule> rules);
boolean applyLBRules(Network network, List<? extends FirewallRule> rules) throws ResourceUnavailableException;
boolean applyPortForwardingRules(Network network, List<? extends FirewallRule> rules) throws AgentUnavailableException;
}

View File

@ -168,11 +168,11 @@ import com.cloud.event.EventVO;
import com.cloud.event.dao.EventDao;
import com.cloud.exception.AgentUnavailableException;
import com.cloud.exception.CloudAuthenticationException;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.ManagementServerException;
import com.cloud.exception.OperationTimedoutException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.host.Host;
import com.cloud.host.HostVO;
import com.cloud.host.Status;
@ -255,6 +255,7 @@ import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;
import com.cloud.utils.db.Transaction;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.exception.ExecutionException;
import com.cloud.utils.net.MacAddress;
import com.cloud.utils.net.NetUtils;
import com.cloud.vm.ConsoleProxyVO;
@ -607,8 +608,9 @@ public class ManagementServerImpl implements ManagementServer {
DomainVO domain = _domainDao.findById(domainId);
String domainName = null;
if(domain != null)
domainName = domain.getName();
if(domain != null) {
domainName = domain.getName();
}
if (!userAccount.getState().equals("enabled") || !userAccount.getAccountState().equals("enabled")) {
if (s_logger.isInfoEnabled()) {
@ -4829,7 +4831,7 @@ public class ManagementServerImpl implements ManagementServer {
if(cert == null){
String msg = "Unable to obtain lock on the cert from uploadCertificate()";
s_logger.error(msg);
throw new ResourceUnavailableException(msg);
throw new ConcurrentOperationException(msg);
}else{
if(cert.getUpdated().equalsIgnoreCase("Y")){
if(s_logger.isDebugEnabled()) {
@ -4866,14 +4868,14 @@ public class ManagementServerImpl implements ManagementServer {
if(cpList.size() == 0){
String msg = "Unable to find any console proxies in the system for certificate update";
s_logger.warn(msg);
throw new ResourceUnavailableException(msg);
throw new ExecutionException(msg);
}
//get a list of all hosts in host table for type cp
List<HostVO> cpHosts = _hostDao.listByType(com.cloud.host.Host.Type.ConsoleProxy);
if(cpHosts.size() == 0){
String msg = "Unable to find any console proxy hosts in the system for certificate update";
s_logger.warn(msg);
throw new ResourceUnavailableException(msg);
throw new ExecutionException(msg);
}
//create a hashmap for fast lookup
Map<String,Long> hostNameToHostIdMap = new HashMap<String, Long>();
@ -4921,7 +4923,7 @@ public class ManagementServerImpl implements ManagementServer {
}
}catch (Exception e) {
s_logger.warn("Failed to successfully update the cert across console proxies on management server:"+this.getId());
if(e instanceof ResourceUnavailableException) {
if(e instanceof ExecutionException) {
throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, e.getMessage());
} else if(e instanceof ManagementServerException) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, e.getMessage());

View File

@ -103,7 +103,6 @@ import com.cloud.exception.OperationTimedoutException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceInUseException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.exception.StorageUnavailableException;
import com.cloud.host.Host;
import com.cloud.host.HostVO;
@ -236,14 +235,14 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
private final boolean _shouldBeSnapshotCapable = true;
@Override
public boolean share(VMInstanceVO vm, List<VolumeVO> vols, HostVO host, boolean cancelPreviousShare) {
public boolean share(VMInstanceVO vm, List<VolumeVO> vols, HostVO host, boolean cancelPreviousShare) throws StorageUnavailableException {
//if pool is in maintenance and it is the ONLY pool available; reject
List<VolumeVO> rootVolForGivenVm = _volsDao.findByInstanceAndType(vm.getId(), VolumeType.ROOT);
if(rootVolForGivenVm != null && rootVolForGivenVm.size() > 0){
boolean isPoolAvailable = isPoolAvailable(rootVolForGivenVm.get(0).getPoolId());
if(!isPoolAvailable){
return false;
throw new StorageUnavailableException("Can not share " + vm, rootVolForGivenVm.get(0).getPoolId());
}
}
@ -2241,7 +2240,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
if(primaryStorage == null){
String msg = "Unable to obtain lock on the storage pool in preparePrimaryStorageForMaintenance()";
s_logger.error(msg);
throw new ResourceUnavailableException(msg);
throw new ExecutionException(msg);
}
if (!primaryStorage.getStatus().equals(Status.Up) && !primaryStorage.getStatus().equals(Status.ErrorInMaintenance)) {
@ -2395,7 +2394,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
return _storagePoolDao.findById(primaryStorageId);
} catch (Exception e) {
if(e instanceof ResourceUnavailableException){
if(e instanceof ExecutionException){
s_logger.error("Exception in enabling primary storage maintenance:",e);
throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, e.getMessage());
}
@ -2438,7 +2437,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
if(primaryStorage == null){
String msg = "Unable to obtain lock on the storage pool in cancelPrimaryStorageForMaintenance()";
s_logger.error(msg);
throw new ResourceUnavailableException(msg);
throw new ExecutionException(msg);
}
if (primaryStorage.getStatus().equals(Status.Up)) {
@ -2472,7 +2471,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
{
String msg = "There was an error starting the console proxy id: "+vmInstance.getId()+" on storage pool, cannot complete primary storage maintenance";
s_logger.warn(msg);
throw new ResourceUnavailableException(msg);
throw new ExecutionException(msg);
}
}
@ -2487,7 +2486,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
{
String msg = "There was an error starting the ssvm id: "+vmInstance.getId()+" on storage pool, cannot complete primary storage maintenance";
s_logger.warn(msg);
throw new ResourceUnavailableException(msg);
throw new ExecutionException(msg);
}
}
@ -2503,26 +2502,26 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
{
String msg = "There was an error starting the user vm id: "+vmInstance.getId()+" on storage pool, cannot complete primary storage maintenance";
s_logger.warn(msg);
throw new ResourceUnavailableException(msg);
throw new ExecutionException(msg);
}
} catch (StorageUnavailableException e) {
String msg = "There was an error starting the user vm id: "+vmInstance.getId()+" on storage pool, cannot complete primary storage maintenance";
s_logger.warn(msg,e);
throw new ResourceUnavailableException(msg);
throw new ExecutionException(msg);
} catch (InsufficientCapacityException e) {
String msg = "There was an error starting the user vm id: "+vmInstance.getId()+" on storage pool, cannot complete primary storage maintenance";
s_logger.warn(msg,e);
throw new ResourceUnavailableException(msg);
throw new ExecutionException(msg);
} catch (ConcurrentOperationException e) {
String msg = "There was an error starting the user vm id: "+vmInstance.getId()+" on storage pool, cannot complete primary storage maintenance";
s_logger.warn(msg,e);
primaryStorage.setStatus(Status.ErrorInMaintenance);
_storagePoolDao.persist(primaryStorage);
throw new ResourceUnavailableException(msg);
throw new ExecutionException(msg);
} catch (ExecutionException e) {
String msg = "There was an error starting the user vm id: "+vmInstance.getId()+" on storage pool, cannot complete primary storage maintenance";
s_logger.warn(msg,e);
throw new ResourceUnavailableException(msg);
throw new ExecutionException(msg);
}
}
}
@ -2535,11 +2534,11 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
} catch (InvalidParameterValueException e) {
String msg = "Error changing consoleproxy.restart back to false at end of cancel maintenance:";
s_logger.warn(msg,e);
throw new ResourceUnavailableException(msg);
throw new ExecutionException(msg);
} catch (CloudRuntimeException e) {
String msg = "Error changing consoleproxy.restart back to false at end of cancel maintenance:";
s_logger.warn(msg,e);
throw new ResourceUnavailableException(msg);
throw new ExecutionException(msg);
}
//Change the storage state back to up
@ -2548,19 +2547,15 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
return primaryStorage;
} catch (Exception e) {
if(e instanceof ResourceUnavailableException){
primaryStorage.setStatus(Status.ErrorInMaintenance);
_storagePoolDao.persist(primaryStorage);
primaryStorage.setStatus(Status.ErrorInMaintenance);
_storagePoolDao.persist(primaryStorage);
if(e instanceof ExecutionException){
throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, e.getMessage());
}
else if(e instanceof InvalidParameterValueException){
primaryStorage.setStatus(Status.ErrorInMaintenance);
_storagePoolDao.persist(primaryStorage);
throw new ServerApiException(BaseCmd.PARAM_ERROR, e.getMessage());
}
else{//all other exceptions
primaryStorage.setStatus(Status.ErrorInMaintenance);
_storagePoolDao.persist(primaryStorage);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, e.getMessage());
}
}finally{

View File

@ -451,9 +451,6 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
} catch (InsufficientCapacityException e) {
s_logger.warn("InsufficientCapacity", e);
throw new CloudRuntimeException("Insufficient capacity exception", e);
} catch (ResourceUnavailableException e) {
s_logger.warn("Unable to contact resource", e);
throw new CloudRuntimeException("Unable to contact resource", e);
}
Map<String, Object> context = new HashMap<String, Object>();

View File

@ -34,7 +34,6 @@ import org.apache.log4j.Logger;
import com.cloud.agent.AgentManager;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.storage.DestroyCommand;
import com.cloud.agent.api.storage.DownloadAnswer;
import com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer;
import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand;
import com.cloud.api.ApiDBUtils;
@ -51,11 +50,10 @@ import com.cloud.api.commands.ExtractTemplateCmd;
import com.cloud.api.commands.RegisterIsoCmd;
import com.cloud.api.commands.RegisterTemplateCmd;
import com.cloud.async.AsyncJobManager;
import com.cloud.async.AsyncJobResult;
import com.cloud.async.AsyncJobVO;
import com.cloud.async.executor.ExtractJobResultObject;
import com.cloud.configuration.ResourceCount.ResourceType;
import com.cloud.configuration.dao.ConfigurationDao;
import com.cloud.dc.DataCenter;
import com.cloud.dc.DataCenterVO;
import com.cloud.dc.dao.DataCenterDao;
import com.cloud.domain.dao.DomainDao;
@ -735,10 +733,10 @@ public class TemplateManagerImpl implements TemplateManager, Manager, TemplateSe
}
if (srcSecHost == null) {
throw new StorageUnavailableException("Source zone is not ready");
throw new StorageUnavailableException("Source zone is not ready", DataCenter.class, sourceZoneId);
}
if (dstSecHost == null) {
throw new StorageUnavailableException("Destination zone is not ready");
throw new StorageUnavailableException("Destination zone is not ready", DataCenter.class, destZoneId);
}
VMTemplateVO vmTemplate = _tmpltDao.findById(templateId);
@ -847,8 +845,9 @@ public class TemplateManagerImpl implements TemplateManager, Manager, TemplateSe
boolean success = copy(userId, isoId, sourceZoneId, destZoneId, eventId);
VMTemplateVO copiedIso = null;
if (success)
copiedIso = _tmpltDao.findById(isoId);
if (success) {
copiedIso = _tmpltDao.findById(isoId);
}
return copiedIso;
}
@ -881,8 +880,9 @@ public class TemplateManagerImpl implements TemplateManager, Manager, TemplateSe
boolean success = copy(userId, templateId, sourceZoneId, destZoneId, eventId);
VMTemplateVO copiedTemplate = null;
if (success)
copiedTemplate = _tmpltDao.findById(templateId);
if (success) {
copiedTemplate = _tmpltDao.findById(templateId);
}
return copiedTemplate;
}
@ -1309,8 +1309,9 @@ public class TemplateManagerImpl implements TemplateManager, Manager, TemplateSe
}
}
// If command is executed via 8096 port, set userId to the id of System account (1)
if (userId == null)
if (userId == null) {
userId = new Long(1);
}
return userId;
}

View File

@ -814,25 +814,6 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
}
private void checkIfPoolAvailable(long vmId) throws StorageUnavailableException {
//check if the sp is up before starting
List<VolumeVO> rootVolList = _volsDao.findByInstanceAndType(vmId, VolumeType.ROOT);
if(rootVolList == null || rootVolList.size() == 0){
throw new StorageUnavailableException("Could not find the root disk for this vm to verify if the pool on which it exists is Up or not");
}else{
Long poolId = rootVolList.get(0).getPoolId();//each vm has 1 root vol
StoragePoolVO sp = _storagePoolDao.findById(poolId);
if(sp == null){
throw new StorageUnavailableException("Could not find the pool for the root disk of vm"+vmId+", to confirm if it is Up or not");
}else{
//found pool
if(!sp.getStatus().equals(com.cloud.host.Status.Up) && !sp.getStatus().equals(com.cloud.host.Status.CancelMaintenance)){
throw new StorageUnavailableException("Could not start the vm; the associated storage pool is in:"+sp.getStatus().toString()+" state");
}
}
}
}
private boolean rebootVirtualMachine(long userId, long vmId) {
UserVmVO vm = _vmDao.findById(vmId);
@ -1426,7 +1407,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
}
@Override
public UserVmVO start(long vmId, long startEventId) throws StorageUnavailableException, ConcurrentOperationException, ExecutionException {
public UserVmVO start(long vmId, long startEventId) throws StorageUnavailableException, ConcurrentOperationException {
return null; // FIXME start(1L, vmId, null, null, startEventId);
}
@ -1556,10 +1537,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
s_logger.debug("Trying to migrate router to host " + vmHost.getName());
}
if( !_storageMgr.share(vm, vols, vmHost, false) ) {
s_logger.warn("Can not share " + vm.toString() + " on host " + vmHost.getId());
throw new StorageUnavailableException("Can not share " + vm.toString() + " on host " + vmHost.getId());
}
_storageMgr.share(vm, vols, vmHost, false);
Answer answer = _agentMgr.easySend(vmHost.getId(), cmd);
if (answer != null && answer.getResult()) {

View File

@ -111,7 +111,7 @@ public interface VirtualMachineGuru<T extends VirtualMachine> {
* @throws ExecutionException
* @throws ResourceUnavailableException
*/
T start(long vmId, long startEventId) throws InsufficientCapacityException, StorageUnavailableException, ConcurrentOperationException, ExecutionException;
T start(long vmId, long startEventId) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException;
/**
* stop the vm

View File

@ -50,7 +50,7 @@ public interface VirtualMachineManager extends Manager {
Map<String, Object> params,
DeploymentPlan plan,
HypervisorType hyperType,
Account owner) throws InsufficientCapacityException, ResourceUnavailableException;
Account owner) throws InsufficientCapacityException;
<T extends VMInstanceVO> T allocate(T vm,
VMTemplateVO template,
@ -60,7 +60,7 @@ public interface VirtualMachineManager extends Manager {
List<Pair<NetworkVO, NicProfile>> networks,
DeploymentPlan plan,
HypervisorType hyperType,
Account owner) throws InsufficientCapacityException, ResourceUnavailableException;
Account owner) throws InsufficientCapacityException;
<T extends VMInstanceVO> T allocate(T vm,
VMTemplateVO template,
@ -68,7 +68,7 @@ public interface VirtualMachineManager extends Manager {
List<Pair<NetworkVO, NicProfile>> networkProfiles,
DeploymentPlan plan,
HypervisorType hyperType,
Account owner) throws InsufficientCapacityException, ResourceUnavailableException;
Account owner) throws InsufficientCapacityException;
<T extends VMInstanceVO> T start(T vm, Map<String, Object> params, User caller, Account account, HypervisorType hyperType) throws InsufficientCapacityException, ResourceUnavailableException;
@ -79,7 +79,6 @@ public interface VirtualMachineManager extends Manager {
<T extends VMInstanceVO> void registerGuru(VirtualMachine.Type type, VirtualMachineGuru<T> guru);
boolean stateTransitTo(VMInstanceVO vm, Event e, Long id);
<T extends VMInstanceVO> T advanceStart(T vm, Map<String, Object> params, User caller, Account account, HypervisorType hyperType) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException, OperationTimedoutException;

View File

@ -54,7 +54,6 @@ import com.cloud.event.EventVO;
import com.cloud.exception.AgentUnavailableException;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InsufficientNetworkCapacityException;
import com.cloud.exception.InsufficientServerCapacityException;
import com.cloud.exception.OperationTimedoutException;
import com.cloud.exception.ResourceUnavailableException;
@ -62,7 +61,6 @@ import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.hypervisor.HypervisorGuru;
import com.cloud.network.NetworkManager;
import com.cloud.network.NetworkVO;
import com.cloud.network.dao.NetworkDao;
import com.cloud.service.ServiceOfferingVO;
import com.cloud.service.dao.ServiceOfferingDao;
import com.cloud.storage.DiskOfferingVO;
@ -89,7 +87,6 @@ import com.cloud.vm.ItWorkVO.Type;
import com.cloud.vm.VirtualMachine.Event;
import com.cloud.vm.dao.ConsoleProxyDao;
import com.cloud.vm.dao.DomainRouterDao;
import com.cloud.vm.dao.NicDao;
import com.cloud.vm.dao.SecondaryStorageVmDao;
import com.cloud.vm.dao.UserVmDao;
import com.cloud.vm.dao.VMInstanceDao;
@ -458,7 +455,7 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Cluster
try {
return advanceStop(vm, user, account);
} catch (OperationTimedoutException e) {
throw new ResourceUnavailableException("Unable to stop vm because the operation to stop timed out", e);
throw new AgentUnavailableException("Unable to stop vm because the operation to stop timed out", vm.getHostId(), e);
} catch (ConcurrentOperationException e) {
throw new CloudRuntimeException("Unable to stop vm because of a concurrent operation", e);
}

View File

@ -33,8 +33,8 @@ public interface SerialVersionUID {
public static final long CloudStartupServlet = Base | 0x3;
public static final long CloudServiceImpl = Base | 0x4;
public static final long AccountLimitException = Base | 0x5;
public static final long InsufficientNetworkCapacity = Base | 0x6;
public static final long InsufficientVirtualNetworkCapacityException = Base | 0x7;
public static final long NetworkUnavailableException = Base | 0x8;
public static final long UnsupportedVersionException = Base | 0xb;
public static final long DataCenterIpAddressPK = Base | 0xc;
public static final long UnableToExecuteException = Base | 0xd;

View File

@ -19,6 +19,13 @@ package com.cloud.utils.exception;
import com.cloud.utils.SerialVersionUID;
/**
* ExecutionException is a generic exception to indicate that execution has
* a problem so that the method can catch it and handle it properly. This
* exception should never be declared to be thrown out of
* a public method.
*
*/
public class ExecutionException extends Exception {
private static final long serialVersionUID = SerialVersionUID.ExecutionException;