Search in sources :

Example 16 with Service

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;
}
Also used : ClusterInfo(com.emc.vipr.model.sys.ClusterInfo) NodeState(com.emc.vipr.model.sys.ClusterInfo.NodeState) RepositoryInfo(com.emc.storageos.coordinator.client.model.RepositoryInfo) Service(com.emc.storageos.coordinator.common.Service) HashMap(java.util.HashMap) Map(java.util.Map)

Example 17 with Service

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();
}
Also used : SysSvcBeaconImpl(com.emc.storageos.systemservices.impl.SysSvcBeaconImpl) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) SysSvcImpl(com.emc.storageos.systemservices.impl.SysSvcImpl) ServiceImpl(com.emc.storageos.coordinator.common.impl.ServiceImpl) CoordinatorClient(com.emc.storageos.coordinator.client.service.CoordinatorClient) Service(com.emc.storageos.coordinator.common.Service) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 18 with Service

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;
}
Also used : CoordinatorClient(com.emc.storageos.coordinator.client.service.CoordinatorClient) DbService(com.emc.storageos.db.server.DbService) Service(com.emc.storageos.coordinator.common.Service) RetryableCoordinatorException(com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException) URI(java.net.URI) URISyntaxException(java.net.URISyntaxException) RetryableCoordinatorException(com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException) IOException(java.io.IOException)

Example 19 with Service

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;
}
Also used : Site(com.emc.storageos.coordinator.client.model.Site) DrUtil(com.emc.storageos.coordinator.client.service.DrUtil) Service(com.emc.storageos.coordinator.common.Service) URI(java.net.URI) CoordinatorClientInetAddressMap(com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap)

Example 20 with Service

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

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