Search in sources :

Example 31 with InterProcessLock

use of org.apache.curator.framework.recipes.locks.InterProcessLock in project coprhd-controller by CoprHD.

the class CoordinatorClientImpl method setNodeDualInetAddressInfo.

/**
 * Set node info to zk so that it can be available for lookup in coordinatorclient.
 *
 * @param nodeId the node_id to be persisted
 * @param addresses A string of ip addresses(v4/v6) with ',' as separator
 */
public void setNodeDualInetAddressInfo(String nodeId, String addresses) {
    // grab a lock and verifyPublishedDualInetAddress first
    InterProcessLock lock = null;
    try {
        lock = getLock(Constants.NODE_DUALINETADDR_CONFIG + nodeId);
        lock.acquire();
        if (!verifyPublishedDualInetAddress(nodeId)) {
            ConfigurationImpl cfg = new ConfigurationImpl();
            cfg.setId(nodeId);
            cfg.setKind(Constants.NODE_DUALINETADDR_CONFIG);
            cfg.setConfig(Constants.CONFIG_DUAL_INETADDRESSES, addresses);
            persistServiceConfiguration(cfg);
        }
    } catch (Exception e) {
        log.warn("Unexpected exception during setNodeDualInetAddressInfo()", e);
    } finally {
        if (lock != null) {
            try {
                lock.release();
            } catch (Exception e) {
                log.warn("Unexpected exception unlocking in setNodeDualInetAddressInfo()", e);
            }
        }
    }
}
Also used : InterProcessLock(org.apache.curator.framework.recipes.locks.InterProcessLock) ConfigurationImpl(com.emc.storageos.coordinator.common.impl.ConfigurationImpl) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) RetryableCoordinatorException(com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException) KeeperException(org.apache.zookeeper.KeeperException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException)

Example 32 with InterProcessLock

use of org.apache.curator.framework.recipes.locks.InterProcessLock in project coprhd-controller by CoprHD.

the class OrderService method saveJobInfo.

public void saveJobInfo(OrderJobStatus status) throws Exception {
    InterProcessLock lock = coordinatorClient.getLock(ORDER_JOB_LOCK);
    lock.acquire();
    coordinatorClient.persistRuntimeState(status.getType().name(), status);
    lock.release();
}
Also used : InterProcessLock(org.apache.curator.framework.recipes.locks.InterProcessLock)

Example 33 with InterProcessLock

use of org.apache.curator.framework.recipes.locks.InterProcessLock in project coprhd-controller by CoprHD.

the class RecoveryManager method checkRecoveryStatus.

/**
 * Check the recovery status saved in ZK.
 * a. No recovery required(DONE/FAILED/NULL): nothing to do. simply wait
 * b. In progress(PREPARING/REPAIRING/SYNCING): fail new request if there is one in progress
 * c. Triggering(INIT): current node should take charge of node recovery
 */
private void checkRecoveryStatus() throws Exception {
    while (true) {
        InterProcessLock lock = null;
        try {
            lock = getRecoveryLock();
            RecoveryStatus status = queryNodeRecoveryStatus();
            if (isRecovering(status)) {
                log.warn("This is a stale recovery request due to recovery leader change");
                return;
            } else if (isTriggering(status)) {
                log.info("The recovery status is triggering so run recovery directly");
                return;
            }
            setWaitingRecoveryTriggeringFlag(true);
        } catch (Exception e) {
            markRecoveryFailed(RecoveryStatus.ErrorCode.INTERNAL_ERROR);
            throw e;
        } finally {
            releaseLock(lock);
        }
        log.info("Wait to be triggered");
        waitOnRecoveryTriggering();
    }
}
Also used : InterProcessLock(org.apache.curator.framework.recipes.locks.InterProcessLock) RecoveryStatus(com.emc.vipr.model.sys.recovery.RecoveryStatus) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) SysClientException(com.emc.storageos.systemservices.exceptions.SysClientException)

Example 34 with InterProcessLock

use of org.apache.curator.framework.recipes.locks.InterProcessLock in project coprhd-controller by CoprHD.

the class RecoveryManager method informHibernateNodeToReconfigure.

private void informHibernateNodeToReconfigure() {
    DrUtil drUtil = new DrUtil(coordinator.getCoordinatorClient());
    if (drUtil.isMultisite()) {
        InterProcessLock lock = null;
        try {
            lock = drUtil.getDROperationLock();
            long vdcConfigVersion = DrUtil.newVdcConfigVersion();
            log.info("Has multi sites, informing the hibernate nodes to reconfigure..");
            drUtil.updateVdcTargetVersion(coordinator.getCoordinatorClient().getSiteId(), SiteInfo.DR_OP_NODE_RECOVERY, vdcConfigVersion);
        } catch (Exception e) {
            log.error("Failed to inform the hibernate nodes to reconfigure", e);
        } finally {
            try {
                if (lock != null) {
                    lock.release();
                }
            } catch (Exception ignore) {
                log.error("Release lock failed when node recovery", ignore);
            }
        }
    }
}
Also used : DrUtil(com.emc.storageos.coordinator.client.service.DrUtil) InterProcessLock(org.apache.curator.framework.recipes.locks.InterProcessLock) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) SysClientException(com.emc.storageos.systemservices.exceptions.SysClientException)

Example 35 with InterProcessLock

use of org.apache.curator.framework.recipes.locks.InterProcessLock in project coprhd-controller by CoprHD.

the class RecoveryManager method markRecoveryCancelled.

/**
 * Set node recovery status as 'CANCELLED'
 */
private void markRecoveryCancelled() {
    InterProcessLock lock = null;
    try {
        lock = getRecoveryLock();
        setRecoveryStatusWithEndTimeMarked(RecoveryStatus.Status.CANCELLED);
    } finally {
        releaseLock(lock);
    }
}
Also used : InterProcessLock(org.apache.curator.framework.recipes.locks.InterProcessLock)

Aggregations

InterProcessLock (org.apache.curator.framework.recipes.locks.InterProcessLock)98 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)25 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)21 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)15 IOException (java.io.IOException)15 ControllerException (com.emc.storageos.volumecontroller.ControllerException)14 Configuration (com.emc.storageos.coordinator.common.Configuration)12 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)12 UnknownHostException (java.net.UnknownHostException)12 Site (com.emc.storageos.coordinator.client.model.Site)11 RetryableCoordinatorException (com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException)11 NetworkDeviceControllerException (com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException)10 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)9 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)9 BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)9 ArrayList (java.util.ArrayList)9 POST (javax.ws.rs.POST)9 NetworkSystem (com.emc.storageos.db.client.model.NetworkSystem)8 Path (javax.ws.rs.Path)8 ConfigurationImpl (com.emc.storageos.coordinator.common.impl.ConfigurationImpl)6