use of com.emc.storageos.coordinator.common.Service in project coprhd-controller by CoprHD.
the class ClusterInfoMapper method toClusterInfo.
public static ClusterInfo toClusterInfo(final ClusterState controlNodesState, final Map<Service, RepositoryInfo> controlNodesInfo, final Map<Service, ConfigVersion> controlNodesConfigVersions, final RepositoryInfo targetRepository, final PropertyInfoExt targetProperty) {
ClusterInfo toClusterInfo = new ClusterInfo();
toClusterInfo.setCurrentState((controlNodesState != ClusterState.STABLE) ? controlNodesState.toString() : ClusterState.STABLE.toString());
if (!controlNodesInfo.isEmpty()) {
toClusterInfo.setControlNodes(new HashMap<String, NodeState>());
for (Map.Entry<Service, RepositoryInfo> entry : controlNodesInfo.entrySet()) {
addControlNodeInfo(toClusterInfo, entry.getKey().getNodeId(), entry.getValue(), controlNodesConfigVersions != null ? controlNodesConfigVersions.get(entry.getKey()) : null);
}
}
if (targetRepository != null) {
addTargetInfo(toClusterInfo, targetRepository, targetProperty);
}
return toClusterInfo;
}
use of com.emc.storageos.coordinator.common.Service in project coprhd-controller by CoprHD.
the class TestSysServiceBeacon method testBeacon.
@Test
@Ignore("This references a configuration that doesn't exist (syssvc-config.xml), either fix or delete this test")
public void testBeacon() throws Exception {
String curVersion = "current_version";
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("/syssvc-config.xml");
SysSvcImpl sysservice = (SysSvcImpl) ctx.getBean(SERVICE_BEAN);
sysservice.start();
ServiceImpl svc = (ServiceImpl) ctx.getBean(SERVICE_INFO);
CoordinatorClient client = connectClient();
SysSvcBeaconImpl beacon = (SysSvcBeaconImpl) ctx.getBean(BEACON_BEAN);
List<Service> found = client.locateAllServices(svc.getName(), svc.getVersion(), (String) null, null);
Assert.assertNotNull(found);
Assert.assertEquals(found.size(), 1);
Service first = found.get(0);
Assert.assertEquals(first.getId(), svc.getId());
Assert.assertEquals(first.getEndpoint(), svc.getEndpoint());
Assert.assertEquals(first.getAttribute(curVersion), null);
svc.setAttribute(curVersion, "2");
beacon.publish();
found = client.locateAllServices(svc.getName(), svc.getVersion(), (String) null, null);
Assert.assertNotNull(found);
Assert.assertEquals(found.size(), 1);
first = found.get(0);
Assert.assertEquals(first.getId(), svc.getId());
Assert.assertEquals(first.getEndpoint(), svc.getEndpoint());
Assert.assertEquals(first.getAttribute(curVersion), "2");
sysservice.stop();
}
use of com.emc.storageos.coordinator.common.Service in project coprhd-controller by CoprHD.
the class DbSvcRunner method isStarted.
/**
* Check if service is started
*
* @return
*/
public boolean isStarted() {
try {
CoordinatorClient coordinator = getCoordinator();
List<Service> service = coordinator.locateAllServices(serviceName, SVC_VERSION, null, null);
if (service.iterator().hasNext()) {
Service svc = service.iterator().next();
URI hostUri = svc.getEndpoint();
log.info("Found " + svc.getName() + "; host = " + hostUri.getHost() + "; port = " + hostUri.getPort());
return true;
}
} catch (RetryableCoordinatorException e) {
log.warn("no {} instance running. Coordinator exception message: {}", serviceName, e.getMessage());
} catch (Exception e) {
log.error("service lookup failure", e);
}
return false;
}
use of com.emc.storageos.coordinator.common.Service in project coprhd-controller by CoprHD.
the class BackupOps method getNodesInfo.
public Map<String, URI> getNodesInfo() throws URISyntaxException {
List<Service> services = coordinatorClient.locateAllServices(((CoordinatorClientImpl) coordinatorClient).getSysSvcName(), ((CoordinatorClientImpl) coordinatorClient).getSysSvcVersion(), null, null);
// get URL schema and port
Service svc = services.get(0);
URI uri = svc.getEndpoint();
int port = uri.getPort();
String scheme = uri.getScheme();
DrUtil util = new DrUtil();
util.setCoordinator(coordinatorClient);
Site localSite = util.getLocalSite();
Map<String, String> addresses = localSite.getHostIPv4AddressMap();
if (!localSite.isUsingIpv4()) {
addresses = localSite.getHostIPv6AddressMap();
}
Map<String, URI> nodesInfo = new HashMap();
for (Map.Entry<String, String> addr : addresses.entrySet()) {
String nodeUri = scheme + "://" + addr.getValue() + ":" + port + "/";
nodesInfo.put(addr.getKey(), new URI(nodeUri));
}
return nodesInfo;
}
use of com.emc.storageos.coordinator.common.Service in project coprhd-controller by CoprHD.
the class CoordinatorClientExt method getNodeEndpointWithGoodDbsvc.
/**
* Get a syssvc endpoint URI for a node where has good dbsvc/geodbsvc
*/
public URI getNodeEndpointWithGoodDbsvc() {
try {
String dbVersion = _coordinator.getTargetDbSchemaVersion();
Set<String> localDbSvcState = getGoodNodes(Constants.DBSVC_NAME, dbVersion);
Set<String> geoDbSvcState = getGoodNodes(Constants.GEODBSVC_NAME, dbVersion);
List<Service> sysSvcs = _coordinator.locateAllServices(_svc.getName(), _svc.getVersion(), (String) null, null);
for (Service sysSvc : sysSvcs) {
String nodeSeq = getNodeSeqFromSvcId(sysSvc.getId());
if (localDbSvcState.contains(nodeSeq) && geoDbSvcState.contains(nodeSeq)) {
return sysSvc.getEndpoint();
}
_log.info("Syssvc " + nodeSeq + " is ignored for its dbsvc state: " + localDbSvcState.contains(nodeSeq) + ", " + geoDbSvcState.contains(nodeSeq));
}
} catch (Exception e) {
_log.info("Fail to get the cluster information " + e.getMessage());
}
return null;
}
Aggregations