Search in sources :

Example 6 with DbConsistencyStatus

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();
}
Also used : DbConsistencyStatus(com.emc.storageos.coordinator.client.model.DbConsistencyStatus) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 7 with DbConsistencyStatus

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;
}
Also used : DbConsistencyStatus(com.emc.storageos.coordinator.client.model.DbConsistencyStatus)

Example 8 with DbConsistencyStatus

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();
    }
}
Also used : DbConsistencyStatus(com.emc.storageos.coordinator.client.model.DbConsistencyStatus) CancellationException(java.util.concurrent.CancellationException) ConnectionException(com.netflix.astyanax.connectionpool.exceptions.ConnectionException) CancellationException(java.util.concurrent.CancellationException) ConnectionException(com.netflix.astyanax.connectionpool.exceptions.ConnectionException)

Example 9 with DbConsistencyStatus

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;
}
Also used : DbConsistencyStatus(com.emc.storageos.coordinator.client.model.DbConsistencyStatus)

Example 10 with DbConsistencyStatus

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;
}
Also used : DbConsistencyStatus(com.emc.storageos.coordinator.client.model.DbConsistencyStatus) CancellationException(java.util.concurrent.CancellationException) ConnectionException(com.netflix.astyanax.connectionpool.exceptions.ConnectionException)

Aggregations

DbConsistencyStatus (com.emc.storageos.coordinator.client.model.DbConsistencyStatus)11 CheckResult (com.emc.storageos.db.client.impl.DbConsistencyCheckerHelper.CheckResult)2 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)2 ConnectionException (com.netflix.astyanax.connectionpool.exceptions.ConnectionException)2 CancellationException (java.util.concurrent.CancellationException)2 Path (javax.ws.rs.Path)2 IndexAndCf (com.emc.storageos.db.client.impl.DbConsistencyCheckerHelper.IndexAndCf)1 GET (javax.ws.rs.GET)1 POST (javax.ws.rs.POST)1 Produces (javax.ws.rs.Produces)1