Search in sources :

Example 6 with RecoveryStatus

use of com.emc.vipr.model.sys.recovery.RecoveryStatus in project coprhd-controller by CoprHD.

the class RecoveryManager method triggerNodeRecovery.

/**
 * Trigger node recovery by update recovery status to 'INIT'
 */
public void triggerNodeRecovery() {
    InterProcessLock lock = null;
    try {
        lock = getRecoveryLock();
        validateNodeRecoveryStatus();
        validateClusterState();
        RecoveryStatus status = new RecoveryStatus();
        status.setStatus(RecoveryStatus.Status.INIT);
        status.setStartTime(new Date());
        persistNodeRecoveryStatus(status);
    } finally {
        releaseLock(lock);
    }
}
Also used : InterProcessLock(org.apache.curator.framework.recipes.locks.InterProcessLock) RecoveryStatus(com.emc.vipr.model.sys.recovery.RecoveryStatus) Date(java.util.Date)

Example 7 with RecoveryStatus

use of com.emc.vipr.model.sys.recovery.RecoveryStatus in project coprhd-controller by CoprHD.

the class RecoveryManager method queryNodeRecoveryStatus.

/**
 * Query recovery status from ZK
 */
public RecoveryStatus queryNodeRecoveryStatus() {
    RecoveryStatus status = new RecoveryStatus();
    Configuration cfg = coordinator.getCoordinatorClient().queryConfiguration(Constants.NODE_RECOVERY_STATUS, Constants.GLOBAL_ID);
    if (cfg != null) {
        String statusStr = cfg.getConfig(RecoveryConstants.RECOVERY_STATUS);
        status.setStatus(RecoveryStatus.Status.valueOf(statusStr));
        String startTimeStr = cfg.getConfig(RecoveryConstants.RECOVERY_STARTTIME);
        if (startTimeStr != null && startTimeStr.length() > 0) {
            status.setStartTime(new Date(Long.parseLong(startTimeStr)));
        }
        String endTimeStr = cfg.getConfig(RecoveryConstants.RECOVERY_ENDTIME);
        if (endTimeStr != null && endTimeStr.length() > 0) {
            status.setEndTime(new Date(Long.parseLong(endTimeStr)));
        }
        String errorCodeStr = cfg.getConfig(RecoveryConstants.RECOVERY_ERRCODE);
        if (errorCodeStr != null && errorCodeStr.length() > 0) {
            status.setErrorCode(RecoveryStatus.ErrorCode.valueOf(errorCodeStr));
        }
    }
    log.info("Recovery status is: {}", status);
    return status;
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration) RecoveryStatus(com.emc.vipr.model.sys.recovery.RecoveryStatus) Date(java.util.Date)

Example 8 with RecoveryStatus

use of com.emc.vipr.model.sys.recovery.RecoveryStatus in project coprhd-controller by CoprHD.

the class RecoveryManager method setRecoveryStatus.

/**
 * Update node recovery status to ZK
 */
private void setRecoveryStatus(RecoveryStatus.Status status) {
    if (!isLeader.get()) {
        log.warn("This node is not the recovery leader");
        throw new IllegalStateException("This node is not the recovery leader");
    }
    RecoveryStatus recoveryStatus = queryNodeRecoveryStatus();
    recoveryStatus.setStatus(status);
    persistNodeRecoveryStatus(recoveryStatus);
}
Also used : RecoveryStatus(com.emc.vipr.model.sys.recovery.RecoveryStatus)

Example 9 with RecoveryStatus

use of com.emc.vipr.model.sys.recovery.RecoveryStatus in project coprhd-controller by CoprHD.

the class RecoveryManager method markRecoveryFailed.

/**
 * Mark recovery status as failed and set error message and end time
 */
private void markRecoveryFailed(RecoveryStatus.ErrorCode errorMessage) {
    if (!isLeader.get()) {
        log.warn("This node is not the recovery leader");
        throw new IllegalStateException("This node is not the recovery leader");
    }
    RecoveryStatus recoveryStatus = queryNodeRecoveryStatus();
    if (recoveryStatus.getErrorCode() != null) {
        log.debug("Have already marked.");
        return;
    }
    recoveryStatus.setErrorCode(errorMessage);
    recoveryStatus.setEndTime(new Date());
    recoveryStatus.setStatus(RecoveryStatus.Status.FAILED);
    persistNodeRecoveryStatus(recoveryStatus);
    poweroff(getHibernateNodes());
}
Also used : RecoveryStatus(com.emc.vipr.model.sys.recovery.RecoveryStatus) Date(java.util.Date)

Example 10 with RecoveryStatus

use of com.emc.vipr.model.sys.recovery.RecoveryStatus in project coprhd-controller by CoprHD.

the class Control method getRecoveryStatus.

/**
 * Gets status of recoverMinotiryNode.
 * <p>
 * Cluster recovery status: Current status of the cluster recovery process INIT - triggering recover PREPARING - preparing recovery
 * REPAIRING - repairing db inconsistency.
 * <p>
 * SYNCING - new node is syncing data FAILED - recovery failed DONE - recovery successful
 * <p>
 * API Call: GET /cluster/recovery
 *
 * @return The Recovery Status
 */
public RecoveryStatus getRecoveryStatus() {
    RecoveryStatus status = null;
    UriBuilder builder = client.uriBuilder(CLUSTER_NODE_RECOVERY_URL);
    try {
        status = client.getURI(RecoveryStatus.class, builder.build());
    } catch (UniformInterfaceException e) {
        log.warn("Issue with retrieving response from client.", e);
        status = new RecoveryStatus();
    }
    return status;
}
Also used : UniformInterfaceException(com.sun.jersey.api.client.UniformInterfaceException) RecoveryStatus(com.emc.vipr.model.sys.recovery.RecoveryStatus) UriBuilder(javax.ws.rs.core.UriBuilder)

Aggregations

RecoveryStatus (com.emc.vipr.model.sys.recovery.RecoveryStatus)11 ViPRSystemClient (com.emc.vipr.client.ViPRSystemClient)4 Date (java.util.Date)4 ClusterInfo (com.emc.vipr.model.sys.ClusterInfo)3 DateTime (org.joda.time.DateTime)3 RecoveryPrecheckStatus (com.emc.vipr.model.sys.recovery.RecoveryPrecheckStatus)2 Restrictions (controllers.deadbolt.Restrictions)2 InterProcessLock (org.apache.curator.framework.recipes.locks.InterProcessLock)2 Configuration (com.emc.storageos.coordinator.common.Configuration)1 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)1 SysClientException (com.emc.storageos.systemservices.exceptions.SysClientException)1 NodeHealth (com.emc.vipr.model.sys.healthmonitor.NodeHealth)1 Gson (com.google.gson.Gson)1 JsonElement (com.google.gson.JsonElement)1 JsonObject (com.google.gson.JsonObject)1 UniformInterfaceException (com.sun.jersey.api.client.UniformInterfaceException)1 UriBuilder (javax.ws.rs.core.UriBuilder)1 MinorityNodeRecoveryJob (jobs.MinorityNodeRecoveryJob)1