Search in sources :

Example 41 with Service

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

the class ZookeeperServiceRegistrarTest method testRegisterZookeeperServerPropertyNotPresent.

@Test
public void testRegisterZookeeperServerPropertyNotPresent() throws Exception {
    Cluster cluster = getTestCluster(1L);
    ZookeeperServiceRegistrar registrar = initializeServiceRegistrar();
    try {
        registrar.register(cluster, new Config(), Collections.emptyList());
        fail("Should throw IllegalArgumentException");
    } catch (IllegalArgumentException e) {
        // OK
        Service zkService = environmentService.getServiceByName(cluster.getId(), Constants.Zookeeper.SERVICE_NAME);
        assertNull(zkService);
    }
}
Also used : 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 42 with Service

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

the class NotificationSinkBundleSourceHintProviderTest method getHintsOnCluster.

@Test
public void getHintsOnCluster() throws Exception {
    ObjectMapper objectMapper = new ObjectMapper();
    Cluster cluster = new Cluster();
    cluster.setId(1L);
    cluster.setName("cluster1");
    Service service = new Service();
    service.setId(1L);
    service.setName(Constants.Email.SERVICE_NAME);
    Map<String, String> confMap = new HashMap<>();
    confMap.put(Constants.Email.PROPERTY_KEY_HOST, "svr1");
    confMap.put(Constants.Email.PROPERTY_KEY_PORT, "1111");
    confMap.put(Constants.Email.PROPERTY_KEY_SSL, "true");
    confMap.put(Constants.Email.PROPERTY_KEY_STARTTLS, "true");
    confMap.put(Constants.Email.PROPERTY_KEY_PROTOCOL, "smtp");
    confMap.put(Constants.Email.PROPERTY_KEY_AUTH, "true");
    ServiceConfiguration serviceConfiguration = new ServiceConfiguration();
    serviceConfiguration.setId(1L);
    serviceConfiguration.setName(Constants.Email.CONF_TYPE_PROPERTIES);
    serviceConfiguration.setConfiguration(objectMapper.writeValueAsString(confMap));
    new Expectations() {

        {
            environmentService.getServiceByName(cluster.getId(), Constants.Email.SERVICE_NAME);
            result = service;
            environmentService.getServiceConfigurationByName(service.getId(), Constants.Email.CONF_TYPE_PROPERTIES);
            result = serviceConfiguration;
        }
    };
    provider.init(environmentService);
    Map<String, Object> hints = provider.getHintsOnCluster(cluster, null, null);
    Assert.assertNotNull(hints);
    Assert.assertEquals("svr1", hints.get(NotificationSinkBundleHintProvider.FIELD_NAME_HOST));
    Assert.assertEquals("1111", hints.get(NotificationSinkBundleHintProvider.FIELD_NAME_PORT));
    Assert.assertEquals("true", hints.get(NotificationSinkBundleHintProvider.FIELD_NAME_SSL));
    Assert.assertEquals("true", hints.get(NotificationSinkBundleHintProvider.FIELD_NAME_STARTTLS));
    Assert.assertEquals("smtp", hints.get(NotificationSinkBundleHintProvider.FIELD_NAME_PROTOCOL));
    Assert.assertEquals("true", hints.get(NotificationSinkBundleHintProvider.FIELD_NAME_AUTH));
}
Also used : Expectations(mockit.Expectations) ServiceConfiguration(com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration) HashMap(java.util.HashMap) Cluster(com.hortonworks.streamline.streams.cluster.catalog.Cluster) EnvironmentService(com.hortonworks.streamline.streams.cluster.service.EnvironmentService) Service(com.hortonworks.streamline.streams.cluster.catalog.Service) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 43 with Service

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

the class DruidServiceRegistrarTest method testRegister_zookeeper_connection_notPresent.

@Test
public void testRegister_zookeeper_connection_notPresent() throws Exception {
    Cluster cluster = getTestCluster(1L);
    DruidServiceRegistrar registerer = initializeServiceRegistrar();
    try {
        Config config = new Config();
        config.put(DruidServiceRegistrar.PARAM_INDEXING_SERVICE_NAME, "druid/overlord");
        config.put(DruidServiceRegistrar.PARAM_DISCOVERY_CURATOR_PATH, "/prod/discovery");
        registerer.register(cluster, config, Collections.emptyList());
        fail("Should throw IllegalArgumentException");
    } catch (IllegalArgumentException e) {
        // OK
        Service druidService = environmentService.getServiceByName(cluster.getId(), Constants.Druid.SERVICE_NAME);
        assertNull(druidService);
    }
}
Also used : 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 44 with Service

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

the class EmailServiceRegistrarTest method testRegister.

@Test
public void testRegister() throws Exception {
    Cluster cluster = getTestCluster(1L);
    EmailServiceRegistrar registrar = initializeServiceRegistrar();
    Config config = new Config();
    config.setAny("host", "host");
    config.setAny("port", 1111);
    config.setAny("ssl", true);
    config.setAny("starttls", true);
    config.setAny("protocol", "smtp");
    config.setAny("auth", true);
    registrar.register(cluster, config, Collections.emptyList());
    Service emailService = environmentService.getServiceByName(cluster.getId(), Constants.Email.SERVICE_NAME);
    assertNotNull(emailService);
    ServiceConfiguration propertiesConf = environmentService.getServiceConfigurationByName(emailService.getId(), Constants.Email.CONF_TYPE_PROPERTIES);
    assertNotNull(propertiesConf);
}
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 45 with Service

use of com.hortonworks.streamline.streams.cluster.catalog.Service 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

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