@Test(expectedExceptions = IllegalArgumentException.class) public void testClientBuilderWithServiceUrlAndServiceUrlProviderNotSet() throws PulsarClientException { PulsarClient.builder().build(); }
@Override public PulsarClient build() throws PulsarClientException { if (StringUtils.isBlank(conf.getServiceUrl()) && conf.getServiceUrlProvider() == null) { throw new IllegalArgumentException("service URL or service URL provider needs to be specified on the ClientBuilder object."); } if (StringUtils.isNotBlank(conf.getServiceUrl()) && conf.getServiceUrlProvider() != null) { throw new IllegalArgumentException("Can only chose one way service URL or service URL provider."); } if (conf.getServiceUrlProvider() != null) { if (StringUtils.isBlank(conf.getServiceUrlProvider().getServiceUrl())) { throw new IllegalArgumentException("Cannot get service url from service url provider."); } else { conf.setServiceUrl(conf.getServiceUrlProvider().getServiceUrl()); } } PulsarClient client = new PulsarClientImpl(conf); if (conf.getServiceUrlProvider() != null) { conf.getServiceUrlProvider().initialize(client); } return client; }
ClientBuilderImpl implements ClientBuilder { @Override public PulsarClient build() throws PulsarClientException { if (StringUtils.isBlank(conf.getServiceUrl()) && conf.getServiceUrlProvider() == null) { throw new IllegalArgumentException("service URL or service URL provider needs to be specified on the ClientBuilder object."); } if (StringUtils.isNotBlank(conf.getServiceUrl()) && conf.getServiceUrlProvider() != null) { throw new IllegalArgumentException("Can only chose one way service URL or service URL provider."); } if (conf.getServiceUrlProvider() != null) { if (StringUtils.isBlank(conf.getServiceUrlProvider().getServiceUrl())) { throw new IllegalArgumentException("Cannot get service url from service url provider."); } else { conf.setServiceUrl(conf.getServiceUrlProvider().getServiceUrl()); } } PulsarClient client = new PulsarClientImpl(conf); if (conf.getServiceUrlProvider() != null) { conf.getServiceUrlProvider().initialize(client); } return client; } }
ClientBuilderImpl implements ClientBuilder { @Override public PulsarClient build() throws PulsarClientException { if (StringUtils.isBlank(conf.getServiceUrl()) && conf.getServiceUrlProvider() == null) { throw new IllegalArgumentException("service URL or service URL provider needs to be specified on the ClientBuilder object."); } if (StringUtils.isNotBlank(conf.getServiceUrl()) && conf.getServiceUrlProvider() != null) { throw new IllegalArgumentException("Can only chose one way service URL or service URL provider."); } if (conf.getServiceUrlProvider() != null) { if (StringUtils.isBlank(conf.getServiceUrlProvider().getServiceUrl())) { throw new IllegalArgumentException("Cannot get service url from service url provider."); } else { conf.setServiceUrl(conf.getServiceUrlProvider().getServiceUrl()); } } PulsarClient client = new PulsarClientImpl(conf); if (conf.getServiceUrlProvider() != null) { conf.getServiceUrlProvider().initialize(client); } return client; } ClientBuilderImpl();  ClientBuilderImpl(ClientConfigurationData conf); }
ClientBuilderImpl implements ClientBuilder { @Override public PulsarClient build() throws PulsarClientException { if (StringUtils.isBlank(conf.getServiceUrl()) && conf.getServiceUrlProvider() == null) { throw new IllegalArgumentException("service URL or service URL provider needs to be specified on the ClientBuilder object."); } if (StringUtils.isNotBlank(conf.getServiceUrl()) && conf.getServiceUrlProvider() != null) { throw new IllegalArgumentException("Can only chose one way service URL or service URL provider."); } if (conf.getServiceUrlProvider() != null) { if (StringUtils.isBlank(conf.getServiceUrlProvider().getServiceUrl())) { throw new IllegalArgumentException("Cannot get service url from service url provider."); } else { conf.setServiceUrl(conf.getServiceUrlProvider().getServiceUrl()); } } PulsarClient client = new PulsarClientImpl(conf); if (conf.getServiceUrlProvider() != null) { conf.getServiceUrlProvider().initialize(client); } return client; } ClientBuilderImpl();  ClientBuilderImpl(ClientConfigurationData conf); @Override PulsarClient build(); @Override ClientBuilder clone(); @Override ClientBuilder loadConf(Map<String, Object> config); @Override ClientBuilder serviceUrl(String serviceUrl); @Override ClientBuilder serviceUrlProvider(ServiceUrlProvider serviceUrlProvider); @Override ClientBuilder listenerName(String listenerName); @Override ClientBuilder authentication(Authentication authentication); @Override ClientBuilder authentication(String authPluginClassName, String authParamsString); @Override ClientBuilder authentication(String authPluginClassName, Map<String, String> authParams); @Override ClientBuilder operationTimeout(int operationTimeout, TimeUnit unit); @Override ClientBuilder ioThreads(int numIoThreads); @Override ClientBuilder listenerThreads(int numListenerThreads); @Override ClientBuilder connectionsPerBroker(int connectionsPerBroker); @Override ClientBuilder enableTcpNoDelay(boolean useTcpNoDelay); @Override ClientBuilder enableTls(boolean useTls); @Override ClientBuilder enableTlsHostnameVerification(boolean enableTlsHostnameVerification); @Override ClientBuilder tlsTrustCertsFilePath(String tlsTrustCertsFilePath); @Override ClientBuilder allowTlsInsecureConnection(boolean tlsAllowInsecureConnection); @Override ClientBuilder useKeyStoreTls(boolean useKeyStoreTls); @Override ClientBuilder sslProvider(String sslProvider); @Override ClientBuilder tlsTrustStoreType(String tlsTrustStoreType); @Override ClientBuilder tlsTrustStorePath(String tlsTrustStorePath); @Override ClientBuilder tlsTrustStorePassword(String tlsTrustStorePassword); @Override ClientBuilder tlsCiphers(Set<String> tlsCiphers); @Override ClientBuilder tlsProtocols(Set<String> tlsProtocols); @Override ClientBuilder statsInterval(long statsInterval, TimeUnit unit); @Override ClientBuilder maxConcurrentLookupRequests(int concurrentLookupRequests); @Override ClientBuilder maxLookupRequests(int maxLookupRequests); @Override ClientBuilder maxLookupRedirects(int maxLookupRedirects); @Override ClientBuilder maxNumberOfRejectedRequestPerConnection(int maxNumberOfRejectedRequestPerConnection); @Override ClientBuilder keepAliveInterval(int keepAliveInterval, TimeUnit unit); @Override ClientBuilder connectionTimeout(int duration, TimeUnit unit); @Override ClientBuilder startingBackoffInterval(long duration, TimeUnit unit); @Override ClientBuilder maxBackoffInterval(long duration, TimeUnit unit); ClientConfigurationData getClientConfigurationData(); @Override ClientBuilder clock(Clock clock); @Override ClientBuilder proxyServiceUrl(String proxyServiceUrl, ProxyProtocol proxyProtocol); @Override ClientBuilder enableTransaction(boolean enableTransaction); }
ClientBuilderImpl implements ClientBuilder { @Override public PulsarClient build() throws PulsarClientException { if (StringUtils.isBlank(conf.getServiceUrl()) && conf.getServiceUrlProvider() == null) { throw new IllegalArgumentException("service URL or service URL provider needs to be specified on the ClientBuilder object."); } if (StringUtils.isNotBlank(conf.getServiceUrl()) && conf.getServiceUrlProvider() != null) { throw new IllegalArgumentException("Can only chose one way service URL or service URL provider."); } if (conf.getServiceUrlProvider() != null) { if (StringUtils.isBlank(conf.getServiceUrlProvider().getServiceUrl())) { throw new IllegalArgumentException("Cannot get service url from service url provider."); } else { conf.setServiceUrl(conf.getServiceUrlProvider().getServiceUrl()); } } PulsarClient client = new PulsarClientImpl(conf); if (conf.getServiceUrlProvider() != null) { conf.getServiceUrlProvider().initialize(client); } return client; } ClientBuilderImpl();  ClientBuilderImpl(ClientConfigurationData conf); @Override PulsarClient build(); @Override ClientBuilder clone(); @Override ClientBuilder loadConf(Map<String, Object> config); @Override ClientBuilder serviceUrl(String serviceUrl); @Override ClientBuilder serviceUrlProvider(ServiceUrlProvider serviceUrlProvider); @Override ClientBuilder listenerName(String listenerName); @Override ClientBuilder authentication(Authentication authentication); @Override ClientBuilder authentication(String authPluginClassName, String authParamsString); @Override ClientBuilder authentication(String authPluginClassName, Map<String, String> authParams); @Override ClientBuilder operationTimeout(int operationTimeout, TimeUnit unit); @Override ClientBuilder ioThreads(int numIoThreads); @Override ClientBuilder listenerThreads(int numListenerThreads); @Override ClientBuilder connectionsPerBroker(int connectionsPerBroker); @Override ClientBuilder enableTcpNoDelay(boolean useTcpNoDelay); @Override ClientBuilder enableTls(boolean useTls); @Override ClientBuilder enableTlsHostnameVerification(boolean enableTlsHostnameVerification); @Override ClientBuilder tlsTrustCertsFilePath(String tlsTrustCertsFilePath); @Override ClientBuilder allowTlsInsecureConnection(boolean tlsAllowInsecureConnection); @Override ClientBuilder useKeyStoreTls(boolean useKeyStoreTls); @Override ClientBuilder sslProvider(String sslProvider); @Override ClientBuilder tlsTrustStoreType(String tlsTrustStoreType); @Override ClientBuilder tlsTrustStorePath(String tlsTrustStorePath); @Override ClientBuilder tlsTrustStorePassword(String tlsTrustStorePassword); @Override ClientBuilder tlsCiphers(Set<String> tlsCiphers); @Override ClientBuilder tlsProtocols(Set<String> tlsProtocols); @Override ClientBuilder statsInterval(long statsInterval, TimeUnit unit); @Override ClientBuilder maxConcurrentLookupRequests(int concurrentLookupRequests); @Override ClientBuilder maxLookupRequests(int maxLookupRequests); @Override ClientBuilder maxLookupRedirects(int maxLookupRedirects); @Override ClientBuilder maxNumberOfRejectedRequestPerConnection(int maxNumberOfRejectedRequestPerConnection); @Override ClientBuilder keepAliveInterval(int keepAliveInterval, TimeUnit unit); @Override ClientBuilder connectionTimeout(int duration, TimeUnit unit); @Override ClientBuilder startingBackoffInterval(long duration, TimeUnit unit); @Override ClientBuilder maxBackoffInterval(long duration, TimeUnit unit); ClientConfigurationData getClientConfigurationData(); @Override ClientBuilder clock(Clock clock); @Override ClientBuilder proxyServiceUrl(String proxyServiceUrl, ProxyProtocol proxyProtocol); @Override ClientBuilder enableTransaction(boolean enableTransaction);  }