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