當前位置: 首頁>>代碼示例>>Java>>正文


Java GlobalLock.unlock方法代碼示例

本文整理匯總了Java中com.cloud.utils.db.GlobalLock.unlock方法的典型用法代碼示例。如果您正苦於以下問題:Java GlobalLock.unlock方法的具體用法?Java GlobalLock.unlock怎麽用?Java GlobalLock.unlock使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.cloud.utils.db.GlobalLock的用法示例。


在下文中一共展示了GlobalLock.unlock方法的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);
    }
}
 
開發者ID:MissionCriticalCloud,項目名稱:cosmic,代碼行數:20,代碼來源:UploadMonitorImpl.java

示例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();
    }
}
 
開發者ID:apache,項目名稱:cloudstack,代碼行數:27,代碼來源:DatabaseIntegrityChecker.java

示例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();
    }
}
 
開發者ID:apache,項目名稱:cloudstack,代碼行數:27,代碼來源:ExternalDeviceUsageManagerImpl.java

示例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;
}
 
開發者ID:apache,項目名稱:cloudstack,代碼行數:23,代碼來源:ExternalFirewallDeviceManagerImpl.java

示例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);
    }
}
 
開發者ID:apache,項目名稱:cloudstack,代碼行數:21,代碼來源:UploadMonitorImpl.java

示例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;
}
 
開發者ID:apache,項目名稱:cloudstack,代碼行數:21,代碼來源:RootCAProvider.java

示例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();
    }
}
 
開發者ID:MissionCriticalCloud,項目名稱:cosmic,代碼行數:41,代碼來源:VirtualMachineManagerImpl.java

示例8: runInContext

import com.cloud.utils.db.GlobalLock; //導入方法依賴的package包/類
@Override
protected void runInContext() {
    final GlobalLock lock = GlobalLock.getInternLock("TransitionChecking");
    if (lock == null) {
        s_logger.debug("Couldn't get the global lock");
        return;
    }

    if (!lock.lock(30)) {
        s_logger.debug("Couldn't lock the db");
        return;
    }
    try {
        scanStalledVMInTransitionStateOnDisconnectedHosts();

        final List<VMInstanceVO> instances = _vmDao.findVMInTransition(new Date(new Date().getTime() - AgentManager.Wait.value() * 1000), State.Starting, State.Stopping);
        for (final VMInstanceVO instance : instances) {
            final State state = instance.getState();
            if (state == State.Stopping) {
                _haMgr.scheduleStop(instance, instance.getHostId(), WorkType.CheckStop);
            } else if (state == State.Starting) {
                _haMgr.scheduleRestart(instance, true);
            }
        }
    } catch (final Exception e) {
        s_logger.warn("Caught the following exception on transition checking", e);
    } finally {
        lock.unlock();
    }
}
 
開發者ID:MissionCriticalCloud,項目名稱:cosmic,代碼行數:31,代碼來源:VirtualMachineManagerImpl.java

示例9: 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();
    }
}
 
開發者ID:MissionCriticalCloud,項目名稱:cosmic,代碼行數:16,代碼來源:NetworkOrchestrator.java

示例10: runInContext

import com.cloud.utils.db.GlobalLock; //導入方法依賴的package包/類
@Override
protected void runInContext() {
    GlobalLock replacementLock = null;
    try {
        replacementLock = GlobalLock.getInternLock("storageCacheMgr.replacement");
        if (replacementLock.lock(3)) {
            final List<DataStore> stores = getCacheStores();
            Collections.shuffle(stores);
            DataObject object = null;
            DataStore findAStore = null;
            for (final DataStore store : stores) {
                object = cacheReplacementAlgorithm.chooseOneToBeReplaced(store);
                findAStore = store;
                if (object != null) {
                    break;
                }
            }

            if (object == null) {
                return;
            }

            while (object != null) {
                object.delete();
                object = cacheReplacementAlgorithm.chooseOneToBeReplaced(findAStore);
            }
        }
    } catch (final Exception e) {
        s_logger.debug("Failed to execute CacheReplacementRunner: " + e.toString());
    } finally {
        if (replacementLock != null) {
            replacementLock.unlock();
        }
    }
}
 
開發者ID:MissionCriticalCloud,項目名稱:cosmic,代碼行數:36,代碼來源:StorageCacheManagerImpl.java

示例11: 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();
    }
}
 
開發者ID:shapeblue,項目名稱:ccs,代碼行數:16,代碼來源:ContainerClusterManagerImpl.java

示例12: runInContext

import com.cloud.utils.db.GlobalLock; //導入方法依賴的package包/類
@Override
protected void runInContext() {
    final GlobalLock lock = GlobalLock.getInternLock("TransitionChecking");
    if (lock == null) {
        s_logger.debug("Couldn't get the global lock");
        return;
    }

    if (!lock.lock(30)) {
        s_logger.debug("Couldn't lock the db");
        return;
    }
    try {
        scanStalledVMInTransitionStateOnDisconnectedHosts();

        final List<VMInstanceVO> instances = _vmDao.findVMInTransition(new Date(DateUtil.currentGMTTime().getTime() - AgentManager.Wait.value() * 1000), State.Starting, State.Stopping);
        for (final VMInstanceVO instance : instances) {
            final State state = instance.getState();
            if (state == State.Stopping) {
                _haMgr.scheduleStop(instance, instance.getHostId(), WorkType.CheckStop);
            } else if (state == State.Starting) {
                _haMgr.scheduleRestart(instance, true);
            }
        }
    } catch (final Exception e) {
        s_logger.warn("Caught the following exception on transition checking", e);
    } finally {
        lock.unlock();
    }
}
 
開發者ID:apache,項目名稱:cloudstack,代碼行數:31,代碼來源:VirtualMachineManagerImpl.java

示例13: runInContext

import com.cloud.utils.db.GlobalLock; //導入方法依賴的package包/類
@Override
protected void runInContext() {
    GlobalLock replacementLock = null;
    try {
        replacementLock = GlobalLock.getInternLock("storageCacheMgr.replacement");
        if (replacementLock.lock(3)) {
            List<DataStore> stores = getCacheStores();
            Collections.shuffle(stores);
            DataObject object = null;
            DataStore findAStore = null;
            for (DataStore store : stores) {
                object = cacheReplacementAlgorithm.chooseOneToBeReplaced(store);
                findAStore = store;
                if (object != null) {
                    break;
                }
            }

            if (object == null) {
                return;
            }

            while (object != null) {
                object.delete();
                object = cacheReplacementAlgorithm.chooseOneToBeReplaced(findAStore);
            }
        }
    } catch (Exception e) {
        s_logger.debug("Failed to execute CacheReplacementRunner: " + e.toString());
    } finally {
        if (replacementLock != null) {
            replacementLock.unlock();
        }
    }
}
 
開發者ID:apache,項目名稱:cloudstack,代碼行數:36,代碼來源:StorageCacheManagerImpl.java

示例14: 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();
    }
}
 
開發者ID:apache,項目名稱:cloudstack,代碼行數:39,代碼來源:DatabaseUpgradeChecker.java

示例15: 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;
}
 
開發者ID:apache,項目名稱:cloudstack,代碼行數:32,代碼來源:NetworkUsageManagerImpl.java


注:本文中的com.cloud.utils.db.GlobalLock.unlock方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。