Search in sources :

Example 26 with Service

use of com.hortonworks.streamline.streams.cluster.catalog.Service in project streamline by hortonworks.

the class ServiceCatalogResource method addOrUpdateService.

@PUT
@Path("/clusters/{clusterId}/services/{id}")
@Timed
public Response addOrUpdateService(@PathParam("clusterId") Long clusterId, @PathParam("id") Long serviceId, Service service, @Context SecurityContext securityContext) {
    SecurityUtil.checkPermissions(authorizer, securityContext, Cluster.NAMESPACE, clusterId, WRITE);
    // overwrite cluster id to given path param
    service.setClusterId(clusterId);
    Cluster cluster = environmentService.getCluster(clusterId);
    if (cluster == null) {
        throw EntityNotFoundException.byId("cluster: " + clusterId.toString());
    }
    Service newService = environmentService.addOrUpdateService(serviceId, service);
    return WSUtils.respondEntity(newService, OK);
}
Also used : Cluster(com.hortonworks.streamline.streams.cluster.catalog.Cluster) Service(com.hortonworks.streamline.streams.cluster.catalog.Service) EnvironmentService(com.hortonworks.streamline.streams.cluster.service.EnvironmentService) Path(javax.ws.rs.Path) Timed(com.codahale.metrics.annotation.Timed) PUT(javax.ws.rs.PUT)

Example 27 with Service

use of com.hortonworks.streamline.streams.cluster.catalog.Service in project streamline by hortonworks.

the class EnvironmentService method removeService.

public Service removeService(Long serviceId) {
    Service service = new Service();
    service.setId(serviceId);
    return dao.remove(new StorableKey(SERVICE_NAMESPACE, service.getPrimaryKey()));
}
Also used : StorableKey(com.hortonworks.registries.storage.StorableKey) Service(com.hortonworks.streamline.streams.cluster.catalog.Service)

Example 28 with Service

use of com.hortonworks.streamline.streams.cluster.catalog.Service in project streamline by hortonworks.

the class ClusterResourceUtil method enrichCluster.

public static ClusterServicesImportResult enrichCluster(Cluster cluster, EnvironmentService environmentService) {
    ClusterServicesImportResult result = new ClusterServicesImportResult(cluster);
    for (Service service : environmentService.listServices(cluster.getId())) {
        Collection<ServiceConfiguration> configurations = environmentService.listServiceConfigurations(service.getId());
        Collection<Component> components = environmentService.listComponents(service.getId());
        ServiceWithComponents s = new ServiceWithComponents(service);
        s.setComponents(components);
        s.setConfigurations(configurations);
        result.addService(s);
    }
    return result;
}
Also used : ServiceConfiguration(com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration) EnvironmentService(com.hortonworks.streamline.streams.cluster.service.EnvironmentService) Service(com.hortonworks.streamline.streams.cluster.catalog.Service) Component(com.hortonworks.streamline.streams.cluster.catalog.Component) ServiceWithComponents(com.hortonworks.streamline.streams.cluster.model.ServiceWithComponents)

Example 29 with Service

use of com.hortonworks.streamline.streams.cluster.catalog.Service in project streamline by hortonworks.

the class ClusterCatalogResource method removeCluster.

