james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [11/15] james-project git commit: JAMES-2202 Create a default ElasticSearch configuration
Date Wed, 01 Nov 2017 11:00:09 GMT
JAMES-2202 Create a default ElasticSearch configuration


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/a312fde2
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/a312fde2
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/a312fde2

Branch: refs/heads/master
Commit: a312fde2ebbb0e12c2cb781467c27463816902fd
Parents: 76699b3
Author: benwa <btellier@linagora.com>
Authored: Fri Oct 27 08:50:22 2017 +0700
Committer: benwa <btellier@linagora.com>
Committed: Wed Nov 1 17:55:12 2017 +0700

----------------------------------------------------------------------
 .../modules/mailbox/ElasticSearchConfiguration.java     | 12 ++++++++++++
 .../modules/mailbox/ElasticSearchMailboxModule.java     |  7 ++-----
 2 files changed, 14 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/a312fde2/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchConfiguration.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchConfiguration.java
b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchConfiguration.java
index e73ecc7..2fc32e9 100644
--- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchConfiguration.java
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchConfiguration.java
@@ -55,8 +55,20 @@ public class ElasticSearchConfiguration {
     public static final int DEFAULT_NB_SHARDS = 1;
     public static final int DEFAULT_NB_REPLICA = 0;
     public static final int DEFAULT_PORT = 9300;
+    private static final String LOCALHOST = "127.0.0.1";
     public static final Optional<Integer> DEFAULT_PORT_AS_OPTIONAL = Optional.of(DEFAULT_PORT);
 
+    public static final ElasticSearchConfiguration DEFAULT_CONFIGURATION = new ElasticSearchConfiguration(
+        ImmutableList.of(Host.from(LOCALHOST, DEFAULT_PORT)),
+        MailboxElasticSearchConstants.DEFAULT_MAILBOX_INDEX,
+        MailboxElasticSearchConstants.DEFAULT_MAILBOX_READ_ALIAS,
+        MailboxElasticSearchConstants.DEFAULT_MAILBOX_WRITE_ALIAS,
+        DEFAULT_NB_SHARDS,
+        DEFAULT_NB_REPLICA,
+        DEFAULT_CONNECTION_MIN_DELAY,
+        DEFAULT_CONNECTION_MAX_RETRIES,
+        IndexAttachments.YES);
+
     public static ElasticSearchConfiguration fromProperties(PropertiesConfiguration configuration)
throws ConfigurationException {
         int nbShards = configuration.getInt(ELASTICSEARCH_NB_SHARDS, DEFAULT_NB_SHARDS);
         int nbReplica = configuration.getInt(ELASTICSEARCH_NB_REPLICA, DEFAULT_NB_REPLICA);

http://git-wip-us.apache.org/repos/asf/james-project/blob/a312fde2/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchMailboxModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchMailboxModule.java
b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchMailboxModule.java
index 82f27a4..5286def 100644
--- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchMailboxModule.java
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchMailboxModule.java
@@ -28,9 +28,9 @@ import javax.inject.Singleton;
 
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.PropertiesConfiguration;
-import org.apache.james.backends.es.ElasticSearchConstants;
 import org.apache.james.backends.es.AliasName;
 import org.apache.james.backends.es.ClientProviderImpl;
+import org.apache.james.backends.es.ElasticSearchConstants;
 import org.apache.james.backends.es.IndexCreationFactory;
 import org.apache.james.backends.es.IndexName;
 import org.apache.james.backends.es.NodeMappingFactory;
@@ -57,7 +57,6 @@ public class ElasticSearchMailboxModule extends AbstractModule {
     private static final Logger LOGGER = LoggerFactory.getLogger(ElasticSearchMailboxModule.class);
 
     public static final String ELASTICSEARCH_CONFIGURATION_NAME = "elasticsearch";
-    private static final String LOCALHOST = "127.0.0.1";
 
     @Override
     protected void configure() {
@@ -75,9 +74,7 @@ public class ElasticSearchMailboxModule extends AbstractModule {
             return ElasticSearchConfiguration.fromProperties(configuration);
         } catch (FileNotFoundException e) {
             LOGGER.warn("Could not find " + ELASTICSEARCH_CONFIGURATION_NAME + " configuration
file. Using 127.0.0.1:9300 as contact point");
-            PropertiesConfiguration configuration = new PropertiesConfiguration();
-            configuration.addProperty(ElasticSearchConfiguration.ELASTICSEARCH_HOSTS, LOCALHOST);
-            return ElasticSearchConfiguration.fromProperties(configuration);
+            return ElasticSearchConfiguration.DEFAULT_CONFIGURATION;
         }
     }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message