Search in sources :

Example 21 with Component

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());
}
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 22 with Component

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));
}
Also used : Config(com.hortonworks.streamline.common.Config) ComponentPropertyPattern(com.hortonworks.streamline.streams.cluster.discovery.ambari.ComponentPropertyPattern) Collection(java.util.Collection) Test(org.junit.Test) Component(com.hortonworks.streamline.streams.cluster.catalog.Component) ComponentProcess(com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess) Constants(com.hortonworks.streamline.streams.cluster.Constants) Service(com.hortonworks.streamline.streams.cluster.catalog.Service) ServiceConfiguration(com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration) Map(java.util.Map) Assert(org.junit.Assert) Collections(java.util.Collections) Cluster(com.hortonworks.streamline.streams.cluster.catalog.Cluster) Before(org.junit.Before) ServiceConfiguration(com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration) Config(com.hortonworks.streamline.common.Config) Cluster(com.hortonworks.streamline.streams.cluster.catalog.Cluster) Service(com.hortonworks.streamline.streams.cluster.catalog.Service) Component(com.hortonworks.streamline.streams.cluster.catalog.Component) ComponentProcess(com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess) Test(org.junit.Test)

Example 23 with Component

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));
}
Also used : Config(com.hortonworks.streamline.common.Config) ComponentPropertyPattern(com.hortonworks.streamline.streams.cluster.discovery.ambari.ComponentPropertyPattern) Collection(java.util.Collection) Test(org.junit.Test) Component(com.hortonworks.streamline.streams.cluster.catalog.Component) ComponentProcess(com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess) Constants(com.hortonworks.streamline.streams.cluster.Constants) Service(com.hortonworks.streamline.streams.cluster.catalog.Service) ServiceConfiguration(com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration) Map(java.util.Map) Assert(org.junit.Assert) Collections(java.util.Collections) Cluster(com.hortonworks.streamline.streams.cluster.catalog.Cluster) Before(org.junit.Before) ServiceConfiguration(com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration) Config(com.hortonworks.streamline.common.Config) Cluster(com.hortonworks.streamline.streams.cluster.catalog.Cluster) Service(com.hortonworks.streamline.streams.cluster.catalog.Service) Component(com.hortonworks.streamline.streams.cluster.catalog.Component) ComponentProcess(com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess) Test(org.junit.Test)

Example 24 with Component

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());
}
Also used : ServiceComponentNotFoundException(com.hortonworks.streamline.streams.cluster.exception.ServiceComponentNotFoundException) EnvironmentService(com.hortonworks.streamline.streams.cluster.service.EnvironmentService) ComponentPropertyPattern(com.hortonworks.streamline.streams.cluster.discovery.ambari.ComponentPropertyPattern) List(java.util.List) ServiceConfigurations(com.hortonworks.streamline.streams.cluster.discovery.ambari.ServiceConfigurations) Collection(java.util.Collection) Component(com.hortonworks.streamline.streams.cluster.catalog.Component) HostPort(com.hortonworks.streamline.streams.cluster.service.metadata.common.HostPort) ServiceNotFoundException(com.hortonworks.streamline.streams.cluster.exception.ServiceNotFoundException) ComponentProcess(com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess) Collectors(java.util.stream.Collectors) ServiceComponentNotFoundException(com.hortonworks.streamline.streams.cluster.exception.ServiceComponentNotFoundException) ServiceNotFoundException(com.hortonworks.streamline.streams.cluster.exception.ServiceNotFoundException) HostPort(com.hortonworks.streamline.streams.cluster.service.metadata.common.HostPort) Component(com.hortonworks.streamline.streams.cluster.catalog.Component) ComponentProcess(com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess)

Example 25 with Component

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

Aggregations

Component (com.hortonworks.streamline.streams.cluster.catalog.Component)28 ComponentProcess (com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess)15 Service (com.hortonworks.streamline.streams.cluster.catalog.Service)13 ServiceConfiguration (com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration)11 EnvironmentService (com.hortonworks.streamline.streams.cluster.service.EnvironmentService)10 Config (com.hortonworks.streamline.common.Config)7 ComponentPropertyPattern (com.hortonworks.streamline.streams.cluster.discovery.ambari.ComponentPropertyPattern)6 HashMap (java.util.HashMap)6 Map (java.util.Map)6 Timed (com.codahale.metrics.annotation.Timed)5 Constants (com.hortonworks.streamline.streams.cluster.Constants)5 Cluster (com.hortonworks.streamline.streams.cluster.catalog.Cluster)5 List (java.util.List)5 Path (javax.ws.rs.Path)5 ServiceConfigurations (com.hortonworks.streamline.streams.cluster.discovery.ambari.ServiceConfigurations)4 Collections (java.util.Collections)4 Pair (org.apache.commons.math3.util.Pair)4 Test (org.junit.Test)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3