Search in sources :

Example 1 with DbManagerOps

use of com.emc.storageos.management.jmx.recovery.DbManagerOps in project coprhd-controller by CoprHD.

the class DbRepairStatusHandler method queryDbRepairStatus.

/**
 * Query repair status of dbsvc or geodbsvc from DB
 */
private DbRepairStatus queryDbRepairStatus(String svcName) throws Exception {
    int progress = -1;
    DbRepairStatus.Status status = null;
    Date startTime = null;
    Date endTime = null;
    log.info("Try to get repair status of {}", svcName);
    try (DbManagerOps dbManagerOps = new DbManagerOps(svcName)) {
        DbRepairStatus repairState = dbManagerOps.getLastRepairStatus(false);
        if (repairState != null) {
            log.info("Current repair status of {} is: {}", svcName, repairState.toString());
            progress = repairState.getProgress();
            status = repairState.getStatus();
            startTime = repairState.getStartTime();
            endTime = repairState.getLastCompletionTime();
        }
        if (endTime != null) {
            return repairState;
        }
        repairState = dbManagerOps.getLastSucceededRepairStatus(false);
        if (repairState != null) {
            log.info("Last successful repair status of {} is: {}", svcName, repairState.toString());
            progress = (progress == -1) ? repairState.getProgress() : progress;
            status = (status == null) ? repairState.getStatus() : status;
            startTime = (startTime == null) ? repairState.getStartTime() : startTime;
            endTime = (endTime == null) ? repairState.getLastCompletionTime() : endTime;
        }
    }
    if (status != null) {
        return new DbRepairStatus(status, startTime, endTime, progress);
    }
    return null;
}
Also used : DbManagerOps(com.emc.storageos.management.jmx.recovery.DbManagerOps) DbRepairStatus(com.emc.vipr.model.sys.recovery.DbRepairStatus) Date(java.util.Date)

Example 2 with DbManagerOps

use of com.emc.storageos.management.jmx.recovery.DbManagerOps in project coprhd-controller by CoprHD.

the class VdcOpHandler method removeDbNodesFromGossip.

/**
 * remove a site from cassandra gossip ring of dbsvc and geodbsvc with force
 */
protected void removeDbNodesFromGossip(Site site) {
    String dcName = drUtil.getCassandraDcId(site);
    try (DbManagerOps dbOps = new DbManagerOps(Constants.DBSVC_NAME);
        DbManagerOps geodbOps = new DbManagerOps(Constants.GEODBSVC_NAME)) {
        dbOps.removeDataCenter(dcName);
        geodbOps.removeDataCenter(dcName);
    }
}
Also used : DbManagerOps(com.emc.storageos.management.jmx.recovery.DbManagerOps)

Example 3 with DbManagerOps

use of com.emc.storageos.management.jmx.recovery.DbManagerOps in project coprhd-controller by CoprHD.

the class DrDbHealthMonitor method isDataCenterSynced.

private boolean isDataCenterSynced(String host, int port, String dcName) throws MalformedObjectNameException, IOException {
    JMXServiceURL jmxUrl = new JMXServiceURL(String.format(FMTURL, host, host, port));
    Map<String, Object> env = new HashMap<String, Object>();
    JMXConnector jmxc = JMXConnectorFactory.connect(jmxUrl, env);
    MBeanServerConnection mbeanServerConn = jmxc.getMBeanServerConnection();
    try (DbManagerOps dbOps = new DbManagerOps(mbeanServerConn)) {
        boolean isDbSynced = dbOps.isDataCenterSynced(dcName);
        if (!isDbSynced) {
            log.info("Data is not synced to standby site on {}. JMX port {}", host, port);
            return false;
        }
    }
    return true;
}
Also used : JMXServiceURL(javax.management.remote.JMXServiceURL) HashMap(java.util.HashMap) DbManagerOps(com.emc.storageos.management.jmx.recovery.DbManagerOps) JMXConnector(javax.management.remote.JMXConnector) MBeanServerConnection(javax.management.MBeanServerConnection)

Example 4 with DbManagerOps

use of com.emc.storageos.management.jmx.recovery.DbManagerOps in project coprhd-controller by CoprHD.

the class RecoveryManager method runDbRepair.

/**
 * Remove the corrupted nodes and then run db node repair between the alive nodes
 */
private void runDbRepair() {
    try {
        for (String svcName : serviceNames) {
            try (DbManagerOps dbManagerOps = new DbManagerOps(svcName)) {
                dbManagerOps.removeNodes(corruptedNodes);
                dbManagerOps.startNodeRepairAndWaitFinish(true, false);
            }
        }
    } catch (Exception e) {
        log.error("Node repair failed", e);
        markRecoveryFailed(RecoveryStatus.ErrorCode.REPAIR_FAILED);
        throw APIException.internalServerErrors.nodeRepairFailed();
    }
}
Also used : DbManagerOps(com.emc.storageos.management.jmx.recovery.DbManagerOps) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) SysClientException(com.emc.storageos.systemservices.exceptions.SysClientException)

Example 5 with DbManagerOps

use of com.emc.storageos.management.jmx.recovery.DbManagerOps in project coprhd-controller by CoprHD.

the class RecoveryManager method initNodeListByCheckDbStatus.

/**
 * Init alive node list and corrupted node list by checking db status and geodb status
 */
private void initNodeListByCheckDbStatus() throws Exception {
    aliveNodes.clear();
    corruptedNodes.clear();
    for (String serviceName : serviceNames) {
        try (DbManagerOps dbManagerOps = new DbManagerOps(serviceName)) {
            Map<String, Boolean> statusMap = dbManagerOps.getNodeStates();
            for (Map.Entry<String, Boolean> statusEntry : statusMap.entrySet()) {
                log.info("status map entry: {}-{}", statusEntry.getKey(), statusEntry.getValue());
                String nodeId = statusEntry.getKey();
                if (statusEntry.getValue().equals(Boolean.TRUE)) {
                    if (!aliveNodes.contains(nodeId)) {
                        aliveNodes.add(nodeId);
                    }
                } else {
                    if (!corruptedNodes.contains(nodeId)) {
                        corruptedNodes.add(nodeId);
                    }
                    if (aliveNodes.contains(nodeId)) {
                        aliveNodes.remove(nodeId);
                    }
                }
            }
        }
    }
    log.info("Alive nodes:{}, corrupted nodes: {}", aliveNodes, corruptedNodes);
}
Also used : DbManagerOps(com.emc.storageos.management.jmx.recovery.DbManagerOps) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Map(java.util.Map)

Aggregations

DbManagerOps (com.emc.storageos.management.jmx.recovery.DbManagerOps)6 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)1 SysClientException (com.emc.storageos.systemservices.exceptions.SysClientException)1 DbRepairStatus (com.emc.vipr.model.sys.recovery.DbRepairStatus)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 MBeanServerConnection (javax.management.MBeanServerConnection)1 JMXConnector (javax.management.remote.JMXConnector)1 JMXServiceURL (javax.management.remote.JMXServiceURL)1