@Override public PublicIp doInTransaction(TransactionStatus status) throws InsufficientAddressCapacityException { Account owner = _accountDao.acquireInLockTable(ownerId); if (owner == null) { // this ownerId comes from owner or type Account. See the class "AccountVO" and the annotations in that class // to get the table name and field name that is queried to fill this ownerid. ConcurrentOperationException ex = new ConcurrentOperationException("Unable to lock account"); throw ex; } if (s_logger.isDebugEnabled()) { s_logger.debug("lock account " + ownerId + " is acquired"); } boolean displayIp = true; if (guestNtwkId != null) { Network ntwk = _networksDao.findById(guestNtwkId); displayIp = ntwk.getDisplayNetwork(); } else if (vpcId != null) { VpcVO vpc = _vpcDao.findById(vpcId); displayIp = vpc.isDisplay(); } return fetchNewPublicIp(dcId, null, null, owner, VlanType.VirtualNetwork, guestNtwkId, isSourceNat, true, null, false, vpcId, displayIp, false); } });
@DB private InstanceGroupVO createVmGroup(String groupName, long accountId) { Account account = null; try { 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; } InstanceGroupVO group = _vmGroupDao.findByAccountAndName(accountId, groupName); if (group == null) { group = new InstanceGroupVO(groupName, accountId); group = _vmGroupDao.persist(group); } return group; } finally { if (account != null) { _accountDao.releaseFromLockTable(accountId); } } }
s_logger.debug("Associate IP address called by the user " + callerUserId + " account " + ipOwner.getId()); accountToLock = _accountDao.acquireInLockTable(ipOwner.getId()); if (accountToLock == null) { s_logger.warn("Unable to lock account: " + ipOwner.getId());
public LoadBalancer handleCreateLoadBalancerRule(final CreateLoadBalancerRuleCmd lb, Account account, final long networkId) throws InsufficientAddressCapacityException, NetworkRuleConflictException { //this part of code is executed when the LB provider is Elastic Load Balancer vm if (!_networkModel.isProviderSupportServiceInNetwork(lb.getNetworkId(), Service.Lb, Provider.ElasticLoadBalancerVm)) { return null; } final Long ipId = lb.getSourceIpAddressId(); if (ipId != null) { return null; } account = _accountDao.acquireInLockTable(account.getId()); if (account == null) { s_logger.warn("ELB: CreateLoadBalancer: Failed to acquire lock on account"); throw new CloudRuntimeException("Failed to acquire lock on account"); } try { return handleCreateLoadBalancerRuleWithLock(lb, account, networkId); } finally { if (account != null) { _accountDao.releaseFromLockTable(account.getId()); } } }
final Boolean isDisplayNetworkEnabled) throws ConcurrentOperationException { final Account locked = _accountDao.acquireInLockTable(owner.getId()); if (locked == null) { throw new ConcurrentOperationException("Unable to acquire lock on " + owner);