use of com.hortonworks.streamline.streams.cluster.service.metadata.common.HostPort in project streamline by hortonworks.
the class AbstractKafkaBundleHintProviderTest method getHintsOnCluster.
protected void getHintsOnCluster() throws Exception {
final List<String> topics = Lists.newArrayList("test1", "test2", "test3");
final List<HostPort> zkHosts = Lists.newArrayList(new HostPort("svr1", 2181), new HostPort("svr2", 2181), new HostPort("svr3", 2181));
final Map<KafkaBrokerListeners.Protocol, List<String>> protocolToHostsWithPort = getProtocolToHostsWithPort();
new Expectations() {
{
kafkaMetadataService.getTopicsFromZk();
result = new KafkaTopics(topics, security);
zookeeperMetadataService.getZookeeperServers();
result = zkHosts;
kafkaMetadataService.getKafkaBrokerListeners().getProtocolToHostsWithPort();
result = protocolToHostsWithPort;
}
};
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));
Assert.assertEquals(AbstractKafkaBundleHintProvider.mapValuesJoiner(protocolToHostsWithPort, ","), hints.get(KafkaBundleHintProvider.FIELD_NAME_BOOTSTRAP_SERVERS));
new Verifications() {
{
kafkaMetadataService.getTopicsFromZk();
zookeeperMetadataService.getZookeeperServers();
}
};
}
use of com.hortonworks.streamline.streams.cluster.service.metadata.common.HostPort 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());
}
Aggregations