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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations