Search in sources :

Example 16 with ServiceConfiguration

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

the class HiveServiceRegistrarTest method testRegister.

@Test
public void testRegister() throws Exception {
    Cluster cluster = getTestCluster(1L);
    HiveServiceRegistrar registrar = initializeServiceRegistrar();
    try (InputStream is = getClass().getClassLoader().getResourceAsStream(HIVE_SITE_XML_FILE_PATH)) {
        ManualServiceRegistrar.ConfigFileInfo hiveSiteXml = new ManualServiceRegistrar.ConfigFileInfo(HIVE_SITE_XML, is);
        registrar.register(cluster, new Config(), Lists.newArrayList(hiveSiteXml));
    }
    Service hiveService = environmentService.getServiceByName(cluster.getId(), Constants.Hive.SERVICE_NAME);
    assertNotNull(hiveService);
    ServiceConfiguration coreSiteConf = environmentService.getServiceConfigurationByName(hiveService.getId(), CONFIGURATION_NAME_HIVE_SITE);
    assertNotNull(coreSiteConf);
}
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)

Example 17 with ServiceConfiguration

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

the class StormServiceRegistrarTest method testRegisterWithoutOptionalParams.

@Test
public void testRegisterWithoutOptionalParams() throws Exception {
    Cluster cluster = getTestCluster(1L);
    StormServiceRegistrar registrar = initializeServiceRegistrar();
    Config config = new Config();
    config.put(StormServiceRegistrar.PARAM_NIMBUS_SEEDS, "storm-1,storm-2");
    config.put(StormServiceRegistrar.PARAM_NIMBUS_THRIFT_PORT, (Object) 6627);
    config.put(StormServiceRegistrar.PARAM_UI_HOST, "storm-1");
    config.put(StormServiceRegistrar.PARAM_UI_PORT, (Object) 8080);
    registrar.register(cluster, config, Collections.emptyList());
    Service stormService = environmentService.getServiceByName(cluster.getId(), Constants.Storm.SERVICE_NAME);
    assertNotNull(stormService);
    ServiceConfiguration stormYamlConf = environmentService.getServiceConfigurationByName(stormService.getId(), CONFIGURATION_NAME_STORM_YAML);
    assertNotNull(stormYamlConf);
    ServiceConfiguration stormEnvConf = environmentService.getServiceConfigurationByName(stormService.getId(), CONFIGURATION_NAME_STORM_ENV);
    assertNotNull(stormEnvConf);
    Map<String, String> confMap = stormEnvConf.getConfigurationMap();
    assertFalse(confMap.containsKey(StormServiceRegistrar.PARAM_NIMBUS_THRIFT_MAX_BUFFER_SIZE));
    assertFalse(confMap.containsKey(StormServiceRegistrar.PARAM_PRINCIPAL_TO_LOCAL));
    assertFalse(confMap.containsKey(StormServiceRegistrar.PARAM_THRIFT_TRANSPORT));
    assertFalse(confMap.containsKey(StormServiceRegistrar.PARAM_NIMBUS_PRINCIPAL_NAME));
}
Also used : 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) Test(org.junit.Test)

Example 18 with ServiceConfiguration

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

the class StormServiceRegistrarTest method testRegister.

