Search in sources :

Example 11 with Service

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

the class CoordinatorClientExt method getRemoteDownloadLeader.

/**
 * The method to retrieve the node holding the non-persistent remote download lock
 *
 * @return id for node which holds the leader lock, null if no node
 *         holds the leader lock
 */
public String getRemoteDownloadLeader() {
    try {
        String leader = _svc.getAttribute(REMOTE_DOWNLOAD_LEADER);
        if (leader != null && !leader.isEmpty()) {
            return leader;
        }
        List<Service> svcList = _coordinator.locateAllServices(_svc.getName(), _svc.getVersion(), (String) null, null);
        Iterator<Service> svcIter = svcList.iterator();
        while (svcIter.hasNext()) {
            Service svc = svcIter.next();
            leader = svc.getAttribute(REMOTE_DOWNLOAD_LEADER);
            if (leader != null && !leader.isEmpty()) {
                return leader;
            }
        }
    } catch (Exception ex) {
        _log.error("Failed probing for leader", ex);
    }
    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)

Example 12 with Service

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

the class EndPointLocator method getServiceEndpointList.

/**
 * Extracts a list of endpoints from a list of service info
 *
 * @return
 */
public List<URI> getServiceEndpointList() {
    // get a list of the endpoints on the cluster.
    ArrayList<URI> toReturn = new ArrayList<URI>();
    List<Service> services = getServiceInfoListInternal();
    for (Service s : services) {
        toReturn.add(s.getEndpoint());
    }
    // if not, return the list we got from the coordinator.
    return toReturn;
}
Also used : ArrayList(java.util.ArrayList) Service(com.emc.storageos.coordinator.common.Service) URI(java.net.URI)

Example 13 with Service

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

the class EndPointLocator method getServiceInfoListInternal.

/**
 * Queries the coordinator for a list of Service info objects for authsvc
 *
 * @return a list of services.
 */
private List<Service> getServiceInfoListInternal() {
    _log.debug("Retrieving authsvc service info from coordinator service");
    List<Service> services = null;
    try {
        services = _coordinator.locateAllServices(_svcInfo.getServiceName(), _svcInfo.getServiceVersion(), null, null);
        if (_log.isDebugEnabled()) {
            for (Service s : services) {
                _log.debug("Service name: {}", s.getName());
                _log.debug("Service version: {}", s.getVersion());
                _log.debug("Service id: {}", s.getId());
                _log.debug("Service end point: {}", s.getEndpoint().toString());
            }
        }
    } catch (Exception ex) {
        _log.error("Exception while retrieving authsvc service information: {}", ex.getStackTrace());
        throw SecurityException.retryables.requiredServiceUnvailable(_svcInfo.getServiceName(), ex);
    }
    if (services == null || services.isEmpty()) {
        throw SecurityException.retryables.requiredServiceUnvailable(_svcInfo.getServiceName());
    }
    return services;
}
Also used : Service(com.emc.storageos.coordinator.common.Service) SecurityException(com.emc.storageos.security.exceptions.SecurityException)

Example 14 with Service

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

the class LicenseManagerImpl method getControllerCapacity.

/**
 * Gets capacity from controller.
 * List of returned resources include volume, file and free storage pool capacities.
 */
public ManagedResourcesCapacity getControllerCapacity() throws InternalServerErrorException {
    _log.info("Getting controller capacity");
    List<Service> services = _coordinator.locateAllServices(LicenseConstants.API_SVC_LOOKUP_KEY, LicenseConstants.SERVICE_LOOKUP_VERSION, null, null);
    for (Service service : services) {
        try {
            // service could be null, if so get next service.
            if (service != null) {
                return getClient(service).get(SysClientFactory._URI_PROVISIONING_MANAGED_CAPACITY, ManagedResourcesCapacity.class, null);
            }
        } catch (SysClientException exception) {
            _log.error("LicenseManager::getCapacity for Controller. Cannot connect to host: {}", service.getEndpoint().toString());
        }
    }
    // if capacity cannot be retrieved
    _log.error("Controller capacity could not be retrieved");
    throw APIException.internalServerErrors.getObjectError("controller capacity", null);
}
Also used : Service(com.emc.storageos.coordinator.common.Service) SysClientException(com.emc.storageos.systemservices.exceptions.SysClientException)

Example 15 with Service

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

the class InternalAlertsClient method getControllerSysClient.

/**
 * Returns client for active controller VMs syssvc instance.
 */
private SysClientFactory.SysClient getControllerSysClient() {
    List<Service> services = coordinatorClient.locateAllServices(SYS_SVC_LOOKUP_KEY, SERVICE_LOOKUP_VERSION, null, null);
    URI hostUri = null;
    for (Service service : services) {
        try {
            // service could be null, if so get next service.
            if (service != null && CONTROL_NODE_SYSSVC_ID_PATTERN.matcher(service.getId()).matches()) {
                _log.info("Using {} to send alert event", service.getId());
                hostUri = service.getEndpoint();
                String baseNodeURL = String.format(SysClientFactory.BASE_URL_FORMAT, hostUri.getHost(), hostUri.getPort());
                return SysClientFactory.getSysClient(URI.create(baseNodeURL));
            }
        } catch (SysClientException exception) {
            _log.error("InternalAlertsClient. Cannot connect to host: {}", hostUri != null ? hostUri.toString() : "");
        }
    }
    throw APIException.internalServerErrors.getObjectError("controller sysvsc instance", null);
}
Also used : Service(com.emc.storageos.coordinator.common.Service) SysClientException(com.emc.storageos.systemservices.exceptions.SysClientException) URI(java.net.URI)

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