Search in sources :

Example 6 with DistributedPersistentLock

use of com.emc.storageos.coordinator.client.service.DistributedPersistentLock in project coprhd-controller by CoprHD.

the class UpgradeManager method hasUpgradeLock.

/**
 * Helper method to provide backward compatibility for upgrade from pre-Yoda releases
 * This should be replaced with hasRebootLock() when pre-Yoda releases are no longer in the direct upgrade path
 *
 * @param svcId
 * @throws Exception needs to be caught by the caller
 * @return
 */
private boolean hasUpgradeLock(String svcId) throws Exception {
    if (backCompatPreYoda) {
        log.info("Pre-yoda back compatible flag detected. Check upgrade lock from the global area");
        // The lock content has changed in Yoda, previously there's only svcId in the lock node
        String oldSvcId = coordinator.getMySvcId();
        DistributedPersistentLock lock = coordinator.getCoordinatorClient().getPersistentLock(DISTRIBUTED_UPGRADE_LOCK);
        log.info("Acquiring the upgrade lock for {}...", oldSvcId);
        if (lock != null) {
            String lockOwner = lock.getLockOwner();
            if (lockOwner != null && lockOwner.equals(oldSvcId)) {
                log.info("Current owner of the upgrade lock: {} ", lockOwner);
                return true;
            }
        }
        return false;
    } else {
        return hasRebootLock(svcId);
    }
}
Also used : DistributedPersistentLock(com.emc.storageos.coordinator.client.service.DistributedPersistentLock)

Example 7 with DistributedPersistentLock

use of com.emc.storageos.coordinator.client.service.DistributedPersistentLock in project coprhd-controller by CoprHD.

the class UpgradeManager method getUpgradeLock.

/**
 * Helper method to provide backward compatibility for upgrade from pre-Yoda releases
 * This should be replaced with getRebootLock() when pre-Yoda releases are no longer in the direct upgrade path
 *
 * @param svcId
 * @throws Exception needs to be caught by the caller
 * @return
 */
private boolean getUpgradeLock(String svcId) throws Exception {
    if (backCompatPreYoda) {
        log.info("Pre-yoda back compatible flag detected. Check upgrade lock from the global area");
        // The lock content has changed in Yoda, previously there's only svcId in the lock node
        String oldSvcId = coordinator.getMySvcId();
        DistributedPersistentLock lock = coordinator.getCoordinatorClient().getPersistentLock(DISTRIBUTED_UPGRADE_LOCK);
        log.info("Acquiring the upgrade lock for {}...", oldSvcId);
        boolean result = lock.acquireLock(oldSvcId);
        if (!result) {
            log.info("Acquiring reboot lock failed. Retrying...");
            return false;
        }
        log.info("Successfully acquired the reboot lock.");
        return true;
    } else {
        return getRebootLock(svcId);
    }
}
Also used : DistributedPersistentLock(com.emc.storageos.coordinator.client.service.DistributedPersistentLock)

Aggregations

DistributedPersistentLock (com.emc.storageos.coordinator.client.service.DistributedPersistentLock)7 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)3 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)2 CoordinatorClientException (com.emc.storageos.systemservices.exceptions.CoordinatorClientException)1 InvalidLockOwnerException (com.emc.storageos.systemservices.exceptions.InvalidLockOwnerException)1 SyssvcException (com.emc.storageos.systemservices.exceptions.SyssvcException)1 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1