Java Code Examples for org.apache.pulsar.client.api.PulsarClient#builder()
The following examples show how to use
org.apache.pulsar.client.api.PulsarClient#builder() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PulsarBoltTest.java From pulsar with Apache License 2.0 | 6 votes |
@Test public void testFailedProducer() { PulsarBoltConfiguration pulsarBoltConf = new PulsarBoltConfiguration(); pulsarBoltConf.setServiceUrl(serviceUrl); pulsarBoltConf.setTopic("persistent://invalid"); pulsarBoltConf.setTupleToMessageMapper(tupleToMessageMapper); pulsarBoltConf.setMetricsTimeIntervalInSecs(60); PulsarBolt bolt = new PulsarBolt(pulsarBoltConf, PulsarClient.builder()); MockOutputCollector mockCollector = new MockOutputCollector(); OutputCollector collector = new OutputCollector(mockCollector); TopologyContext context = mock(TopologyContext.class); when(context.getThisComponentId()).thenReturn("new" + methodName); when(context.getThisTaskId()).thenReturn(0); try { bolt.prepare(Maps.newHashMap(), context, collector); fail("should have failed as producer creation failed"); } catch (IllegalStateException ie) { // Ok. } }
Example 2
Source File: PulsarClientTool.java From pulsar with Apache License 2.0 | 6 votes |
private void updateConfig() throws UnsupportedAuthenticationException { ClientBuilder clientBuilder = PulsarClient.builder(); Authentication authentication = null; if (isNotBlank(this.authPluginClassName)) { authentication = AuthenticationFactory.create(authPluginClassName, authParams); clientBuilder.authentication(authentication); } clientBuilder.allowTlsInsecureConnection(this.tlsAllowInsecureConnection); clientBuilder.tlsTrustCertsFilePath(this.tlsTrustCertsFilePath); clientBuilder.serviceUrl(serviceURL); clientBuilder.useKeyStoreTls(useKeyStoreTls) .tlsTrustStoreType(tlsTrustStoreType) .tlsTrustStorePath(tlsTrustStorePath) .tlsTrustStorePassword(tlsTrustStorePassword); if (StringUtils.isNotBlank(proxyServiceURL)) { if (proxyProtocol == null) { System.out.println("proxy-protocol must be provided with proxy-url"); System.exit(-1); } clientBuilder.proxyServiceUrl(proxyServiceURL, proxyProtocol); } this.produceCommand.updateConfig(clientBuilder, authentication, this.serviceURL); this.consumeCommand.updateConfig(clientBuilder, authentication, this.serviceURL); }
Example 3
Source File: PulsarSpoutTest.java From pulsar with Apache License 2.0 | 6 votes |
@Override protected void setup() throws Exception { super.internalSetup(); super.producerBaseSetup(); serviceUrl = pulsar.getWebServiceAddress(); pulsarSpoutConf = new PulsarSpoutConfiguration(); pulsarSpoutConf.setServiceUrl(serviceUrl); pulsarSpoutConf.setTopic(topic); pulsarSpoutConf.setSubscriptionName(subscriptionName); pulsarSpoutConf.setMessageToValuesMapper(messageToValuesMapper); pulsarSpoutConf.setFailedRetriesTimeout(1, TimeUnit.SECONDS); pulsarSpoutConf.setMaxFailedRetries(2); pulsarSpoutConf.setSharedConsumerEnabled(true); pulsarSpoutConf.setMetricsTimeIntervalInSecs(60); pulsarSpoutConf.setSubscriptionType(SubscriptionType.Shared); spout = new PulsarSpout(pulsarSpoutConf, PulsarClient.builder()); mockCollector = new MockSpoutOutputCollector(); SpoutOutputCollector collector = new SpoutOutputCollector(mockCollector); TopologyContext context = mock(TopologyContext.class); when(context.getThisComponentId()).thenReturn("test-spout-" + methodName); when(context.getThisTaskId()).thenReturn(0); spout.open(Maps.newHashMap(), context, collector); producer = pulsarClient.newProducer().topic(topic).create(); }
Example 4
Source File: PulsarSpoutTest.java From pulsar with Apache License 2.0 | 6 votes |
@Test public void testSharedConsumer() throws Exception { TopicStats topicStats = admin.topics().getStats(topic); assertEquals(topicStats.subscriptions.get(subscriptionName).consumers.size(), 1); PulsarSpout otherSpout = new PulsarSpout(pulsarSpoutConf, PulsarClient.builder()); MockSpoutOutputCollector otherMockCollector = new MockSpoutOutputCollector(); SpoutOutputCollector collector = new SpoutOutputCollector(otherMockCollector); TopologyContext context = mock(TopologyContext.class); when(context.getThisComponentId()).thenReturn("test-spout-" + methodName); when(context.getThisTaskId()).thenReturn(1); otherSpout.open(Maps.newHashMap(), context, collector); topicStats = admin.topics().getStats(topic); assertEquals(topicStats.subscriptions.get(subscriptionName).consumers.size(), 1); otherSpout.close(); topicStats = admin.topics().getStats(topic); assertEquals(topicStats.subscriptions.get(subscriptionName).consumers.size(), 1); }
Example 5
Source File: PulsarSpoutTest.java From pulsar with Apache License 2.0 | 6 votes |
@Test public void testNoSharedConsumer() throws Exception { TopicStats topicStats = admin.topics().getStats(topic); assertEquals(topicStats.subscriptions.get(subscriptionName).consumers.size(), 1); pulsarSpoutConf.setSharedConsumerEnabled(false); PulsarSpout otherSpout = new PulsarSpout(pulsarSpoutConf, PulsarClient.builder()); MockSpoutOutputCollector otherMockCollector = new MockSpoutOutputCollector(); SpoutOutputCollector collector = new SpoutOutputCollector(otherMockCollector); TopologyContext context = mock(TopologyContext.class); when(context.getThisComponentId()).thenReturn("test-spout-" + methodName); when(context.getThisTaskId()).thenReturn(1); otherSpout.open(Maps.newHashMap(), context, collector); topicStats = admin.topics().getStats(topic); assertEquals(topicStats.subscriptions.get(subscriptionName).consumers.size(), 2); otherSpout.close(); topicStats = admin.topics().getStats(topic); assertEquals(topicStats.subscriptions.get(subscriptionName).consumers.size(), 1); }
Example 6
Source File: PulsarBlockChainEventBroadcaster.java From eventeum with Apache License 2.0 | 6 votes |
public PulsarBlockChainEventBroadcaster(PulsarSettings settings, ObjectMapper mapper) throws PulsarClientException { this.mapper = mapper; ClientBuilder builder = PulsarClient.builder(); if (settings.getConfig() != null) { builder.loadConf(settings.getConfig()); } Authentication authSettings = settings.getAuthentication(); if (authSettings != null) { builder.authentication( authSettings.getPluginClassName(), authSettings.getParams()); } client = builder.build(); blockEventProducer = createProducer(settings.getTopic().getBlockEvents()); contractEventProducer = createProducer(settings.getTopic().getContractEvents()); transactionEventProducer = createProducer(settings.getTopic().getTransactionEvents()); }
Example 7
Source File: PulsarSpoutTest.java From pulsar with Apache License 2.0 | 6 votes |
@Test public void testFailedConsumer() { PulsarSpoutConfiguration pulsarSpoutConf = new PulsarSpoutConfiguration(); pulsarSpoutConf.setServiceUrl(serviceUrl); pulsarSpoutConf.setTopic("persistent://invalidTopic"); pulsarSpoutConf.setSubscriptionName(subscriptionName); pulsarSpoutConf.setMessageToValuesMapper(messageToValuesMapper); pulsarSpoutConf.setFailedRetriesTimeout(1, TimeUnit.SECONDS); pulsarSpoutConf.setMaxFailedRetries(2); pulsarSpoutConf.setSharedConsumerEnabled(false); pulsarSpoutConf.setMetricsTimeIntervalInSecs(60); pulsarSpoutConf.setSubscriptionType(SubscriptionType.Shared); PulsarSpout spout = new PulsarSpout(pulsarSpoutConf, PulsarClient.builder()); MockSpoutOutputCollector mockCollector = new MockSpoutOutputCollector(); SpoutOutputCollector collector = new SpoutOutputCollector(mockCollector); TopologyContext context = mock(TopologyContext.class); when(context.getThisComponentId()).thenReturn("new-test" + methodName); when(context.getThisTaskId()).thenReturn(0); try { spout.open(Maps.newHashMap(), context, collector); fail("should have failed as consumer creation failed"); } catch (IllegalStateException e) { // Ok } }
Example 8
Source File: PulsarBoltTest.java From pulsar with Apache License 2.0 | 6 votes |
@Override protected void setup() throws Exception { super.internalSetup(); super.producerBaseSetup(); serviceUrl = pulsar.getWebServiceAddress(); pulsarBoltConf = new PulsarBoltConfiguration(); pulsarBoltConf.setServiceUrl(serviceUrl); pulsarBoltConf.setTopic(topic); pulsarBoltConf.setTupleToMessageMapper(tupleToMessageMapper); pulsarBoltConf.setMetricsTimeIntervalInSecs(60); bolt = new PulsarBolt(pulsarBoltConf, PulsarClient.builder()); mockCollector = new MockOutputCollector(); OutputCollector collector = new OutputCollector(mockCollector); TopologyContext context = mock(TopologyContext.class); when(context.getThisComponentId()).thenReturn("test-bolt-" + methodName); when(context.getThisTaskId()).thenReturn(0); bolt.prepare(Maps.newHashMap(), context, collector); consumer = pulsarClient.newConsumer().topic(topic).subscriptionName(subscriptionName).subscribe(); }
Example 9
Source File: PulsarBoltTest.java From pulsar with Apache License 2.0 | 6 votes |
@Test public void testSharedProducer() throws Exception { TopicStats topicStats = admin.topics().getStats(topic); Assert.assertEquals(topicStats.publishers.size(), 1); PulsarBolt otherBolt = new PulsarBolt(pulsarBoltConf, PulsarClient.builder()); MockOutputCollector otherMockCollector = new MockOutputCollector(); OutputCollector collector = new OutputCollector(otherMockCollector); TopologyContext context = mock(TopologyContext.class); when(context.getThisComponentId()).thenReturn("test-bolt-" + methodName); when(context.getThisTaskId()).thenReturn(1); otherBolt.prepare(Maps.newHashMap(), context, collector); topicStats = admin.topics().getStats(topic); Assert.assertEquals(topicStats.publishers.size(), 1); otherBolt.close(); topicStats = admin.topics().getStats(topic); Assert.assertEquals(topicStats.publishers.size(), 1); }
Example 10
Source File: PulsarSpoutTest.java From pulsar with Apache License 2.0 | 4 votes |
@Test public void testSerializability() throws Exception { // test serializability with no auth PulsarSpout spoutWithNoAuth = new PulsarSpout(pulsarSpoutConf, PulsarClient.builder()); TestUtil.testSerializability(spoutWithNoAuth); }
Example 11
Source File: BasePulsarConfig.java From datacollector with Apache License 2.0 | 4 votes |
public List<ConfigIssue> init(Stage.Context context) { List<ConfigIssue> issues = new ArrayList<>(); //Validate BasePulsarConfig configs (currently no validation needed as constraints defined in annotations). issues.addAll(extraInit(context)); issues.addAll(securityConfig.init(context)); //configure client builder if issues is empty if (issues.isEmpty()) { ClientBuilder clientBuilder; clientBuilder = PulsarClient.builder(); clientBuilder.serviceUrl(serviceURL) .keepAliveInterval(keepAliveInterval, TimeUnit.MILLISECONDS) .operationTimeout(operationTimeout, TimeUnit.MILLISECONDS); // chance to subclass to further configure issues = extraBuilderConfiguration(clientBuilder); if (issues.isEmpty()) { try { securityConfig.configurePulsarBuilder(clientBuilder); } catch (StageException e) { LOG.error(e.toString()); issues.add(context.createConfigIssue(PulsarGroups.PULSAR.name(), null, e.getErrorCode(), e.getParams())); } try { client = clientBuilder.build(); } catch (Exception ex) { LOG.info(Utils.format(PulsarErrors.PULSAR_00.getMessage(), serviceURL), ex); issues.add(context.createConfigIssue(PulsarGroups.PULSAR.name(), "pulsarConfig.serviceURL", PulsarErrors.PULSAR_00, serviceURL, ex.toString() )); } } } return issues; }
Example 12
Source File: PulsarBolt.java From pulsar with Apache License 2.0 | 4 votes |
public PulsarBolt(PulsarBoltConfiguration pulsarBoltConf) { this(pulsarBoltConf, PulsarClient.builder()); }
Example 13
Source File: PulsarSpout.java From pulsar with Apache License 2.0 | 4 votes |
public PulsarSpout(PulsarSpoutConfiguration pulsarSpoutConf) { this(pulsarSpoutConf, PulsarClient.builder()); }
Example 14
Source File: PulsarBoltTest.java From pulsar with Apache License 2.0 | 4 votes |
@Test public void testSerializability() throws Exception { // test serializability with no auth PulsarBolt boltWithNoAuth = new PulsarBolt(pulsarBoltConf, PulsarClient.builder()); TestUtil.testSerializability(boltWithNoAuth); }
Example 15
Source File: CompactorTool.java From pulsar with Apache License 2.0 | 4 votes |
public static void main(String[] args) throws Exception { Arguments arguments = new Arguments(); JCommander jcommander = new JCommander(arguments); jcommander.setProgramName("PulsarTopicCompactor"); // parse args by JCommander jcommander.parse(args); if (arguments.help) { jcommander.usage(); System.exit(-1); } // init broker config ServiceConfiguration brokerConfig; if (isBlank(arguments.brokerConfigFile)) { jcommander.usage(); throw new IllegalArgumentException("Need to specify a configuration file for broker"); } else { brokerConfig = PulsarConfigurationLoader.create( arguments.brokerConfigFile, ServiceConfiguration.class); } ClientBuilder clientBuilder = PulsarClient.builder(); if (isNotBlank(brokerConfig.getBrokerClientAuthenticationPlugin())) { clientBuilder.authentication(brokerConfig.getBrokerClientAuthenticationPlugin(), brokerConfig.getBrokerClientAuthenticationParameters()); } if (brokerConfig.getBrokerServicePortTls().isPresent()) { clientBuilder .serviceUrl(PulsarService.brokerUrlTls(PulsarService.advertisedAddress(brokerConfig), brokerConfig.getBrokerServicePortTls().get())) .allowTlsInsecureConnection(brokerConfig.isTlsAllowInsecureConnection()) .tlsTrustCertsFilePath(brokerConfig.getTlsCertificateFilePath()); } else { clientBuilder.serviceUrl(PulsarService.brokerUrl(PulsarService.advertisedAddress(brokerConfig), brokerConfig.getBrokerServicePort().get())); } ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor( new ThreadFactoryBuilder().setNameFormat("compaction-%d").setDaemon(true).build()); OrderedScheduler executor = OrderedScheduler.newSchedulerBuilder().build(); ZooKeeperClientFactory zkClientFactory = new ZookeeperBkClientFactoryImpl(executor); ZooKeeper zk = zkClientFactory.create(brokerConfig.getZookeeperServers(), ZooKeeperClientFactory.SessionType.ReadWrite, (int)brokerConfig.getZooKeeperSessionTimeoutMillis()).get(); BookKeeperClientFactory bkClientFactory = new BookKeeperClientFactoryImpl(); BookKeeper bk = bkClientFactory.create(brokerConfig, zk, Optional.empty(), null); try (PulsarClient pulsar = clientBuilder.build()) { Compactor compactor = new TwoPhaseCompactor(brokerConfig, pulsar, bk, scheduler); long ledgerId = compactor.compact(arguments.topic).get(); log.info("Compaction of topic {} complete. Compacted to ledger {}", arguments.topic, ledgerId); } finally { bk.close(); bkClientFactory.close(); zk.close(); scheduler.shutdownNow(); executor.shutdown(); } }
Example 16
Source File: PulsarClientKafkaConfig.java From pulsar with Apache License 2.0 | 4 votes |
public static ClientBuilder getClientBuilder(Properties properties) { ClientBuilder clientBuilder = PulsarClient.builder(); if (properties.containsKey(AUTHENTICATION_CLASS)) { String className = properties.getProperty(AUTHENTICATION_CLASS); try { if (properties.containsKey(AUTHENTICATION_PARAMS_STRING)) { String authParamsString = (String) properties.get(AUTHENTICATION_PARAMS_STRING); clientBuilder.authentication(className, authParamsString); } else if (properties.containsKey(AUTHENTICATION_PARAMS_MAP)) { Map<String, String> authParams = (Map<String, String>) properties.get(AUTHENTICATION_PARAMS_MAP); clientBuilder.authentication(className, authParams); } else { @SuppressWarnings("unchecked") Class<Authentication> clazz = (Class<Authentication>) Class.forName(className); Authentication auth = clazz.newInstance(); clientBuilder.authentication(auth); } } catch (Exception e) { throw new RuntimeException(e); } } clientBuilder.enableTls(Boolean.parseBoolean(properties.getProperty(USE_TLS, "false"))); clientBuilder.allowTlsInsecureConnection( Boolean.parseBoolean(properties.getProperty(TLS_ALLOW_INSECURE_CONNECTION, "false"))); clientBuilder.enableTlsHostnameVerification( Boolean.parseBoolean(properties.getProperty(TLS_HOSTNAME_VERIFICATION, "false"))); if (properties.containsKey(TLS_TRUST_CERTS_FILE_PATH)) { clientBuilder.tlsTrustCertsFilePath(properties.getProperty(TLS_TRUST_CERTS_FILE_PATH)); } if (properties.containsKey(OPERATION_TIMEOUT_MS)) { clientBuilder.operationTimeout(Integer.parseInt(properties.getProperty(OPERATION_TIMEOUT_MS)), TimeUnit.MILLISECONDS); } if (properties.containsKey(STATS_INTERVAL_SECONDS)) { clientBuilder.statsInterval(Integer.parseInt(properties.getProperty(STATS_INTERVAL_SECONDS)), TimeUnit.SECONDS); } if (properties.containsKey(NUM_IO_THREADS)) { clientBuilder.ioThreads(Integer.parseInt(properties.getProperty(NUM_IO_THREADS))); } if (properties.containsKey(CONNECTIONS_PER_BROKER)) { clientBuilder.connectionsPerBroker(Integer.parseInt(properties.getProperty(CONNECTIONS_PER_BROKER))); } if (properties.containsKey(USE_TCP_NODELAY)) { clientBuilder.enableTcpNoDelay(Boolean.parseBoolean(properties.getProperty(USE_TCP_NODELAY))); } if (properties.containsKey(CONCURRENT_LOOKUP_REQUESTS)) { clientBuilder.maxConcurrentLookupRequests(Integer.parseInt(properties.getProperty(CONCURRENT_LOOKUP_REQUESTS))); } if (properties.containsKey(MAX_NUMBER_OF_REJECTED_REQUESTS_PER_CONNECTION)) { clientBuilder.maxNumberOfRejectedRequestPerConnection( Integer.parseInt(properties.getProperty(MAX_NUMBER_OF_REJECTED_REQUESTS_PER_CONNECTION))); } return clientBuilder; }
Example 17
Source File: PulsarClientKafkaConfig.java From pulsar with Apache License 2.0 | 4 votes |
public static ClientBuilder getClientBuilder(Properties properties) { ClientBuilder clientBuilder = PulsarClient.builder(); if (properties.containsKey(AUTHENTICATION_CLASS)) { String className = properties.getProperty(AUTHENTICATION_CLASS); try { if (properties.containsKey(AUTHENTICATION_PARAMS_STRING)) { String authParamsString = (String) properties.get(AUTHENTICATION_PARAMS_STRING); clientBuilder.authentication(className, authParamsString); } else if (properties.containsKey(AUTHENTICATION_PARAMS_MAP)) { Map<String, String> authParams = (Map<String, String>) properties.get(AUTHENTICATION_PARAMS_MAP); clientBuilder.authentication(className, authParams); } else { @SuppressWarnings("unchecked") Class<Authentication> clazz = (Class<Authentication>) Class.forName(className); Authentication auth = clazz.newInstance(); clientBuilder.authentication(auth); } } catch (Exception e) { throw new RuntimeException(e); } } clientBuilder.enableTls(Boolean.parseBoolean(properties.getProperty(USE_TLS, "false"))); clientBuilder.allowTlsInsecureConnection( Boolean.parseBoolean(properties.getProperty(TLS_ALLOW_INSECURE_CONNECTION, "false"))); clientBuilder.enableTlsHostnameVerification( Boolean.parseBoolean(properties.getProperty(TLS_HOSTNAME_VERIFICATION, "false"))); if (properties.containsKey(TLS_TRUST_CERTS_FILE_PATH)) { clientBuilder.tlsTrustCertsFilePath(properties.getProperty(TLS_TRUST_CERTS_FILE_PATH)); } if (properties.containsKey(OPERATION_TIMEOUT_MS)) { clientBuilder.operationTimeout(Integer.parseInt(properties.getProperty(OPERATION_TIMEOUT_MS)), TimeUnit.MILLISECONDS); } if (properties.containsKey(STATS_INTERVAL_SECONDS)) { clientBuilder.statsInterval(Integer.parseInt(properties.getProperty(STATS_INTERVAL_SECONDS)), TimeUnit.SECONDS); } if (properties.containsKey(NUM_IO_THREADS)) { clientBuilder.ioThreads(Integer.parseInt(properties.getProperty(NUM_IO_THREADS))); } if (properties.containsKey(CONNECTIONS_PER_BROKER)) { clientBuilder.connectionsPerBroker(Integer.parseInt(properties.getProperty(CONNECTIONS_PER_BROKER))); } if (properties.containsKey(USE_TCP_NODELAY)) { clientBuilder.enableTcpNoDelay(Boolean.parseBoolean(properties.getProperty(USE_TCP_NODELAY))); } if (properties.containsKey(CONCURRENT_LOOKUP_REQUESTS)) { clientBuilder.maxConcurrentLookupRequests(Integer.parseInt(properties.getProperty(CONCURRENT_LOOKUP_REQUESTS))); } if (properties.containsKey(MAX_NUMBER_OF_REJECTED_REQUESTS_PER_CONNECTION)) { clientBuilder.maxNumberOfRejectedRequestPerConnection( Integer.parseInt(properties.getProperty(MAX_NUMBER_OF_REJECTED_REQUESTS_PER_CONNECTION))); } if (properties.containsKey(KEEPALIVE_INTERVAL_MS)) { clientBuilder.keepAliveInterval(Integer.parseInt(properties.getProperty(KEEPALIVE_INTERVAL_MS)), TimeUnit.MILLISECONDS); } return clientBuilder; }
Example 18
Source File: PulsarClientKafkaConfig.java From pulsar with Apache License 2.0 | 4 votes |
public static ClientBuilder getClientBuilder(Properties properties) { ClientBuilder clientBuilder = PulsarClient.builder(); if (properties == null) { return clientBuilder; } if (properties.containsKey(AUTHENTICATION_CLASS)) { String className = properties.getProperty(AUTHENTICATION_CLASS); try { if (properties.containsKey(AUTHENTICATION_PARAMS_STRING)) { String authParamsString = (String) properties.get(AUTHENTICATION_PARAMS_STRING); clientBuilder.authentication(className, authParamsString); } else if (properties.containsKey(AUTHENTICATION_PARAMS_MAP)) { Map<String, String> authParams = (Map<String, String>) properties.get(AUTHENTICATION_PARAMS_MAP); clientBuilder.authentication(className, authParams); } else { @SuppressWarnings("unchecked") Class<Authentication> clazz = (Class<Authentication>) Class.forName(className); Authentication auth = clazz.newInstance(); clientBuilder.authentication(auth); } } catch (Exception e) { throw new RuntimeException(e); } } clientBuilder.enableTls(Boolean.parseBoolean(properties.getProperty(USE_TLS, "false"))); clientBuilder.allowTlsInsecureConnection( Boolean.parseBoolean(properties.getProperty(TLS_ALLOW_INSECURE_CONNECTION, "false"))); clientBuilder.enableTlsHostnameVerification( Boolean.parseBoolean(properties.getProperty(TLS_HOSTNAME_VERIFICATION, "false"))); if (properties.containsKey(TLS_TRUST_CERTS_FILE_PATH)) { clientBuilder.tlsTrustCertsFilePath(properties.getProperty(TLS_TRUST_CERTS_FILE_PATH)); } if (properties.containsKey(OPERATION_TIMEOUT_MS)) { clientBuilder.operationTimeout(Integer.parseInt(properties.getProperty(OPERATION_TIMEOUT_MS)), TimeUnit.MILLISECONDS); } if (properties.containsKey(STATS_INTERVAL_SECONDS)) { clientBuilder.statsInterval(Integer.parseInt(properties.getProperty(STATS_INTERVAL_SECONDS)), TimeUnit.SECONDS); } if (properties.containsKey(NUM_IO_THREADS)) { clientBuilder.ioThreads(Integer.parseInt(properties.getProperty(NUM_IO_THREADS))); } if (properties.containsKey(CONNECTIONS_PER_BROKER)) { clientBuilder.connectionsPerBroker(Integer.parseInt(properties.getProperty(CONNECTIONS_PER_BROKER))); } if (properties.containsKey(USE_TCP_NODELAY)) { clientBuilder.enableTcpNoDelay(Boolean.parseBoolean(properties.getProperty(USE_TCP_NODELAY))); } if (properties.containsKey(CONCURRENT_LOOKUP_REQUESTS)) { clientBuilder .maxConcurrentLookupRequests(Integer.parseInt(properties.getProperty(CONCURRENT_LOOKUP_REQUESTS))); } if (properties.containsKey(MAX_NUMBER_OF_REJECTED_REQUESTS_PER_CONNECTION)) { clientBuilder.maxNumberOfRejectedRequestPerConnection( Integer.parseInt(properties.getProperty(MAX_NUMBER_OF_REJECTED_REQUESTS_PER_CONNECTION))); } return clientBuilder; }