Search in sources :

Example 1 with RecoveryStatus

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

the class SystemHealth method nodeRecoveryVapp.

public static void nodeRecoveryVapp() {
    ViPRSystemClient client = BourneUtil.getSysClient();
    RecoveryStatus recoveryStatus = client.control().getRecoveryStatus();
    if (recoveryStatus.getStartTime() != null) {
        DateTime startTime = new DateTime(recoveryStatus.getStartTime().getTime());
        renderArgs.put("startTime", startTime);
    }
    if (recoveryStatus.getEndTime() != null) {
        DateTime endTime = new DateTime(recoveryStatus.getEndTime().getTime());
        renderArgs.put("endTime", endTime);
    }
    RecoveryPrecheckStatus recoveryPrecheckStatus = client.control().getRecoveryPrecheckStatus();
    String precheckMsg = "";
    switch(recoveryPrecheckStatus.getStatus()) {
        case RECOVERY_NEEDED:
            precheckMsg = Messages.get("nodeRecovery.precheck.success", recoveryPrecheckStatus.getRecoverables().toString());
            break;
        case ALL_GOOD:
            precheckMsg = Messages.get("nodeRecovery.precheck.fail.allgood");
            break;
        case VAPP_IN_DR_OR_GEO:
            precheckMsg = Messages.get("nodeRecovery.precheck.fail.drorgeo");
            break;
        case NODE_UNREACHABLE:
            precheckMsg = Messages.get("nodeRecovery.precheck.fail.unreachable");
            break;
        case CORRUPTED_NODE_COUNT_MORE_THAN_QUORUM:
            precheckMsg = Messages.get("nodeRecovery.precheck.fail.quorum");
            break;
        case CORRUPTED_NODE_FOR_OTHER_REASON:
            precheckMsg = Messages.get("nodeRecovery.precheck.fail.other");
            break;
    }
    renderArgs.put("precheckMsg", precheckMsg);
    renderArgs.put("precheckStatus", recoveryPrecheckStatus.getStatus().name());
    String recoveringMsg = Messages.get("nodeRecovery.recovering.status", recoveryPrecheckStatus.getRecoverables().toString());
    renderArgs.put("recoveringMsg", recoveringMsg);
    ClusterInfo clusterInfo = AdminDashboardUtils.getClusterInfo();
    render(recoveryStatus, clusterInfo);
}
Also used : ViPRSystemClient(com.emc.vipr.client.ViPRSystemClient) ClusterInfo(com.emc.vipr.model.sys.ClusterInfo) RecoveryPrecheckStatus(com.emc.vipr.model.sys.recovery.RecoveryPrecheckStatus) RecoveryStatus(com.emc.vipr.model.sys.recovery.RecoveryStatus) DateTime(org.joda.time.DateTime)

Example 2 with RecoveryStatus

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

the class SystemHealth method getRecoveryStatus.

@Restrictions({ @Restrict("SYSTEM_ADMIN"), @Restrict("SECURITY_ADMIN"), @Restrict("RESTRICTED_SECURITY_ADMIN") })
public static void getRecoveryStatus() {
    ViPRSystemClient client = BourneUtil.getSysClient();
    RecoveryStatus recoveryStatus = client.control().getRecoveryStatus();
    JsonElement jsonElement = new Gson().toJsonTree(recoveryStatus);
    JsonObject jsonObj = jsonElement.getAsJsonObject();
    if (recoveryStatus.getStartTime() != null) {
        DateTime startTime = new DateTime(recoveryStatus.getStartTime().getTime());
        jsonObj.addProperty("startTime", startTime.toString());
    }
    if (recoveryStatus.getEndTime() != null) {
        DateTime endTime = new DateTime(recoveryStatus.getEndTime().getTime());
        jsonObj.addProperty("endTime", endTime.toString());
    }
    renderJSON(jsonObj.toString());
}
Also used : ViPRSystemClient(com.emc.vipr.client.ViPRSystemClient) JsonElement(com.google.gson.JsonElement) Gson(com.google.gson.Gson) JsonObject(com.google.gson.JsonObject) RecoveryStatus(com.emc.vipr.model.sys.recovery.RecoveryStatus) DateTime(org.joda.time.DateTime) Restrictions(controllers.deadbolt.Restrictions)

Example 3 with RecoveryStatus

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

the class SystemHealth method nodeRecovery.

public static void nodeRecovery() {
    ViPRSystemClient client = BourneUtil.getSysClient();
    RecoveryStatus recoveryStatus = client.control().getRecoveryStatus();
    if (recoveryStatus.getStartTime() != null) {
        DateTime startTime = new DateTime(recoveryStatus.getStartTime().getTime());
        renderArgs.put("startTime", startTime);
    }
    if (recoveryStatus.getEndTime() != null) {
        DateTime endTime = new DateTime(recoveryStatus.getEndTime().getTime());
        renderArgs.put("endTime", endTime);
    }
    ClusterInfo clusterInfo = AdminDashboardUtils.getClusterInfo();
    render(recoveryStatus, clusterInfo);
}
Also used : ViPRSystemClient(com.emc.vipr.client.ViPRSystemClient) ClusterInfo(com.emc.vipr.model.sys.ClusterInfo) RecoveryStatus(com.emc.vipr.model.sys.recovery.RecoveryStatus) DateTime(org.joda.time.DateTime)

Example 4 with RecoveryStatus

use of com.emc.vipr.model.sys.recovery.RecoveryStatus 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 5 with RecoveryStatus

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

the class RecoveryManager method setRecoveryStatusWithEndTimeMarked.

/**
 * Update node recovery status to ZK
 */
private void setRecoveryStatusWithEndTimeMarked(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);
    recoveryStatus.setEndTime(new Date());
    persistNodeRecoveryStatus(recoveryStatus);
}
Also used : RecoveryStatus(com.emc.vipr.model.sys.recovery.RecoveryStatus) Date(java.util.Date)

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