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