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;
}
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;
}
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;
}
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);
}
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);
}
Aggregations