use of com.emc.vipr.model.sys.ClusterInfo in project coprhd-controller by CoprHD.
the class UpgradeService method wakeupManager.
/**
* *Internal API, used only between nodes*
* <p>
* Wake up node
*
* @return Cluster state information.
*/
@POST
@Path("internal/wakeup/")
public Response wakeupManager(@QueryParam("type") String managerType) {
if (managerType == null) {
managerType = "all";
}
switch(managerType) {
case "upgrade":
_upgradeManager.wakeup();
break;
case "secrets":
_secretsManager.wakeup();
break;
case "property":
_propertyManager.wakeup();
break;
case "vdc":
_vdcManager.wakeup();
break;
default:
_upgradeManager.wakeup();
_secretsManager.wakeup();
_propertyManager.wakeup();
_vdcManager.wakeup();
}
ClusterInfo clusterInfo = _coordinator.getClusterInfo();
if (clusterInfo == null) {
throw APIException.internalServerErrors.targetIsNullOrEmpty("Cluster info");
}
_log.debug("Successfully woke up {} manager(s)", managerType);
return toClusterResponse(clusterInfo);
}
use of com.emc.vipr.model.sys.ClusterInfo in project coprhd-controller by CoprHD.
the class ConfigService method updatePropertiesCommon.
/**
* Common method called by setProps and resetProps
* Callers should prepare valid updateProps and deleteProps,
* by verifying against validateAndUpdateProperties
* before call this method
*
* @param updateProps update properties' keys and values
* @param deleteKeys delete properties' keys
* @throws Exception
* @throws CoordinatorClientException
*/
private Response updatePropertiesCommon(PropertyInfoRestRep updateProps, List<String> deleteKeys) throws Exception {
// validate
if (!_coordinator.isClusterUpgradable()) {
throw APIException.serviceUnavailable.clusterStateNotStable();
}
StringBuilder propChanges = new StringBuilder();
// get current property set
PropertyInfoRestRep oldProps = new PropertyInfoRestRep();
oldProps.addProperties(getTargetPropsCommon().getAllProperties());
boolean doSetTarget = false;
PropertyInfoRestRep currentProps = _coordinator.getTargetProperties();
// remove properties
if (deleteKeys != null && !deleteKeys.isEmpty()) {
doSetTarget = true;
for (String key : deleteKeys) {
currentProps.removeProperty(key);
propChanges.append(key);
propChanges.append(" deleted");
}
currentProps.removeProperties(deleteKeys);
}
// update properties, increment config_version
if (updateProps != null && !updateProps.isEmpty()) {
doSetTarget = true;
currentProps.addProperties(updateProps.getAllProperties());
String configVersion = System.currentTimeMillis() + "";
currentProps.addProperty(PropertyInfoRestRep.CONFIG_VERSION, configVersion);
if (propChanges.length() > 0) {
propChanges.append(",");
}
propChanges.append(PropertyInfoRestRep.CONFIG_VERSION);
propChanges.append("=");
propChanges.append(configVersion);
}
if (doSetTarget) {
// perform before handlers
_propertyHandlers.before(oldProps, currentProps);
_coordinator.setTargetProperties(currentProps.getAllProperties());
for (Map.Entry<String, String> entry : updateProps.getAllProperties().entrySet()) {
if (propChanges.length() > 0) {
propChanges.append(",");
}
propChanges.append(entry.getKey());
propChanges.append("=");
// Hide encrypted string in audit log
if (PropertyInfoExt.isEncryptedProperty(entry.getKey())) {
propChanges.append(HIDDEN_TEXT_MASK);
} else {
propChanges.append(entry.getValue());
}
}
auditConfig(OperationTypeEnum.UPDATE_SYSTEM_PROPERTY, AuditLogManager.AUDITLOG_SUCCESS, null, propChanges.toString());
// perform after handlers
_propertyHandlers.after(oldProps, currentProps);
}
ClusterInfo clusterInfo = _coordinator.getClusterInfo();
if (clusterInfo == null) {
throw APIException.internalServerErrors.targetIsNullOrEmpty("Cluster information");
}
return toClusterResponse(clusterInfo);
}
use of com.emc.vipr.model.sys.ClusterInfo in project coprhd-controller by CoprHD.
the class SystemHealth method logs.
public static void logs() {
List<NodeHealth> nodeHealthList = MonitorUtils.getNodeHealth();
ClusterInfo clusterInfo = AdminDashboardUtils.getClusterInfo();
renderArgs.put("severities", SEVERITIES);
if (DisasterRecoveryUtils.isActiveSite()) {
renderArgs.put("orderTypes", ORDER_TYPES);
}
Set<String> controlServiceNames = getControlServiceNames(nodeHealthList, clusterInfo);
renderArgs.put("controlServices", controlServiceNames);
Set<String> allServiceNames = getAllServiceNames(nodeHealthList);
renderArgs.put("allServices", allServiceNames);
List<NodeHealth> controlNodes = getControlNodes(nodeHealthList, clusterInfo);
renderArgs.put("controlNodes", controlNodes);
DateTime defaultStartTime = new DateTime().minusMinutes(15);
// Remove some logs from the default list
Set<String> defaultServiceNames = Sets.newHashSet(allServiceNames);
defaultServiceNames.remove(SystemLogUtils.MESSAGES_LOG);
defaultServiceNames.remove(SystemLogUtils.NGINX_ACCESS_LOG);
defaultServiceNames.remove(SystemLogUtils.NGINX_ERROR_LOG);
renderArgs.put("allDiagnosticOptions", getDiagnosticOptions());
renderArgs.put("defaultDiagnosticOptions", getDefaultDiagnosticOptions().values());
loadSystemLogArgument(PARAM_NODE_ID, null);
loadSystemLogArgument(PARAM_SERVICE, defaultServiceNames, String[].class);
loadSystemLogArgument(PARAM_SEVERITY, DEFAULT_SEVERITY);
loadSystemLogArgument(PARAM_SEARCH_MESSAGE, null);
loadSystemLogArgument(PARAM_START_TIME, defaultStartTime.getMillis(), Long.class);
Common.copyRenderArgsToAngular();
render();
}
use of com.emc.vipr.model.sys.ClusterInfo in project coprhd-controller by CoprHD.
the class SystemHealth method minorityNodeRecovery.
@Restrictions({ @Restrict("SYSTEM_ADMIN"), @Restrict("SECURITY_ADMIN"), @Restrict("RESTRICTED_SECURITY_ADMIN") })
public static void minorityNodeRecovery() {
new MinorityNodeRecoveryJob(getSysClient()).in(3);
ViPRSystemClient client = BourneUtil.getSysClient();
List<NodeHealth> nodeHealthList = MonitorUtils.getNodeHealth();
ClusterInfo clusterInfo = AdminDashboardUtils.getClusterInfo();
if (PlatformUtils.isVMwareVapp()) {
RecoveryPrecheckStatus recoveryPrecheckStatus = client.control().getRecoveryPrecheckStatus();
String recoveringMsg = Messages.get("nodeRecovery.recovering.status", recoveryPrecheckStatus.getRecoverables().toString());
renderArgs.put("recoveringMsg", recoveringMsg);
}
RecoveryStatus recoveryStatus = client.control().getRecoveryStatus();
renderArgs.put("nodeHealthList", nodeHealthList);
renderArgs.put("clusterInfo", clusterInfo);
renderArgs.put("recoveryStatus", recoveryStatus);
if (PlatformUtils.isVMwareVapp()) {
render("@nodeRecoveryVapp");
} else {
render("@nodeRecovery");
}
}
use of com.emc.vipr.model.sys.ClusterInfo in project coprhd-controller by CoprHD.
the class Maintenance method clusterState.
public static void clusterState() {
request.format = "json";
ClusterInfo clusterInfo = null;
try {
clusterInfo = getClusterState();
Logger.info("cluster status %s", clusterInfo.getCurrentState());
} catch (ViPRHttpException e) {
Common.handleExpiredToken(e);
Logger.error(e, "Failed to get cluster state");
error(e.getHttpCode(), e.getMessage());
} catch (Exception e) {
Logger.error(e, "Failed to get cluster state");
error(e.getMessage());
}
renderJSON(clusterInfo);
}
Aggregations