Search in sources :

Example 21 with Service

use of com.emc.storageos.coordinator.common.Service in project coprhd-controller by CoprHD.

the class CoordinatorClientExt method getGoodNodes.

private Set<String> getGoodNodes(String siteId, String svcName, String version) {
    Set<String> goodNodes = new HashSet<String>();
    List<Service> svcs = _coordinator.locateAllServices(siteId, svcName, version, (String) null, null);
    for (Service svc : svcs) {
        String svcId = svc.getId();
        goodNodes.add(getNodeSeqFromSvcId(svcId));
    }
    return goodNodes;
}
Also used : Service(com.emc.storageos.coordinator.common.Service) HashSet(java.util.HashSet)

Example 22 with Service

use of com.emc.storageos.coordinator.common.Service in project coprhd-controller by CoprHD.

the class CoordinatorClientExt method getAllNodes.

public List<String> getAllNodes(String siteIdParam) {
    String siteId = siteIdParam == null ? _coordinator.getSiteId() : siteIdParam;
    List<String> nodeIds = new ArrayList<>();
    try {
        List<Service> svcs = getAllServices(siteId);
        for (Service svc : svcs) {
            final String nodeId = svc.getId();
            if (nodeId != null) {
                nodeIds.add(nodeId);
            }
        }
    } catch (Exception e) {
        _log.error("getAllNodes(): Failed to get all nodeIds: {}", e);
    }
    _log.info("getAllNodes(): Node Ids: {}", Strings.repr(nodeIds));
    return nodeIds;
}
Also used : ArrayList(java.util.ArrayList) Service(com.emc.storageos.coordinator.common.Service) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) SyssvcException(com.emc.storageos.systemservices.exceptions.SyssvcException) InvalidLockOwnerException(com.emc.storageos.systemservices.exceptions.InvalidLockOwnerException) IOException(java.io.IOException) CoordinatorClientException(com.emc.storageos.systemservices.exceptions.CoordinatorClientException)

Example 23 with Service

use of com.emc.storageos.coordinator.common.Service in project coprhd-controller by CoprHD.

the class CoordinatorClientExt method getMatchingNodeIds.

/**
 * The utility method to find the corresponding nodeIds for the provided
 * node names. When each node starts, the system management service on each
 * node, registers themselves with the coordninator. This method iterates
 * over that registration namespace to find the nodes in the cluster
 *
 * @return NodeHandle for mathing node in the cluster
 */
public List<String> getMatchingNodeIds(List<String> nodeNames) {
    List<String> nodeIds = new ArrayList<String>();
    // if use short name is enabled allow matching short name to nodeId
    boolean useShortName = Boolean.parseBoolean(getPropertyInfo().getProperty("use_short_node_name"));
    try {
        List<Service> svcs = getAllServices();
        for (Service svc : svcs) {
            if (useShortName) {
                if (nodeNames.contains(svc.getNodeName()) || nodeNames.contains(svc.getNodeName().split("\\.")[0])) {
                    final String nodeId = svc.getNodeId();
                    nodeIds.add(nodeId);
                }
            } else {
                if (nodeNames.contains(svc.getNodeName())) {
                    final String nodeId = svc.getNodeId();
                    nodeIds.add(nodeId);
                }
            }
        }
    } catch (Exception e) {
        _log.error("getMatchingNodeIds(): Failed to get all nodeIds for nodeNames {}: {}", nodeNames, e);
    }
    _log.info("getMatchingNodeIds(): Node Ids: {}", Strings.repr(nodeIds));
    return nodeIds;
}
Also used : ArrayList(java.util.ArrayList) Service(com.emc.storageos.coordinator.common.Service) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) SyssvcException(com.emc.storageos.systemservices.exceptions.SyssvcException) InvalidLockOwnerException(com.emc.storageos.systemservices.exceptions.InvalidLockOwnerException) IOException(java.io.IOException) CoordinatorClientException(com.emc.storageos.systemservices.exceptions.CoordinatorClientException)

Example 24 with Service

use of com.emc.storageos.coordinator.common.Service in project coprhd-controller by CoprHD.

the class CoordinatorClientExt method getMatchingNodeId.

/**
 * The utility method to find the corresponding nodeId for the provided
 * node name. When each node starts, the system management service on each
 * node, registers themselves with the coordninator. This method iterates
 * over that registration namespace to find the node in the cluster
 *
 * @return NodeHandle for mathing node in the cluster
 */
