use of com.hortonworks.streamline.streams.cluster.catalog.Component 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.Component in project streamline by hortonworks.
the class KafkaServiceRegistrarTest method testRegisterWithoutOptionalParams.
@Test
public void testRegisterWithoutOptionalParams() throws Exception {
Cluster cluster = getTestCluster(1L);
KafkaServiceRegistrar registrar = initializeServiceRegistrar();
Config config = new Config();
config.put(KafkaServiceRegistrar.PARAM_ZOOKEEPER_CONNECT, "zookeeper-1:2181,zookeeper-2:2181,zookeeper-3:2181");
config.put(KafkaServiceRegistrar.PARAM_LISTENERS, "PLAINTEXT://kafka-1:9092");
registrar.register(cluster, config, Collections.emptyList());
Service kafkaService = environmentService.getServiceByName(cluster.getId(), Constants.Kafka.SERVICE_NAME);
assertNotNull(kafkaService);
Component broker = environmentService.getComponentByName(kafkaService.getId(), ComponentPropertyPattern.KAFKA_BROKER.name());
assertNotNull(broker);
Collection<ComponentProcess> brokerProcesses = environmentService.listComponentProcesses(broker.getId());
assertEquals(1, brokerProcesses.size());
assertTrue(brokerProcesses.stream().anyMatch(p -> p.getHost().equals("kafka-1") && p.getPort().equals(9092) && p.getProtocol().equals("PLAINTEXT")));
ServiceConfiguration serverPropertiesConf = environmentService.getServiceConfigurationByName(kafkaService.getId(), CONFIGURATION_NAME_SERVER_PROPERTIES);
assertNotNull(serverPropertiesConf);
Map<String, String> serverPropertiesConfMap = serverPropertiesConf.getConfigurationMap();
assertFalse(serverPropertiesConfMap.containsKey(KafkaServiceRegistrar.PARAM_SECURITY_INTER_BROKER_PROTOCOL));
}
use of com.hortonworks.streamline.streams.cluster.catalog.Component in project streamline by hortonworks.
the class KafkaServiceRegistrarTest method testRegister.
@Test
public void testRegister() throws Exception {
Cluster cluster = getTestCluster(1L);
KafkaServiceRegistrar registrar = initializeServiceRegistrar();
Config config = new Config();
config.put(KafkaServiceRegistrar.PARAM_ZOOKEEPER_CONNECT, "zookeeper-1:2181,zookeeper-2:2181,zookeeper-3:2181");
config.put(KafkaServiceRegistrar.PARAM_LISTENERS, "SASL_PLAINTEXT://kafka-1:6668,PLAINTEXT://kafka-2:6669,SSL://kafka-3:6670,SASL_SSL://kafka-4:6671");
config.put(KafkaServiceRegistrar.PARAM_SECURITY_INTER_BROKER_PROTOCOL, "SSL");
registrar.register(cluster, config, Collections.emptyList());
Service kafkaService = environmentService.getServiceByName(cluster.getId(), Constants.Kafka.SERVICE_NAME);
assertNotNull(kafkaService);
Component broker = environmentService.getComponentByName(kafkaService.getId(), ComponentPropertyPattern.KAFKA_BROKER.name());
assertNotNull(broker);
Collection<ComponentProcess> brokerProcesses = environmentService.listComponentProcesses(broker.getId());
// we have 4 component processes according to listener
assertEquals(4, brokerProcesses.size());
assertTrue(brokerProcesses.stream().anyMatch(p -> p.getHost().equals("kafka-1") && p.getPort().equals(6668) && p.getProtocol().equals("SASL_PLAINTEXT")));
assertTrue(brokerProcesses.stream().anyMatch(p -> p.getHost().equals("kafka-2") && p.getPort().equals(6669) && p.getProtocol().equals("PLAINTEXT")));
assertTrue(brokerProcesses.stream().anyMatch(p -> p.getHost().equals("kafka-3") && p.getPort().equals(6670) && p.getProtocol().equals("SSL")));
assertTrue(brokerProcesses.stream().anyMatch(p -> p.getHost().equals("kafka-4") && p.getPort().equals(6671) && p.getProtocol().equals("SASL_SSL")));
ServiceConfiguration serverPropertiesConf = environmentService.getServiceConfigurationByName(kafkaService.getId(), CONFIGURATION_NAME_SERVER_PROPERTIES);
assertNotNull(serverPropertiesConf);
Map<String, String> serverPropertiesConfMap = serverPropertiesConf.getConfigurationMap();
assertEquals(config.get(KafkaServiceRegistrar.PARAM_SECURITY_INTER_BROKER_PROTOCOL), serverPropertiesConfMap.get(KafkaServiceRegistrar.PARAM_SECURITY_INTER_BROKER_PROTOCOL));
}
use of com.hortonworks.streamline.streams.cluster.catalog.Component in project streamline by hortonworks.
the class ZookeeperMetadataService method getZookeeperServers.
public List<HostPort> getZookeeperServers() throws ServiceNotFoundException, ServiceComponentNotFoundException {
final Long serviceId = environmentService.getServiceIdByName(clusterId, STREAMS_JSON_SCHEMA_SERVICE_ZOOKEEPER);
if (serviceId == null) {
throw new ServiceNotFoundException(clusterId, ServiceConfigurations.ZOOKEEPER.name());
}
final Component zookeeperServer = environmentService.getComponentByName(serviceId, STREAMS_JSON_SCHEMA_COMPONENT_ZOOKEEPER_SERVER);
if (zookeeperServer == null) {
throw new ServiceComponentNotFoundException(clusterId, ServiceConfigurations.STORM.name(), ComponentPropertyPattern.ZOOKEEPER_SERVER.name());
}
final Collection<ComponentProcess> zookeeperServers = environmentService.listComponentProcesses(zookeeperServer.getId());
return zookeeperServers.stream().map(cp -> new HostPort(cp.getHost(), cp.getPort())).collect(Collectors.toList());
}
use of com.hortonworks.streamline.streams.cluster.catalog.Component in project streamline by hortonworks.
the class ClusterImporter method removeAllServices.
private void removeAllServices(Cluster cluster) {
Collection<Service> services = environmentService.listServices(cluster.getId());
for (Service service : services) {
Collection<Component> components = environmentService.listComponents(service.getId());
for (Component component : components) {
environmentService.listComponentProcesses(component.getId()).forEach(componentProcess -> environmentService.removeComponentProcess(componentProcess.getId()));
environmentService.removeComponent(component.getId());
}
Collection<ServiceConfiguration> configurations = environmentService.listServiceConfigurations(service.getId());
for (ServiceConfiguration configuration : configurations) {
environmentService.removeServiceConfiguration(configuration.getId());
}
environmentService.removeService(service.getId());
}
}
Aggregations