Search in sources :

Example 1 with HostPort

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();
        }
    };
}
Also used : Expectations(mockit.Expectations) HostPort(com.hortonworks.streamline.streams.cluster.service.metadata.common.HostPort) Cluster(com.hortonworks.streamline.streams.cluster.catalog.Cluster) Verifications(mockit.Verifications) KafkaTopics(com.hortonworks.streamline.streams.cluster.service.metadata.json.KafkaTopics) List(java.util.List)

Example 2 with HostPort

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());
}
Also used : ServiceComponentNotFoundException(com.hortonworks.streamline.streams.cluster.exception.ServiceComponentNotFoundException) EnvironmentService(com.hortonworks.streamline.streams.cluster.service.EnvironmentService) ComponentPropertyPattern(com.hortonworks.streamline.streams.cluster.discovery.ambari.ComponentPropertyPattern) List(java.util.List) ServiceConfigurations(com.hortonworks.streamline.streams.cluster.discovery.ambari.ServiceConfigurations) Collection(java.util.Collection) Component(com.hortonworks.streamline.streams.cluster.catalog.Component) HostPort(com.hortonworks.streamline.streams.cluster.service.metadata.common.HostPort) ServiceNotFoundException(com.hortonworks.streamline.streams.cluster.exception.ServiceNotFoundException) ComponentProcess(com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess) Collectors(java.util.stream.Collectors) ServiceComponentNotFoundException(com.hortonworks.streamline.streams.cluster.exception.ServiceComponentNotFoundException) ServiceNotFoundException(com.hortonworks.streamline.streams.cluster.exception.ServiceNotFoundException) HostPort(com.hortonworks.streamline.streams.cluster.service.metadata.common.HostPort) Component(com.hortonworks.streamline.streams.cluster.catalog.Component) ComponentProcess(com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess)

Aggregations

HostPort (com.hortonworks.streamline.streams.cluster.service.metadata.common.HostPort)2 List (java.util.List)2 Cluster (com.hortonworks.streamline.streams.cluster.catalog.Cluster)1 Component (com.hortonworks.streamline.streams.cluster.catalog.Component)1 ComponentProcess (com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess)1 ComponentPropertyPattern (com.hortonworks.streamline.streams.cluster.discovery.ambari.ComponentPropertyPattern)1 ServiceConfigurations (com.hortonworks.streamline.streams.cluster.discovery.ambari.ServiceConfigurations)1 ServiceComponentNotFoundException (com.hortonworks.streamline.streams.cluster.exception.ServiceComponentNotFoundException)1 ServiceNotFoundException (com.hortonworks.streamline.streams.cluster.exception.ServiceNotFoundException)1 EnvironmentService (com.hortonworks.streamline.streams.cluster.service.EnvironmentService)1 KafkaTopics (com.hortonworks.streamline.streams.cluster.service.metadata.json.KafkaTopics)1 Collection (java.util.Collection)1 Collectors (java.util.stream.Collectors)1 Expectations (mockit.Expectations)1 Verifications (mockit.Verifications)1