@Test
public void testRegister() throws Exception {
    Cluster cluster = getTestCluster(1L);
    StormServiceRegistrar registrar = initializeServiceRegistrar();
    // explicit convert Object
    Config config = new Config();
    config.put(StormServiceRegistrar.PARAM_NIMBUS_SEEDS, "storm-1,storm-2");
    config.put(StormServiceRegistrar.PARAM_NIMBUS_THRIFT_PORT, (Object) 6627);
    config.put(StormServiceRegistrar.PARAM_UI_HOST, "storm-1");
    config.put(StormServiceRegistrar.PARAM_UI_PORT, (Object) 8080);
    config.put(StormServiceRegistrar.PARAM_NIMBUS_THRIFT_MAX_BUFFER_SIZE, (Object) 102476800);
    config.put(StormServiceRegistrar.PARAM_THRIFT_TRANSPORT, "org.apache.storm.security.auth.SimpleTransportPlugin");
    config.put(StormServiceRegistrar.PARAM_PRINCIPAL_TO_LOCAL, "org.apache.storm.security.auth.DefaultPrincipalToLocal");
    config.put(StormServiceRegistrar.PARAM_NIMBUS_PRINCIPAL_NAME, "nimbus/_HOST@EXAMPLE.COM");
    registrar.register(cluster, config, Collections.emptyList());
    Service stormService = environmentService.getServiceByName(cluster.getId(), Constants.Storm.SERVICE_NAME);
    assertNotNull(stormService);
    Component nimbus = environmentService.getComponentByName(stormService.getId(), ComponentPropertyPattern.NIMBUS.name());
    assertNotNull(nimbus);
    Collection<ComponentProcess> nimbusProcesses = environmentService.listComponentProcesses(nimbus.getId());
    List<String> hosts = nimbusProcesses.stream().map(ComponentProcess::getHost).collect(Collectors.toList());
    assertEquals(Sets.newHashSet("storm-1", "storm-2"), new HashSet<>(hosts));
    List<Integer> ports = nimbusProcesses.stream().map(ComponentProcess::getPort).collect(Collectors.toList());
    assertEquals(Sets.newHashSet(6627, 6627), new HashSet<>(ports));
    Component ui = environmentService.getComponentByName(stormService.getId(), ComponentPropertyPattern.STORM_UI_SERVER.name());
    assertNotNull(ui);
    Collection<ComponentProcess> uiProcesses = environmentService.listComponentProcesses(ui.getId());
    assertEquals(Sets.newHashSet("storm-1"), uiProcesses.stream().map(ComponentProcess::getHost).collect(Collectors.toSet()));
    assertEquals(Sets.newHashSet(8080), uiProcesses.stream().map(ComponentProcess::getPort).collect(Collectors.toSet()));
    ServiceConfiguration stormYamlConf = environmentService.getServiceConfigurationByName(stormService.getId(), CONFIGURATION_NAME_STORM_YAML);
    assertNotNull(stormYamlConf);
    Map<String, String> stormYamlConfMap = stormYamlConf.getConfigurationMap();
    assertEquals(config.getAny(StormServiceRegistrar.PARAM_NIMBUS_THRIFT_MAX_BUFFER_SIZE), Integer.valueOf(stormYamlConfMap.get(StormServiceRegistrar.PARAM_NIMBUS_THRIFT_MAX_BUFFER_SIZE)));
    assertEquals(config.get(StormServiceRegistrar.PARAM_THRIFT_TRANSPORT), stormYamlConfMap.get(StormServiceRegistrar.PARAM_THRIFT_TRANSPORT));
    assertEquals(config.get(StormServiceRegistrar.PARAM_PRINCIPAL_TO_LOCAL), stormYamlConfMap.get(StormServiceRegistrar.PARAM_PRINCIPAL_TO_LOCAL));
    ServiceConfiguration stormEnvConf = environmentService.getServiceConfigurationByName(stormService.getId(), CONFIGURATION_NAME_STORM_ENV);
    assertNotNull(stormEnvConf);
    Map<String, String> stormEnvConfMap = stormEnvConf.getConfigurationMap();
    assertEquals(config.get(StormServiceRegistrar.PARAM_NIMBUS_PRINCIPAL_NAME), stormEnvConfMap.get(StormServiceRegistrar.PARAM_NIMBUS_PRINCIPAL_NAME));
}
Also used : Config(com.hortonworks.streamline.common.Config) Cluster(com.hortonworks.streamline.streams.cluster.catalog.Cluster) Service(com.hortonworks.streamline.streams.cluster.catalog.Service) ServiceConfiguration(com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration) Component(com.hortonworks.streamline.streams.cluster.catalog.Component) ComponentProcess(com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess) Test(org.junit.Test)

Example 19 with ServiceConfiguration

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

the class ZookeeperServiceRegistrarTest method testRegister.

@Test
public void testRegister() throws Exception {
    Cluster cluster = getTestCluster(1L);
    ZookeeperServiceRegistrar registrar = initializeServiceRegistrar();
    Config config = new Config();
    config.put(ZookeeperServiceRegistrar.PARAM_ZOOKEEPER_SERVER_HOSTNAMES, Lists.newArrayList("zookeeper-1", "zookeeper-2"));
    config.put(ZookeeperServiceRegistrar.PARAM_ZOOKEEPER_PORT, (Object) 2181);
    registrar.register(cluster, config, Collections.emptyList());
    Service zkService = environmentService.getServiceByName(cluster.getId(), Constants.Zookeeper.SERVICE_NAME);
    assertNotNull(zkService);
    Component zkServer = environmentService.getComponentByName(zkService.getId(), ComponentPropertyPattern.ZOOKEEPER_SERVER.name());
    assertNotNull(zkServer);
    Collection<ComponentProcess> zkServerProcesses = environmentService.listComponentProcesses(zkServer.getId());
    assertEquals(Sets.newHashSet("zookeeper-1", "zookeeper-2"), zkServerProcesses.stream().map(ComponentProcess::getHost).collect(Collectors.toSet()));
    assertEquals(Sets.newHashSet(2181, 2181), zkServerProcesses.stream().map(ComponentProcess::getPort).collect(Collectors.toSet()));
    ServiceConfiguration zooConf = environmentService.getServiceConfigurationByName(zkService.getId(), CONFIGURATION_NAME_ZOO_CFG);
    assertNotNull(zooConf);
}
Also used : 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 20 with ServiceConfiguration

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

