Search in sources :

Example 6 with Service

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

the class CoordinatorClientImpl method isDatabaseServiceUp.

private Boolean isDatabaseServiceUp(String serviceName) {
    try {
        String siteId = _zkConnection.getSiteId();
        List<Service> services = locateAllServices(siteId, serviceName, dbVersionInfo.getSchemaVersion(), null, null);
        DrUtil drUtil = new DrUtil(this);
        Site site = drUtil.getSiteFromLocalVdc(siteId);
        log.info("Node count is {}, running {} count is {}", site.getNodeCount(), serviceName, services.size());
        return services.size() == site.getNodeCount();
    } catch (CoordinatorException e) {
        return false;
    }
}
Also used : Site(com.emc.storageos.coordinator.client.model.Site) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) RetryableCoordinatorException(com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException) DrUtil(com.emc.storageos.coordinator.client.service.DrUtil) Service(com.emc.storageos.coordinator.common.Service) ExecutorService(java.util.concurrent.ExecutorService) PropertyInfoMapper.decodeFromString(com.emc.storageos.coordinator.mapper.PropertyInfoMapper.decodeFromString)

Example 7 with Service

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

the class CoordinatorClientImpl method getNodeInfo.

public <T extends CoordinatorSerializable> T getNodeInfo(Service service, String nodeId, Class<T> clazz) throws Exception {
    List<Service> svcs = locateAllServices(service.getName(), service.getVersion(), (String) null, null);
    for (Service svc : svcs) {
        if (svc.getId().equals(nodeId)) {
            final T state = getNodeSessionScopeInfo(svc, clazz);
            log.debug("getNodeSessionScopeInfo(): node={}: {}", nodeId, state);
            return state;
        }
    }
    return null;
}
Also used : Service(com.emc.storageos.coordinator.common.Service) ExecutorService(java.util.concurrent.ExecutorService)

Example 8 with Service

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

the class CoordinatorClientImpl method locateAllServices.

@Override
public List<Service> locateAllServices(String siteId, String name, String version, String tag, String endpointKey) throws CoordinatorException {
    String serviceRoot = String.format("%1$s/%2$s", name, version);
    List<String> servicePaths = lookupServicePath(siteId, serviceRoot);
    if (servicePaths.isEmpty()) {
        throw CoordinatorException.retryables.cannotLocateService(String.format("%1$s/%2$s", getServicePath(siteId), serviceRoot));
    }
    // poor man's load balancing
    Collections.shuffle(servicePaths);
    List<Service> filtered = new ArrayList<Service>(servicePaths.size());
    for (int i = 0; i < servicePaths.size(); i++) {
        String spath = servicePaths.get(i);
        byte[] data = getServiceData(siteId, serviceRoot, spath);
        if (data == null) {
            continue;
        }
        Service service = ServiceImpl.parse(data);
        if (tag != null && !service.isTagged(tag)) {
            continue;
        }
        if (endpointKey != null && service.getEndpoint(endpointKey) == null) {
            continue;
        }
        if (endpointKey == null) {
            // default endpoint
            URI endpoint = expandEndpointURI(service.getEndpoint(), siteId);
            ((ServiceImpl) service).setEndpoint(endpoint);
        } else {
            // swap the ip for the entry with the endpointkey in the map
            URI endpoint = expandEndpointURI(service.getEndpoint(endpointKey), siteId);
            ((ServiceImpl) service).setEndpoint(endpointKey, endpoint);
        }
        log.debug("locateAllServices->service endpoint: " + service.getEndpoint());
        filtered.add(service);
    }
    return Collections.unmodifiableList(filtered);
}
Also used : ServiceImpl(com.emc.storageos.coordinator.common.impl.ServiceImpl) 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) URI(java.net.URI)

Example 9 with Service

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

the class CoordinatorClientExt method isDBServiceStarted.

public boolean isDBServiceStarted() {
    List<Service> svcs = null;
    try {
        svcs = locateAllServices(DBSVC_NAME, _coordinator.getTargetDbSchemaVersion(), (String) null, null);
    } catch (CoordinatorException e) {
        return false;
    }
    String dbSvcId = "db" + mySvcId.substring(mySvcId.lastIndexOf("-"));
    for (Service svc : svcs) {
        if (svc.getId().equals(dbSvcId)) {
            return true;
        }
    }
    return false;
}
Also used : CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) Service(com.emc.storageos.coordinator.common.Service)

Example 10 with Service

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

the class CoordinatorClientExt method getClusterInfo.

public ClusterInfo getClusterInfo(String siteIdParam) {
    try {
        String siteId = siteIdParam == null ? _coordinator.getSiteId() : siteIdParam;
        // get target repository and configVersion
        final RepositoryInfo targetRepository = _coordinator.getTargetInfo(RepositoryInfo.class);
        final PropertyInfoExt targetProperty = _coordinator.getTargetInfo(PropertyInfoExt.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);
        ClusterInfo.ClusterState controlNodesState = _coordinator.getControlNodesState(siteId);
        // rotating ipsec key. We should report upgrade in progress on UI
        if (backCompatPreYoda && ClusterInfo.ClusterState.STABLE.equals(controlNodesState)) {
            if (!drUtil.isMultivdc()) {
                _log.info("Back compat flag for preyoda is true. ");
                controlNodesState = ClusterInfo.ClusterState.UPDATING;
            }
        }
        // cluster state is determined both by control nodes' state and extra nodes
        return toClusterInfo(controlNodesState, controlNodesInfo, controlNodesConfigVersions, targetRepository, targetProperty);
    } catch (Exception e) {
        _log.info("Fail to get the cluster information ", e);
        return null;
    }
}
Also used : ClusterInfoMapper.toClusterInfo(com.emc.storageos.systemservices.mapper.ClusterInfoMapper.toClusterInfo) ClusterInfo(com.emc.vipr.model.sys.ClusterInfo) RepositoryInfo(com.emc.storageos.coordinator.client.model.RepositoryInfo) PropertyInfoExt(com.emc.storageos.coordinator.client.model.PropertyInfoExt) ConfigVersion(com.emc.storageos.coordinator.client.model.ConfigVersion) Service(com.emc.storageos.coordinator.common.Service) ClusterState(com.emc.vipr.model.sys.ClusterInfo.ClusterState) 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