public String getMatchingNodeId(String nodeName) {
    String nodeId = null;
    // if use short name is enabled allow matching short name to nodeId
    boolean useShortName = Boolean.parseBoolean(getPropertyInfo().getProperty("use_short_node_name"));
    try {
        List<Service> svcs = getAllServices();
        for (Service svc : svcs) {
            if (useShortName) {
                if (nodeName.equals(svc.getNodeName()) || nodeName.equals(svc.getNodeName().split("\\.")[0])) {
                    nodeId = svc.getNodeId();
                }
            } else {
                if (nodeName.equals(svc.getNodeName())) {
                    nodeId = svc.getNodeId();
                }
            }
        }
    } catch (Exception e) {
        _log.error("getMatchingNodeId(): Failed to get all nodes while searching for {}: {}", nodeName, e);
    }
    if (nodeId == null) {
        _log.error("getMatchingNodeId(): Failed to get nodeId for nodeName {}", nodeName);
    } else {
        _log.info("getMatchingNodeId(): Node Id: {}", nodeId);
    }
    return nodeId;
}
Also used : Service(com.emc.storageos.coordinator.common.Service) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) SyssvcException(com.emc.storageos.systemservices.exceptions.SyssvcException) InvalidLockOwnerException(com.emc.storageos.systemservices.exceptions.InvalidLockOwnerException) IOException(java.io.IOException) CoordinatorClientException(com.emc.storageos.systemservices.exceptions.CoordinatorClientException)

Example 25 with Service

use of com.emc.storageos.coordinator.common.Service in project coprhd-controller by CoprHD.

the class AbstractManager method isQuorumMaintained.

/**
 * Check if node_count/2 + 1 dbsvc instances are active on other nodes in the cluster
 * so that if the current node is powered off, a quorum will still be maintained.
 *
 * @return true if a quorum can be maintained, false otherwise
 */
protected boolean isQuorumMaintained() {
    if (nodeCount == 1) {
        log.info("There's no way to maintain quorum on single node deployments. Proceed anyway.");
        return true;
    }
    int quorumNodeCnt = nodeCount / 2 + 1;
    CoordinatorClient coordinatorClient = coordinator.getCoordinatorClient();
    List<Service> allActiveDbsvcs = coordinatorClient.locateAllSvcsAllVers(Constants.DBSVC_NAME);
    List<String> otherActiveDbsvcIds = new ArrayList<>();
    String mySvcId = coordinator.getMySvcId();
    String localDbSvcId = "db" + mySvcId.substring(mySvcId.lastIndexOf("-"));
    for (Service activeDbsvc : allActiveDbsvcs) {
        if (!localDbSvcId.equals(activeDbsvc.getId())) {
            otherActiveDbsvcIds.add(activeDbsvc.getId());
        }
    }
    log.info("List of active dbsvc instances on other nodes: {}, expect {} instances to maintain quorum", otherActiveDbsvcIds, quorumNodeCnt);
    boolean isMaintained = otherActiveDbsvcIds.size() >= quorumNodeCnt;
    if (!isMaintained) {
        log.info("quorum would lost if reboot the current node. Retrying...");
    }
    return isMaintained;
}
Also used : ArrayList(java.util.ArrayList) CoordinatorClient(com.emc.storageos.coordinator.client.service.CoordinatorClient) Service(com.emc.storageos.coordinator.common.Service)

Aggregations

Service (com.emc.storageos.coordinator.common.Service)38 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)13 ArrayList (java.util.ArrayList)12 IOException (java.io.IOException)11 ExecutorService (java.util.concurrent.ExecutorService)10 URI (java.net.URI)9 RetryableCoordinatorException (com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException)7 PropertyInfoMapper.decodeFromString (com.emc.storageos.coordinator.mapper.PropertyInfoMapper.decodeFromString)7 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)7 CoordinatorClientException (com.emc.storageos.systemservices.exceptions.CoordinatorClientException)6 InvalidLockOwnerException (com.emc.storageos.systemservices.exceptions.InvalidLockOwnerException)6 SyssvcException (com.emc.storageos.systemservices.exceptions.SyssvcException)6 RepositoryInfo (com.emc.storageos.coordinator.client.model.RepositoryInfo)4 CoordinatorClient (com.emc.storageos.coordinator.client.service.CoordinatorClient)4 UnknownHostException (java.net.UnknownHostException)4 HashMap (java.util.HashMap)4 Site (com.emc.storageos.coordinator.client.model.Site)3 SysClientException (com.emc.storageos.systemservices.exceptions.SysClientException)3 Map (java.util.Map)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3