use of com.emc.storageos.coordinator.client.model.DbConsistencyStatus in project coprhd-controller by CoprHD.
the class DbConsistencyService method cancelDbConsistencyCheck.
/**
* Cancel db consistency check if it's in progress
* @brief Cancel db consistency check if it's in progress
* @return boolean to indicate if db consistency check cancelled or not
*/
@POST
@Path("consistency/cancel")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public Response cancelDbConsistencyCheck() {
log.info("receive cancel db consistency check request");
if (!isDbConsistencyCheckInProgress()) {
log.warn("db consistency check is not in progress");
throw APIException.badRequests.canNotCanceldbConsistencyCheck();
}
DbConsistencyStatus status = getStatusFromZk();
status.setStatus(DbConsistencyStatusRestRep.Status.CANCEL);
this.coordinator.persistRuntimeState(Constants.DB_CONSISTENCY_STATUS, status);
log.info("try to cancel db consistency check");
return Response.ok().build();
}
use of com.emc.storageos.coordinator.client.model.DbConsistencyStatus in project coprhd-controller by CoprHD.
the class DbConsistencyJobConsumer method markFailure.
private DbConsistencyStatus markFailure() {
DbConsistencyStatus status = this.dbChecker.getStatusFromZk();
status.markResult(Status.FAILED);
return status;
}
use of com.emc.storageos.coordinator.client.model.DbConsistencyStatus in project coprhd-controller by CoprHD.
the class DbConsistencyJobConsumer method consumeItem.
@Override
public void consumeItem(DbConsistencyJob job, DistributedQueueItemProcessedCallback callback) throws Exception {
DbConsistencyStatus status = dbChecker.getStatusFromZk();
log.info("start db consistency check, current status:{}", status);
if (isFreshStart(status)) {
log.info("it's first time to run db consistency check, init status in zk");
status = createStatusInZk();
} else if (status.isFinished()) {
log.info("there is finished state, move it to previous");
status.moveToPrevious();
} else if (status.isCancelled()) {
log.info("current status is cancel, restart db consistency check");
status.init();
}
try {
dbChecker.persistStatus(status);
initSchemaIfNot();
dbChecker.check();
status = markResult();
} catch (CancellationException ce) {
log.warn("cancellation:{}", ce.getMessage());
status.markResult(Status.CANCEL);
} catch (ConnectionException e) {
log.warn("ConnectionException:{}", e);
status.markResult(Status.FAILED);
} catch (Exception e) {
log.error("failed to check db consistency {}", e);
status = markFailure();
} finally {
log.info("db consistency check done, persist final result {} in zk", status.getStatus());
this.dbChecker.persistStatus(status);
callback.itemProcessed();
DbCheckerFileWriter.close();
}
}
use of com.emc.storageos.coordinator.client.model.DbConsistencyStatus in project coprhd-controller by CoprHD.
the class DbConsistencyJobConsumer method markResult.
private DbConsistencyStatus markResult() {
DbConsistencyStatus status = dbChecker.getStatusFromZk();
if (status.getInconsistencyCount() > 0) {
log.info("there are {} inconsistency found, mark result as fail", status.getInconsistencyCount());
status.markResult(Status.FAILED);
} else {
log.info("no inconsistency record found, mark result as successful");
status.markResult(Status.SUCCESS);
}
return status;
}
use of com.emc.storageos.coordinator.client.model.DbConsistencyStatus in project coprhd-controller by CoprHD.
the class DbConsistencyChecker method getCheckTypeFromZK.
private CheckType getCheckTypeFromZK() {
CheckType defaultType = CheckType.OBJECT_ID;
if (toConsole) {
return defaultType;
}
DbConsistencyStatus status = getStatusFromZk();
helper.logMessage(String.format("status %s in zk", status.toString()), false, false);
CheckType checkType;
try {
checkType = CheckType.valueOf(status.getCheckType());
} catch (Exception e) {
checkType = defaultType;
}
return checkType;
}
Aggregations