本文整理汇总了Java中com.cloud.utils.db.GlobalLock.releaseRef方法的典型用法代码示例。如果您正苦于以下问题:Java GlobalLock.releaseRef方法的具体用法?Java GlobalLock.releaseRef怎么用?Java GlobalLock.releaseRef使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.cloud.utils.db.GlobalLock
的用法示例。
在下文中一共展示了GlobalLock.releaseRef方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runInContext
import com.cloud.utils.db.GlobalLock; //导入方法依赖的package包/类
@Override
protected void runInContext() {
try {
final GlobalLock scanLock = GlobalLock.getInternLock("uploadmonitor.storageGC");
try {
if (scanLock.lock(3)) {
try {
cleanupStorage();
} finally {
scanLock.unlock();
}
}
} finally {
scanLock.releaseRef();
}
} catch (final Exception e) {
s_logger.error("Caught the following Exception", e);
}
}
示例2: check
import com.cloud.utils.db.GlobalLock; //导入方法依赖的package包/类
@Override
public void check() {
GlobalLock lock = GlobalLock.getInternLock("DatabaseIntegrity");
try {
s_logger.info("Grabbing lock to check for database integrity.");
if (!lock.lock(20 * 60)) {
throw new CloudRuntimeException("Unable to acquire lock to check for database integrity.");
}
try {
s_logger.info("Performing database integrity check");
if (!checkDuplicateHostWithTheSameLocalStorage()) {
throw new CloudRuntimeException("checkDuplicateHostWithTheSameLocalStorage detected error");
}
if (!checkMissedPremiumUpgradeFor228()) {
s_logger.error("Your current database version is 2.2.8, management server detected some missed premium upgrade, please contact CloudStack support and attach log file. Thank you!");
throw new CloudRuntimeException("Detected missed premium upgrade");
}
} finally {
lock.unlock();
}
} finally {
lock.releaseRef();
}
}
示例3: runInContext
import com.cloud.utils.db.GlobalLock; //导入方法依赖的package包/类
@Override
protected void runInContext() {
// Check if there are any external devices
// Skip external device usage collection if none exist
if(_hostDao.listByType(Host.Type.ExternalFirewall).isEmpty() && _hostDao.listByType(Host.Type.ExternalLoadBalancer).isEmpty()){
s_logger.debug("External devices are not used. Skipping external device usage collection");
return;
}
GlobalLock scanLock = GlobalLock.getInternLock("ExternalDeviceNetworkUsageManagerImpl");
try {
if (scanLock.lock(20)) {
try {
runExternalDeviceNetworkUsageTask();
} finally {
scanLock.unlock();
}
}
} catch (Exception e) {
s_logger.warn("Problems while getting external device usage", e);
} finally {
scanLock.releaseRef();
}
}
示例4: freeFirewallForNetwork
import com.cloud.utils.db.GlobalLock; //导入方法依赖的package包/类
@DB
protected boolean freeFirewallForNetwork(Network network) {
GlobalLock deviceMapLock = GlobalLock.getInternLock("NetworkFirewallDeviceMap");
try {
if (deviceMapLock.lock(120)) {
try {
NetworkExternalFirewallVO fwDeviceForNetwork = _networkExternalFirewallDao.findByNetworkId(network.getId());
if (fwDeviceForNetwork != null) {
_networkExternalFirewallDao.remove(fwDeviceForNetwork.getId());
}
} catch (Exception exception) {
s_logger.error("Failed to release firewall device for the network" + network.getId() + " due to " + exception.getMessage());
return false;
} finally {
deviceMapLock.unlock();
}
}
} finally {
deviceMapLock.releaseRef();
}
return true;
}
示例5: runInContext
import com.cloud.utils.db.GlobalLock; //导入方法依赖的package包/类
@Override
protected void runInContext() {
try {
GlobalLock scanLock = GlobalLock.getInternLock("uploadmonitor.storageGC");
try {
if (scanLock.lock(3)) {
try {
cleanupStorage();
} finally {
scanLock.unlock();
}
}
} finally {
scanLock.releaseRef();
}
} catch (Exception e) {
s_logger.error("Caught the following Exception", e);
}
}
示例6: configure
import com.cloud.utils.db.GlobalLock; //导入方法依赖的package包/类
@Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
super.configure(name, params);
Security.addProvider(new BouncyCastleProvider());
final GlobalLock caLock = GlobalLock.getInternLock("RootCAProviderSetup");
try {
if (caLock.lock(5 * 60)) {
try {
return setupCA();
} finally {
caLock.unlock();
}
} else {
LOG.error("Failed to grab lock and setup CA, startup method will try to load the CA certificate and keypair.");
}
} finally {
caLock.releaseRef();
}
return true;
}
示例7: cancelWorkItems
import com.cloud.utils.db.GlobalLock; //导入方法依赖的package包/类
protected void cancelWorkItems(final long nodeId) {
final GlobalLock scanLock = GlobalLock.getInternLock("vmmgr.cancel.workitem");
try {
if (scanLock.lock(3)) {
try {
final List<ItWorkVO> works = _workDao.listWorkInProgressFor(nodeId);
for (final ItWorkVO work : works) {
s_logger.info("Handling unfinished work item: " + work);
try {
final VMInstanceVO vm = _vmDao.findById(work.getInstanceId());
if (vm != null) {
if (work.getType() == State.Starting) {
_haMgr.scheduleRestart(vm, true);
work.setManagementServerId(_nodeId);
work.setStep(Step.Done);
_workDao.update(work.getId(), work);
} else if (work.getType() == State.Stopping) {
_haMgr.scheduleStop(vm, vm.getHostId(), WorkType.CheckStop);
work.setManagementServerId(_nodeId);
work.setStep(Step.Done);
_workDao.update(work.getId(), work);
} else if (work.getType() == State.Migrating) {
_haMgr.scheduleMigration(vm);
work.setStep(Step.Done);
_workDao.update(work.getId(), work);
}
}
} catch (final Exception e) {
s_logger.error("Error while handling " + work, e);
}
}
} finally {
scanLock.unlock();
}
}
} finally {
scanLock.releaseRef();
}
}
示例8: runInContext
import com.cloud.utils.db.GlobalLock; //导入方法依赖的package包/类
@Override
protected void runInContext() {
final GlobalLock gcLock = GlobalLock.getInternLock("Network.GC.Lock");
try {
if (gcLock.lock(3)) {
try {
reallyRun();
} finally {
gcLock.unlock();
}
}
} finally {
gcLock.releaseRef();
}
}
示例9: runInContext
import com.cloud.utils.db.GlobalLock; //导入方法依赖的package包/类
@Override
protected void runInContext() {
GlobalLock gcLock = GlobalLock.getInternLock("ContainerCluster.GC.Lock");
try {
if (gcLock.lock(3)) {
try {
reallyRun();
} finally {
gcLock.unlock();
}
}
} finally {
gcLock.releaseRef();
}
}
示例10: check
import com.cloud.utils.db.GlobalLock; //导入方法依赖的package包/类
@Override
public void check() {
GlobalLock lock = GlobalLock.getInternLock("DatabaseUpgrade");
try {
s_logger.info("Grabbing lock to check for database upgrade.");
if (!lock.lock(20 * 60)) {
throw new CloudRuntimeException("Unable to acquire lock to check for database integrity.");
}
try {
final CloudStackVersion dbVersion = CloudStackVersion.parse(_dao.getCurrentVersion());
final String currentVersionValue = this.getClass().getPackage().getImplementationVersion();
if (StringUtils.isBlank(currentVersionValue)) {
return;
}
final CloudStackVersion currentVersion = CloudStackVersion.parse(currentVersionValue);
s_logger.info("DB version = " + dbVersion + " Code Version = " + currentVersion);
if (dbVersion.compareTo(currentVersion) > 0) {
throw new CloudRuntimeException("Database version " + dbVersion + " is higher than management software version " + currentVersionValue);
}
if (dbVersion.compareTo(currentVersion) == 0) {
s_logger.info("DB version and code version matches so no upgrade needed.");
return;
}
upgrade(dbVersion, currentVersion);
} finally {
lock.unlock();
}
} finally {
lock.releaseRef();
}
}
示例11: releasePortableIpAddress
import com.cloud.utils.db.GlobalLock; //导入方法依赖的package包/类
@DB
@Override
public boolean releasePortableIpAddress(final long addrId) {
final GlobalLock portableIpLock = GlobalLock.getInternLock("PortablePublicIpRange");
try {
return Transaction.execute(new TransactionCallback<Boolean>() {
@Override
public Boolean doInTransaction(TransactionStatus status) {
portableIpLock.lock(5);
IPAddressVO ip = _ipAddressDao.findById(addrId);
// unassign portable IP
PortableIpVO portableIp = _portableIpDao.findByIpAddress(ip.getAddress().addr());
_portableIpDao.unassignIpAddress(portableIp.getId());
// removed the provisioned vlan
VlanVO vlan = _vlanDao.findById(ip.getVlanId());
_vlanDao.remove(vlan.getId());
// remove the provisioned public ip address
_ipAddressDao.remove(ip.getId());
return true;
}
});
} finally {
portableIpLock.releaseRef();
}
}
示例12: processAnswers
import com.cloud.utils.db.GlobalLock; //导入方法依赖的package包/类
@Override
@DB
public boolean processAnswers(long agentId, long seq, Answer[] answers) {
/*
* Do not collect Direct Network usage stats if the Traffic Monitor is not owned by this mgmt server
*/
HostVO host = _hostDao.findById(agentId);
if (host != null) {
if ((host.getManagementServerId() == null) || (mgmtSrvrId != host.getManagementServerId())) {
s_logger.warn("Not the owner. Not collecting Direct Network usage from TrafficMonitor : " + agentId);
return false;
}
} else {
s_logger.warn("Agent not found. Not collecting Direct Network usage from TrafficMonitor : " + agentId);
return false;
}
GlobalLock scanLock = GlobalLock.getInternLock("direct.network.usage.collect" + host.getDataCenterId());
try {
if (scanLock.lock(10)) {
try {
return collectDirectNetworkUsage(host);
} finally {
scanLock.unlock();
}
}
} finally {
scanLock.releaseRef();
}
return false;
}
示例13: poll
import com.cloud.utils.db.GlobalLock; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void poll(final Date currentTimestamp) {
// We don't maintain the time. The timer task does.
_currentTimestamp = currentTimestamp;
GlobalLock scanLock = GlobalLock.getInternLock("snapshot.poll");
try {
if (scanLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_COOPERATION)) {
try {
checkStatusOfCurrentlyExecutingSnapshots();
} finally {
scanLock.unlock();
}
}
} finally {
scanLock.releaseRef();
}
scanLock = GlobalLock.getInternLock("snapshot.poll");
try {
if (scanLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_COOPERATION)) {
try {
scheduleSnapshots();
} finally {
scanLock.unlock();
}
}
} finally {
scanLock.releaseRef();
}
try {
deleteExpiredVMSnapshots();
}
catch (Exception e) {
s_logger.warn("Error in expiring vm snapshots", e);
}
}
示例14: create
import com.cloud.utils.db.GlobalLock; //导入方法依赖的package包/类
@Override
public DataObject create(final DataObject obj) {
// create template on primary storage
if (obj.getType() == DataObjectType.TEMPLATE && !isManaged()) {
try {
final String templateIdPoolIdString = "templateId:" + obj.getId() + "poolId:" + getId();
VMTemplateStoragePoolVO templateStoragePoolRef;
final GlobalLock lock = GlobalLock.getInternLock(templateIdPoolIdString);
if (!lock.lock(5)) {
s_logger.debug("Couldn't lock the db on the string " + templateIdPoolIdString);
return null;
}
try {
templateStoragePoolRef = templatePoolDao.findByPoolTemplate(getId(), obj.getId());
if (templateStoragePoolRef == null) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Not found (" + templateIdPoolIdString + ") in template_spool_ref, persisting it");
}
templateStoragePoolRef = new VMTemplateStoragePoolVO(getId(), obj.getId());
templateStoragePoolRef = templatePoolDao.persist(templateStoragePoolRef);
}
} finally {
lock.unlock();
lock.releaseRef();
}
} catch (final Exception e) {
s_logger.debug("Caught exception ", e);
}
} else if (obj.getType() == DataObjectType.SNAPSHOT) {
return objectInStoreMgr.create(obj, this);
} else if (obj.getType() == DataObjectType.VOLUME) {
final VolumeVO vol = volumeDao.findById(obj.getId());
if (vol != null) {
vol.setPoolId(getId());
volumeDao.update(vol.getId(), vol);
}
}
return objectInStoreMgr.get(obj, this);
}
示例15: runInContext
import com.cloud.utils.db.GlobalLock; //导入方法依赖的package包/类
@Override
protected void runInContext() {
final GlobalLock scanLock = GlobalLock.getInternLock("vmIpFetch");
try {
if (scanLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_COOPERATION)) {
try {
for (final Entry<Long, VmAndCountDetails> entry : vmIdCountMap.entrySet()) {
final long nicId = entry.getKey();
final VmAndCountDetails vmIdAndCount = entry.getValue();
final long vmId = vmIdAndCount.getVmId();
if (vmIdAndCount.getRetrievalCount() <= 0) {
vmIdCountMap.remove(nicId);
s_logger.debug("Vm " + vmId + " nic " + nicId + " count is zero .. removing vm nic from map ");
ActionEventUtils.onActionEvent(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM,
Domain.ROOT_DOMAIN, EventTypes.EVENT_NETWORK_EXTERNAL_DHCP_VM_IPFETCH,
"VM " + vmId + " nic id " + nicId + " ip addr fetch failed ");
continue;
}
final UserVm userVm = _vmDao.findById(vmId);
final VMInstanceVO vmInstance = _vmInstanceDao.findById(vmId);
final NicVO nicVo = _nicDao.findById(nicId);
final NetworkVO network = _networkDao.findById(nicVo.getNetworkId());
final VirtualMachineProfile vmProfile = new VirtualMachineProfileImpl(userVm);
final VirtualMachine vm = vmProfile.getVirtualMachine();
final boolean isWindows = _guestOSCategoryDao.findById(_guestOSDao.findById(vm.getGuestOSId()).getCategoryId()).getName().equalsIgnoreCase("Windows");
_vmIpFetchThreadExecutor.execute(new VmIpAddrFetchThread(vmId, nicId, vmInstance.getInstanceName(),
isWindows, vm.getHostId(), network.getCidr()));
}
} catch (final Exception e) {
s_logger.error("Caught the Exception in VmIpFetchTask", e);
} finally {
scanLock.unlock();
}
}
} finally {
scanLock.releaseRef();
}
}