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);
}
}
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;
}
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);
}
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());
}
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;
}
Aggregations