use of com.emc.storageos.coordinator.common.Service in project coprhd-controller by CoprHD.
the class DrUtil method isSiteUp.
/**
* Check if site is up and running
*
* @param siteId
* @return true if any syssvc is running on this site
*/
public boolean isSiteUp(String siteId) {
// Get service beacons for given site - - assume syssvc on all sites share same service name in beacon
try {
String syssvcName = ((CoordinatorClientImpl) coordinator).getSysSvcName();
String syssvcVersion = ((CoordinatorClientImpl) coordinator).getSysSvcVersion();
List<Service> svcs = coordinator.locateAllServices(siteId, syssvcName, syssvcVersion, null, null);
List<String> nodeList = new ArrayList<>();
for (Service svc : svcs) {
nodeList.add(svc.getNodeId());
}
log.info("Site {} is up. active nodes {}", siteId, StringUtils.join(nodeList, ","));
return true;
} catch (CoordinatorException ex) {
if (ex.getServiceCode() == ServiceCode.COORDINATOR_SVC_NOT_FOUND) {
// no service beacon found for given site
return false;
}
log.error("Unexpected error when checking site service becons", ex);
return true;
}
}
use of com.emc.storageos.coordinator.common.Service in project coprhd-controller by CoprHD.
the class CoordinatorClientImpl method locateAllSvcsAllVers.
@Override
public List<Service> locateAllSvcsAllVers(String siteId, String name) throws CoordinatorException {
List<String> svcVerPaths = lookupServicePath(siteId, name);
List<Service> allActiveSvcs = new ArrayList<>();
for (String version : svcVerPaths) {
log.debug("locateAllSvcsAllVers->service version: {}", version);
String serviceRoot = String.format("%1$s/%2$s", name, version);
List<String> servicePaths = lookupServicePath(siteId, serviceRoot);
for (String spath : servicePaths) {
byte[] data = getServiceData(siteId, serviceRoot, spath);
if (data == null) {
continue;
}
Service service = ServiceImpl.parse(data);
allActiveSvcs.add(service);
}
}
return Collections.unmodifiableList(allActiveSvcs);
}
use of com.emc.storageos.coordinator.common.Service 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;
}
}
use of com.emc.storageos.coordinator.common.Service in project coprhd-controller by CoprHD.
the class CoordinatorClientImpl method getAllNodeInfos.
public <T extends CoordinatorSerializable> Map<Service, T> getAllNodeInfos(Class<T> clazz, Pattern nodeIdFilter, String siteId) throws Exception {
final Map<Service, T> infos = new HashMap<Service, T>();
List<Service> allSysSvcs = locateAllServices(siteId, sysSvcName, sysSvcVersion, (String) null, null);
for (Service svc : allSysSvcs) {
if (nodeIdFilter.matcher(svc.getId()).matches()) {
try {
T info = getNodeSessionScopeInfo(svc, clazz);
if (info != null) {
infos.put(svc, info);
}
} catch (Exception e) {
log.info("Failed to get all node info from {}: {}", svc.getId() + ":" + clazz.getName(), e);
}
}
}
return infos;
}
use of com.emc.storageos.coordinator.common.Service in project coprhd-controller by CoprHD.
the class RmiInvocationHandler method invoke.
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
List<Service> services = _client.locateAllServices(_name, _version, _tag, _endpointKey);
if (services == null || services.isEmpty()) {
throw CoordinatorException.fatals.endPointUnavailable();
}
_log.info("Invoking task {}: {} ", method, args);
Throwable lastError = null;
for (int index = 0; index < services.size(); index++) {
Service svc = services.get(index);
URI endpoint = null;
if (_endpointKey != null) {
endpoint = svc.getEndpoint(_endpointKey);
} else {
endpoint = svc.getEndpoint();
}
Object rmiProxy = _proxyMap.get(endpoint);
try {
if (rmiProxy == null) {
rmiProxy = createRmiProxy(endpoint);
}
_log.info("Sending RMI request to {} ", endpoint);
return method.invoke(rmiProxy, args);
} catch (RemoteLookupFailureException e) {
lastError = e;
_log.warn("Unable to lookup registry at {}", endpoint);
continue;
} catch (InvocationTargetException e) {
Throwable target = e.getTargetException();
if (target instanceof RemoteException || target instanceof RemoteLookupFailureException) {
// fail over to next host
lastError = target;
_log.warn("Remote exception trying to reach {}", endpoint, target);
continue;
}
throw target;
}
}
throw CoordinatorException.fatals.unableToConnectToEndpoint(lastError);
}
Aggregations