Search in sources :

Example 31 with Service

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

the class DrUtil method isSiteUp.

/**
 * Check if site is up and running
 *
 * @param siteId
 * @return true if any syssvc is running on this site
 */
public boolean isSiteUp(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);
        List<String> nodeList = new ArrayList<>();
        for (Service svc : svcs) {
            nodeList.add(svc.getNodeId());
        }
        log.info("Site {} is up. active nodes {}", siteId, StringUtils.join(nodeList, ","));
        return true;
    } catch (CoordinatorException ex) {
        if (ex.getServiceCode() == ServiceCode.COORDINATOR_SVC_NOT_FOUND) {
            // no service beacon found for given site
            return false;
        }
        log.error("Unexpected error when checking site service becons", ex);
        return true;
    }
}
Also used : CoordinatorClientImpl(com.emc.storageos.coordinator.client.service.impl.CoordinatorClientImpl) RetryableCoordinatorException(com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) ArrayList(java.util.ArrayList) Service(com.emc.storageos.coordinator.common.Service)

Example 32 with Service

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

the class CoordinatorClientImpl method locateAllSvcsAllVers.

@Override
public List<Service> locateAllSvcsAllVers(String siteId, String name) throws CoordinatorException {
    List<String> svcVerPaths = lookupServicePath(siteId, name);
    List<Service> allActiveSvcs = new ArrayList<>();
    for (String version : svcVerPaths) {
        log.debug("locateAllSvcsAllVers->service version: {}", version);
        String serviceRoot = String.format("%1$s/%2$s", name, version);
        List<String> servicePaths = lookupServicePath(siteId, serviceRoot);
        for (String spath : servicePaths) {
            byte[] data = getServiceData(siteId, serviceRoot, spath);
            if (data == null) {
                continue;
            }
            Service service = ServiceImpl.parse(data);
            allActiveSvcs.add(service);
        }
    }
    return Collections.unmodifiableList(allActiveSvcs);
}
Also used : 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)

Example 33 with Service

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

the class CoordinatorClientImpl method getControlNodesState.

@Override
public ClusterInfo.ClusterState getControlNodesState(String siteId) {
    try {
        // get target repository and configVersion
        final RepositoryInfo targetRepository = getTargetInfo(RepositoryInfo.class);
        final PropertyInfoRestRep targetProperty = getTargetInfo(PropertyInfoExt.class);
        final PowerOffState targetPowerOffState = getTargetInfo(PowerOffState.class);
        final StorageDriversInfo targetDrivers = getTargetInfo(StorageDriversInfo.class);
        // get control nodes' repository and configVersion info
        final Map<Service, RepositoryInfo> controlNodesInfo = getAllNodeInfos(RepositoryInfo.class, CONTROL_NODE_SYSSVC_ID_PATTERN, siteId);
        final Map<Service, ConfigVersion> controlNodesConfigVersions = getAllNodeInfos(ConfigVersion.class, CONTROL_NODE_SYSSVC_ID_PATTERN, siteId);
        final Map<Service, VdcConfigVersion> controlNodesVdcConfigVersions = getAllNodeInfos(VdcConfigVersion.class, CONTROL_NODE_SYSSVC_ID_PATTERN, siteId);
        final Map<Service, StorageDriversInfo> controlNodesDrivers = getAllNodeInfos(StorageDriversInfo.class, CONTROL_NODE_SYSSVC_ID_PATTERN, siteId);
        return getControlNodesState(targetRepository, controlNodesInfo, targetProperty, controlNodesConfigVersions, controlNodesVdcConfigVersions, targetPowerOffState, targetDrivers, controlNodesDrivers, siteId);
    } catch (Exception e) {
        log.info("Fail to get the control node information ", e);
        return ClusterInfo.ClusterState.UNKNOWN;
    }
}
Also used : PropertyInfoRestRep(com.emc.storageos.model.property.PropertyInfoRestRep) RepositoryInfo(com.emc.storageos.coordinator.client.model.RepositoryInfo) VdcConfigVersion(com.emc.storageos.coordinator.client.model.VdcConfigVersion) ConfigVersion(com.emc.storageos.coordinator.client.model.ConfigVersion) Service(com.emc.storageos.coordinator.common.Service) ExecutorService(java.util.concurrent.ExecutorService) StorageDriversInfo(com.emc.storageos.coordinator.client.model.StorageDriversInfo) VdcConfigVersion(com.emc.storageos.coordinator.client.model.VdcConfigVersion) PowerOffState(com.emc.storageos.coordinator.client.model.PowerOffState) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) RetryableCoordinatorException(com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException) KeeperException(org.apache.zookeeper.KeeperException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException)

Example 34 with Service

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

the class CoordinatorClientImpl method getAllNodeInfos.

public <T extends CoordinatorSerializable> Map<Service, T> getAllNodeInfos(Class<T> clazz, Pattern nodeIdFilter, String siteId) throws Exception {
    final Map<Service, T> infos = new HashMap<Service, T>();
    List<Service> allSysSvcs = locateAllServices(siteId, sysSvcName, sysSvcVersion, (String) null, null);
    for (Service svc : allSysSvcs) {
        if (nodeIdFilter.matcher(svc.getId()).matches()) {
            try {
                T info = getNodeSessionScopeInfo(svc, clazz);
                if (info != null) {
                    infos.put(svc, info);
                }
            } catch (Exception e) {
                log.info("Failed to get all node info from {}: {}", svc.getId() + ":" + clazz.getName(), e);
            }
        }
    }
    return infos;
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) Service(com.emc.storageos.coordinator.common.Service) ExecutorService(java.util.concurrent.ExecutorService) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) RetryableCoordinatorException(com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException) KeeperException(org.apache.zookeeper.KeeperException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException)

Example 35 with Service

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

the class RmiInvocationHandler method invoke.

@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    List<Service> services = _client.locateAllServices(_name, _version, _tag, _endpointKey);
    if (services == null || services.isEmpty()) {
        throw CoordinatorException.fatals.endPointUnavailable();
    }
    _log.info("Invoking task {}: {} ", method, args);
    Throwable lastError = null;
    for (int index = 0; index < services.size(); index++) {
        Service svc = services.get(index);
        URI endpoint = null;
        if (_endpointKey != null) {
            endpoint = svc.getEndpoint(_endpointKey);
        } else {
            endpoint = svc.getEndpoint();
        }
        Object rmiProxy = _proxyMap.get(endpoint);
        try {
            if (rmiProxy == null) {
                rmiProxy = createRmiProxy(endpoint);
            }
            _log.info("Sending RMI request to {} ", endpoint);
            return method.invoke(rmiProxy, args);
        } catch (RemoteLookupFailureException e) {
            lastError = e;
            _log.warn("Unable to lookup registry at {}", endpoint);
            continue;
        } catch (InvocationTargetException e) {
            Throwable target = e.getTargetException();
            if (target instanceof RemoteException || target instanceof RemoteLookupFailureException) {
                // fail over to next host
                lastError = target;
                _log.warn("Remote exception trying to reach {}", endpoint, target);
                continue;
            }
            throw target;
        }
    }
    throw CoordinatorException.fatals.unableToConnectToEndpoint(lastError);
}
Also used : Service(com.emc.storageos.coordinator.common.Service) RemoteLookupFailureException(org.springframework.remoting.RemoteLookupFailureException) RemoteException(java.rmi.RemoteException) URI(java.net.URI) InvocationTargetException(java.lang.reflect.InvocationTargetException)

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