Search in sources :

Example 36 with Service

use of com.emc.storageos.coordinator.common.Service in project coprhd-controller by CoprHD.

the class HostSupplierImpl method internalGet.

public List<Host> internalGet() {
    try {
        _log.debug("getting hosts for " + dbSvcName + "; version = " + _version);
        boolean isGeodb = Constants.GEODBSVC_NAME.equals(dbSvcName);
        List<Service> service = _coordinator.locateAllServices(dbSvcName, _version, (String) null, null);
        List<Host> hostList = new ArrayList<Host>(service.size());
        for (int i = 0; i < service.size(); i++) {
            Service svc = service.get(i);
            if (isGeodb && isDbReinitializing(svc)) {
                _log.debug("Ignore host {} because its geodb is reinitialzing", svc.getId());
                continue;
            }
            URI hostUri = svc.getEndpoint();
            _log.debug("Found " + svc.getName() + "; host = " + hostUri.getHost() + "; port = " + hostUri.getPort());
            hostList.add(new Host(String.format("%1$s:%2$d", hostUri.getHost(), hostUri.getPort()), hostUri.getPort()));
        }
        _log.debug("dbsvc endpoint refreshed");
        return hostList;
    } catch (RetryableCoordinatorException e) {
        _log.warn("no dbsvc instance running. Coordinator exception message: {}", e.getMessage());
    } catch (Exception e) {
        _log.error("dbsvc lookup failure", e);
    }
    return Collections.emptyList();
}
Also used : Service(com.emc.storageos.coordinator.common.Service) RetryableCoordinatorException(com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException) Host(com.netflix.astyanax.connectionpool.Host) URI(java.net.URI) RetryableCoordinatorException(com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException)

Example 37 with Service

use of com.emc.storageos.coordinator.common.Service in project coprhd-controller by CoprHD.

the class GeoSeedProviderImpl method getStartedGeodbsvcList.

private List<String> getStartedGeodbsvcList() {
    List<String> geodbsvcIds = new ArrayList<String>();
    try {
        final String schemaVersion = coordinator.getCurrentDbSchemaVersion();
        final List<Service> serviceList = coordinator.locateAllServices(Constants.GEODBSVC_NAME, schemaVersion, (String) null, null);
        for (Service getdbsvc : serviceList) {
            geodbsvcIds.add(getdbsvc.getId());
        }
        log.info("Geodbsvc started status: {}", geodbsvcIds);
    } catch (Exception ex) {
        log.warn("Check geodbsvc beacon error", ex);
    }
    return geodbsvcIds;
}
Also used : ArrayList(java.util.ArrayList) Service(com.emc.storageos.coordinator.common.Service) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException)

Example 38 with Service

use of com.emc.storageos.coordinator.common.Service in project coprhd-controller by CoprHD.

the class BackupOps method getAvailableNodes.

private List<String> getAvailableNodes() {
    List<String> goodNodes = new ArrayList<String>();
    try {
        List<Service> svcs = coordinatorClient.locateAllServices(((CoordinatorClientImpl) coordinatorClient).getSysSvcName(), ((CoordinatorClientImpl) coordinatorClient).getSysSvcVersion(), (String) null, null);
        for (Service svc : svcs) {
            String svcId = svc.getId();
            String nodeId = String.format(Constants.NODE_ID_FORMAT, svcId.substring(svcId.lastIndexOf("-") + 1));
            if (svcId.endsWith(Constants.STANDALONE_ID)) {
                nodeId = Constants.STANDALONE_ID;
            }
            goodNodes.add(nodeId);
        }
        log.debug("Available nodes: {}", goodNodes);
    } catch (Exception e) {
        log.warn("Failed to get available nodes by query syssvc beacon", e);
        goodNodes.addAll(hosts.keySet());
    }
    return goodNodes;
}
Also used : Service(com.emc.storageos.coordinator.common.Service) URISyntaxException(java.net.URISyntaxException) CancellationException(java.util.concurrent.CancellationException) MalformedObjectNameException(javax.management.MalformedObjectNameException) RetryableBackupException(com.emc.storageos.management.backup.exceptions.RetryableBackupException) KeeperException(org.apache.zookeeper.KeeperException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) ExecutionException(java.util.concurrent.ExecutionException) BackupException(com.emc.storageos.management.backup.exceptions.BackupException)

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