@DELETE
@Path("/clusters/{id}")
@Timed
public Response removeCluster(@PathParam("id") Long clusterId, @Context SecurityContext securityContext) {
    assertNoNamespaceRefersCluster(clusterId);
    SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_SERVICE_POOL_SUPER_ADMIN, NAMESPACE, clusterId, DELETE);
    // remove all services / service configurations / components / component processes in this cluster
    Collection<Service> services = environmentService.listServices(clusterId);
    services.forEach(svc -> {
        environmentService.listServiceConfigurations(svc.getId()).forEach(sc -> environmentService.removeServiceConfiguration(sc.getId()));
        Collection<Component> components = environmentService.listComponents(svc.getId());
        components.forEach(component -> {
            environmentService.listComponentProcesses(component.getId()).forEach(componentProcess -> environmentService.removeComponentProcess(componentProcess.getId()));
            environmentService.removeComponent(component.getId());
        });
        environmentService.removeService(svc.getId());
    });
    Cluster removedCluster = environmentService.removeCluster(clusterId);
    if (removedCluster != null) {
        SecurityUtil.removeAcl(authorizer, securityContext, NAMESPACE, clusterId);
        return WSUtils.respondEntity(removedCluster, OK);
    }
    throw EntityNotFoundException.byId(clusterId.toString());
}
Also used : Service(com.hortonworks.streamline.streams.cluster.catalog.Service) StormMetadataService(com.hortonworks.streamline.streams.cluster.service.metadata.StormMetadataService) EnvironmentService(com.hortonworks.streamline.streams.cluster.service.EnvironmentService) Cluster(com.hortonworks.streamline.streams.cluster.catalog.Cluster) Component(com.hortonworks.streamline.streams.cluster.catalog.Component) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) DELETE(com.hortonworks.streamline.streams.security.Permission.DELETE) Timed(com.codahale.metrics.annotation.Timed)

Example 30 with Service

use of com.hortonworks.streamline.streams.cluster.catalog.Service in project streamline by hortonworks.

the class HBaseServiceRegistrarTest method testRegister.

@Test
public void testRegister() throws Exception {
    Cluster cluster = getTestCluster(1L);
    HBaseServiceRegistrar registrar = initializeServiceRegistrar();
    try (InputStream is = getClass().getClassLoader().getResourceAsStream(HBASE_SITE_XML_FILE_PATH)) {
        ManualServiceRegistrar.ConfigFileInfo hiveSiteXml = new ManualServiceRegistrar.ConfigFileInfo(HBASE_SITE_XML, is);
        registrar.register(cluster, new Config(), Lists.newArrayList(hiveSiteXml));
    }
    Service hbaseService = environmentService.getServiceByName(cluster.getId(), Constants.HBase.SERVICE_NAME);
    assertNotNull(hbaseService);
    ServiceConfiguration hbaseSiteConf = environmentService.getServiceConfigurationByName(hbaseService.getId(), CONFIGURATION_NAME_HBASE_SITE);
    assertNotNull(hbaseSiteConf);
}
Also used : ManualServiceRegistrar(com.hortonworks.streamline.streams.cluster.register.ManualServiceRegistrar) ServiceConfiguration(com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration) InputStream(java.io.InputStream) Config(com.hortonworks.streamline.common.Config) Cluster(com.hortonworks.streamline.streams.cluster.catalog.Cluster) Service(com.hortonworks.streamline.streams.cluster.catalog.Service) Test(org.junit.Test)

Aggregations

Service (com.hortonworks.streamline.streams.cluster.catalog.Service)50 Cluster (com.hortonworks.streamline.streams.cluster.catalog.Cluster)31 Test (org.junit.Test)26 Config (com.hortonworks.streamline.common.Config)25 ServiceConfiguration (com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration)22 EnvironmentService (com.hortonworks.streamline.streams.cluster.service.EnvironmentService)21 Component (com.hortonworks.streamline.streams.cluster.catalog.Component)14 Timed (com.codahale.metrics.annotation.Timed)9 ManualServiceRegistrar (com.hortonworks.streamline.streams.cluster.register.ManualServiceRegistrar)9 InputStream (java.io.InputStream)9 Path (javax.ws.rs.Path)9 ComponentProcess (com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess)8 HashMap (java.util.HashMap)7 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 Map (java.util.Map)4 POST (javax.ws.rs.POST)4 ArrayList (java.util.ArrayList)3 Collection (java.util.Collection)3 DELETE (javax.ws.rs.DELETE)3 PUT (javax.ws.rs.PUT)3