Search in sources :

Example 1 with DbOfflineStatus

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

the class RecoveryManager method initNodeListByCheckOfflineTime.

private void initNodeListByCheckOfflineTime() {
    aliveNodes.clear();
    corruptedNodes.clear();
    ArrayList<String> nodeList = coordinator.getAllNodeIds();
    for (String nodeId : nodeList) {
        try {
            DbOfflineStatus dbOfflineStatus = SysClientFactory.getSysClient(coordinator.getNodeEndpoint(nodeId)).get(SysClientFactory.URI_GET_DB_OFFLINE_STATUS, DbOfflineStatus.class, null);
            if (dbOfflineStatus.getOutageTimeExceeded()) {
                corruptedNodes.add(nodeId);
            } else {
                aliveNodes.add(nodeId);
            }
        } catch (SysClientException e) {
            log.warn("Internal error on clean up purge data: ", e.getMessage());
            throw e;
        }
    }
    log.info("Alive nodes:{}, corrupted nodes: {}", aliveNodes, corruptedNodes);
}
Also used : DbOfflineStatus(com.emc.vipr.model.sys.recovery.DbOfflineStatus) SysClientException(com.emc.storageos.systemservices.exceptions.SysClientException)

Example 2 with DbOfflineStatus

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

the class ControlService method checkDbOfflineTime.

@GET
@Path("internal/node/dbsvc-offline-status")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public DbOfflineStatus checkDbOfflineTime() {
    _log.info("Check db offline time");
    try {
        DbInfoUtils.checkDBOfflineInfo(_coordinator.getCoordinatorClient(), Constants.DBSVC_NAME, "/data/db", false);
        DbInfoUtils.checkDBOfflineInfo(_coordinator.getCoordinatorClient(), Constants.GEODBSVC_NAME, "/data/geodb", false);
    } catch (IllegalStateException e) {
        return new DbOfflineStatus(true);
    }
    return new DbOfflineStatus(false);
}
Also used : DbOfflineStatus(com.emc.vipr.model.sys.recovery.DbOfflineStatus) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 3 with DbOfflineStatus

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

the class ControlService method recoveryPrecheck.

@GET
@Path("cluster/recovery/precheck-status")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SECURITY_ADMIN, Role.RESTRICTED_SECURITY_ADMIN })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public RecoveryPrecheckStatus recoveryPrecheck() {
    RecoveryPrecheckStatus recoveryPrecheckStatus = new RecoveryPrecheckStatus();
    DrUtil drUtil = new DrUtil(_coordinator.getCoordinatorClient());
    if (drUtil.isMultivdc() || drUtil.isMultisite()) {
        recoveryPrecheckStatus.setStatus(RecoveryPrecheckStatus.Status.VAPP_IN_DR_OR_GEO);
        return recoveryPrecheckStatus;
    }
    ArrayList<String> nodeList = _coordinator.getAllNodeIds();
    HashSet<String> unvaliableNodeSet = new HashSet<>();
    ArrayList<String> recoverableNodeList = new ArrayList<>();
    for (String nodeId : nodeList) {
        Long dbOfflineTime = DbInfoUtils.getDbOfflineTime(_coordinator.getCoordinatorClient(), Constants.DBSVC_NAME, nodeId);
        if (dbOfflineTime != null) {
            unvaliableNodeSet.add(nodeId);
        } else {
            dbOfflineTime = DbInfoUtils.getDbOfflineTime(_coordinator.getCoordinatorClient(), Constants.GEODBSVC_NAME, nodeId);
            if (dbOfflineTime != null) {
                unvaliableNodeSet.add(nodeId);
            }
        }
        try {
            DbOfflineStatus dbOfflineStatus = SysClientFactory.getSysClient(_coordinator.getNodeEndpoint(nodeId)).get(SysClientFactory.URI_GET_DB_OFFLINE_STATUS, DbOfflineStatus.class, null);
            if (dbOfflineStatus.getOutageTimeExceeded()) {
                recoverableNodeList.add(nodeId);
                unvaliableNodeSet.add(nodeId);
            }
        } catch (Exception e) {
            recoveryPrecheckStatus.setStatus(RecoveryPrecheckStatus.Status.NODE_UNREACHABLE);
            _log.warn("Failed to check dbOfflineStatus on {} :{}", nodeId, e.getMessage());
        }
    }
    ArrayList<String> unvaliableNodeList = new ArrayList<>(unvaliableNodeSet);
    setRecoverPrecheckStatus(recoveryPrecheckStatus, unvaliableNodeList, recoverableNodeList, nodeList.size());
    recoveryPrecheckStatus.setUnavailables(unvaliableNodeList);
    recoveryPrecheckStatus.setRecoverables(recoverableNodeList);
    return recoveryPrecheckStatus;
}
Also used : RecoveryPrecheckStatus(com.emc.vipr.model.sys.recovery.RecoveryPrecheckStatus) DrUtil(com.emc.storageos.coordinator.client.service.DrUtil) ArrayList(java.util.ArrayList) DbOfflineStatus(com.emc.vipr.model.sys.recovery.DbOfflineStatus) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) LocalRepositoryException(com.emc.storageos.systemservices.exceptions.LocalRepositoryException) IOException(java.io.IOException) SysClientException(com.emc.storageos.systemservices.exceptions.SysClientException) ClientHandlerException(com.sun.jersey.api.client.ClientHandlerException) HashSet(java.util.HashSet) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

DbOfflineStatus (com.emc.vipr.model.sys.recovery.DbOfflineStatus)3 SysClientException (com.emc.storageos.systemservices.exceptions.SysClientException)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 DrUtil (com.emc.storageos.coordinator.client.service.DrUtil)1 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)1 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)1 LocalRepositoryException (com.emc.storageos.systemservices.exceptions.LocalRepositoryException)1 RecoveryPrecheckStatus (com.emc.vipr.model.sys.recovery.RecoveryPrecheckStatus)1 ClientHandlerException (com.sun.jersey.api.client.ClientHandlerException)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1