use of com.hortonworks.streamline.streams.cluster.exception.ServiceNotFoundException in project streamline by hortonworks.
the class NotificationSinkBundleHintProvider method getHintsOnCluster.
@Override
public Map<String, Object> getHintsOnCluster(Cluster cluster, SecurityContext securityContext, Subject subject) {
Map<String, Object> hintMap = new HashMap<>();
try {
Service email = environmentService.getServiceByName(cluster.getId(), Constants.Email.SERVICE_NAME);
if (email == null) {
throw new ServiceNotFoundException(Constants.Email.SERVICE_NAME);
}
ServiceConfiguration properties = environmentService.getServiceConfigurationByName(email.getId(), Constants.Email.CONF_TYPE_PROPERTIES);
if (properties == null) {
throw new ServiceConfigurationNotFoundException(Constants.Email.CONF_TYPE_PROPERTIES);
}
Map<String, String> configurationMap = properties.getConfigurationMap();
putToHintMapIfAvailable(configurationMap, hintMap, Constants.Email.PROPERTY_KEY_HOST, FIELD_NAME_HOST);
putToHintMapIfAvailable(configurationMap, hintMap, Constants.Email.PROPERTY_KEY_PORT, FIELD_NAME_PORT);
putToHintMapIfAvailable(configurationMap, hintMap, Constants.Email.PROPERTY_KEY_SSL, FIELD_NAME_SSL);
putToHintMapIfAvailable(configurationMap, hintMap, Constants.Email.PROPERTY_KEY_STARTTLS, FIELD_NAME_STARTTLS);
putToHintMapIfAvailable(configurationMap, hintMap, Constants.Email.PROPERTY_KEY_PROTOCOL, FIELD_NAME_PROTOCOL);
putToHintMapIfAvailable(configurationMap, hintMap, Constants.Email.PROPERTY_KEY_AUTH, FIELD_NAME_AUTH);
} catch (ServiceNotFoundException e) {
// we access it from mapping information so shouldn't be here
throw new IllegalStateException("Service " + Constants.Email.SERVICE_NAME + " in cluster " + cluster.getName() + " not found but mapping information exists.");
} catch (ServiceConfigurationNotFoundException e) {
// there's Email service configuration but not having enough information
} catch (Exception e) {
throw new RuntimeException(e);
}
return hintMap;
}
use of com.hortonworks.streamline.streams.cluster.exception.ServiceNotFoundException in project streamline by hortonworks.
the class AbstractKafkaBundleHintProviderTest method getHintsOnClusterWithZkServiceNotAvailable.
protected void getHintsOnClusterWithZkServiceNotAvailable() throws Exception {
final List<String> topics = Lists.newArrayList("test1", "test2", "test3");
new Expectations() {
{
kafkaMetadataService.getTopicsFromZk();
result = new KafkaTopics(topics, security);
zookeeperMetadataService.getZookeeperServers();
result = new ServiceNotFoundException(1L, ServiceConfigurations.ZOOKEEPER.name());
}
};
Cluster cluster = new Cluster();
cluster.setId(1L);
cluster.setName("cluster1");
Map<String, Object> hints = provider.getHintsOnCluster(cluster, null, null);
Assert.assertNotNull(hints);
Assert.assertEquals(4, hints.size());
Assert.assertEquals(topics, hints.get(KafkaBundleHintProvider.FIELD_NAME_TOPIC));
new Verifications() {
{
kafkaMetadataService.getTopicsFromZk();
zookeeperMetadataService.getZookeeperServers();
}
};
}
use of com.hortonworks.streamline.streams.cluster.exception.ServiceNotFoundException 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.exception.ServiceNotFoundException in project streamline by hortonworks.
the class AbstractKafkaBundleHintProvider method getHintsOnCluster.
@Override
public Map<String, Object> getHintsOnCluster(Cluster cluster, SecurityContext securityContext, Subject subject) {
Map<String, Object> hintClusterMap = new HashMap<>();
try (KafkaMetadataService kms = KafkaMetadataService.newInstance(environmentService, cluster.getId(), securityContext)) {
KafkaTopics topics = kms.getTopicsFromZk();
hintClusterMap.put(FIELD_NAME_TOPIC, topics.list());
fillZookeeperHints(cluster, hintClusterMap);
final Map<KafkaBrokerListeners.Protocol, List<String>> protocolToHostsWithPort = kms.getKafkaBrokerListeners().getProtocolToHostsWithPort();
hintClusterMap.put(FIELD_NAME_BOOTSTRAP_SERVERS, mapValuesJoiner(protocolToHostsWithPort, ","));
hintClusterMap.put(FIELD_NAME_SECURITY_PROTOCOL, protocolToHostsWithPort.keySet());
hintClusterMap.put(FIELD_NAME_KAFKA_SERVICE_NAME, kms.getKafkaServiceName());
} catch (ServiceNotFoundException e) {
// we access it from mapping information so shouldn't be here
throw new IllegalStateException("Service " + Constants.Kafka.SERVICE_NAME + " in cluster " + cluster.getName() + " not found but mapping information exists.");
} catch (ServiceConfigurationNotFoundException e) {
// there's KAFKA service but not enough configuration info.
} catch (Exception e) {
throw new RuntimeException(e);
}
return hintClusterMap;
}
use of com.hortonworks.streamline.streams.cluster.exception.ServiceNotFoundException in project streamline by hortonworks.
the class AbstractHDFSBundleHintProvider method getHintsOnCluster.
@Override
public Map<String, Object> getHintsOnCluster(Cluster cluster, SecurityContext securityContext, Subject subject) {
Map<String, Object> hintMap = new HashMap<>();
try {
HDFSMetadataService hdfsMetadataService = HDFSMetadataService.newInstance(environmentService, cluster.getId());
hintMap.put(getFieldNameForFSUrl(), hdfsMetadataService.getDefaultFsUrl());
} catch (ServiceNotFoundException e) {
// we access it from mapping information so shouldn't be here
throw new IllegalStateException("Service " + Constants.HDFS.SERVICE_NAME + " in cluster " + cluster.getName() + " not found but mapping information exists.");
} catch (ServiceConfigurationNotFoundException e) {
// there's HBASE service but not enough configuration info.
} catch (Exception e) {
throw new RuntimeException(e);
}
return hintMap;
}
Aggregations