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