@Test void validateHostsConfigurationOptionsShouldThrowWhenMonoHostWithoutAddress() { assertThatThrownBy(() -> ElasticSearchConfiguration.validateHostsConfigurationOptions( Optional.empty(), Optional.of(9200), ImmutableList.of())) .isInstanceOf(ConfigurationException.class) .hasMessage(ElasticSearchConfiguration.ELASTICSEARCH_MASTER_HOST + " and " + ElasticSearchConfiguration.ELASTICSEARCH_PORT + " should be specified together"); }
@VisibleForTesting static void validateHostsConfigurationOptions(Optional<String> masterHost, Optional<Integer> masterPort, List<String> multiHosts) throws ConfigurationException { if (masterHost.isPresent() != masterPort.isPresent()) { throw new ConfigurationException(ELASTICSEARCH_MASTER_HOST + " and " + ELASTICSEARCH_PORT + " should be specified together"); } if (!multiHosts.isEmpty() && masterHost.isPresent()) { throw new ConfigurationException("You should choose between mono host set up and " + ELASTICSEARCH_HOSTS); } if (multiHosts.isEmpty() && !masterHost.isPresent()) { throw new ConfigurationException("You should specify either (" + ELASTICSEARCH_MASTER_HOST + " and " + ELASTICSEARCH_PORT + ") or " + ELASTICSEARCH_HOSTS); } }
ElasticSearchConfiguration { @VisibleForTesting static void validateHostsConfigurationOptions(Optional<String> masterHost, Optional<Integer> masterPort, List<String> multiHosts) throws ConfigurationException { if (masterHost.isPresent() != masterPort.isPresent()) { throw new ConfigurationException(ELASTICSEARCH_MASTER_HOST + " and " + ELASTICSEARCH_PORT + " should be specified together"); } if (!multiHosts.isEmpty() && masterHost.isPresent()) { throw new ConfigurationException("You should choose between mono host set up and " + ELASTICSEARCH_HOSTS); } if (multiHosts.isEmpty() && !masterHost.isPresent()) { throw new ConfigurationException("You should specify either (" + ELASTICSEARCH_MASTER_HOST + " and " + ELASTICSEARCH_PORT + ") or " + ELASTICSEARCH_HOSTS); } } }
ElasticSearchConfiguration { @VisibleForTesting static void validateHostsConfigurationOptions(Optional<String> masterHost, Optional<Integer> masterPort, List<String> multiHosts) throws ConfigurationException { if (masterHost.isPresent() != masterPort.isPresent()) { throw new ConfigurationException(ELASTICSEARCH_MASTER_HOST + " and " + ELASTICSEARCH_PORT + " should be specified together"); } if (!multiHosts.isEmpty() && masterHost.isPresent()) { throw new ConfigurationException("You should choose between mono host set up and " + ELASTICSEARCH_HOSTS); } if (multiHosts.isEmpty() && !masterHost.isPresent()) { throw new ConfigurationException("You should specify either (" + ELASTICSEARCH_MASTER_HOST + " and " + ELASTICSEARCH_PORT + ") or " + ELASTICSEARCH_HOSTS); } } private  ElasticSearchConfiguration(ImmutableList<Host> hosts, int nbShards, int nbReplica, int waitForActiveShards, int minDelay, int maxRetries, Duration requestTimeout,
                                       HostScheme hostScheme, Optional<Credential> credential, SSLConfiguration sslConfiguration); }
