use of com.emc.storageos.coordinator.client.model.PowerOffState in project coprhd-controller by CoprHD.
the class AbstractManager method resetTargetPowerOffState.
/**
* Reset target power off state back to NONE
*/
protected void resetTargetPowerOffState() {
poweroffAgreementsKeeper = new HashSet<String>();
while (true) {
try {
if (coordinator.isControlNode()) {
try {
coordinator.setTargetInfo(new PowerOffState(PowerOffState.State.NONE), false);
log.info("Step2: Target poweroff state change to: {}", PowerOffState.State.NONE);
} catch (CoordinatorClientException e) {
log.info("Step2: Wait another control node to set target poweroff state");
retrySleep();
}
} else {
log.info("Wait control node to set target poweroff state");
retrySleep();
}
// exit only when target poweroff state is NONE
if (coordinator.getTargetInfo(PowerOffState.class).getPowerOffState() == PowerOffState.State.NONE) {
break;
}
} catch (Exception e) {
retrySleep();
log.info("reset cluster poweroff state retrying. {}", e);
}
}
}
use of com.emc.storageos.coordinator.client.model.PowerOffState in project coprhd-controller by CoprHD.
the class AbstractManager method publishNodePowerOffState.
/**
* Publish node power off state
*
* @param toState
* @throws com.emc.storageos.systemservices.exceptions.CoordinatorClientException
*/
protected void publishNodePowerOffState(PowerOffState.State toState) throws CoordinatorClientException {
log.info("Send {} signal", toState);
coordinator.setNodeSessionScopeInfo(new PowerOffState(toState));
}
use of com.emc.storageos.coordinator.client.model.PowerOffState in project coprhd-controller by CoprHD.
the class ControlService method powerOffCluster.
/**
* This method will set the target poweroff state to PowerOffState.State.START
* If UpgradeManager sees the target poweroff state is not NONE,
* node will start to sync with each other's poweroff state until they agree to power off.
* Node's poweroff state will change from NOTICED to ACKNOWLEDGED. During the process, all nodes
* are checked to see each other's state until they can move to next state.
* After all nodes move to ACKNOWLEDGED state, they move to POWEROFF state,
* in which, they are free to power off
*
* @brief Power off ViPR controller appliance
* @prereq none
* @return Status of ViPR controller appliance
* @throws Exception
*/
@POST
@Path("cluster/poweroff")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SECURITY_ADMIN, Role.RESTRICTED_SECURITY_ADMIN })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response powerOffCluster(@QueryParam("force") String forceSet) throws Exception {
_log.debug("Poweroff cluster");
PowerOffState.State targetPoweroffState = _coordinator.getTargetInfo(PowerOffState.class).getPowerOffState();
_log.info("Current target poweroff state is: {}", targetPoweroffState.toString());
if (targetPoweroffState.equals(PowerOffState.State.FORCESTART) || targetPoweroffState.equals(PowerOffState.State.START)) {
return Response.status(Response.Status.CONFLICT).entity("A poweroff proccess is in progress, cannot accept another poweroff request.").build();
}
PowerOffState poweroffState;
if (FORCE.equals(forceSet)) {
poweroffState = new PowerOffState(PowerOffState.State.FORCESTART);
} else {
poweroffState = new PowerOffState(PowerOffState.State.START);
}
// set target poweroff state to START or FORCESTART
try {
_coordinator.setTargetInfo(poweroffState, false);
vdcManager.wakeupOtherNodes();
_alertsLog.warn("power off start");
} catch (ClientHandlerException e) {
if (!FORCE.equals(forceSet)) {
throw APIException.internalServerErrors.poweroffWakeupError(e);
} else {
// if the force option is specified, ignore sysclient exceptions since the poweroff will succeed anyways.
_log.warn("failed to wakeup all nodes. Will poweroff the cluster by force.");
}
} catch (Exception e) {
throw APIException.internalServerErrors.setObjectToError("target poweroff state", "coordinator", e);
}
// ignore audit log for internal calls
if (sc != null && sc.getUserPrincipal() != null) {
auditControl(OperationTypeEnum.POWER_OFF_CLUSTER, AuditLogManager.AUDITLOG_SUCCESS, null);
}
try {
return Response.status(Response.Status.ACCEPTED).build();
} finally {
vdcManager.wakeup();
}
}
use of com.emc.storageos.coordinator.client.model.PowerOffState in project coprhd-controller by CoprHD.
the class PropertyManager method initializeLocalAndTargetInfo.
/**
* Initialize local and target info
*
* @throws Exception
*/
private void initializeLocalAndTargetInfo(String svcId) throws Exception {
// publish config_version which is also a target property
// used as a flag denoting whether target properties have been changed
PropertyInfoExt localPropInfo = localRepository.getOverrideProperties();
localConfigVersion = localPropInfo.getProperty(PropertyInfoExt.CONFIG_VERSION);
if (localConfigVersion == null) {
localConfigVersion = "0";
localPropInfo.addProperty(PropertyInfoExt.CONFIG_VERSION, localConfigVersion);
}
coordinator.setNodeSessionScopeInfo(new ConfigVersion(localConfigVersion));
log.info("Step1a: Local config version: {}", localConfigVersion);
// get local target property info
localTargetPropInfo = getLocalTargetPropInfo(localPropInfo);
log.debug("Step1a: Local target properties: {}", localTargetPropInfo);
// set target if empty
targetPropInfo = coordinator.getTargetProperties();
if (targetPropInfo == null) {
// only control node can set target
try {
// Set the updated propperty info in coordinator
coordinator.setTargetProperties(localPropInfo.getAllProperties());
coordinator.setTargetInfo(new PowerOffState(PowerOffState.State.NONE));
targetPropInfo = coordinator.getTargetInfo(PropertyInfoExt.class);
log.info("Step1b: Target property set to local state: {}", targetPropInfo);
} catch (CoordinatorClientException e) {
log.info("Step1b: Wait another control node to set target");
retrySleep();
throw e;
}
}
}
use of com.emc.storageos.coordinator.client.model.PowerOffState in project coprhd-controller by CoprHD.
the class CoordinatorClientImpl method getControlNodesState.
@Override
public ClusterInfo.ClusterState getControlNodesState(String siteId) {
try {
// get target repository and configVersion
final RepositoryInfo targetRepository = getTargetInfo(RepositoryInfo.class);
final PropertyInfoRestRep targetProperty = getTargetInfo(PropertyInfoExt.class);
final PowerOffState targetPowerOffState = getTargetInfo(PowerOffState.class);
final StorageDriversInfo targetDrivers = getTargetInfo(StorageDriversInfo.class);
// get control nodes' repository and configVersion info
final Map<Service, RepositoryInfo> controlNodesInfo = getAllNodeInfos(RepositoryInfo.class, CONTROL_NODE_SYSSVC_ID_PATTERN, siteId);
final Map<Service, ConfigVersion> controlNodesConfigVersions = getAllNodeInfos(ConfigVersion.class, CONTROL_NODE_SYSSVC_ID_PATTERN, siteId);
final Map<Service, VdcConfigVersion> controlNodesVdcConfigVersions = getAllNodeInfos(VdcConfigVersion.class, CONTROL_NODE_SYSSVC_ID_PATTERN, siteId);
final Map<Service, StorageDriversInfo> controlNodesDrivers = getAllNodeInfos(StorageDriversInfo.class, CONTROL_NODE_SYSSVC_ID_PATTERN, siteId);
return getControlNodesState(targetRepository, controlNodesInfo, targetProperty, controlNodesConfigVersions, controlNodesVdcConfigVersions, targetPowerOffState, targetDrivers, controlNodesDrivers, siteId);
} catch (Exception e) {
log.info("Fail to get the control node information ", e);
return ClusterInfo.ClusterState.UNKNOWN;
}
}
Aggregations