Search in sources :

Example 1 with PowerOffState

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);
        }
    }
}
Also used : CoordinatorClientException(com.emc.storageos.systemservices.exceptions.CoordinatorClientException) PowerOffState(com.emc.storageos.coordinator.client.model.PowerOffState) SysClientException(com.emc.storageos.systemservices.exceptions.SysClientException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) CoordinatorClientException(com.emc.storageos.systemservices.exceptions.CoordinatorClientException)

Example 2 with PowerOffState

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));
}
Also used : PowerOffState(com.emc.storageos.coordinator.client.model.PowerOffState)

Example 3 with PowerOffState

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();
    }
}
Also used : ClientHandlerException(com.sun.jersey.api.client.ClientHandlerException) PowerOffState(com.emc.storageos.coordinator.client.model.PowerOffState) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) LocalRepositoryException(com.emc.storageos.systemservices.exceptions.LocalRepositoryException) IOException(java.io.IOException) SysClientException(com.emc.storageos.systemservices.exceptions.SysClientException) ClientHandlerException(com.sun.jersey.api.client.ClientHandlerException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 4 with PowerOffState

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;
        }
    }
}
Also used : PropertyInfoExt(com.emc.storageos.coordinator.client.model.PropertyInfoExt) ConfigVersion(com.emc.storageos.coordinator.client.model.ConfigVersion) CoordinatorClientException(com.emc.storageos.systemservices.exceptions.CoordinatorClientException) PowerOffState(com.emc.storageos.coordinator.client.model.PowerOffState)

Example 5 with PowerOffState

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;
    }
}
Also used : PropertyInfoRestRep(com.emc.storageos.model.property.PropertyInfoRestRep) RepositoryInfo(com.emc.storageos.coordinator.client.model.RepositoryInfo) VdcConfigVersion(com.emc.storageos.coordinator.client.model.VdcConfigVersion) ConfigVersion(com.emc.storageos.coordinator.client.model.ConfigVersion) Service(com.emc.storageos.coordinator.common.Service) ExecutorService(java.util.concurrent.ExecutorService) StorageDriversInfo(com.emc.storageos.coordinator.client.model.StorageDriversInfo) VdcConfigVersion(com.emc.storageos.coordinator.client.model.VdcConfigVersion) PowerOffState(com.emc.storageos.coordinator.client.model.PowerOffState) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) RetryableCoordinatorException(com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException) KeeperException(org.apache.zookeeper.KeeperException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException)

Aggregations

PowerOffState (com.emc.storageos.coordinator.client.model.PowerOffState)5 ConfigVersion (com.emc.storageos.coordinator.client.model.ConfigVersion)2 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)2 CoordinatorClientException (com.emc.storageos.systemservices.exceptions.CoordinatorClientException)2 SysClientException (com.emc.storageos.systemservices.exceptions.SysClientException)2 IOException (java.io.IOException)2 PropertyInfoExt (com.emc.storageos.coordinator.client.model.PropertyInfoExt)1 RepositoryInfo (com.emc.storageos.coordinator.client.model.RepositoryInfo)1 StorageDriversInfo (com.emc.storageos.coordinator.client.model.StorageDriversInfo)1 VdcConfigVersion (com.emc.storageos.coordinator.client.model.VdcConfigVersion)1 Service (com.emc.storageos.coordinator.common.Service)1 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)1 RetryableCoordinatorException (com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException)1 PropertyInfoRestRep (com.emc.storageos.model.property.PropertyInfoRestRep)1 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)1 LocalRepositoryException (com.emc.storageos.systemservices.exceptions.LocalRepositoryException)1 ClientHandlerException (com.sun.jersey.api.client.ClientHandlerException)1 UnknownHostException (java.net.UnknownHostException)1 ExecutorService (java.util.concurrent.ExecutorService)1 POST (javax.ws.rs.POST)1