use of com.emc.storageos.coordinator.common.Service in project coprhd-controller by CoprHD.
the class CoordinatorClientImpl method isDatabaseServiceUp.
private Boolean isDatabaseServiceUp(String serviceName) {
try {
String siteId = _zkConnection.getSiteId();
List<Service> services = locateAllServices(siteId, serviceName, dbVersionInfo.getSchemaVersion(), null, null);
DrUtil drUtil = new DrUtil(this);
Site site = drUtil.getSiteFromLocalVdc(siteId);
log.info("Node count is {}, running {} count is {}", site.getNodeCount(), serviceName, services.size());
return services.size() == site.getNodeCount();
} catch (CoordinatorException e) {
return false;
}
}
use of com.emc.storageos.coordinator.common.Service in project coprhd-controller by CoprHD.
the class CoordinatorClientImpl method getNodeInfo.
public <T extends CoordinatorSerializable> T getNodeInfo(Service service, String nodeId, Class<T> clazz) throws Exception {
List<Service> svcs = locateAllServices(service.getName(), service.getVersion(), (String) null, null);
for (Service svc : svcs) {
if (svc.getId().equals(nodeId)) {
final T state = getNodeSessionScopeInfo(svc, clazz);
log.debug("getNodeSessionScopeInfo(): node={}: {}", nodeId, state);
return state;
}
}
return null;
}
use of com.emc.storageos.coordinator.common.Service in project coprhd-controller by CoprHD.
the class CoordinatorClientImpl method locateAllServices.
@Override
public List<Service> locateAllServices(String siteId, String name, String version, String tag, String endpointKey) throws CoordinatorException {
String serviceRoot = String.format("%1$s/%2$s", name, version);
List<String> servicePaths = lookupServicePath(siteId, serviceRoot);
if (servicePaths.isEmpty()) {
throw CoordinatorException.retryables.cannotLocateService(String.format("%1$s/%2$s", getServicePath(siteId), serviceRoot));
}
// poor man's load balancing
Collections.shuffle(servicePaths);
List<Service> filtered = new ArrayList<Service>(servicePaths.size());
for (int i = 0; i < servicePaths.size(); i++) {
String spath = servicePaths.get(i);
byte[] data = getServiceData(siteId, serviceRoot, spath);
if (data == null) {
continue;
}
Service service = ServiceImpl.parse(data);
if (tag != null && !service.isTagged(tag)) {
continue;
}
if (endpointKey != null && service.getEndpoint(endpointKey) == null) {
continue;
}
if (endpointKey == null) {
// default endpoint
URI endpoint = expandEndpointURI(service.getEndpoint(), siteId);
((ServiceImpl) service).setEndpoint(endpoint);
} else {
// swap the ip for the entry with the endpointkey in the map
URI endpoint = expandEndpointURI(service.getEndpoint(endpointKey), siteId);
((ServiceImpl) service).setEndpoint(endpointKey, endpoint);
}
log.debug("locateAllServices->service endpoint: " + service.getEndpoint());
filtered.add(service);
}
return Collections.unmodifiableList(filtered);
}
use of com.emc.storageos.coordinator.common.Service in project coprhd-controller by CoprHD.
the class CoordinatorClientExt method isDBServiceStarted.
public boolean isDBServiceStarted() {
List<Service> svcs = null;
try {
svcs = locateAllServices(DBSVC_NAME, _coordinator.getTargetDbSchemaVersion(), (String) null, null);
} catch (CoordinatorException e) {
return false;
}
String dbSvcId = "db" + mySvcId.substring(mySvcId.lastIndexOf("-"));
for (Service svc : svcs) {
if (svc.getId().equals(dbSvcId)) {
return true;
}
}
return false;
}
use of com.emc.storageos.coordinator.common.Service in project coprhd-controller by CoprHD.
the class CoordinatorClientExt method getClusterInfo.
public ClusterInfo getClusterInfo(String siteIdParam) {
try {
String siteId = siteIdParam == null ? _coordinator.getSiteId() : siteIdParam;
// get target repository and configVersion
final RepositoryInfo targetRepository = _coordinator.getTargetInfo(RepositoryInfo.class);
final PropertyInfoExt targetProperty = _coordinator.getTargetInfo(PropertyInfoExt.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);
ClusterInfo.ClusterState controlNodesState = _coordinator.getControlNodesState(siteId);
// rotating ipsec key. We should report upgrade in progress on UI
if (backCompatPreYoda && ClusterInfo.ClusterState.STABLE.equals(controlNodesState)) {
if (!drUtil.isMultivdc()) {
_log.info("Back compat flag for preyoda is true. ");
controlNodesState = ClusterInfo.ClusterState.UPDATING;
}
}
// cluster state is determined both by control nodes' state and extra nodes
return toClusterInfo(controlNodesState, controlNodesInfo, controlNodesConfigVersions, targetRepository, targetProperty);
} catch (Exception e) {
_log.info("Fail to get the cluster information ", e);
return null;
}
}
Aggregations