ElasticSearchConfiguration { @VisibleForTesting static void validateHostsConfigurationOptions(Optional<String> masterHost, Optional<Integer> masterPort, List<String> multiHosts) throws ConfigurationException { if (masterHost.isPresent() != masterPort.isPresent()) { throw new ConfigurationException(ELASTICSEARCH_MASTER_HOST + " and " + ELASTICSEARCH_PORT + " should be specified together"); } if (!multiHosts.isEmpty() && masterHost.isPresent()) { throw new ConfigurationException("You should choose between mono host set up and " + ELASTICSEARCH_HOSTS); } if (multiHosts.isEmpty() && !masterHost.isPresent()) { throw new ConfigurationException("You should specify either (" + ELASTICSEARCH_MASTER_HOST + " and " + ELASTICSEARCH_PORT + ") or " + ELASTICSEARCH_HOSTS); } } private  ElasticSearchConfiguration(ImmutableList<Host> hosts, int nbShards, int nbReplica, int waitForActiveShards, int minDelay, int maxRetries, Duration requestTimeout,
                                       HostScheme hostScheme, Optional<Credential> credential, SSLConfiguration sslConfiguration); static Builder builder(); static ElasticSearchConfiguration fromProperties(Configuration configuration); ImmutableList<Host> getHosts(); int getNbShards(); int getNbReplica(); int getWaitForActiveShards(); int getMinDelay(); int getMaxRetries(); Duration getRequestTimeout(); HostScheme getHostScheme(); Optional<Credential> getCredential(); SSLConfiguration getSslConfiguration(); @Override final boolean equals(Object o); @Override final int hashCode(); }
ElasticSearchConfiguration { @VisibleForTesting static void validateHostsConfigurationOptions(Optional<String> masterHost, Optional<Integer> masterPort, List<String> multiHosts) throws ConfigurationException { if (masterHost.isPresent() != masterPort.isPresent()) { throw new ConfigurationException(ELASTICSEARCH_MASTER_HOST + " and " + ELASTICSEARCH_PORT + " should be specified together"); } if (!multiHosts.isEmpty() && masterHost.isPresent()) { throw new ConfigurationException("You should choose between mono host set up and " + ELASTICSEARCH_HOSTS); } if (multiHosts.isEmpty() && !masterHost.isPresent()) { throw new ConfigurationException("You should specify either (" + ELASTICSEARCH_MASTER_HOST + " and " + ELASTICSEARCH_PORT + ") or " + ELASTICSEARCH_HOSTS); } } private  ElasticSearchConfiguration(ImmutableList<Host> hosts, int nbShards, int nbReplica, int waitForActiveShards, int minDelay, int maxRetries, Duration requestTimeout,
                                       HostScheme hostScheme, Optional<Credential> credential, SSLConfiguration sslConfiguration); static Builder builder(); static ElasticSearchConfiguration fromProperties(Configuration configuration); ImmutableList<Host> getHosts(); int getNbShards(); int getNbReplica(); int getWaitForActiveShards(); int getMinDelay(); int getMaxRetries(); Duration getRequestTimeout(); HostScheme getHostScheme(); Optional<Credential> getCredential(); SSLConfiguration getSslConfiguration(); @Override final boolean equals(Object o); @Override final int hashCode(); static final String ELASTICSEARCH_HOSTS; static final String ELASTICSEARCH_MASTER_HOST; static final String ELASTICSEARCH_PORT; static final String ELASTICSEARCH_HOST_SCHEME; static final String ELASTICSEARCH_HTTPS_SSL_VALIDATION_STRATEGY; static final String ELASTICSEARCH_HTTPS_HOSTNAME_VERIFIER; static final String ELASTICSEARCH_HTTPS_TRUST_STORE_PATH; static final String ELASTICSEARCH_HTTPS_TRUST_STORE_PASSWORD; static final String ELASTICSEARCH_USER; static final String ELASTICSEARCH_PASSWORD; static final String ELASTICSEARCH_NB_REPLICA; static final String WAIT_FOR_ACTIVE_SHARDS; static final String ELASTICSEARCH_NB_SHARDS; static final String ELASTICSEARCH_RETRY_CONNECTION_MIN_DELAY; static final String ELASTICSEARCH_RETRY_CONNECTION_MAX_RETRIES; static final int DEFAULT_CONNECTION_MAX_RETRIES; static final int DEFAULT_CONNECTION_MIN_DELAY; static final Duration DEFAULT_REQUEST_TIMEOUT; static final int DEFAULT_NB_SHARDS; static final int DEFAULT_NB_REPLICA; static final int DEFAULT_WAIT_FOR_ACTIVE_SHARDS; static final int DEFAULT_PORT; static final String LOCALHOST; static final Optional<Integer> DEFAULT_PORT_AS_OPTIONAL; static final HostScheme DEFAULT_SCHEME; static final SSLConfiguration DEFAULT_SSL_TRUST_CONFIGURATION; static final ElasticSearchConfiguration DEFAULT_CONFIGURATION; }