Search in sources :

Example 11 with Service

use of com.logicalclocks.servicediscoverclient.service.Service in project hopsworks by logicalclocks.

the class HopsfsTrainingDatasetController method convertHopsfsTrainingDatasetToDTO.

/**
 * Converts a Hopsfs Training Dataset entity into a DTO representation
 *
 * @param trainingDataset the entity to convert
 * @return the converted DTO representation
 */
public TrainingDatasetDTO convertHopsfsTrainingDatasetToDTO(TrainingDatasetDTO trainingDatasetDTO, TrainingDataset trainingDataset) throws ServiceException {
    Service namenodeService;
    try {
        namenodeService = serviceDiscoveryController.getAnyAddressOfServiceWithDNS(ServiceDiscoveryController.HopsworksService.RPC_NAMENODE);
    } catch (ServiceDiscoveryException e) {
        throw new ServiceException(RESTCodes.ServiceErrorCode.SERVICE_NOT_FOUND, Level.SEVERE, "Could not find namenode service", e.getMessage(), e);
    }
    HopsfsTrainingDataset hopsfsTrainingDataset = trainingDataset.getHopsfsTrainingDataset();
    trainingDatasetDTO.setLocation(new Path(DistributedFileSystemOps.HOPSFS_SCHEME, namenodeService.getAddress() + ":" + namenodeService.getPort(), inodeController.getPath(hopsfsTrainingDataset.getInode())).toString());
    trainingDatasetDTO.setInodeId(hopsfsTrainingDataset.getInode().getId());
    FeaturestoreHopsfsConnectorDTO hopsfsConnectorDTO = new FeaturestoreHopsfsConnectorDTO(hopsfsTrainingDataset.getFeaturestoreConnector());
    trainingDatasetDTO.setStorageConnector(hopsfsConnectorDTO);
    return trainingDatasetDTO;
}
Also used : Path(org.apache.hadoop.fs.Path) FeaturestoreHopsfsConnectorDTO(io.hops.hopsworks.common.featurestore.storageconnectors.hopsfs.FeaturestoreHopsfsConnectorDTO) ServiceException(io.hops.hopsworks.exceptions.ServiceException) HopsfsTrainingDataset(io.hops.hopsworks.persistence.entity.featurestore.trainingdataset.hopsfs.HopsfsTrainingDataset) Service(com.logicalclocks.servicediscoverclient.service.Service) ServiceDiscoveryException(com.logicalclocks.servicediscoverclient.exceptions.ServiceDiscoveryException)

Example 12 with Service

use of com.logicalclocks.servicediscoverclient.service.Service in project hopsworks by logicalclocks.

the class Settings method getAlertManagerService.

private static Optional<Service> getAlertManagerService(String serviceFQDN) throws ServiceDiscoveryException {
    ServiceDiscoveryClient client = null;
    Optional<Service> services;
    try {
        client = new Builder(Type.DNS).build();
        String name = Strings.isNullOrEmpty(serviceFQDN) ? DEFAULT_ALERTMANAGER_FQDN : serviceFQDN;
        services = client.getService(ServiceQuery.of(name, Collections.emptySet())).findFirst();
    } finally {
        if (client != null) {
            client.close();
        }
    }
    return services;
}
Also used : ServiceDiscoveryClient(com.logicalclocks.servicediscoverclient.ServiceDiscoveryClient) Builder(com.logicalclocks.servicediscoverclient.Builder) UriBuilder(javax.ws.rs.core.UriBuilder) Service(com.logicalclocks.servicediscoverclient.service.Service)

Aggregations

Service (com.logicalclocks.servicediscoverclient.service.Service)12 ServiceDiscoveryException (com.logicalclocks.servicediscoverclient.exceptions.ServiceDiscoveryException)7 IOException (java.io.IOException)5 HttpHost (org.apache.http.HttpHost)4 ServiceException (io.hops.hopsworks.exceptions.ServiceException)3 HttpGet (org.apache.http.client.methods.HttpGet)3 ServiceNotFoundException (com.logicalclocks.servicediscoverclient.exceptions.ServiceNotFoundException)2 ServiceQuery (com.logicalclocks.servicediscoverclient.service.ServiceQuery)2 TemplateException (freemarker.template.TemplateException)2 HttpClient (io.hops.hopsworks.common.proxies.client.HttpClient)2 YarnClientService (io.hops.hopsworks.common.yarn.YarnClientService)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Lock (javax.ejb.Lock)2 UriBuilder (javax.ws.rs.core.UriBuilder)2 Builder (com.logicalclocks.servicediscoverclient.Builder)1 ServiceDiscoveryClient (com.logicalclocks.servicediscoverclient.ServiceDiscoveryClient)1 DnsResolver (com.logicalclocks.servicediscoverclient.resolvers.DnsResolver)1 FeaturestoreHopsfsConnectorDTO (io.hops.hopsworks.common.featurestore.storageconnectors.hopsfs.FeaturestoreHopsfsConnectorDTO)1 ServiceDiscoveryController (io.hops.hopsworks.common.hosts.ServiceDiscoveryController)1