the class AutoCredsServiceConfigurationReader method read.

@Override
public Map<String, String> read(Long clusterId, String serviceName) {
    Cluster cluster = environmentService.getCluster(clusterId);
    if (cluster == null) {
        throw new IllegalArgumentException("Cluster with id " + clusterId + " doesn't exist.");
    }
    Collection<NamespaceServiceClusterMap> mappings = environmentService.listServiceClusterMapping(namespaceId, serviceName);
    boolean associated = mappings.stream().anyMatch(map -> map.getClusterId().equals(clusterId));
    if (!associated) {
        return Collections.emptyMap();
    }
    Long serviceId = environmentService.getServiceIdByName(clusterId, serviceName);
    if (serviceId == null) {
        throw new IllegalStateException("Cluster " + clusterId + " is associated to the service " + serviceName + " for namespace " + namespaceId + ", but actual service doesn't exist.");
    }
    Collection<ServiceConfiguration> serviceConfigurations = environmentService.listServiceConfigurations(serviceId);
    Map<String, String> flattenConfig = new HashMap<>();
    String[] confNames = AutoCredsServiceConfigurations.valueOf(serviceName).getConfNames();
    // let's forget about optimization here since two lists will be small enough
    Arrays.stream(confNames).forEachOrdered(confName -> {
        Optional<ServiceConfiguration> serviceConfigurationOptional = serviceConfigurations.stream().filter(sc -> sc.getName().equals(confName)).findFirst();
        if (serviceConfigurationOptional.isPresent()) {
            ServiceConfiguration sc = serviceConfigurationOptional.get();
            try {
                Map<String, String> configurationMap = sc.getConfigurationMap();
                flattenConfig.putAll(configurationMap);
            } catch (IOException e) {
                throw new RuntimeException("Can't read configuration from service configuration - ID: " + sc.getId());
            }
        }
    });
    return flattenConfig;
}
Also used : Namespace(com.hortonworks.streamline.streams.cluster.catalog.Namespace) NamespaceServiceClusterMap(com.hortonworks.streamline.streams.cluster.catalog.NamespaceServiceClusterMap) Arrays(java.util.Arrays) Collection(java.util.Collection) IOException(java.io.IOException) HashMap(java.util.HashMap) Collectors(java.util.stream.Collectors) EnvironmentService(com.hortonworks.streamline.streams.cluster.service.EnvironmentService) ServiceConfigurationReadable(com.hortonworks.streamline.streams.storm.common.ServiceConfigurationReadable) List(java.util.List) ServiceConfiguration(com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration) Map(java.util.Map) Optional(java.util.Optional) Collections(java.util.Collections) Cluster(com.hortonworks.streamline.streams.cluster.catalog.Cluster) HashMap(java.util.HashMap) Cluster(com.hortonworks.streamline.streams.cluster.catalog.Cluster) IOException(java.io.IOException) ServiceConfiguration(com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration) NamespaceServiceClusterMap(com.hortonworks.streamline.streams.cluster.catalog.NamespaceServiceClusterMap)

Aggregations

ServiceConfiguration (com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration)40 Service (com.hortonworks.streamline.streams.cluster.catalog.Service)21 Cluster (com.hortonworks.streamline.streams.cluster.catalog.Cluster)14 Test (org.junit.Test)13 HashMap (java.util.HashMap)12 Config (com.hortonworks.streamline.common.Config)11 EnvironmentService (com.hortonworks.streamline.streams.cluster.service.EnvironmentService)9 Component (com.hortonworks.streamline.streams.cluster.catalog.Component)8 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)7 ComponentProcess (com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess)5 Map (java.util.Map)5 Timed (com.codahale.metrics.annotation.Timed)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 Path (javax.ws.rs.Path)4 ServiceConfigurationNotFoundException (com.hortonworks.streamline.streams.cluster.exception.ServiceConfigurationNotFoundException)3 ManualServiceRegistrar (com.hortonworks.streamline.streams.cluster.register.ManualServiceRegistrar)3 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3 Collection (java.util.Collection)3 Collections (java.util.Collections)3