Search in sources :

Example 1 with Service

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

the class CoordinatorClientImpl method locateService.

@Override
public <T> T locateService(Class<T> clazz, String name, String version, String tag, String endpointKey) throws CoordinatorException {
    String key = String.format("%1$s:%2$s:%3$s:%4$s", name, version, tag, endpointKey);
    Object proxy = _proxyCache.get(key);
    if (proxy == null) {
        List<Service> services = locateAllServices(name, version, tag, endpointKey);
        if (services == null || services.isEmpty()) {
            throw CoordinatorException.retryables.unableToLocateService(name, version, tag, endpointKey);
        }
        Service service = services.get(0);
        URI endpoint = service.getEndpoint(endpointKey);
        if (endpoint == null) {
            throw CoordinatorException.retryables.unableToLocateServiceNoEndpoint(name, version, tag, endpointKey);
        }
        // check local host IPv6/IPv4
        endpoint = getInetAddessLookupMap().expandURI(endpoint);
        if (endpoint.getScheme().equals("rmi")) {
            RmiInvocationHandler handler = new RmiInvocationHandler();
            handler.setName(name);
            handler.setVersion(version);
            handler.setTag(tag);
            handler.setEndpointKey(endpointKey);
            handler.setEndpointInterface(clazz);
            handler.setCoordinator(this);
            proxy = Proxy.newProxyInstance(clazz.getClassLoader(), new Class[] { clazz }, handler);
            _proxyCache.putIfAbsent(key, proxy);
        } else {
            throw CoordinatorException.retryables.unsupportedEndPointSchema(endpoint.getScheme());
        }
    }
    return clazz.cast(proxy);
}
Also used : Service(com.emc.storageos.coordinator.common.Service) ExecutorService(java.util.concurrent.ExecutorService) PropertyInfoMapper.decodeFromString(com.emc.storageos.coordinator.mapper.PropertyInfoMapper.decodeFromString) URI(java.net.URI)

Example 2 with Service

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

the class CoordinatorClientImpl method getDifferentVdcConfigVersionCommon.

/**
 * Common method to compare vdcConfigVersions with target's vdcConfigVersion
 *
 * @param vdcConfigVersions
 *            nodes' vdcConfigVersions
 * @return list of nodes which configVersions are different from the target's
 */
private List<String> getDifferentVdcConfigVersionCommon(final Map<Service, VdcConfigVersion> vdcConfigVersions) {
    List<String> differentConfigVersions = new ArrayList<String>();
    SiteInfo targetSiteInfo = getTargetInfo(SiteInfo.class);
    if (targetSiteInfo == null) {
        return differentConfigVersions;
    }
    String targetVdcConfigVersion = String.valueOf(targetSiteInfo.getVdcConfigVersion());
    for (Map.Entry<Service, VdcConfigVersion> entry : vdcConfigVersions.entrySet()) {
        if (!StringUtils.equals(targetVdcConfigVersion, entry.getValue().getConfigVersion())) {
            differentConfigVersions.add(entry.getKey().getId());
        }
    }
    return differentConfigVersions;
}
Also used : SiteInfo(com.emc.storageos.coordinator.client.model.SiteInfo) ArrayList(java.util.ArrayList) Service(com.emc.storageos.coordinator.common.Service) ExecutorService(java.util.concurrent.ExecutorService) PropertyInfoMapper.decodeFromString(com.emc.storageos.coordinator.mapper.PropertyInfoMapper.decodeFromString) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) VdcConfigVersion(com.emc.storageos.coordinator.client.model.VdcConfigVersion)

Example 3 with Service

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

the class CoordinatorClientImpl method isControlNodesDriversSynced.

private boolean isControlNodesDriversSynced(StorageDriversInfo target, Map<Service, StorageDriversInfo> infos) {
    Set<String> targetDrivers = new HashSet<String>();
    if (target != null) {
        targetDrivers = target.getInstalledDrivers();
    }
    for (Entry<Service, StorageDriversInfo> info : infos.entrySet()) {
        String nodeName = info.getKey().getId();
        Set<String> installedDrivers = info.getValue().getInstalledDrivers();
        if (!targetDrivers.equals(installedDrivers)) {
            log.info("Target driver list: {}", Strings.repr(installedDrivers));
            log.info("Node {}'s driver list (not synced): {}", nodeName, Strings.repr(installedDrivers));
            return false;
        }
    }
    log.info("Driver lists on all nodes in current site are synced with target");
    return true;
}
Also used : Service(com.emc.storageos.coordinator.common.Service) ExecutorService(java.util.concurrent.ExecutorService) PropertyInfoMapper.decodeFromString(com.emc.storageos.coordinator.mapper.PropertyInfoMapper.decodeFromString) StorageDriversInfo(com.emc.storageos.coordinator.client.model.StorageDriversInfo) HashSet(java.util.HashSet)

Example 4 with Service

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

the class DrUtil method isAllSyssvcUp.

/**
 * Check if all syssvc is up and running for specified site
 * @param siteId
 * @return true if all syssvc is running
 */
public boolean isAllSyssvcUp(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);
        Site site = this.getSiteFromLocalVdc(siteId);
        log.info("Node count is {}, running syssvc count is", site.getNodeCount(), svcs.size());
        return svcs.size() == site.getNodeCount();
    } catch (CoordinatorException ex) {
        return false;
    }
}
Also used : CoordinatorClientImpl(com.emc.storageos.coordinator.client.service.impl.CoordinatorClientImpl) Site(com.emc.storageos.coordinator.client.model.Site) RetryableCoordinatorException(com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) Service(com.emc.storageos.coordinator.common.Service)

Example 5 with Service

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

the class CoordinatorClientImpl method getDifferentCurrentsCommon.

/**
 * Common method to compare current version with target's current version
 *
 * @param targetGiven
 *            target repository
 * @param infos
 *            nodes' repository
 * @return list of nodes which current version is different from the target's
 */
private List<String> getDifferentCurrentsCommon(final RepositoryInfo targetGiven, final Map<Service, RepositoryInfo> infos) {
    List<String> differentCurrents = new ArrayList<String>();
    final SoftwareVersion targetCurrent = targetGiven.getCurrentVersion();
    for (Map.Entry<Service, RepositoryInfo> entry : infos.entrySet()) {
        if (!targetCurrent.equals(entry.getValue().getCurrentVersion())) {
            differentCurrents.add(entry.getKey().getId());
        }
    }
    return differentCurrents;
}
Also used : SoftwareVersion(com.emc.storageos.coordinator.client.model.SoftwareVersion) RepositoryInfo(com.emc.storageos.coordinator.client.model.RepositoryInfo) ArrayList(java.util.ArrayList) Service(com.emc.storageos.coordinator.common.Service) ExecutorService(java.util.concurrent.ExecutorService) PropertyInfoMapper.decodeFromString(com.emc.storageos.coordinator.mapper.PropertyInfoMapper.decodeFromString) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap)

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