mirror of https://github.com/apache/cloudstack.git
Removed InternalErrorException. Renamed the lock methods on the DAO objects to be more understandable.
This commit is contained in:
parent
3279c26796
commit
560d7a275e
|
|
@ -57,7 +57,7 @@ public class DataCenterIpAddressDaoImpl extends GenericDaoBase<DataCenterIpAddre
|
|||
try {
|
||||
txn.start();
|
||||
|
||||
DataCenterIpAddressVO vo = lock(sc, true);
|
||||
DataCenterIpAddressVO vo = lockOneRandomRow(sc, true);
|
||||
if (vo == null) {
|
||||
txn.rollback();
|
||||
return vo;
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ public class DataCenterLinkLocalIpAddressDaoImpl extends GenericDaoBase<DataCent
|
|||
try {
|
||||
txn.start();
|
||||
|
||||
DataCenterLinkLocalIpAddressVO vo = lock(sc, true);
|
||||
DataCenterLinkLocalIpAddressVO vo = lockOneRandomRow(sc, true);
|
||||
if (vo == null) {
|
||||
txn.rollback();
|
||||
return vo;
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ public class DataCenterVnetDaoImpl extends GenericDaoBase<DataCenterVnetVO, Long
|
|||
Transaction txn = Transaction.currentTxn();
|
||||
try {
|
||||
txn.start();
|
||||
DataCenterVnetVO vo = lock(sc, true);
|
||||
DataCenterVnetVO vo = lockOneRandomRow(sc, true);
|
||||
if (vo == null) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ public class PodVlanDaoImpl extends GenericDaoBase<PodVlanVO, Long> implements G
|
|||
Transaction txn = Transaction.currentTxn();
|
||||
try {
|
||||
txn.start();
|
||||
PodVlanVO vo = lock(sc, true);
|
||||
PodVlanVO vo = lockOneRandomRow(sc, true);
|
||||
if (vo == null) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ public class HighAvailabilityDaoImpl extends GenericDaoBase<WorkVO, Long> implem
|
|||
final Filter filter = new Filter(WorkVO.class, null, true, 0l, 1l);
|
||||
|
||||
txn.start();
|
||||
final List<WorkVO> vos = lock(sc, filter, true);
|
||||
final List<WorkVO> vos = lockRows(sc, filter, true);
|
||||
if (vos.size() == 0) {
|
||||
txn.commit();
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ public class IPAddressDaoImpl extends GenericDaoBase<IPAddressVO, String> implem
|
|||
sc.setParameters("vlanDbId", vlanDbId);
|
||||
sc.setParameters("sourceNat", sourceNat);
|
||||
|
||||
List<IPAddressVO> ipList = this.lock(sc, null, true);
|
||||
List<IPAddressVO> ipList = this.lockRows(sc, null, true);
|
||||
List<String> ipStringList = new ArrayList<String>();
|
||||
|
||||
for(IPAddressVO ip:ipList){
|
||||
|
|
@ -127,7 +127,7 @@ public class IPAddressDaoImpl extends GenericDaoBase<IPAddressVO, String> implem
|
|||
SearchCriteria<IPAddressVO> sc = VlanDbIdSearchUnallocated.create();
|
||||
sc.setParameters("vlanDbId", vlanDbId);
|
||||
|
||||
IPAddressVO ip = this.lock(sc, true);
|
||||
IPAddressVO ip = this.lockOneRandomRow(sc, true);
|
||||
if(ip != null) {
|
||||
ip.setAccountId(accountId);
|
||||
ip.setAllocated(new Date());
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ public class NetworkGroupWorkDaoImpl extends GenericDaoBase<NetworkGroupWorkVO,
|
|||
final Filter filter = new Filter(NetworkGroupWorkVO.class, null, true, 0l, 1l);//FIXME: order desc by update time?
|
||||
|
||||
txn.start();
|
||||
final List<NetworkGroupWorkVO> vos = lock(sc, filter, true);
|
||||
final List<NetworkGroupWorkVO> vos = lockRows(sc, filter, true);
|
||||
if (vos.size() == 0) {
|
||||
txn.commit();
|
||||
return null;
|
||||
|
|
@ -144,7 +144,7 @@ public class NetworkGroupWorkDaoImpl extends GenericDaoBase<NetworkGroupWorkVO,
|
|||
|
||||
final Filter filter = new Filter(WorkVO.class, null, true, 0l, 1l);
|
||||
|
||||
final List<NetworkGroupWorkVO> vos = lock(sc, filter, true);
|
||||
final List<NetworkGroupWorkVO> vos = lockRows(sc, filter, true);
|
||||
if (vos.size() == 0) {
|
||||
txn.commit();
|
||||
return;
|
||||
|
|
@ -169,7 +169,7 @@ public class NetworkGroupWorkDaoImpl extends GenericDaoBase<NetworkGroupWorkVO,
|
|||
final Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
|
||||
NetworkGroupWorkVO work = lock(workId, true);
|
||||
NetworkGroupWorkVO work = lockRow(workId, true);
|
||||
if (work == null) {
|
||||
txn.commit();
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -291,7 +291,7 @@ public class VMTemplateHostDaoImpl extends GenericDaoBase<VMTemplateHostVO, Long
|
|||
if (!lock)
|
||||
return findOneIncludingRemovedBy(sc);
|
||||
else
|
||||
return lock(sc, true);
|
||||
return lockOneRandomRow(sc, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ public class UserStatisticsDaoImpl extends GenericDaoBase<UserStatisticsVO, Long
|
|||
SearchCriteria<UserStatisticsVO> sc = UserDcSearch.create();
|
||||
sc.setParameters("account", accountId);
|
||||
sc.setParameters("dc", dcId);
|
||||
return lock(sc, true);
|
||||
return lockOneRandomRow(sc, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ public class SyncQueueManagerImpl implements SyncQueueManager {
|
|||
try {
|
||||
txt.start();
|
||||
|
||||
SyncQueueVO queueVO = _syncQueueDao.lock(queueId, true);
|
||||
SyncQueueVO queueVO = _syncQueueDao.lockRow(queueId, true);
|
||||
if(queueVO == null) {
|
||||
s_logger.error("Sync queue(id: " + queueId + ") does not exist");
|
||||
txt.commit();
|
||||
|
|
@ -140,8 +140,8 @@ public class SyncQueueManagerImpl implements SyncQueueManager {
|
|||
List<SyncQueueItemVO> l = _syncQueueItemDao.getNextQueueItems(maxItems);
|
||||
if(l != null && l.size() > 0) {
|
||||
for(SyncQueueItemVO item : l) {
|
||||
SyncQueueVO queueVO = _syncQueueDao.lock(item.getQueueId(), true);
|
||||
SyncQueueItemVO itemVO = _syncQueueItemDao.lock(item.getId(), true);
|
||||
SyncQueueVO queueVO = _syncQueueDao.lockRow(item.getQueueId(), true);
|
||||
SyncQueueItemVO itemVO = _syncQueueItemDao.lockRow(item.getId(), true);
|
||||
if(queueVO.getLastProcessTime() == null && itemVO.getLastProcessNumber() == null) {
|
||||
Long processNumber = queueVO.getLastProcessNumber();
|
||||
if(processNumber == null)
|
||||
|
|
@ -182,7 +182,7 @@ public class SyncQueueManagerImpl implements SyncQueueManager {
|
|||
|
||||
SyncQueueItemVO itemVO = _syncQueueItemDao.findById(queueItemId);
|
||||
if(itemVO != null) {
|
||||
SyncQueueVO queueVO = _syncQueueDao.lock(itemVO.getQueueId(), true);
|
||||
SyncQueueVO queueVO = _syncQueueDao.lockRow(itemVO.getQueueId(), true);
|
||||
|
||||
_syncQueueItemDao.expunge(itemVO.getId());
|
||||
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ public class DisableAccountExecutor extends BaseAsyncJobExecutor {
|
|||
public void initialSchedule(ManagementServer managementServer, long accountId) {
|
||||
AsyncJobManager asyncMgr = getAsyncJobMgr();
|
||||
|
||||
AccountVO account = asyncMgr.getExecutorContext().getAccountDao().acquire(accountId);
|
||||
AccountVO account = asyncMgr.getExecutorContext().getAccountDao().acquireInLockTable(accountId);
|
||||
|
||||
if(account == null) {
|
||||
s_logger.warn("Unable to acquire account." + accountId + " to execute disable account command");
|
||||
|
|
@ -104,7 +104,7 @@ public class DisableAccountExecutor extends BaseAsyncJobExecutor {
|
|||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
|
||||
e.getMessage());
|
||||
} finally {
|
||||
asyncMgr.getExecutorContext().getAccountDao().release(accountId);
|
||||
asyncMgr.getExecutorContext().getAccountDao().releaseFromLockTable(accountId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -144,7 +144,7 @@ public class DisableAccountExecutor extends BaseAsyncJobExecutor {
|
|||
try {
|
||||
txn.start();
|
||||
|
||||
AsyncJobVO jobUpdate = asyncMgr.getExecutorContext().getJobDao().lock(job.getId(), true);
|
||||
AsyncJobVO jobUpdate = asyncMgr.getExecutorContext().getJobDao().lockRow(job.getId(), true);
|
||||
int progress = jobUpdate.getProcessStatus();
|
||||
jobUpdate.setProcessStatus(progress -1);
|
||||
asyncMgr.getExecutorContext().getJobDao().update(job.getId(), jobUpdate);
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ public class DisableUserExecutor extends BaseAsyncJobExecutor {
|
|||
try {
|
||||
txn.start();
|
||||
|
||||
AsyncJobVO jobUpdate = asyncMgr.getExecutorContext().getJobDao().lock(job.getId(), true);
|
||||
AsyncJobVO jobUpdate = asyncMgr.getExecutorContext().getJobDao().lockRow(job.getId(), true);
|
||||
int progress = jobUpdate.getProcessStatus();
|
||||
jobUpdate.setProcessStatus(progress -1);
|
||||
asyncMgr.getExecutorContext().getJobDao().update(job.getId(), jobUpdate);
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ public class DisassociateIpAddressExecutor extends BaseAsyncJobExecutor {
|
|||
|
||||
IPAddressVO ip = null;
|
||||
try {
|
||||
ip = ipAddressDao.acquire(param.getIpAddress());
|
||||
ip = ipAddressDao.acquireInLockTable(param.getIpAddress());
|
||||
|
||||
DomainRouterVO router = null;
|
||||
if (ip.isSourceNat()) {
|
||||
|
|
@ -105,7 +105,7 @@ public class DisassociateIpAddressExecutor extends BaseAsyncJobExecutor {
|
|||
|
||||
} finally {
|
||||
if(ip != null) {
|
||||
ipAddressDao.release(param.getIpAddress());
|
||||
ipAddressDao.releaseFromLockTable(param.getIpAddress());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1544,7 +1544,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
|
|||
|
||||
try {
|
||||
//Acquire Lock
|
||||
account = _accountDao.acquire(accountId);
|
||||
account = _accountDao.acquireInLockTable(accountId);
|
||||
if (account == null) {
|
||||
s_logger.warn("Unable to lock account: " + accountId);
|
||||
throw new ConcurrentOperationException("Unable to acquire account lock");
|
||||
|
|
@ -1606,7 +1606,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
|
|||
throw new CloudRuntimeException("Associate IP address exception");
|
||||
} finally {
|
||||
if (account != null) {
|
||||
_accountDao.release(accountId);
|
||||
_accountDao.releaseFromLockTable(accountId);
|
||||
s_logger.debug("Associate IP address lock released");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,6 @@ import com.cloud.exception.ConcurrentOperationException;
|
|||
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InsufficientNetworkCapacityException;
|
||||
import com.cloud.exception.InternalErrorException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.NetworkRuleConflictException;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
|
|
@ -123,7 +122,7 @@ public interface NetworkManager extends Manager {
|
|||
* @return DomainRouter object
|
||||
* @throws InvalidParameterValueException, PermissionDeniedException
|
||||
*/
|
||||
DomainRouterVO startRouter(StartRouterCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
|
||||
DomainRouterVO startRouter(StartRouterCmd cmd);
|
||||
|
||||
boolean releaseRouter(long routerId);
|
||||
|
||||
|
|
@ -137,7 +136,7 @@ public interface NetworkManager extends Manager {
|
|||
* @return router if successful, null otherwise
|
||||
* @throws InvalidParameterValueException, PermissionDeniedException
|
||||
*/
|
||||
DomainRouterVO stopRouter(StopRouterCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
|
||||
DomainRouterVO stopRouter(StopRouterCmd cmd);
|
||||
|
||||
boolean getRouterStatistics(long vmId, Map<String, long[]> netStats, Map<String, long[]> diskStats);
|
||||
|
||||
|
|
@ -149,7 +148,7 @@ public interface NetworkManager extends Manager {
|
|||
* @return the rebooted router
|
||||
* @throws InvalidParameterValueException, PermissionDeniedException
|
||||
*/
|
||||
DomainRouterVO rebootRouter(RebootRouterCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
|
||||
DomainRouterVO rebootRouter(RebootRouterCmd cmd);
|
||||
/**
|
||||
* @param hostId get all of the virtual machine routers on a host.
|
||||
* @return collection of VirtualMachineRouter
|
||||
|
|
@ -210,21 +209,21 @@ public interface NetworkManager extends Manager {
|
|||
* @param cmd the command specifying the ip address, public port, protocol, private port, and virtual machine id.
|
||||
* @return the newly created FirewallRuleVO if successful, null otherwise.
|
||||
*/
|
||||
public FirewallRuleVO createPortForwardingRule(CreateIPForwardingRuleCmd cmd) throws InvalidParameterValueException, PermissionDeniedException, NetworkRuleConflictException;
|
||||
public FirewallRuleVO createPortForwardingRule(CreateIPForwardingRuleCmd cmd) throws NetworkRuleConflictException;
|
||||
|
||||
/**
|
||||
* List port forwarding rules assigned to an ip address
|
||||
* @param cmd the command object holding the criteria for listing port forwarding rules (the ipAddress)
|
||||
* @return list of port forwarding rules on the given address, empty list if no rules exist
|
||||
*/
|
||||
public List<FirewallRuleVO> listPortForwardingRules(ListPortForwardingRulesCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
|
||||
public List<FirewallRuleVO> listPortForwardingRules(ListPortForwardingRulesCmd cmd);
|
||||
|
||||
/**
|
||||
* Create a load balancer rule from the given ipAddress/port to the given private port
|
||||
* @param cmd the command specifying the ip address, public port, protocol, private port, and algorithm
|
||||
* @return the newly created LoadBalancerVO if successful, null otherwise
|
||||
*/
|
||||
public LoadBalancerVO createLoadBalancerRule(CreateLoadBalancerRuleCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
|
||||
public LoadBalancerVO createLoadBalancerRule(CreateLoadBalancerRuleCmd cmd);
|
||||
|
||||
/**
|
||||
* Associates or disassociates a list of public IP address for a router.
|
||||
|
|
@ -234,30 +233,27 @@ public interface NetworkManager extends Manager {
|
|||
* @param vmId
|
||||
* @return
|
||||
*/
|
||||
boolean associateIP(DomainRouterVO router, List<String> ipAddrList, boolean add, long vmId);
|
||||
boolean associateIP(DomainRouterVO router, List<String> ipAddrList, boolean add, long vmId) throws ConcurrentOperationException;
|
||||
|
||||
/**
|
||||
* Associates a public IP address for a router.
|
||||
* @param cmd - the command specifying ipAddress
|
||||
* @return ip address object
|
||||
* @throws ResourceAllocationException, InsufficientCapacityException, InternalErrorException, InvalidParameterValueException, PermissionDeniedException
|
||||
* @throws ResourceAllocationException, InsufficientCapacityException
|
||||
*/
|
||||
IPAddressVO associateIP(AssociateIPAddrCmd cmd) throws ResourceAllocationException, InsufficientAddressCapacityException, InternalErrorException, InvalidParameterValueException, PermissionDeniedException;
|
||||
IPAddressVO associateIP(AssociateIPAddrCmd cmd) throws ResourceAllocationException, InsufficientAddressCapacityException, ConcurrentOperationException;
|
||||
|
||||
boolean updateFirewallRule(FirewallRuleVO fwRule, String oldPrivateIP, String oldPrivatePort);
|
||||
|
||||
/**
|
||||
* Assign a virtual machine, or list of virtual machines, to a load balancer.
|
||||
*/
|
||||
void assignToLoadBalancer(AssignToLoadBalancerRuleCmd cmd) throws NetworkRuleConflictException,
|
||||
InternalErrorException,
|
||||
PermissionDeniedException,
|
||||
InvalidParameterValueException;
|
||||
void assignToLoadBalancer(AssignToLoadBalancerRuleCmd cmd) throws NetworkRuleConflictException;
|
||||
|
||||
public boolean removeFromLoadBalancer(RemoveFromLoadBalancerRuleCmd cmd) throws InvalidParameterValueException;
|
||||
public boolean removeFromLoadBalancer(RemoveFromLoadBalancerRuleCmd cmd);
|
||||
|
||||
public boolean deleteLoadBalancerRule(DeleteLoadBalancerRuleCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
|
||||
public LoadBalancerVO updateLoadBalancerRule(UpdateLoadBalancerRuleCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
|
||||
public boolean deleteLoadBalancerRule(DeleteLoadBalancerRuleCmd cmd);
|
||||
public LoadBalancerVO updateLoadBalancerRule(UpdateLoadBalancerRuleCmd cmd);
|
||||
|
||||
/**
|
||||
* Add a DHCP entry on the domr dhcp server
|
||||
|
|
@ -295,9 +291,9 @@ public interface NetworkManager extends Manager {
|
|||
*/
|
||||
List<IPAddressVO> listPublicIpAddressesInVirtualNetwork(long accountId, long dcId, Boolean sourceNat);
|
||||
|
||||
public boolean disassociateIpAddress(DisassociateIPAddrCmd cmd) throws PermissionDeniedException;
|
||||
public boolean disassociateIpAddress(DisassociateIPAddrCmd cmd);
|
||||
|
||||
public boolean deleteIpForwardingRule(DeleteIPForwardingRuleCmd cmd) throws PermissionDeniedException, InvalidParameterValueException;
|
||||
public boolean deleteIpForwardingRule(DeleteIPForwardingRuleCmd cmd);
|
||||
|
||||
List<NetworkConfigurationVO> setupNetworkConfiguration(Account owner, NetworkOfferingVO offering, DeploymentPlan plan);
|
||||
List<NetworkConfigurationVO> setupNetworkConfiguration(Account owner, NetworkOfferingVO offering, NetworkConfiguration predefined, DeploymentPlan plan);
|
||||
|
|
@ -310,7 +306,7 @@ public interface NetworkManager extends Manager {
|
|||
void release(VirtualMachineProfile vmProfile);
|
||||
|
||||
<K extends VMInstanceVO> List<NicVO> getNics(K vm);
|
||||
boolean upgradeRouter(UpgradeRouterCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
|
||||
boolean upgradeRouter(UpgradeRouterCmd cmd);
|
||||
|
||||
List<AccountVO> getAccountsUsingNetworkConfiguration(long configurationId);
|
||||
AccountVO getNetworkConfigurationOwner(long configurationId);
|
||||
|
|
@ -328,7 +324,7 @@ public interface NetworkManager extends Manager {
|
|||
* @throws PermissionDeniedException
|
||||
* @throws ConcurrentOperationException
|
||||
*/
|
||||
public RemoteAccessVpnVO createRemoteAccessVpn(CreateRemoteAccessVpnCmd cmd) throws InvalidParameterValueException, PermissionDeniedException, ConcurrentOperationException;
|
||||
public RemoteAccessVpnVO createRemoteAccessVpn(CreateRemoteAccessVpnCmd cmd) throws ConcurrentOperationException;
|
||||
|
||||
/**
|
||||
* Start a remote access vpn for the given public ip address and client ip range
|
||||
|
|
|
|||
|
|
@ -242,7 +242,7 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
|
|||
|
||||
txn.start();
|
||||
|
||||
account = _accountDao.acquire(accountId);
|
||||
account = _accountDao.acquireInLockTable(accountId);
|
||||
if (account == null) {
|
||||
s_logger.warn("Unable to lock account " + accountId);
|
||||
return null;
|
||||
|
|
@ -355,7 +355,7 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
|
|||
if(s_logger.isDebugEnabled())
|
||||
s_logger.debug("Releasing lock account " + accountId);
|
||||
|
||||
_accountDao.release(accountId);
|
||||
_accountDao.releaseFromLockTable(accountId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -376,7 +376,7 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
|
|||
|
||||
txn.start();
|
||||
|
||||
account = _accountDao.acquire(accountId);
|
||||
account = _accountDao.acquireInLockTable(accountId);
|
||||
if (account == null) {
|
||||
s_logger.warn("Unable to lock account " + accountId);
|
||||
return null;
|
||||
|
|
@ -457,7 +457,7 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
|
|||
if(s_logger.isDebugEnabled())
|
||||
s_logger.debug("Releasing lock account " + accountId);
|
||||
|
||||
_accountDao.release(accountId);
|
||||
_accountDao.releaseFromLockTable(accountId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -626,7 +626,7 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
|
|||
}
|
||||
|
||||
@Override @DB
|
||||
public IPAddressVO associateIP(AssociateIPAddrCmd cmd) throws ResourceAllocationException, InsufficientAddressCapacityException, InvalidParameterValueException, InternalErrorException, PermissionDeniedException {
|
||||
public IPAddressVO associateIP(AssociateIPAddrCmd cmd) throws ResourceAllocationException, InsufficientAddressCapacityException, ConcurrentOperationException {
|
||||
String accountName = cmd.getAccountName();
|
||||
Long domainId = cmd.getDomainId();
|
||||
Long zoneId = cmd.getZoneId();
|
||||
|
|
@ -670,11 +670,11 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
|
|||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Associate IP address called for user " + userId + " account " + accountId);
|
||||
}
|
||||
accountToLock = _accountDao.acquire(accountId);
|
||||
accountToLock = _accountDao.acquireInLockTable(accountId);
|
||||
|
||||
if (accountToLock == null) {
|
||||
s_logger.warn("Unable to lock account: " + accountId);
|
||||
throw new InternalErrorException("Unable to acquire account lock");
|
||||
throw new ConcurrentOperationException("Unable to acquire account lock");
|
||||
}
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
|
|
@ -736,7 +736,7 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
|
|||
_eventDao.persist(event);
|
||||
txn.commit();
|
||||
|
||||
throw new InternalErrorException(errorMsg);
|
||||
throw new CloudRuntimeException(errorMsg);
|
||||
} else {
|
||||
event.setDescription("Assigned a public IP address: " + ipAddress);
|
||||
_eventDao.persist(event);
|
||||
|
|
@ -755,15 +755,9 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
|
|||
} catch (InvalidParameterValueException ipve) {
|
||||
s_logger.error("Associate IP threw an InvalidParameterValueException.", ipve);
|
||||
throw ipve;
|
||||
} catch (InternalErrorException iee) {
|
||||
s_logger.error("Associate IP threw an InternalErrorException.", iee);
|
||||
throw iee;
|
||||
} catch (Throwable t) {
|
||||
s_logger.error("Associate IP address threw an exception.", t);
|
||||
throw new InternalErrorException("Associate IP address exception");
|
||||
} finally {
|
||||
if (account != null) {
|
||||
_accountDao.release(accountId);
|
||||
_accountDao.releaseFromLockTable(accountId);
|
||||
s_logger.debug("Associate IP address lock released");
|
||||
}
|
||||
}
|
||||
|
|
@ -1098,8 +1092,7 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
|
|||
}
|
||||
|
||||
@Override @DB
|
||||
public void assignToLoadBalancer(AssignToLoadBalancerRuleCmd cmd) throws NetworkRuleConflictException, InternalErrorException,
|
||||
PermissionDeniedException, InvalidParameterValueException {
|
||||
public void assignToLoadBalancer(AssignToLoadBalancerRuleCmd cmd) throws NetworkRuleConflictException {
|
||||
Long loadBalancerId = cmd.getLoadBalancerId();
|
||||
Long instanceIdParam = cmd.getVirtualMachineId();
|
||||
List<Long> instanceIds = cmd.getVirtualMachineIds();
|
||||
|
|
@ -1135,211 +1128,194 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
|
|||
}
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
try {
|
||||
List<FirewallRuleVO> firewallRulesToApply = new ArrayList<FirewallRuleVO>();
|
||||
long accountId = 0;
|
||||
DomainRouterVO router = null;
|
||||
List<FirewallRuleVO> firewallRulesToApply = new ArrayList<FirewallRuleVO>();
|
||||
long accountId = 0;
|
||||
DomainRouterVO router = null;
|
||||
|
||||
List<LoadBalancerVMMapVO> mappedInstances = _loadBalancerVMMapDao.listByLoadBalancerId(loadBalancerId, false);
|
||||
Set<Long> mappedInstanceIds = new HashSet<Long>();
|
||||
if (mappedInstances != null) {
|
||||
for (LoadBalancerVMMapVO mappedInstance : mappedInstances) {
|
||||
mappedInstanceIds.add(Long.valueOf(mappedInstance.getInstanceId()));
|
||||
}
|
||||
List<LoadBalancerVMMapVO> mappedInstances = _loadBalancerVMMapDao.listByLoadBalancerId(loadBalancerId, false);
|
||||
Set<Long> mappedInstanceIds = new HashSet<Long>();
|
||||
if (mappedInstances != null) {
|
||||
for (LoadBalancerVMMapVO mappedInstance : mappedInstances) {
|
||||
mappedInstanceIds.add(Long.valueOf(mappedInstance.getInstanceId()));
|
||||
}
|
||||
}
|
||||
|
||||
List<Long> finalInstanceIds = new ArrayList<Long>();
|
||||
for (Long instanceId : instanceIds) {
|
||||
if (mappedInstanceIds.contains(instanceId)) {
|
||||
continue;
|
||||
} else {
|
||||
finalInstanceIds.add(instanceId);
|
||||
}
|
||||
|
||||
UserVmVO userVm = _vmDao.findById(instanceId);
|
||||
if (userVm == null) {
|
||||
s_logger.warn("Unable to find virtual machine with id " + instanceId);
|
||||
throw new InvalidParameterValueException("Unable to find virtual machine with id " + instanceId);
|
||||
} else {
|
||||
// sanity check that the vm can be applied to the load balancer
|
||||
ServiceOfferingVO offering = _serviceOfferingDao.findById(userVm.getServiceOfferingId());
|
||||
if ((offering == null) || !GuestIpType.Virtualized.equals(offering.getGuestIpType())) {
|
||||
// we previously added these instanceIds to the loadBalancerVMMap, so remove them here as we are rejecting the API request
|
||||
// without actually modifying the load balancer
|
||||
_loadBalancerVMMapDao.remove(loadBalancerId, instanceIds, Boolean.TRUE);
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Unable to add virtual machine " + userVm.toString() + " to load balancer " + loadBalancerId + ", bad network type (" + ((offering == null) ? "null" : offering.getGuestIpType()) + ")");
|
||||
}
|
||||
|
||||
throw new InvalidParameterValueException("Unable to add virtual machine " + userVm.toString() + " to load balancer " + loadBalancerId + ", bad network type (" + ((offering == null) ? "null" : offering.getGuestIpType()) + ")");
|
||||
}
|
||||
}
|
||||
|
||||
if (accountId == 0) {
|
||||
accountId = userVm.getAccountId();
|
||||
} else if (accountId != userVm.getAccountId()) {
|
||||
s_logger.warn("guest vm " + userVm.getName() + " (id:" + userVm.getId() + ") belongs to account " + userVm.getAccountId()
|
||||
+ ", previous vm in list belongs to account " + accountId);
|
||||
throw new InvalidParameterValueException("guest vm " + userVm.getName() + " (id:" + userVm.getId() + ") belongs to account " + userVm.getAccountId()
|
||||
+ ", previous vm in list belongs to account " + accountId);
|
||||
}
|
||||
|
||||
DomainRouterVO nextRouter = null;
|
||||
if (userVm.getDomainRouterId() != null)
|
||||
nextRouter = _routerMgr.getRouter(userVm.getDomainRouterId());
|
||||
if (nextRouter == null) {
|
||||
s_logger.warn("Unable to find router (" + userVm.getDomainRouterId() + ") for virtual machine with id " + instanceId);
|
||||
throw new InvalidParameterValueException("Unable to find router (" + userVm.getDomainRouterId() + ") for virtual machine with id " + instanceId);
|
||||
}
|
||||
|
||||
if (router == null) {
|
||||
router = nextRouter;
|
||||
|
||||
// Make sure owner of router is owner of load balancer. Since we are already checking that all VMs belong to the same router, by checking router
|
||||
// ownership once we'll make sure all VMs belong to the owner of the load balancer.
|
||||
if (router.getAccountId() != loadBalancer.getAccountId()) {
|
||||
throw new InvalidParameterValueException("guest vm " + userVm.getName() + " (id:" + userVm.getId() + ") does not belong to the owner of load balancer " +
|
||||
loadBalancer.getName() + " (owner is account id " + loadBalancer.getAccountId() + ")");
|
||||
}
|
||||
} else if (router.getId() != nextRouter.getId()) {
|
||||
throw new InvalidParameterValueException("guest vm " + userVm.getName() + " (id:" + userVm.getId() + ") belongs to router " + nextRouter.getName()
|
||||
+ ", previous vm in list belongs to router " + router.getName());
|
||||
}
|
||||
|
||||
// check for ip address/port conflicts by checking exising forwarding and loadbalancing rules
|
||||
String ipAddress = loadBalancer.getIpAddress();
|
||||
String privateIpAddress = userVm.getGuestIpAddress();
|
||||
List<FirewallRuleVO> existingRulesOnPubIp = _rulesDao.listIPForwarding(ipAddress);
|
||||
|
||||
if (existingRulesOnPubIp != null) {
|
||||
for (FirewallRuleVO fwRule : existingRulesOnPubIp) {
|
||||
if (!( (fwRule.isForwarding() == false) &&
|
||||
(fwRule.getGroupId() != null) &&
|
||||
(fwRule.getGroupId() == loadBalancer.getId().longValue()) )) {
|
||||
// if the rule is not for the current load balancer, check to see if the private IP is our target IP,
|
||||
// in which case we have a conflict
|
||||
if (fwRule.getPublicPort().equals(loadBalancer.getPublicPort())) {
|
||||
throw new NetworkRuleConflictException("An existing port forwarding service rule for " + ipAddress + ":" + loadBalancer.getPublicPort()
|
||||
+ " exists, found while trying to apply load balancer " + loadBalancer.getName() + " (id:" + loadBalancer.getId() + ") to instance "
|
||||
+ userVm.getName() + ".");
|
||||
}
|
||||
} else if (fwRule.getPrivateIpAddress().equals(privateIpAddress) && fwRule.getPrivatePort().equals(loadBalancer.getPrivatePort()) && fwRule.isEnabled()) {
|
||||
// for the current load balancer, don't add the same instance to the load balancer more than once
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FirewallRuleVO newFwRule = new FirewallRuleVO();
|
||||
newFwRule.setAlgorithm(loadBalancer.getAlgorithm());
|
||||
newFwRule.setEnabled(true);
|
||||
newFwRule.setForwarding(false);
|
||||
newFwRule.setPrivatePort(loadBalancer.getPrivatePort());
|
||||
newFwRule.setPublicPort(loadBalancer.getPublicPort());
|
||||
newFwRule.setPublicIpAddress(loadBalancer.getIpAddress());
|
||||
newFwRule.setPrivateIpAddress(userVm.getGuestIpAddress());
|
||||
newFwRule.setGroupId(loadBalancer.getId());
|
||||
|
||||
firewallRulesToApply.add(newFwRule);
|
||||
}
|
||||
|
||||
// if there's no work to do, bail out early rather than reconfiguring the proxy with the existing rules
|
||||
if (firewallRulesToApply.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
IPAddressVO ipAddr = _ipAddressDao.findById(loadBalancer.getIpAddress());
|
||||
List<IPAddressVO> ipAddrs = listPublicIpAddressesInVirtualNetwork(accountId, ipAddr.getDataCenterId(), null);
|
||||
for (IPAddressVO ipv : ipAddrs) {
|
||||
List<FirewallRuleVO> rules = _rulesDao.listIPForwarding(ipv.getAddress(), false);
|
||||
firewallRulesToApply.addAll(rules);
|
||||
}
|
||||
|
||||
txn.start();
|
||||
|
||||
List<FirewallRuleVO> updatedRules = null;
|
||||
if (router.getState().equals(State.Starting)) {
|
||||
// Starting is a special case...if the router is starting that means the IP address hasn't yet been assigned to the domR and the update firewall rules script will fail.
|
||||
// In this case, just store the rules and they will be applied when the router state is resent (after the router is started).
|
||||
updatedRules = firewallRulesToApply;
|
||||
List<Long> finalInstanceIds = new ArrayList<Long>();
|
||||
for (Long instanceId : instanceIds) {
|
||||
if (mappedInstanceIds.contains(instanceId)) {
|
||||
continue;
|
||||
} else {
|
||||
updatedRules = updateFirewallRules(loadBalancer.getIpAddress(), firewallRulesToApply, router);
|
||||
finalInstanceIds.add(instanceId);
|
||||
}
|
||||
|
||||
// Save and create the event
|
||||
String description;
|
||||
String type = EventTypes.EVENT_NET_RULE_ADD;
|
||||
String ruleName = "load balancer";
|
||||
String level = EventVO.LEVEL_INFO;
|
||||
UserVmVO userVm = _vmDao.findById(instanceId);
|
||||
if (userVm == null) {
|
||||
s_logger.warn("Unable to find virtual machine with id " + instanceId);
|
||||
throw new InvalidParameterValueException("Unable to find virtual machine with id " + instanceId);
|
||||
} else {
|
||||
// sanity check that the vm can be applied to the load balancer
|
||||
ServiceOfferingVO offering = _serviceOfferingDao.findById(userVm.getServiceOfferingId());
|
||||
if ((offering == null) || !GuestIpType.Virtualized.equals(offering.getGuestIpType())) {
|
||||
// we previously added these instanceIds to the loadBalancerVMMap, so remove them here as we are rejecting the API request
|
||||
// without actually modifying the load balancer
|
||||
_loadBalancerVMMapDao.remove(loadBalancerId, instanceIds, Boolean.TRUE);
|
||||
|
||||
LoadBalancerVO loadBalancerLock = null;
|
||||
try {
|
||||
loadBalancerLock = _loadBalancerDao.acquire(loadBalancerId);
|
||||
if (loadBalancerLock == null) {
|
||||
s_logger.warn("assignToLoadBalancer: Failed to lock load balancer " + loadBalancerId + ", proceeding with updating loadBalancerVMMappings...");
|
||||
}
|
||||
if ((updatedRules != null) && (updatedRules.size() == firewallRulesToApply.size())) {
|
||||
// flag the instances as mapped to the load balancer
|
||||
for (Long addedInstanceId : finalInstanceIds) {
|
||||
LoadBalancerVMMapVO mappedVM = new LoadBalancerVMMapVO(loadBalancerId, addedInstanceId);
|
||||
_loadBalancerVMMapDao.persist(mappedVM);
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Unable to add virtual machine " + userVm.toString() + " to load balancer " + loadBalancerId + ", bad network type (" + ((offering == null) ? "null" : offering.getGuestIpType()) + ")");
|
||||
}
|
||||
|
||||
/* We used to add these instances as pending when the API command is received on the server, and once they were applied,
|
||||
* the pending status was removed. In the 2.2 API framework, this is no longer done and instead the new mappings just
|
||||
* need to be persisted
|
||||
List<LoadBalancerVMMapVO> pendingMappedVMs = _loadBalancerVMMapDao.listByLoadBalancerId(loadBalancerId, true);
|
||||
for (LoadBalancerVMMapVO pendingMappedVM : pendingMappedVMs) {
|
||||
if (instanceIds.contains(pendingMappedVM.getInstanceId())) {
|
||||
LoadBalancerVMMapVO pendingMappedVMForUpdate = _loadBalancerVMMapDao.createForUpdate();
|
||||
pendingMappedVMForUpdate.setPending(false);
|
||||
_loadBalancerVMMapDao.update(pendingMappedVM.getId(), pendingMappedVMForUpdate);
|
||||
throw new InvalidParameterValueException("Unable to add virtual machine " + userVm.toString() + " to load balancer " + loadBalancerId + ", bad network type (" + ((offering == null) ? "null" : offering.getGuestIpType()) + ")");
|
||||
}
|
||||
}
|
||||
|
||||
if (accountId == 0) {
|
||||
accountId = userVm.getAccountId();
|
||||
} else if (accountId != userVm.getAccountId()) {
|
||||
s_logger.warn("guest vm " + userVm.getName() + " (id:" + userVm.getId() + ") belongs to account " + userVm.getAccountId()
|
||||
+ ", previous vm in list belongs to account " + accountId);
|
||||
throw new InvalidParameterValueException("guest vm " + userVm.getName() + " (id:" + userVm.getId() + ") belongs to account " + userVm.getAccountId()
|
||||
+ ", previous vm in list belongs to account " + accountId);
|
||||
}
|
||||
|
||||
DomainRouterVO nextRouter = null;
|
||||
if (userVm.getDomainRouterId() != null)
|
||||
nextRouter = _routerMgr.getRouter(userVm.getDomainRouterId());
|
||||
if (nextRouter == null) {
|
||||
s_logger.warn("Unable to find router (" + userVm.getDomainRouterId() + ") for virtual machine with id " + instanceId);
|
||||
throw new InvalidParameterValueException("Unable to find router (" + userVm.getDomainRouterId() + ") for virtual machine with id " + instanceId);
|
||||
}
|
||||
|
||||
if (router == null) {
|
||||
router = nextRouter;
|
||||
|
||||
// Make sure owner of router is owner of load balancer. Since we are already checking that all VMs belong to the same router, by checking router
|
||||
// ownership once we'll make sure all VMs belong to the owner of the load balancer.
|
||||
if (router.getAccountId() != loadBalancer.getAccountId()) {
|
||||
throw new InvalidParameterValueException("guest vm " + userVm.getName() + " (id:" + userVm.getId() + ") does not belong to the owner of load balancer " +
|
||||
loadBalancer.getName() + " (owner is account id " + loadBalancer.getAccountId() + ")");
|
||||
}
|
||||
} else if (router.getId() != nextRouter.getId()) {
|
||||
throw new InvalidParameterValueException("guest vm " + userVm.getName() + " (id:" + userVm.getId() + ") belongs to router " + nextRouter.getName()
|
||||
+ ", previous vm in list belongs to router " + router.getName());
|
||||
}
|
||||
|
||||
// check for ip address/port conflicts by checking exising forwarding and loadbalancing rules
|
||||
String ipAddress = loadBalancer.getIpAddress();
|
||||
String privateIpAddress = userVm.getGuestIpAddress();
|
||||
List<FirewallRuleVO> existingRulesOnPubIp = _rulesDao.listIPForwarding(ipAddress);
|
||||
|
||||
if (existingRulesOnPubIp != null) {
|
||||
for (FirewallRuleVO fwRule : existingRulesOnPubIp) {
|
||||
if (!( (fwRule.isForwarding() == false) &&
|
||||
(fwRule.getGroupId() != null) &&
|
||||
(fwRule.getGroupId() == loadBalancer.getId().longValue()) )) {
|
||||
// if the rule is not for the current load balancer, check to see if the private IP is our target IP,
|
||||
// in which case we have a conflict
|
||||
if (fwRule.getPublicPort().equals(loadBalancer.getPublicPort())) {
|
||||
throw new NetworkRuleConflictException("An existing port forwarding service rule for " + ipAddress + ":" + loadBalancer.getPublicPort()
|
||||
+ " exists, found while trying to apply load balancer " + loadBalancer.getName() + " (id:" + loadBalancer.getId() + ") to instance "
|
||||
+ userVm.getName() + ".");
|
||||
}
|
||||
} else if (fwRule.getPrivateIpAddress().equals(privateIpAddress) && fwRule.getPrivatePort().equals(loadBalancer.getPrivatePort()) && fwRule.isEnabled()) {
|
||||
// for the current load balancer, don't add the same instance to the load balancer more than once
|
||||
continue;
|
||||
}
|
||||
*/
|
||||
|
||||
for (FirewallRuleVO updatedRule : updatedRules) {
|
||||
if (updatedRule.getId() == null) {
|
||||
_rulesDao.persist(updatedRule);
|
||||
|
||||
description = "created new " + ruleName + " rule [" + updatedRule.getPublicIpAddress() + ":"
|
||||
+ updatedRule.getPublicPort() + "]->[" + updatedRule.getPrivateIpAddress() + ":"
|
||||
+ updatedRule.getPrivatePort() + "]" + " " + updatedRule.getProtocol();
|
||||
|
||||
EventUtils.saveEvent(UserContext.current().getUserId(), loadBalancer.getAccountId(), level, type, description);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Remove the instanceIds from the load balancer since there was a failure. Make sure to commit the
|
||||
// transaction here, otherwise the act of throwing the internal error exception will cause this
|
||||
// remove operation to be rolled back.
|
||||
_loadBalancerVMMapDao.remove(loadBalancerId, instanceIds, null);
|
||||
txn.commit();
|
||||
|
||||
s_logger.warn("Failed to apply load balancer " + loadBalancer.getName() + " (id:" + loadBalancerId + ") to guest virtual machines " + StringUtils.join(instanceIds, ","));
|
||||
throw new InternalErrorException("Failed to apply load balancer " + loadBalancer.getName() + " (id:" + loadBalancerId + ") to guest virtual machine " + StringUtils.join(instanceIds, ","));
|
||||
}
|
||||
} finally {
|
||||
if (loadBalancerLock != null) {
|
||||
_loadBalancerDao.release(loadBalancerId);
|
||||
}
|
||||
}
|
||||
|
||||
txn.commit();
|
||||
} catch (Throwable e) {
|
||||
txn.rollback();
|
||||
if (e instanceof NetworkRuleConflictException) {
|
||||
throw (NetworkRuleConflictException) e;
|
||||
} else if (e instanceof InvalidParameterValueException) {
|
||||
throw (InvalidParameterValueException) e;
|
||||
} else if (e instanceof PermissionDeniedException) {
|
||||
throw (PermissionDeniedException) e;
|
||||
} else if (e instanceof InternalErrorException) {
|
||||
s_logger.warn("ManagementServer error", e);
|
||||
throw (InternalErrorException) e;
|
||||
FirewallRuleVO newFwRule = new FirewallRuleVO();
|
||||
newFwRule.setAlgorithm(loadBalancer.getAlgorithm());
|
||||
newFwRule.setEnabled(true);
|
||||
newFwRule.setForwarding(false);
|
||||
newFwRule.setPrivatePort(loadBalancer.getPrivatePort());
|
||||
newFwRule.setPublicPort(loadBalancer.getPublicPort());
|
||||
newFwRule.setPublicIpAddress(loadBalancer.getIpAddress());
|
||||
newFwRule.setPrivateIpAddress(userVm.getGuestIpAddress());
|
||||
newFwRule.setGroupId(loadBalancer.getId());
|
||||
|
||||
firewallRulesToApply.add(newFwRule);
|
||||
}
|
||||
|
||||
// if there's no work to do, bail out early rather than reconfiguring the proxy with the existing rules
|
||||
if (firewallRulesToApply.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
IPAddressVO ipAddr = _ipAddressDao.findById(loadBalancer.getIpAddress());
|
||||
List<IPAddressVO> ipAddrs = listPublicIpAddressesInVirtualNetwork(accountId, ipAddr.getDataCenterId(), null);
|
||||
for (IPAddressVO ipv : ipAddrs) {
|
||||
List<FirewallRuleVO> rules = _rulesDao.listIPForwarding(ipv.getAddress(), false);
|
||||
firewallRulesToApply.addAll(rules);
|
||||
}
|
||||
|
||||
txn.start();
|
||||
|
||||
List<FirewallRuleVO> updatedRules = null;
|
||||
if (router.getState().equals(State.Starting)) {
|
||||
// Starting is a special case...if the router is starting that means the IP address hasn't yet been assigned to the domR and the update firewall rules script will fail.
|
||||
// In this case, just store the rules and they will be applied when the router state is resent (after the router is started).
|
||||
updatedRules = firewallRulesToApply;
|
||||
} else {
|
||||
updatedRules = updateFirewallRules(loadBalancer.getIpAddress(), firewallRulesToApply, router);
|
||||
}
|
||||
|
||||
// Save and create the event
|
||||
String description;
|
||||
String type = EventTypes.EVENT_NET_RULE_ADD;
|
||||
String ruleName = "load balancer";
|
||||
String level = EventVO.LEVEL_INFO;
|
||||
|
||||
LoadBalancerVO loadBalancerLock = null;
|
||||
try {
|
||||
loadBalancerLock = _loadBalancerDao.acquireInLockTable(loadBalancerId);
|
||||
if (loadBalancerLock == null) {
|
||||
s_logger.warn("assignToLoadBalancer: Failed to lock load balancer " + loadBalancerId + ", proceeding with updating loadBalancerVMMappings...");
|
||||
}
|
||||
if ((updatedRules != null) && (updatedRules.size() == firewallRulesToApply.size())) {
|
||||
// flag the instances as mapped to the load balancer
|
||||
for (Long addedInstanceId : finalInstanceIds) {
|
||||
LoadBalancerVMMapVO mappedVM = new LoadBalancerVMMapVO(loadBalancerId, addedInstanceId);
|
||||
_loadBalancerVMMapDao.persist(mappedVM);
|
||||
}
|
||||
|
||||
/* We used to add these instances as pending when the API command is received on the server, and once they were applied,
|
||||
* the pending status was removed. In the 2.2 API framework, this is no longer done and instead the new mappings just
|
||||
* need to be persisted
|
||||
List<LoadBalancerVMMapVO> pendingMappedVMs = _loadBalancerVMMapDao.listByLoadBalancerId(loadBalancerId, true);
|
||||
for (LoadBalancerVMMapVO pendingMappedVM : pendingMappedVMs) {
|
||||
if (instanceIds.contains(pendingMappedVM.getInstanceId())) {
|
||||
LoadBalancerVMMapVO pendingMappedVMForUpdate = _loadBalancerVMMapDao.createForUpdate();
|
||||
pendingMappedVMForUpdate.setPending(false);
|
||||
_loadBalancerVMMapDao.update(pendingMappedVM.getId(), pendingMappedVMForUpdate);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
for (FirewallRuleVO updatedRule : updatedRules) {
|
||||
if (updatedRule.getId() == null) {
|
||||
_rulesDao.persist(updatedRule);
|
||||
|
||||
description = "created new " + ruleName + " rule [" + updatedRule.getPublicIpAddress() + ":"
|
||||
+ updatedRule.getPublicPort() + "]->[" + updatedRule.getPrivateIpAddress() + ":"
|
||||
+ updatedRule.getPrivatePort() + "]" + " " + updatedRule.getProtocol();
|
||||
|
||||
EventUtils.saveEvent(UserContext.current().getUserId(), loadBalancer.getAccountId(), level, type, description);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Remove the instanceIds from the load balancer since there was a failure. Make sure to commit the
|
||||
// transaction here, otherwise the act of throwing the internal error exception will cause this
|
||||
// remove operation to be rolled back.
|
||||
_loadBalancerVMMapDao.remove(loadBalancerId, instanceIds, null);
|
||||
txn.commit();
|
||||
|
||||
s_logger.warn("Failed to apply load balancer " + loadBalancer.getName() + " (id:" + loadBalancerId + ") to guest virtual machines " + StringUtils.join(instanceIds, ","));
|
||||
throw new CloudRuntimeException("Failed to apply load balancer " + loadBalancer.getName() + " (id:" + loadBalancerId + ") to guest virtual machine " + StringUtils.join(instanceIds, ","));
|
||||
}
|
||||
} finally {
|
||||
if (loadBalancerLock != null) {
|
||||
_loadBalancerDao.releaseFromLockTable(loadBalancerId);
|
||||
}
|
||||
s_logger.warn("ManagementServer error", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1409,7 +1385,7 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
|
|||
throw new InvalidParameterValueException("IP Address (" + publicIp + ") and port (" + publicPort + ") already in use");
|
||||
}
|
||||
|
||||
ipAddr = _ipAddressDao.acquire(publicIp);
|
||||
ipAddr = _ipAddressDao.acquireInLockTable(publicIp);
|
||||
if (ipAddr == null) {
|
||||
throw new PermissionDeniedException("User does not own ip address " + publicIp);
|
||||
}
|
||||
|
|
@ -1445,7 +1421,7 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
|
|||
return _loadBalancerDao.findById(id);
|
||||
} finally {
|
||||
if (locked) {
|
||||
_ipAddressDao.release(publicIp);
|
||||
_ipAddressDao.releaseFromLockTable(publicIp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1454,7 +1430,7 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
|
|||
public boolean releasePublicIpAddress(long userId, final String ipAddress) {
|
||||
IPAddressVO ip = null;
|
||||
try {
|
||||
ip = _ipAddressDao.acquire(ipAddress);
|
||||
ip = _ipAddressDao.acquireInLockTable(ipAddress);
|
||||
|
||||
if (ip == null) {
|
||||
s_logger.warn("Unable to find allocated ip: " + ipAddress);
|
||||
|
|
@ -1578,7 +1554,7 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
|
|||
if(ip != null) {
|
||||
if(s_logger.isDebugEnabled())
|
||||
s_logger.debug("Releasing lock on ip " + ipAddress);
|
||||
_ipAddressDao.release(ipAddress);
|
||||
_ipAddressDao.releaseFromLockTable(ipAddress);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1903,7 +1879,7 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
|
|||
Transaction.currentTxn();
|
||||
Pair<NetworkGuru, NetworkConfigurationVO> implemented = new Pair<NetworkGuru, NetworkConfigurationVO>(null, null);
|
||||
|
||||
NetworkConfigurationVO config = _networkConfigDao.acquire(configId);
|
||||
NetworkConfigurationVO config = _networkConfigDao.acquireInLockTable(configId);
|
||||
if (config == null) {
|
||||
throw new ConcurrentOperationException("Unable to acquire network configuration: " + configId);
|
||||
}
|
||||
|
|
@ -1948,7 +1924,7 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
|
|||
if (implemented.first() == null) {
|
||||
s_logger.debug("Cleaning up because we're unable to implement network " + config);
|
||||
}
|
||||
_networkConfigDao.release(configId);
|
||||
_networkConfigDao.releaseFromLockTable(configId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2109,7 +2085,7 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
|
|||
updateFirewallRules(loadBalancer.getIpAddress(), allLbRules, router);
|
||||
|
||||
// firewall rules are updated, lock the load balancer as mappings are updated
|
||||
loadBalancerLock = _loadBalancerDao.acquire(loadBalancerId);
|
||||
loadBalancerLock = _loadBalancerDao.acquireInLockTable(loadBalancerId);
|
||||
if (loadBalancerLock == null) {
|
||||
s_logger.warn("removeFromLoadBalancer: failed to lock load balancer " + loadBalancerId + ", deleting mappings anyway...");
|
||||
}
|
||||
|
|
@ -2139,7 +2115,7 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
|
|||
txn.rollback();
|
||||
} finally {
|
||||
if (loadBalancerLock != null) {
|
||||
_loadBalancerDao.release(loadBalancerId);
|
||||
_loadBalancerDao.releaseFromLockTable(loadBalancerId);
|
||||
}
|
||||
}
|
||||
return success;
|
||||
|
|
@ -2201,7 +2177,7 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
|
|||
updateFirewallRules(loadBalancer.getIpAddress(), allLbRules, router);
|
||||
|
||||
// firewall rules are updated, lock the load balancer as the mappings are updated
|
||||
loadBalancerLock = _loadBalancerDao.acquire(loadBalancerId);
|
||||
loadBalancerLock = _loadBalancerDao.acquireInLockTable(loadBalancerId);
|
||||
if (loadBalancerLock == null) {
|
||||
s_logger.warn("deleteLoadBalancer: failed to lock load balancer " + loadBalancerId + ", deleting mappings anyway...");
|
||||
}
|
||||
|
|
@ -2233,7 +2209,7 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
|
|||
return false;
|
||||
} finally {
|
||||
if (loadBalancerLock != null) {
|
||||
_loadBalancerDao.release(loadBalancerId);
|
||||
_loadBalancerDao.releaseFromLockTable(loadBalancerId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2504,7 +2480,7 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
|
|||
boolean success = false;
|
||||
try {
|
||||
|
||||
IPAddressVO ipVO = _ipAddressDao.acquire(publicIp);
|
||||
IPAddressVO ipVO = _ipAddressDao.acquireInLockTable(publicIp);
|
||||
if (ipVO == null) {
|
||||
// throw this exception because hackers can use the api to probe for allocated ips
|
||||
throw new PermissionDeniedException("User does not own supplied address");
|
||||
|
|
@ -2550,7 +2526,7 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
|
|||
return false;
|
||||
}finally {
|
||||
if (locked) {
|
||||
_ipAddressDao.release(publicIp);
|
||||
_ipAddressDao.releaseFromLockTable(publicIp);
|
||||
}
|
||||
txn.close();
|
||||
}
|
||||
|
|
@ -2672,7 +2648,7 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
|
|||
txn.start();
|
||||
boolean locked = false;
|
||||
try {
|
||||
ipAddr = _ipAddressDao.acquire(publicIp);
|
||||
ipAddr = _ipAddressDao.acquireInLockTable(publicIp);
|
||||
if (ipAddr == null) {
|
||||
throw new ConcurrentOperationException("Another operation active, unable to create vpn");
|
||||
}
|
||||
|
|
@ -2683,7 +2659,7 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
|
|||
return vpnVO;
|
||||
} finally {
|
||||
if (locked) {
|
||||
_ipAddressDao.release(publicIp);
|
||||
_ipAddressDao.releaseFromLockTable(publicIp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2702,7 +2678,7 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
|
|||
boolean locked = false;
|
||||
boolean created = false;
|
||||
try {
|
||||
IPAddressVO ipAddr = _ipAddressDao.acquire(publicIp);
|
||||
IPAddressVO ipAddr = _ipAddressDao.acquireInLockTable(publicIp);
|
||||
if (ipAddr == null) {
|
||||
throw new ConcurrentOperationException("Another operation active, unable to create vpn");
|
||||
}
|
||||
|
|
@ -2721,7 +2697,7 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
|
|||
}
|
||||
txn.commit();
|
||||
if (locked) {
|
||||
_ipAddressDao.release(publicIp);
|
||||
_ipAddressDao.releaseFromLockTable(publicIp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2744,7 +2720,7 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
|
|||
boolean locked = false;
|
||||
boolean deleted = false;
|
||||
try {
|
||||
IPAddressVO ipAddr = _ipAddressDao.acquire(publicIp);
|
||||
IPAddressVO ipAddr = _ipAddressDao.acquireInLockTable(publicIp);
|
||||
if (ipAddr == null) {
|
||||
throw new ConcurrentOperationException("Another operation active, unable to create vpn");
|
||||
}
|
||||
|
|
@ -2761,7 +2737,7 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
|
|||
}
|
||||
txn.commit();
|
||||
if (locked) {
|
||||
_ipAddressDao.release(publicIp);
|
||||
_ipAddressDao.releaseFromLockTable(publicIp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||
|
||||
@Override
|
||||
public boolean release(String uniqueId) {
|
||||
return _vlanDao.release(Long.parseLong(uniqueId));
|
||||
return _vlanDao.releaseFromLockTable(Long.parseLong(uniqueId));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -287,7 +287,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, VirtualMach
|
|||
final Transaction txn = Transaction.currentTxn();
|
||||
DomainRouterVO router = null;
|
||||
Long podId = pod.getId();
|
||||
pod = _podDao.acquire(podId, 20*60);
|
||||
pod = _podDao.acquireInLockTable(podId, 20*60);
|
||||
if (pod == null) {
|
||||
throw new ConcurrentOperationException("Unable to acquire lock on pod " + podId );
|
||||
}
|
||||
|
|
@ -343,7 +343,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, VirtualMach
|
|||
|
||||
txn.start();
|
||||
router = _routerDao.persist(router);
|
||||
router = _routerDao.acquire(router.getId());
|
||||
router = _routerDao.acquireInLockTable(router.getId());
|
||||
if (router == null) {
|
||||
s_logger.debug("Unable to acquire lock on router " + id);
|
||||
throw new CloudRuntimeException("Unable to acquire lock on router " + id);
|
||||
|
|
@ -398,12 +398,12 @@ public class DomainRouterManagerImpl implements DomainRouterManager, VirtualMach
|
|||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Releasing lock on router " + id);
|
||||
}
|
||||
_routerDao.release(id);
|
||||
_routerDao.releaseFromLockTable(id);
|
||||
}
|
||||
if (pod != null) {
|
||||
if(s_logger.isDebugEnabled())
|
||||
s_logger.debug("Releasing lock on pod " + podId);
|
||||
_podDao.release(pod.getId());
|
||||
_podDao.releaseFromLockTable(pod.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -421,7 +421,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, VirtualMach
|
|||
s_logger.debug("Creating a router for account=" + accountId + "; publicIpAddress=" + publicIpAddress + "; dc=" + dataCenterId + "domain=" + domain);
|
||||
}
|
||||
|
||||
final AccountVO account = _accountDao.acquire(accountId);
|
||||
final AccountVO account = _accountDao.acquireInLockTable(accountId);
|
||||
if (account == null) {
|
||||
throw new ConcurrentOperationException("Unable to acquire account " + accountId);
|
||||
}
|
||||
|
|
@ -570,7 +570,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, VirtualMach
|
|||
if (account != null) {
|
||||
if(s_logger.isDebugEnabled())
|
||||
s_logger.debug("Releasing lock on account " + account.getId() + " for createRouter");
|
||||
_accountDao.release(account.getId());
|
||||
_accountDao.releaseFromLockTable(account.getId());
|
||||
}
|
||||
if(!success){
|
||||
EventVO event = new EventVO();
|
||||
|
|
@ -592,7 +592,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, VirtualMach
|
|||
s_logger.debug("Attempting to destroy router " + routerId);
|
||||
}
|
||||
|
||||
DomainRouterVO router = _routerDao.acquire(routerId);
|
||||
DomainRouterVO router = _routerDao.acquireInLockTable(routerId);
|
||||
|
||||
if (router == null) {
|
||||
s_logger.debug("Unable to acquire lock on router " + routerId);
|
||||
|
|
@ -628,7 +628,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, VirtualMach
|
|||
} finally {
|
||||
if (s_logger.isDebugEnabled())
|
||||
s_logger.debug("Release lock on router " + routerId + " for stop");
|
||||
_routerDao.release(routerId);
|
||||
_routerDao.releaseFromLockTable(routerId);
|
||||
}
|
||||
|
||||
router.setPublicIpAddress(null);
|
||||
|
|
@ -774,7 +774,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, VirtualMach
|
|||
_asyncMgr.updateAsyncJobAttachment(job.getId(), "domain_router", routerId);
|
||||
}
|
||||
|
||||
DomainRouterVO router = _routerDao.acquire(routerId);
|
||||
DomainRouterVO router = _routerDao.acquireInLockTable(routerId);
|
||||
if (router == null) {
|
||||
s_logger.debug("Unable to lock the router " + routerId);
|
||||
return router;
|
||||
|
|
@ -1084,7 +1084,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, VirtualMach
|
|||
if (router != null) {
|
||||
if(s_logger.isDebugEnabled())
|
||||
s_logger.debug("Releasing lock on router " + routerId);
|
||||
_routerDao.release(routerId);
|
||||
_routerDao.releaseFromLockTable(routerId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1117,10 +1117,15 @@ public class DomainRouterManagerImpl implements DomainRouterManager, VirtualMach
|
|||
ipAddrList.add(ipVO.getAddress());
|
||||
}
|
||||
if (!ipAddrList.isEmpty()) {
|
||||
final boolean success = _networkMgr.associateIP(router, ipAddrList, true, 0);
|
||||
if (!success) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
final boolean success = _networkMgr.associateIP(router, ipAddrList, true, 0);
|
||||
if (!success) {
|
||||
return false;
|
||||
}
|
||||
} catch (ConcurrentOperationException e) {
|
||||
s_logger.warn("unable to associate ip due to ", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
final List<FirewallRuleVO> fwRules = new ArrayList<FirewallRuleVO>();
|
||||
for (final IPAddressVO ipVO : ipAddrs) {
|
||||
|
|
@ -1600,7 +1605,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, VirtualMach
|
|||
public boolean stop(DomainRouterVO router, long eventId) {
|
||||
long routerId = router.getId();
|
||||
|
||||
router = _routerDao.acquire(routerId);
|
||||
router = _routerDao.acquireInLockTable(routerId);
|
||||
if (router == null) {
|
||||
s_logger.debug("Unable to acquire lock on router " + routerId);
|
||||
return false;
|
||||
|
|
@ -1691,7 +1696,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, VirtualMach
|
|||
} finally {
|
||||
if(s_logger.isDebugEnabled())
|
||||
s_logger.debug("Release lock on router " + routerId + " for stop");
|
||||
_routerDao.release(routerId);
|
||||
_routerDao.releaseFromLockTable(routerId);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -2013,7 +2018,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, VirtualMach
|
|||
|
||||
DataCenterDeployment plan = new DataCenterDeployment(dcId, 1);
|
||||
|
||||
guestConfig = _networkConfigurationDao.lock(guestConfig.getId(), true);
|
||||
guestConfig = _networkConfigurationDao.lockRow(guestConfig.getId(), true);
|
||||
if (guestConfig == null) {
|
||||
throw new ConcurrentOperationException("Unable to get the lock on " + guestConfig);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -322,7 +322,7 @@ public class NetworkGroupManagerImpl implements NetworkGroupManager {
|
|||
NetworkGroupWorkVO work = null;
|
||||
UserVm vm = null;
|
||||
try {
|
||||
vm = _userVMDao.acquire(vmId);
|
||||
vm = _userVMDao.acquireInLockTable(vmId);
|
||||
if (vm == null) {
|
||||
s_logger.warn("Failed to acquire lock on vm id " + vmId);
|
||||
continue;
|
||||
|
|
@ -348,7 +348,7 @@ public class NetworkGroupManagerImpl implements NetworkGroupManager {
|
|||
|
||||
} finally {
|
||||
if (vm != null) {
|
||||
_userVMDao.release(vmId);
|
||||
_userVMDao.releaseFromLockTable(vmId);
|
||||
}
|
||||
}
|
||||
txn.commit();
|
||||
|
|
@ -573,7 +573,7 @@ public class NetworkGroupManagerImpl implements NetworkGroupManager {
|
|||
return null;
|
||||
}
|
||||
//Prevents other threads/management servers from creating duplicate ingress rules
|
||||
NetworkGroupVO networkGroupLock = _networkGroupDao.acquire(networkGroup.getId());
|
||||
NetworkGroupVO networkGroupLock = _networkGroupDao.acquireInLockTable(networkGroup.getId());
|
||||
if (networkGroupLock == null) {
|
||||
s_logger.warn("Could not acquire lock on network security group: name= " + groupName);
|
||||
return null;
|
||||
|
|
@ -581,7 +581,7 @@ public class NetworkGroupManagerImpl implements NetworkGroupManager {
|
|||
List<IngressRuleVO> newRules = new ArrayList<IngressRuleVO>();
|
||||
try {
|
||||
//Don't delete the group from under us.
|
||||
networkGroup = _networkGroupDao.lock(networkGroup.getId(), false);
|
||||
networkGroup = _networkGroupDao.lockRow(networkGroup.getId(), false);
|
||||
if (networkGroup == null) {
|
||||
s_logger.warn("Could not acquire lock on network group " + groupName);
|
||||
return null;
|
||||
|
|
@ -591,7 +591,7 @@ public class NetworkGroupManagerImpl implements NetworkGroupManager {
|
|||
final Long ngId = ngVO.getId();
|
||||
//Don't delete the referenced group from under us
|
||||
if (ngVO.getId() != networkGroup.getId()) {
|
||||
final NetworkGroupVO tmpGrp = _networkGroupDao.lock(ngId, false);
|
||||
final NetworkGroupVO tmpGrp = _networkGroupDao.lockRow(ngId, false);
|
||||
if (tmpGrp == null) {
|
||||
s_logger.warn("Failed to acquire lock on network group: " + ngId);
|
||||
txn.rollback();
|
||||
|
|
@ -628,7 +628,7 @@ public class NetworkGroupManagerImpl implements NetworkGroupManager {
|
|||
throw new CloudRuntimeException("Exception caught when adding ingress rules", e);
|
||||
} finally {
|
||||
if (networkGroupLock != null) {
|
||||
_networkGroupDao.release(networkGroupLock.getId());
|
||||
_networkGroupDao.releaseFromLockTable(networkGroupLock.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -809,7 +809,7 @@ public class NetworkGroupManagerImpl implements NetworkGroupManager {
|
|||
try {
|
||||
txn.start();
|
||||
|
||||
networkGroupHandle = _networkGroupDao.acquire(networkGroupHandle.getId());
|
||||
networkGroupHandle = _networkGroupDao.acquireInLockTable(networkGroupHandle.getId());
|
||||
if (networkGroupHandle == null) {
|
||||
s_logger.warn("Could not acquire lock on network security group: name= " + networkGroup);
|
||||
return false;
|
||||
|
|
@ -832,7 +832,7 @@ public class NetworkGroupManagerImpl implements NetworkGroupManager {
|
|||
throw new CloudRuntimeException("Exception caught when deleting ingress rules", e);
|
||||
} finally {
|
||||
if (networkGroup != null) {
|
||||
_networkGroupDao.release(networkGroupHandle.getId());
|
||||
_networkGroupDao.releaseFromLockTable(networkGroupHandle.getId());
|
||||
}
|
||||
txn.commit();
|
||||
}
|
||||
|
|
@ -915,7 +915,7 @@ public class NetworkGroupManagerImpl implements NetworkGroupManager {
|
|||
AccountVO account = null;
|
||||
txn.start();
|
||||
try {
|
||||
account = _accountDao.acquire(accountId); //to ensure duplicate group names are not created.
|
||||
account = _accountDao.acquireInLockTable(accountId); //to ensure duplicate group names are not created.
|
||||
if (account == null) {
|
||||
s_logger.warn("Failed to acquire lock on account");
|
||||
return null;
|
||||
|
|
@ -928,7 +928,7 @@ public class NetworkGroupManagerImpl implements NetworkGroupManager {
|
|||
return group;
|
||||
} finally {
|
||||
if (account != null) {
|
||||
_accountDao.release(accountId);
|
||||
_accountDao.releaseFromLockTable(accountId);
|
||||
}
|
||||
txn.commit();
|
||||
}
|
||||
|
|
@ -1009,7 +1009,7 @@ public class NetworkGroupManagerImpl implements NetworkGroupManager {
|
|||
final Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
try {
|
||||
vm = _userVMDao.acquire(work.getInstanceId());
|
||||
vm = _userVMDao.acquireInLockTable(work.getInstanceId());
|
||||
if (vm == null) {
|
||||
s_logger.warn("Unable to acquire lock on vm id=" + userVmId);
|
||||
return ;
|
||||
|
|
@ -1039,7 +1039,7 @@ public class NetworkGroupManagerImpl implements NetworkGroupManager {
|
|||
}
|
||||
} finally {
|
||||
if (vm != null) {
|
||||
_userVMDao.release(userVmId);
|
||||
_userVMDao.releaseFromLockTable(userVmId);
|
||||
_workDao.updateStep(work.getId(), Step.Done);
|
||||
}
|
||||
txn.commit();
|
||||
|
|
@ -1059,14 +1059,14 @@ public class NetworkGroupManagerImpl implements NetworkGroupManager {
|
|||
uniqueGroups.addAll(groups);
|
||||
final Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
UserVm userVm = _userVMDao.acquire(userVmId); //ensures that duplicate entries are not created.
|
||||
UserVm userVm = _userVMDao.acquireInLockTable(userVmId); //ensures that duplicate entries are not created.
|
||||
if (userVm == null) {
|
||||
s_logger.warn("Failed to acquire lock on user vm id=" + userVmId);
|
||||
}
|
||||
try {
|
||||
for (NetworkGroupVO networkGroup:uniqueGroups) {
|
||||
//don't let the group be deleted from under us.
|
||||
NetworkGroupVO ngrpLock = _networkGroupDao.lock(networkGroup.getId(), false);
|
||||
NetworkGroupVO ngrpLock = _networkGroupDao.lockRow(networkGroup.getId(), false);
|
||||
if (ngrpLock == null) {
|
||||
s_logger.warn("Failed to acquire lock on network group id=" + networkGroup.getId() + " name=" + networkGroup.getName());
|
||||
txn.rollback();
|
||||
|
|
@ -1081,7 +1081,7 @@ public class NetworkGroupManagerImpl implements NetworkGroupManager {
|
|||
return true;
|
||||
} finally {
|
||||
if (userVm != null) {
|
||||
_userVMDao.release(userVmId);
|
||||
_userVMDao.releaseFromLockTable(userVmId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1099,13 +1099,13 @@ public class NetworkGroupManagerImpl implements NetworkGroupManager {
|
|||
}
|
||||
final Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
UserVm userVm = _userVMDao.acquire(userVmId); //ensures that duplicate entries are not created in addInstance
|
||||
UserVm userVm = _userVMDao.acquireInLockTable(userVmId); //ensures that duplicate entries are not created in addInstance
|
||||
if (userVm == null) {
|
||||
s_logger.warn("Failed to acquire lock on user vm id=" + userVmId);
|
||||
}
|
||||
int n = _networkGroupVMMapDao.deleteVM(userVmId);
|
||||
s_logger.info("Disassociated " + n + " network groups " + " from uservm " + userVmId);
|
||||
_userVMDao.release(userVmId);
|
||||
_userVMDao.releaseFromLockTable(userVmId);
|
||||
txn.commit();
|
||||
}
|
||||
|
||||
|
|
@ -1165,7 +1165,7 @@ public class NetworkGroupManagerImpl implements NetworkGroupManager {
|
|||
final Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
|
||||
final NetworkGroupVO group = _networkGroupDao.lock(groupId, true);
|
||||
final NetworkGroupVO group = _networkGroupDao.lockRow(groupId, true);
|
||||
if (group == null) {
|
||||
s_logger.info("Not deleting group -- cannot find id " + groupId);
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -5911,7 +5911,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
Transaction.currentTxn();
|
||||
String certificatePath = cmd.getPath();
|
||||
cert = _certDao.listAll().get(0); //always 1 record in db (from the deploydb time)
|
||||
cert = _certDao.acquire(cert.getId());
|
||||
cert = _certDao.acquireInLockTable(cert.getId());
|
||||
//assign mgmt server id to mark as processing under this ms
|
||||
if(cert == null){
|
||||
String msg = "Unable to obtain lock on the cert from uploadCertificate()";
|
||||
|
|
@ -6020,7 +6020,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
throw new ServerApiException(BaseCmd.CUSTOM_CERT_UPDATE_ERROR, msg);
|
||||
}
|
||||
}finally{
|
||||
_certDao.release(cert.getId());
|
||||
_certDao.releaseFromLockTable(cert.getId());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@ import com.cloud.agent.manager.Commands;
|
|||
import com.cloud.capacity.CapacityVO;
|
||||
import com.cloud.capacity.dao.CapacityDao;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.InternalErrorException;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.HostStats;
|
||||
import com.cloud.host.HostVO;
|
||||
|
|
@ -237,7 +236,7 @@ public class StatsCollector {
|
|||
}
|
||||
}
|
||||
|
||||
} catch (InternalErrorException e) {
|
||||
} catch (Exception e) {
|
||||
s_logger.debug("Failed to get VM stats for host with ID: " + host.getId());
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -732,7 +732,7 @@ public class StorageManagerImpl implements StorageManager {
|
|||
txn.start();
|
||||
|
||||
long podId = pod.getId();
|
||||
pod = _podDao.lock(podId, true);
|
||||
pod = _podDao.lockRow(podId, true);
|
||||
if (pod == null) {
|
||||
txn.rollback();
|
||||
volume.setStatus(AsyncInstanceCreateStatus.Failed);
|
||||
|
|
@ -1484,7 +1484,7 @@ public class StorageManagerImpl implements StorageManager {
|
|||
else {
|
||||
// First get the host_id from storage_pool_host_ref for given
|
||||
// pool id
|
||||
StoragePoolVO lock = _storagePoolDao.acquire(sPool.getId());
|
||||
StoragePoolVO lock = _storagePoolDao.acquireInLockTable(sPool.getId());
|
||||
try {
|
||||
if (lock == null) {
|
||||
s_logger.debug("Failed to acquire lock when deleting StoragePool with ID: " + sPool.getId());
|
||||
|
|
@ -1505,7 +1505,7 @@ public class StorageManagerImpl implements StorageManager {
|
|||
|
||||
} finally {
|
||||
if (lock != null) {
|
||||
_storagePoolDao.release(lock.getId());
|
||||
_storagePoolDao.releaseFromLockTable(lock.getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -240,7 +240,7 @@ public class SnapshotManagerImpl implements SnapshotManager {
|
|||
Long userId = UserContext.current().getUserId();
|
||||
SnapshotVO createdSnapshot = null;
|
||||
|
||||
VolumeVO volume = _volsDao.lock(volumeId, true);
|
||||
VolumeVO volume = _volsDao.lockRow(volumeId, true);
|
||||
if (volume == null) {
|
||||
throw new CloudRuntimeException("Failed to lock volume " + volumeId + " for creating a snapshot.");
|
||||
}
|
||||
|
|
@ -461,12 +461,12 @@ public class SnapshotManagerImpl implements SnapshotManager {
|
|||
long snapshotId = ss.getId();
|
||||
SnapshotVO snapshot = null;
|
||||
try {
|
||||
snapshot = _snapshotDao.acquire(snapshotId);
|
||||
snapshot = _snapshotDao.acquireInLockTable(snapshotId);
|
||||
snapshot.setStatus(Snapshot.Status.BackingUp);
|
||||
_snapshotDao.update(snapshot.getId(), snapshot);
|
||||
|
||||
long volumeId = snapshot.getVolumeId();
|
||||
VolumeVO volume = _volsDao.lock(volumeId, true);
|
||||
VolumeVO volume = _volsDao.lockRow(volumeId, true);
|
||||
|
||||
String primaryStoragePoolNameLabel = _storageMgr.getPrimaryStorageNameLabel(volume);
|
||||
Long dcId = volume.getDataCenterId();
|
||||
|
|
@ -608,7 +608,7 @@ public class SnapshotManagerImpl implements SnapshotManager {
|
|||
return backedUp;
|
||||
} finally {
|
||||
if( snapshot != null ) {
|
||||
_snapshotDao.release(snapshotId);
|
||||
_snapshotDao.releaseFromLockTable(snapshotId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -982,7 +982,7 @@ public class SnapshotManagerImpl implements SnapshotManager {
|
|||
} catch (EntityExistsException e ) {
|
||||
policy = _snapshotPolicyDao.findOneByVolume(volumeId);
|
||||
try {
|
||||
policy = _snapshotPolicyDao.acquire(policy.getId());
|
||||
policy = _snapshotPolicyDao.acquireInLockTable(policy.getId());
|
||||
policy.setSchedule(cmd.getSchedule());
|
||||
policy.setTimezone(timezoneId);
|
||||
policy.setInterval((short)type.ordinal());
|
||||
|
|
@ -991,7 +991,7 @@ public class SnapshotManagerImpl implements SnapshotManager {
|
|||
_snapshotPolicyDao.update(policy.getId(), policy);
|
||||
} finally {
|
||||
if( policy != null) {
|
||||
_snapshotPolicyDao.release(policy.getId());
|
||||
_snapshotPolicyDao.releaseFromLockTable(policy.getId());
|
||||
}
|
||||
}
|
||||
event.setType(EventTypes.EVENT_SNAPSHOT_POLICY_UPDATE);
|
||||
|
|
|
|||
|
|
@ -218,7 +218,7 @@ public class SnapshotSchedulerImpl implements SnapshotScheduler {
|
|||
long snapshotScheId = snapshotToBeExecuted.getId();
|
||||
SnapshotScheduleVO tmpSnapshotScheduleVO = null;
|
||||
try {
|
||||
tmpSnapshotScheduleVO = _snapshotScheduleDao.acquire(snapshotScheId);
|
||||
tmpSnapshotScheduleVO = _snapshotScheduleDao.acquireInLockTable(snapshotScheId);
|
||||
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
params.put("volumeid", ""+volumeId);
|
||||
|
|
@ -237,7 +237,7 @@ public class SnapshotSchedulerImpl implements SnapshotScheduler {
|
|||
_snapshotScheduleDao.update(snapshotScheId, tmpSnapshotScheduleVO);
|
||||
} finally {
|
||||
if (tmpSnapshotScheduleVO != null) {
|
||||
_snapshotScheduleDao.release(snapshotScheId);
|
||||
_snapshotScheduleDao.releaseFromLockTable(snapshotScheId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -269,13 +269,13 @@ public class SnapshotSchedulerImpl implements SnapshotScheduler {
|
|||
} catch (EntityExistsException e ) {
|
||||
snapshotScheduleVO = _snapshotScheduleDao.findOneByVolume(policyInstance.getVolumeId());
|
||||
try {
|
||||
snapshotScheduleVO = _snapshotScheduleDao.acquire(snapshotScheduleVO.getId());
|
||||
snapshotScheduleVO = _snapshotScheduleDao.acquireInLockTable(snapshotScheduleVO.getId());
|
||||
snapshotScheduleVO.setPolicyId(policyId);
|
||||
snapshotScheduleVO.setScheduledTimestamp(nextSnapshotTimestamp);
|
||||
_snapshotScheduleDao.update(snapshotScheduleVO.getId(), snapshotScheduleVO);
|
||||
} finally {
|
||||
if(snapshotScheduleVO != null ) {
|
||||
_snapshotScheduleDao.release(snapshotScheduleVO.getId());
|
||||
_snapshotScheduleDao.releaseFromLockTable(snapshotScheduleVO.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -619,7 +619,7 @@ public class TemplateManagerImpl implements TemplateManager {
|
|||
|
||||
List<StoragePoolHostVO> vos = _poolHostDao.listByPoolId(poolId);
|
||||
|
||||
templateStoragePoolRef = _tmpltPoolDao.acquire(templateStoragePoolRefId, 1200);
|
||||
templateStoragePoolRef = _tmpltPoolDao.acquireInLockTable(templateStoragePoolRefId, 1200);
|
||||
if (templateStoragePoolRef == null) {
|
||||
throw new CloudRuntimeException("Unable to acquire lock on VMTemplateStoragePool: " + templateStoragePoolRefId);
|
||||
}
|
||||
|
|
@ -658,7 +658,7 @@ public class TemplateManagerImpl implements TemplateManager {
|
|||
}
|
||||
}
|
||||
} finally {
|
||||
_tmpltPoolDao.release(templateStoragePoolRefId);
|
||||
_tmpltPoolDao.releaseFromLockTable(templateStoragePoolRefId);
|
||||
}
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Template " + templateId + " is not found on and can not be downloaded to pool " + poolId);
|
||||
|
|
@ -738,7 +738,7 @@ public class TemplateManagerImpl implements TemplateManager {
|
|||
try {
|
||||
dstTmpltHost = _tmpltHostDao.findByHostTemplate(dstSecHost.getId(), templateId, true);
|
||||
if (dstTmpltHost != null) {
|
||||
dstTmpltHost = _tmpltHostDao.lock(dstTmpltHost.getId(), true);
|
||||
dstTmpltHost = _tmpltHostDao.lockRow(dstTmpltHost.getId(), true);
|
||||
if (dstTmpltHost != null && dstTmpltHost.getDownloadState() == Status.DOWNLOADED) {
|
||||
if (dstTmpltHost.getDestroyed() == false) {
|
||||
return true;
|
||||
|
|
@ -894,7 +894,7 @@ public class TemplateManagerImpl implements TemplateManager {
|
|||
long sZoneId = secondaryStorageHost.getDataCenterId();
|
||||
List<VMTemplateHostVO> templateHostVOs = _tmpltHostDao.listByHostTemplate(hostId, templateId);
|
||||
for (VMTemplateHostVO templateHostVO : templateHostVOs) {
|
||||
VMTemplateHostVO lock = _tmpltHostDao.acquire(templateHostVO.getId());
|
||||
VMTemplateHostVO lock = _tmpltHostDao.acquireInLockTable(templateHostVO.getId());
|
||||
|
||||
try {
|
||||
if (lock == null) {
|
||||
|
|
@ -915,7 +915,7 @@ public class TemplateManagerImpl implements TemplateManager {
|
|||
saveEvent(userId, account.getId(), account.getDomainId(), eventType, description + template.getName() + " succesfully deleted.", EventVO.LEVEL_INFO, zoneParams, 0);
|
||||
} finally {
|
||||
if (lock != null) {
|
||||
_tmpltHostDao.release(lock.getId());
|
||||
_tmpltHostDao.releaseFromLockTable(lock.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -931,7 +931,7 @@ public class TemplateManagerImpl implements TemplateManager {
|
|||
if (success && (_tmpltHostDao.listByTemplateId(templateId).size() == 0)) {
|
||||
long accountId = template.getAccountId();
|
||||
|
||||
VMTemplateVO lock = _tmpltDao.acquire(templateId);
|
||||
VMTemplateVO lock = _tmpltDao.acquireInLockTable(templateId);
|
||||
|
||||
try {
|
||||
if (lock == null) {
|
||||
|
|
@ -944,7 +944,7 @@ public class TemplateManagerImpl implements TemplateManager {
|
|||
|
||||
} finally {
|
||||
if (lock != null) {
|
||||
_tmpltDao.release(lock.getId());
|
||||
_tmpltDao.releaseFromLockTable(lock.getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ import com.cloud.async.executor.VMOperationParam;
|
|||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientStorageCapacityException;
|
||||
import com.cloud.exception.InternalErrorException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.StorageUnavailableException;
|
||||
import com.cloud.network.security.NetworkGroupVO;
|
||||
|
|
@ -72,11 +71,11 @@ public interface UserVmManager extends Manager, VirtualMachineManager<UserVmVO>
|
|||
* @param diskOffering the disk offering for the root disk (deploying from ISO) or the data disk (deploying from a normal template)
|
||||
* @return UserVmVO if created; null if not.
|
||||
*/
|
||||
UserVmVO createVirtualMachine(Long vmId, long userId, AccountVO account, DataCenterVO dc, ServiceOfferingVO offering, VMTemplateVO template, DiskOfferingVO diskOffering, String displayName, String userData, List<StoragePoolVO> avoids, long startEventId, long size) throws InsufficientStorageCapacityException, InternalErrorException, ResourceAllocationException;
|
||||
UserVmVO createVirtualMachine(Long vmId, long userId, AccountVO account, DataCenterVO dc, ServiceOfferingVO offering, VMTemplateVO template, DiskOfferingVO diskOffering, String displayName, String userData, List<StoragePoolVO> avoids, long startEventId, long size) throws InsufficientStorageCapacityException, ResourceAllocationException;
|
||||
|
||||
UserVmVO createDirectlyAttachedVM(Long vmId, long userId, AccountVO account, DataCenterVO dc, ServiceOfferingVO offering, VMTemplateVO template, DiskOfferingVO diskOffering, String displayName, String userData, List<StoragePoolVO> a, List<NetworkGroupVO> networkGroupVO, long startEventId, long size) throws InternalErrorException, ResourceAllocationException;
|
||||
UserVmVO createDirectlyAttachedVM(Long vmId, long userId, AccountVO account, DataCenterVO dc, ServiceOfferingVO offering, VMTemplateVO template, DiskOfferingVO diskOffering, String displayName, String userData, List<StoragePoolVO> a, List<NetworkGroupVO> networkGroupVO, long startEventId, long size) throws ResourceAllocationException;
|
||||
|
||||
UserVmVO createDirectlyAttachedVMExternal(Long vmId, long userId, AccountVO account, DataCenterVO dc, ServiceOfferingVO offering, VMTemplateVO template, DiskOfferingVO diskOffering, String displayName, String userData, List<StoragePoolVO> a, List<NetworkGroupVO> networkGroupVO, long startEventId, long size) throws InternalErrorException, ResourceAllocationException;
|
||||
UserVmVO createDirectlyAttachedVMExternal(Long vmId, long userId, AccountVO account, DataCenterVO dc, ServiceOfferingVO offering, VMTemplateVO template, DiskOfferingVO diskOffering, String displayName, String userData, List<StoragePoolVO> a, List<NetworkGroupVO> networkGroupVO, long startEventId, long size) throws ResourceAllocationException;
|
||||
|
||||
boolean destroyVirtualMachine(long userId, long vmId);
|
||||
// OperationResponse executeDestroyVM(DestroyVMExecutor executor, VMOperationParam param);
|
||||
|
|
@ -132,9 +131,8 @@ public interface UserVmManager extends Manager, VirtualMachineManager<UserVmVO>
|
|||
* @param host name
|
||||
* @param list of VM IDs or host id
|
||||
* @return GetVmStatsAnswer
|
||||
* @throws InternalErrorException
|
||||
*/
|
||||
HashMap<Long, VmStatsEntry> getVirtualMachineStatistics(long hostId, String hostName, List<Long> vmIds) throws InternalErrorException;
|
||||
HashMap<Long, VmStatsEntry> getVirtualMachineStatistics(long hostId, String hostName, List<Long> vmIds);
|
||||
|
||||
boolean destroyTemplateSnapshot(Long userId, long snapshotId);
|
||||
|
||||
|
|
|
|||
|
|
@ -987,7 +987,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
|||
List<VolumeVO> vos = new ArrayList<VolumeVO>();
|
||||
/*compete with take snapshot*/
|
||||
for (VolumeVO userVmVol : vols) {
|
||||
vos.add(_volsDao.lock(userVmVol.getId(), true));
|
||||
vos.add(_volsDao.lockRow(userVmVol.getId(), true));
|
||||
}
|
||||
|
||||
Answer answer = null;
|
||||
|
|
@ -1482,7 +1482,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
|||
Transaction txn = Transaction.currentTxn();
|
||||
try {
|
||||
txn.start();
|
||||
router = _routerDao.acquire(routerId);
|
||||
router = _routerDao.acquireInLockTable(routerId);
|
||||
if (router == null) {
|
||||
throw new CloudRuntimeException("Unable to lock up the router:" + routerId);
|
||||
}
|
||||
|
|
@ -1513,13 +1513,13 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
|||
_vmDao.update(userVm.getId(), userVm);
|
||||
txn.commit();
|
||||
if (routerLock) {
|
||||
_routerDao.release(routerId);
|
||||
_routerDao.releaseFromLockTable(routerId);
|
||||
routerLock = false;
|
||||
}
|
||||
return ipAddressStr;
|
||||
}finally {
|
||||
if (routerLock) {
|
||||
_routerDao.release(routerId);
|
||||
_routerDao.releaseFromLockTable(routerId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1591,7 +1591,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
|||
String name;
|
||||
txn.start();
|
||||
|
||||
account = _accountDao.lock(accountId, true);
|
||||
account = _accountDao.lockRow(accountId, true);
|
||||
if (account == null) {
|
||||
throw new CloudRuntimeException("Unable to lock up the account: " + accountId);
|
||||
}
|
||||
|
|
@ -1934,7 +1934,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
|||
AccountVO account = null;
|
||||
txn.start();
|
||||
|
||||
account = _accountDao.lock(vm.getAccountId(), true);
|
||||
account = _accountDao.lockRow(vm.getAccountId(), true);
|
||||
|
||||
//if the account is deleted, throw error
|
||||
if(account.getRemoved()!=null)
|
||||
|
|
@ -2785,7 +2785,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
|||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
|
||||
account = _accountDao.lock(accountId, true);
|
||||
account = _accountDao.lockRow(accountId, true);
|
||||
if (account == null) {
|
||||
throw new CloudRuntimeException("Unable to lock up the account: " + accountId);
|
||||
}
|
||||
|
|
@ -3042,7 +3042,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
|||
UserVmVO vm = null;
|
||||
txn.start();
|
||||
|
||||
account = _accountDao.lock(accountId, true);
|
||||
account = _accountDao.lockRow(accountId, true);
|
||||
if (account == null) {
|
||||
throw new CloudRuntimeException("Unable to lock up the account: " + accountId);
|
||||
}
|
||||
|
|
@ -3428,7 +3428,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
|||
final Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
try {
|
||||
account = _accountDao.acquire(accountId); //to ensure duplicate vm group names are not created.
|
||||
account = _accountDao.acquireInLockTable(accountId); //to ensure duplicate vm group names are not created.
|
||||
if (account == null) {
|
||||
s_logger.warn("Failed to acquire lock on account");
|
||||
return null;
|
||||
|
|
@ -3441,7 +3441,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
|||
return group;
|
||||
} finally {
|
||||
if (account != null) {
|
||||
_accountDao.release(accountId);
|
||||
_accountDao.releaseFromLockTable(accountId);
|
||||
}
|
||||
txn.commit();
|
||||
}
|
||||
|
|
@ -3500,13 +3500,13 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
|||
if (group != null) {
|
||||
final Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
UserVm userVm = _vmDao.acquire(userVmId);
|
||||
UserVm userVm = _vmDao.acquireInLockTable(userVmId);
|
||||
if (userVm == null) {
|
||||
s_logger.warn("Failed to acquire lock on user vm id=" + userVmId);
|
||||
}
|
||||
try {
|
||||
//don't let the group be deleted when we are assigning vm to it.
|
||||
InstanceGroupVO ngrpLock = _vmGroupDao.lock(group.getId(), false);
|
||||
InstanceGroupVO ngrpLock = _vmGroupDao.lockRow(group.getId(), false);
|
||||
if (ngrpLock == null) {
|
||||
s_logger.warn("Failed to acquire lock on vm group id=" + group.getId() + " name=" + group.getName());
|
||||
txn.rollback();
|
||||
|
|
@ -3530,7 +3530,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
|||
return true;
|
||||
} finally {
|
||||
if (userVm != null) {
|
||||
_vmDao.release(userVmId);
|
||||
_vmDao.releaseFromLockTable(userVmId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ import com.cloud.async.executor.RebootVMExecutor;
|
|||
import com.cloud.async.executor.VMOperationParam;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InternalErrorException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
|
|
@ -66,7 +65,7 @@ public interface UserVmService extends Manager {
|
|||
/**
|
||||
* Attaches the specified volume to the specified VM
|
||||
* @param cmd - the command specifying volumeId and vmId
|
||||
* @throws InternalErrorException, InvalidParameterValueException, PermissionDeniedException
|
||||
* @throws InvalidParameterValueException, PermissionDeniedException
|
||||
*/
|
||||
void attachVolumeToVM(AttachVolumeCmd cmd);
|
||||
|
||||
|
|
@ -74,7 +73,6 @@ public interface UserVmService extends Manager {
|
|||
* Detaches the specified volume from the VM it is currently attached to.
|
||||
* @param cmd - the command specifying volumeId
|
||||
* @return the VolumeResponse object if detach worked successfully.
|
||||
* @throws InternalErrorException
|
||||
* @throws InvalidParameterValueException
|
||||
*/
|
||||
VolumeResponse detachVolumeFromVM(DetachVolumeCmd cmmd);
|
||||
|
|
|
|||
|
|
@ -198,14 +198,14 @@ public class TestAsyncJobManager extends ComponentTestCase {
|
|||
while(true) {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
try {
|
||||
HostVO host = hostDao.acquire(getRandomLockId(), 10);
|
||||
HostVO host = hostDao.acquireInLockTable(getRandomLockId(), 10);
|
||||
if(host != null) {
|
||||
s_logger.info("Thread " + (current + 1) + " acquired lock");
|
||||
|
||||
try { Thread.sleep(getRandomMilliseconds(1000, 5000)); } catch (InterruptedException e) {}
|
||||
|
||||
s_logger.info("Thread " + (current + 1) + " released lock");
|
||||
hostDao.release(host.getId());
|
||||
hostDao.releaseFromLockTable(host.getId());
|
||||
|
||||
try { Thread.sleep(getRandomMilliseconds(1000, 5000)); } catch (InterruptedException e) {}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ public interface GenericDao<T, ID extends Serializable> {
|
|||
* @param exclusive exclusive or share lock
|
||||
* @return List<T> list of entity beans
|
||||
*/
|
||||
List<T> lock(SearchCriteria<T> sc, Filter filter, boolean exclusive);
|
||||
List<T> lockRows(SearchCriteria<T> sc, Filter filter, boolean exclusive);
|
||||
|
||||
/**
|
||||
* lock 1 of the return set. This method needs to be run within a
|
||||
|
|
@ -85,7 +85,7 @@ public interface GenericDao<T, ID extends Serializable> {
|
|||
* @param exclusive
|
||||
* @return T if found and locked. null if not.
|
||||
*/
|
||||
T lock(SearchCriteria<T> sc, boolean exclusive);
|
||||
T lockOneRandomRow(SearchCriteria<T> sc, boolean exclusive);
|
||||
|
||||
/**
|
||||
* Find and lock the row for update.
|
||||
|
|
@ -93,7 +93,7 @@ public interface GenericDao<T, ID extends Serializable> {
|
|||
* @param exclusive is this a read share lock or exclusive lock?
|
||||
* @return T
|
||||
*/
|
||||
T lock(ID id, Boolean exclusive);
|
||||
T lockRow(ID id, Boolean exclusive);
|
||||
|
||||
/**
|
||||
* Acquires a database wide lock on the id of the entity. This ensures
|
||||
|
|
@ -102,7 +102,7 @@ public interface GenericDao<T, ID extends Serializable> {
|
|||
* @param id id of the entity to acquire an lock on.
|
||||
* @return object if acquired; null if not. If null, you need to call findById to see if it is actually not found.
|
||||
*/
|
||||
T acquire(ID id);
|
||||
T acquireInLockTable(ID id);
|
||||
|
||||
/**
|
||||
* Acquires a database wide lock on the id of the entity. This ensures
|
||||
|
|
@ -112,14 +112,14 @@ public interface GenericDao<T, ID extends Serializable> {
|
|||
* @param seconds time to wait for the lock.
|
||||
* @return entity if the lock is acquired; null if not.
|
||||
*/
|
||||
T acquire(ID id, int seconds);
|
||||
T acquireInLockTable(ID id, int seconds);
|
||||
|
||||
/**
|
||||
* releases the lock acquired in the acquire method call.
|
||||
* @param id id of the entity to release the lock on.
|
||||
* @return true if it is released. false if not or not found.
|
||||
*/
|
||||
boolean release(final ID id);
|
||||
boolean releaseFromLockTable(final ID id);
|
||||
|
||||
boolean update(ID id, T entity);
|
||||
|
||||
|
|
|
|||
|
|
@ -278,12 +278,12 @@ public abstract class GenericDaoBase<T, ID extends Serializable> implements Gene
|
|||
}
|
||||
|
||||
@Override @DB(txn=false)
|
||||
public List<T> lock(final SearchCriteria<T> sc, final Filter filter, final boolean exclusive) {
|
||||
public List<T> lockRows(final SearchCriteria<T> sc, final Filter filter, final boolean exclusive) {
|
||||
return search(sc, filter, exclusive, false);
|
||||
}
|
||||
|
||||
@Override @DB(txn=false)
|
||||
public T lock(final SearchCriteria<T> sc, final boolean exclusive) {
|
||||
public T lockOneRandomRow(final SearchCriteria<T> sc, final boolean exclusive) {
|
||||
final Filter filter = new Filter(1);
|
||||
final List<T> beans = search(sc, filter, exclusive, true);
|
||||
return beans.isEmpty() ? null : beans.get(0);
|
||||
|
|
@ -784,9 +784,9 @@ public abstract class GenericDaoBase<T, ID extends Serializable> implements Gene
|
|||
public T findById(final ID id) {
|
||||
if (_cache != null) {
|
||||
final Element element = _cache.get(id);
|
||||
return element == null ? lock(id, null) : (T)element.getObjectValue();
|
||||
return element == null ? lockRow(id, null) : (T)element.getObjectValue();
|
||||
} else {
|
||||
return lock(id, null);
|
||||
return lockRow(id, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -803,11 +803,11 @@ public abstract class GenericDaoBase<T, ID extends Serializable> implements Gene
|
|||
if (_cache != null) {
|
||||
_cache.remove(id);
|
||||
}
|
||||
return lock(id, null);
|
||||
return lockRow(id, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T lock(ID id, Boolean lock) {
|
||||
public T lockRow(ID id, Boolean lock) {
|
||||
return findById(id, false, lock);
|
||||
}
|
||||
|
||||
|
|
@ -836,12 +836,12 @@ public abstract class GenericDaoBase<T, ID extends Serializable> implements Gene
|
|||
}
|
||||
|
||||
@Override @DB(txn=false)
|
||||
public T acquire(ID id) {
|
||||
return acquire(id, _timeoutSeconds);
|
||||
public T acquireInLockTable(ID id) {
|
||||
return acquireInLockTable(id, _timeoutSeconds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T acquire(final ID id, int seconds) {
|
||||
public T acquireInLockTable(final ID id, int seconds) {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
T t = null;
|
||||
boolean locked = false;
|
||||
|
|
@ -861,7 +861,7 @@ public abstract class GenericDaoBase<T, ID extends Serializable> implements Gene
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean release(final ID id) {
|
||||
public boolean releaseFromLockTable(final ID id) {
|
||||
final Transaction txn = Transaction.currentTxn();
|
||||
return txn.release(_table + id);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue