use of com.emc.storageos.coordinator.client.model.MigrationStatus in project coprhd-controller by CoprHD.
the class CoordinatorClientImpl method getControlNodesState.
/**
* Get all control nodes' state
*
* @param targetGiven
* target repository
* @param infos
* control nodes' repository
* @param targetPropertiesGiven
* target property
* @param configVersions
* control nodes' configVersions
* @param targetPowerOffState
* target poweroff state
* @param targetDrivers
* target driver list
* @param drivers
* control nodes' driver lists
* @param siteId
* @return Control nodes' state
*/
private ClusterInfo.ClusterState getControlNodesState(final RepositoryInfo targetGiven, final Map<Service, RepositoryInfo> infos, final PropertyInfoRestRep targetPropertiesGiven, final Map<Service, ConfigVersion> configVersions, final Map<Service, VdcConfigVersion> vdcConfigVersions, final PowerOffState targetPowerOffState, final StorageDriversInfo targetDrivers, final Map<Service, StorageDriversInfo> drivers, String siteId) {
if (targetGiven == null || targetPropertiesGiven == null || targetPowerOffState == null) {
// only for first time target initializing
return ClusterInfo.ClusterState.INITIALIZING;
}
DrUtil drUtil = new DrUtil(this);
Site site = drUtil.getSiteFromLocalVdc(siteId);
SiteState siteState = site.getState();
int siteNodeCount = site.getNodeCount();
if (infos == null || infos.size() != siteNodeCount || configVersions == null || configVersions.size() != siteNodeCount) {
return ClusterInfo.ClusterState.DEGRADED;
}
if (siteState == SiteState.STANDBY_ERROR) {
log.info("Control nodes' state DEGRADED since DR site state is STANDBY_ERROR");
return ClusterInfo.ClusterState.DEGRADED;
}
// 1st. Find nodes which currents and versions are different from target's
List<String> differentCurrents = getDifferentCurrentsCommon(targetGiven, infos);
List<String> differentVersions = getDifferentVersionsCommon(targetGiven, infos);
// 2nd. Find nodes which configVersions are different from target's
// Note : we use config version to judge if properties on a node are sync-ed with target's.
List<String> differentConfigVersions = getDifferentConfigVersionCommon(targetPropertiesGiven, configVersions);
List<String> differentVdcConfigVersions = getDifferentVdcConfigVersionCommon(vdcConfigVersions);
if (targetPowerOffState.getPowerOffState() != PowerOffState.State.NONE) {
log.info("Control nodes' state POWERINGOFF");
return ClusterInfo.ClusterState.POWERINGOFF;
} else if (!differentConfigVersions.isEmpty()) {
log.info("Control nodes' state UPDATING: {}", Strings.repr(targetPropertiesGiven));
return ClusterInfo.ClusterState.UPDATING;
} else if (!differentVdcConfigVersions.isEmpty()) {
log.info("Control nodes' state UPDATING vdc config version: {}", Strings.repr(differentVdcConfigVersions));
return ClusterInfo.ClusterState.UPDATING;
} else if (siteState.isDROperationOngoing()) {
log.info("Control nodes' state UPDATING since DR operation ongoing: {}", siteState);
return ClusterInfo.ClusterState.UPDATING;
} else if (!isControlNodesDriversSynced(targetDrivers, drivers)) {
log.info("Control nodes' state UPDATING since not all nodes' drivers are synced with target");
return ClusterInfo.ClusterState.UPDATING;
} else if (differentCurrents.isEmpty() && differentVersions.isEmpty()) {
// check for the extra upgrading states
if (isDbSchemaVersionChanged()) {
MigrationStatus status = getMigrationStatus();
if (status == null) {
log.info("Control nodes state is UPGRADING_PREP_DB ");
return ClusterInfo.ClusterState.UPGRADING_PREP_DB;
}
log.info("Control nodes state is {}", status);
switch(status) {
case RUNNING:
return ClusterInfo.ClusterState.UPGRADING_CONVERT_DB;
case FAILED:
return ClusterInfo.ClusterState.UPGRADING_FAILED;
case DONE:
break;
default:
log.error("The current db schema version doesn't match the target db schema version, " + "but the current migration status is {} ", status);
}
}
log.info("Control nodes' state STABLE");
return ClusterInfo.ClusterState.STABLE;
} else if (differentCurrents.isEmpty()) {
log.info("Control nodes' state SYNCING: {}", Strings.repr(differentVersions));
return ClusterInfo.ClusterState.SYNCING;
} else if (differentVersions.isEmpty()) {
log.info("Control nodes' state UPGRADING: {}", Strings.repr(differentCurrents));
return ClusterInfo.ClusterState.UPGRADING;
} else {
log.error("Control nodes' in an UNKNOWN state. Target given: {} {}", targetGiven, Strings.repr(infos));
return ClusterInfo.ClusterState.UNKNOWN;
}
}
Aggregations