Repository: james-project Updated Branches: refs/heads/master 0e1f12bdb -> 3ae482a71
JAMES-2398 Keep ElasticSearch indexer generic Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/6013f913 Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/6013f913 Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/6013f913 Branch: refs/heads/master Commit: 6013f91398bbb91966b0e3904489f39fc030f791 Parents: cdf8ce7 Author: benwa <[email protected]> Authored: Thu May 17 15:37:55 2018 +0700 Committer: Matthieu Baechler <[email protected]> Committed: Mon May 21 11:37:43 2018 +0200 ---------------------------------------------------------------------- .../james/backends/es/ElasticSearchIndexer.java | 36 --- .../org/apache/james/backends/es/Indexer.java | 104 ++++++++ .../james/backends/es/IndexerSupplier.java | 24 ++ .../apache/james/backends/es/IndexerTest.java | 256 ++++++++++++++++++ .../ElasticSearchMailboxIndexer.java | 118 -------- .../elasticsearch/MailboxIndexerSupplier.java | 46 ++++ ...lasticSearchListeningMessageSearchIndex.java | 9 +- .../ElasticSearchIntegrationTest.java | 2 +- .../ElasticSearchMailboxIndexerTest.java | 266 ------------------- ...icSearchListeningMessageSearchIndexTest.java | 6 +- .../host/ElasticSearchHostSystem.java | 4 +- .../mailbox/ElasticSearchMailboxModule.java | 11 +- 12 files changed, 446 insertions(+), 436 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/6013f913/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ElasticSearchIndexer.java ---------------------------------------------------------------------- diff --git a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ElasticSearchIndexer.java b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ElasticSearchIndexer.java deleted file mode 100644 index cefbd58..0000000 --- a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ElasticSearchIndexer.java +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one * - * or more contributor license agreements. See the NOTICE file * - * distributed with this work for additional information * - * regarding copyright ownership. The ASF licenses this file * - * to you under the Apache License, Version 2.0 (the * - * "License"); you may not use this file except in compliance * - * with the License. You may obtain a copy of the License at * - * * - * http://www.apache.org/licenses/LICENSE-2.0 * - * * - * Unless required by applicable law or agreed to in writing, * - * software distributed under the License is distributed on an * - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * - * KIND, either express or implied. See the License for the * - * specific language governing permissions and limitations * - * under the License. * - ****************************************************************/ -package org.apache.james.backends.es; - -import java.util.List; -import java.util.Optional; - -import org.elasticsearch.action.bulk.BulkResponse; -import org.elasticsearch.action.index.IndexResponse; -import org.elasticsearch.index.query.QueryBuilder; - -public interface ElasticSearchIndexer { - IndexResponse indexMessage(String id, String content); - - Optional<BulkResponse> updateMessages(List<UpdatedRepresentation> updatedDocumentParts); - - Optional<BulkResponse> deleteMessages(List<String> ids); - - void deleteAllMatchingQuery(QueryBuilder queryBuilder); -} http://git-wip-us.apache.org/repos/asf/james-project/blob/6013f913/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/Indexer.java ---------------------------------------------------------------------- diff --git a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/Indexer.java b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/Indexer.java new file mode 100644 index 0000000..9a3c83b --- /dev/null +++ b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/Indexer.java @@ -0,0 +1,104 @@ +/**************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one * + * or more contributor license agreements. See the NOTICE file * + * distributed with this work for additional information * + * regarding copyright ownership. The ASF licenses this file * + * to you under the Apache License, Version 2.0 (the * + * "License"); you may not use this file except in compliance * + * with the License. You may obtain a copy of the License at * + * * + * http://www.apache.org/licenses/LICENSE-2.0 * + * * + * Unless required by applicable law or agreed to in writing, * + * software distributed under the License is distributed on an * + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * + * KIND, either express or implied. See the License for the * + * specific language governing permissions and limitations * + * under the License. * + ****************************************************************/ +package org.apache.james.backends.es; + +import java.util.List; +import java.util.Optional; + +import org.apache.commons.lang3.StringUtils; +import org.elasticsearch.action.bulk.BulkRequestBuilder; +import org.elasticsearch.action.bulk.BulkResponse; +import org.elasticsearch.action.index.IndexResponse; +import org.elasticsearch.client.Client; +import org.elasticsearch.common.ValidationException; +import org.elasticsearch.index.query.QueryBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.Preconditions; + +public class Indexer { + private static int DEBUG_MAX_LENGTH_CONTENT = 1000; + + private static final Logger LOGGER = LoggerFactory.getLogger(Indexer.class); + + private final Client client; + private final DeleteByQueryPerformer deleteByQueryPerformer; + private final AliasName aliasName; + private final TypeName typeName; + + public Indexer(Client client, DeleteByQueryPerformer deleteByQueryPerformer, + AliasName aliasName, + TypeName typeName) { + this.client = client; + this.deleteByQueryPerformer = deleteByQueryPerformer; + this.aliasName = aliasName; + this.typeName = typeName; + } + + public IndexResponse indexMessage(String id, String content) { + checkArgument(content); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Indexing {}: {}", id, StringUtils.left(content, DEBUG_MAX_LENGTH_CONTENT)); + } + return client.prepareIndex(aliasName.getValue(), typeName.getValue(), id) + .setSource(content) + .get(); + } + + public Optional<BulkResponse> updateMessages(List<UpdatedRepresentation> updatedDocumentParts) { + try { + Preconditions.checkNotNull(updatedDocumentParts); + BulkRequestBuilder bulkRequestBuilder = client.prepareBulk(); + updatedDocumentParts.forEach(updatedDocumentPart -> bulkRequestBuilder.add( + client.prepareUpdate( + aliasName.getValue(), + typeName.getValue(), + updatedDocumentPart.getId()) + .setDoc(updatedDocumentPart.getUpdatedDocumentPart()))); + return Optional.of(bulkRequestBuilder.get()); + } catch (ValidationException e) { + LOGGER.warn("Error while updating index", e); + return Optional.empty(); + } + } + + public Optional<BulkResponse> deleteMessages(List<String> ids) { + try { + BulkRequestBuilder bulkRequestBuilder = client.prepareBulk(); + ids.forEach(id -> bulkRequestBuilder.add( + client.prepareDelete( + aliasName.getValue(), + typeName.getValue(), + id))); + return Optional.of(bulkRequestBuilder.get()); + } catch (ValidationException e) { + LOGGER.warn("Error while deleting index", e); + return Optional.empty(); + } + } + + public void deleteAllMatchingQuery(QueryBuilder queryBuilder) { + deleteByQueryPerformer.perform(queryBuilder); + } + + private void checkArgument(String content) { + Preconditions.checkArgument(content != null, "content should be provided"); + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/6013f913/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/IndexerSupplier.java ---------------------------------------------------------------------- diff --git a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/IndexerSupplier.java b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/IndexerSupplier.java new file mode 100644 index 0000000..8a3edea --- /dev/null +++ b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/IndexerSupplier.java @@ -0,0 +1,24 @@ +/**************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one * + * or more contributor license agreements. See the NOTICE file * + * distributed with this work for additional information * + * regarding copyright ownership. The ASF licenses this file * + * to you under the Apache License, Version 2.0 (the * + * "License"); you may not use this file except in compliance * + * with the License. You may obtain a copy of the License at * + * * + * http://www.apache.org/licenses/LICENSE-2.0 * + * * + * Unless required by applicable law or agreed to in writing, * + * software distributed under the License is distributed on an * + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * + * KIND, either express or implied. See the License for the * + * specific language governing permissions and limitations * + * under the License. * + ****************************************************************/ + +package org.apache.james.backends.es; + +public interface IndexerSupplier { + Indexer getIndexer(); +} http://git-wip-us.apache.org/repos/asf/james-project/blob/6013f913/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/IndexerTest.java ---------------------------------------------------------------------- diff --git a/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/IndexerTest.java b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/IndexerTest.java new file mode 100644 index 0000000..2abbdda --- /dev/null +++ b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/IndexerTest.java @@ -0,0 +1,256 @@ +/**************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one * + * or more contributor license agreements. See the NOTICE file * + * distributed with this work for additional information * + * regarding copyright ownership. The ASF licenses this file * + * to you under the Apache License, Version 2.0 (the * + * "License"); you may not use this file except in compliance * + * with the License. You may obtain a copy of the License at * + * * + * http://www.apache.org/licenses/LICENSE-2.0 * + * * + * Unless required by applicable law or agreed to in writing, * + * software distributed under the License is distributed on an * + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * + * KIND, either express or implied. See the License for the * + * specific language governing permissions and limitations * + * under the License. * + ****************************************************************/ + +package org.apache.james.backends.es; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.elasticsearch.index.query.QueryBuilders.termQuery; + +import java.util.concurrent.Executors; + +import org.apache.james.backends.es.utils.TestingClientProvider; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.client.Client; +import org.elasticsearch.index.query.QueryBuilder; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.node.Node; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.RuleChain; +import org.junit.rules.TemporaryFolder; + +import com.google.common.collect.Lists; + +public class IndexerTest { + + private static final int MINIMUM_BATCH_SIZE = 1; + private static final IndexName INDEX_NAME = new IndexName("index_name"); + private static final AliasName ALIAS_NAME = new AliasName("alias_name"); + private static final TypeName TYPE_NAME = new TypeName("type_name"); + private TemporaryFolder temporaryFolder = new TemporaryFolder(); + private EmbeddedElasticSearch embeddedElasticSearch = new EmbeddedElasticSearch(temporaryFolder, INDEX_NAME); + + @Rule + public RuleChain ruleChain = RuleChain.outerRule(temporaryFolder).around(embeddedElasticSearch); + + private Node node; + private Indexer testee; + + @Before + public void setup() { + node = embeddedElasticSearch.getNode(); + TestingClientProvider clientProvider = new TestingClientProvider(node); + new IndexCreationFactory() + .useIndex(INDEX_NAME) + .addAlias(ALIAS_NAME) + .createIndexAndAliases(clientProvider.get()); + DeleteByQueryPerformer deleteByQueryPerformer = new DeleteByQueryPerformer(clientProvider.get(), + Executors.newSingleThreadExecutor(), + MINIMUM_BATCH_SIZE, + ALIAS_NAME, + TYPE_NAME) { + @Override + public void perform(QueryBuilder queryBuilder) { + doDeleteByQuery(queryBuilder); + } + }; + testee = new Indexer(clientProvider.get(), deleteByQueryPerformer, ALIAS_NAME, TYPE_NAME); + } + + @Test + public void indexMessageShouldWork() throws Exception { + String messageId = "1"; + String content = "{\"message\": \"trying out Elasticsearch\"}"; + + testee.indexMessage(messageId, content); + embeddedElasticSearch.awaitForElasticSearch(); + + try (Client client = node.client()) { + SearchResponse searchResponse = client.prepareSearch(INDEX_NAME.getValue()) + .setTypes(TYPE_NAME.getValue()) + .setQuery(QueryBuilders.matchQuery("message", "trying")) + .get(); + assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(1); + } + } + + @Test(expected = IllegalArgumentException.class) + public void indexMessageShouldThrowWhenJsonIsNull() throws InterruptedException { + testee.indexMessage("1", null); + } + + @Test + public void updateMessages() throws Exception { + String messageId = "1"; + String content = "{\"message\": \"trying out Elasticsearch\",\"field\":\"Should be unchanged\"}"; + + testee.indexMessage(messageId, content); + embeddedElasticSearch.awaitForElasticSearch(); + + testee.updateMessages(Lists.newArrayList(new UpdatedRepresentation(messageId, "{\"message\": \"mastering out Elasticsearch\"}"))); + embeddedElasticSearch.awaitForElasticSearch(); + + try (Client client = node.client()) { + SearchResponse searchResponse = client.prepareSearch(INDEX_NAME.getValue()) + .setTypes(TYPE_NAME.getValue()) + .setQuery(QueryBuilders.matchQuery("message", "mastering")) + .get(); + assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(1); + } + + try (Client client = node.client()) { + SearchResponse searchResponse = client.prepareSearch(INDEX_NAME.getValue()) + .setTypes(TYPE_NAME.getValue()) + .setQuery(QueryBuilders.matchQuery("field", "unchanged")) + .get(); + assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(1); + } + } + + @Test(expected = IllegalArgumentException.class) + public void updateMessageShouldThrowWhenJsonIsNull() throws InterruptedException { + testee.updateMessages(Lists.newArrayList(new UpdatedRepresentation("1", null))); + } + + @Test(expected = IllegalArgumentException.class) + public void updateMessageShouldThrowWhenIdIsNull() throws InterruptedException { + testee.updateMessages(Lists.newArrayList(new UpdatedRepresentation(null, "{\"message\": \"mastering out Elasticsearch\"}"))); + } + + @Test(expected = IllegalArgumentException.class) + public void updateMessageShouldThrowWhenJsonIsEmpty() throws InterruptedException { + testee.updateMessages(Lists.newArrayList(new UpdatedRepresentation("1", ""))); + } + + @Test(expected = IllegalArgumentException.class) + public void updateMessageShouldThrowWhenIdIsEmpty() throws InterruptedException { + testee.updateMessages(Lists.newArrayList(new UpdatedRepresentation("", "{\"message\": \"mastering out Elasticsearch\"}"))); + } + + @Test + public void deleteByQueryShouldWorkOnSingleMessage() throws Exception { + String messageId = "1:2"; + String content = "{\"message\": \"trying out Elasticsearch\", \"property\":\"1\"}"; + + testee.indexMessage(messageId, content); + embeddedElasticSearch.awaitForElasticSearch(); + + testee.deleteAllMatchingQuery(termQuery("property", "1")); + embeddedElasticSearch.awaitForElasticSearch(); + + try (Client client = node.client()) { + SearchResponse searchResponse = client.prepareSearch(INDEX_NAME.getValue()) + .setTypes(TYPE_NAME.getValue()) + .setQuery(QueryBuilders.matchAllQuery()) + .get(); + assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(0); + } + } + + @Test + public void deleteByQueryShouldWorkWhenMultipleMessages() throws Exception { + String messageId = "1:1"; + String content = "{\"message\": \"trying out Elasticsearch\", \"property\":\"1\"}"; + + testee.indexMessage(messageId, content); + + String messageId2 = "1:2"; + String content2 = "{\"message\": \"trying out Elasticsearch 2\", \"property\":\"1\"}"; + + testee.indexMessage(messageId2, content2); + + String messageId3 = "2:3"; + String content3 = "{\"message\": \"trying out Elasticsearch 3\", \"property\":\"2\"}"; + + testee.indexMessage(messageId3, content3); + embeddedElasticSearch.awaitForElasticSearch(); + + testee.deleteAllMatchingQuery(termQuery("property", "1")); + embeddedElasticSearch.awaitForElasticSearch(); + + try (Client client = node.client()) { + SearchResponse searchResponse = client.prepareSearch(INDEX_NAME.getValue()) + .setTypes(TYPE_NAME.getValue()) + .setQuery(QueryBuilders.matchAllQuery()) + .get(); + assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(1); + } + } + + @Test + public void deleteMessage() throws Exception { + String messageId = "1:2"; + String content = "{\"message\": \"trying out Elasticsearch\"}"; + + testee.indexMessage(messageId, content); + embeddedElasticSearch.awaitForElasticSearch(); + + testee.deleteMessages(Lists.newArrayList(messageId)); + embeddedElasticSearch.awaitForElasticSearch(); + + try (Client client = node.client()) { + SearchResponse searchResponse = client.prepareSearch(INDEX_NAME.getValue()) + .setTypes(TYPE_NAME.getValue()) + .setQuery(QueryBuilders.matchAllQuery()) + .get(); + assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(0); + } + } + + @Test + public void deleteShouldWorkWhenMultipleMessages() throws Exception { + String messageId = "1:1"; + String content = "{\"message\": \"trying out Elasticsearch\", \"mailboxId\":\"1\"}"; + + testee.indexMessage(messageId, content); + + String messageId2 = "1:2"; + String content2 = "{\"message\": \"trying out Elasticsearch 2\", \"mailboxId\":\"1\"}"; + + testee.indexMessage(messageId2, content2); + + String messageId3 = "2:3"; + String content3 = "{\"message\": \"trying out Elasticsearch 3\", \"mailboxId\":\"2\"}"; + + testee.indexMessage(messageId3, content3); + embeddedElasticSearch.awaitForElasticSearch(); + + testee.deleteMessages(Lists.newArrayList(messageId, messageId3)); + embeddedElasticSearch.awaitForElasticSearch(); + + try (Client client = node.client()) { + SearchResponse searchResponse = client.prepareSearch(INDEX_NAME.getValue()) + .setTypes(TYPE_NAME.getValue()) + .setQuery(QueryBuilders.matchAllQuery()) + .get(); + assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(1); + } + } + + @Test + public void updateMessagesShouldNotThrowWhenEmptyList() throws Exception { + testee.updateMessages(Lists.newArrayList()); + } + + @Test + public void deleteMessagesShouldNotThrowWhenEmptyList() throws Exception { + testee.deleteMessages(Lists.newArrayList()); + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/6013f913/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/ElasticSearchMailboxIndexer.java ---------------------------------------------------------------------- diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/ElasticSearchMailboxIndexer.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/ElasticSearchMailboxIndexer.java deleted file mode 100644 index f240baa..0000000 --- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/ElasticSearchMailboxIndexer.java +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one * - * or more contributor license agreements. See the NOTICE file * - * distributed with this work for additional information * - * regarding copyright ownership. The ASF licenses this file * - * to you under the Apache License, Version 2.0 (the * - * "License"); you may not use this file except in compliance * - * with the License. You may obtain a copy of the License at * - * * - * http://www.apache.org/licenses/LICENSE-2.0 * - * * - * Unless required by applicable law or agreed to in writing, * - * software distributed under the License is distributed on an * - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * - * KIND, either express or implied. See the License for the * - * specific language governing permissions and limitations * - * under the License. * - ****************************************************************/ -package org.apache.james.mailbox.elasticsearch; - -import java.util.List; -import java.util.Optional; - -import javax.inject.Inject; -import javax.inject.Named; - -import org.apache.commons.lang3.StringUtils; -import org.apache.james.backends.es.AliasName; -import org.apache.james.backends.es.DeleteByQueryPerformer; -import org.apache.james.backends.es.ElasticSearchConstants; -import org.apache.james.backends.es.ElasticSearchIndexer; -import org.apache.james.backends.es.TypeName; -import org.apache.james.backends.es.UpdatedRepresentation; -import org.elasticsearch.action.bulk.BulkRequestBuilder; -import org.elasticsearch.action.bulk.BulkResponse; -import org.elasticsearch.action.index.IndexResponse; -import org.elasticsearch.client.Client; -import org.elasticsearch.common.ValidationException; -import org.elasticsearch.index.query.QueryBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.Preconditions; - -public class ElasticSearchMailboxIndexer implements ElasticSearchIndexer { - private static int DEBUG_MAX_LENGTH_CONTENT = 1000; - - private static final Logger LOGGER = LoggerFactory.getLogger(ElasticSearchMailboxIndexer.class); - - private final Client client; - private final DeleteByQueryPerformer deleteByQueryPerformer; - private final AliasName aliasName; - private final TypeName typeName; - - @Inject - public ElasticSearchMailboxIndexer(Client client, DeleteByQueryPerformer deleteByQueryPerformer, - @Named(ElasticSearchConstants.WRITE_ALIAS) AliasName aliasName, - TypeName typeName) { - this.client = client; - this.deleteByQueryPerformer = deleteByQueryPerformer; - this.aliasName = aliasName; - this.typeName = typeName; - } - - @Override - public IndexResponse indexMessage(String id, String content) { - checkArgument(content); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Indexing {}: {}", id, StringUtils.left(content, DEBUG_MAX_LENGTH_CONTENT)); - } - return client.prepareIndex(aliasName.getValue(), typeName.getValue(), id) - .setSource(content) - .get(); - } - - @Override - public Optional<BulkResponse> updateMessages(List<UpdatedRepresentation> updatedDocumentParts) { - try { - Preconditions.checkNotNull(updatedDocumentParts); - BulkRequestBuilder bulkRequestBuilder = client.prepareBulk(); - updatedDocumentParts.forEach(updatedDocumentPart -> bulkRequestBuilder.add( - client.prepareUpdate( - aliasName.getValue(), - typeName.getValue(), - updatedDocumentPart.getId()) - .setDoc(updatedDocumentPart.getUpdatedDocumentPart()))); - return Optional.of(bulkRequestBuilder.get()); - } catch (ValidationException e) { - LOGGER.warn("Error while updating index", e); - return Optional.empty(); - } - } - - @Override - public Optional<BulkResponse> deleteMessages(List<String> ids) { - try { - BulkRequestBuilder bulkRequestBuilder = client.prepareBulk(); - ids.forEach(id -> bulkRequestBuilder.add( - client.prepareDelete( - aliasName.getValue(), - typeName.getValue(), - id))); - return Optional.of(bulkRequestBuilder.get()); - } catch (ValidationException e) { - LOGGER.warn("Error while deleting index", e); - return Optional.empty(); - } - } - - @Override - public void deleteAllMatchingQuery(QueryBuilder queryBuilder) { - deleteByQueryPerformer.perform(queryBuilder); - } - - private void checkArgument(String content) { - Preconditions.checkArgument(content != null, "content should be provided"); - } -} http://git-wip-us.apache.org/repos/asf/james-project/blob/6013f913/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxIndexerSupplier.java ---------------------------------------------------------------------- diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxIndexerSupplier.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxIndexerSupplier.java new file mode 100644 index 0000000..e8a2143 --- /dev/null +++ b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxIndexerSupplier.java @@ -0,0 +1,46 @@ +/**************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one * + * or more contributor license agreements. See the NOTICE file * + * distributed with this work for additional information * + * regarding copyright ownership. The ASF licenses this file * + * to you under the Apache License, Version 2.0 (the * + * "License"); you may not use this file except in compliance * + * with the License. You may obtain a copy of the License at * + * * + * http://www.apache.org/licenses/LICENSE-2.0 * + * * + * Unless required by applicable law or agreed to in writing, * + * software distributed under the License is distributed on an * + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * + * KIND, either express or implied. See the License for the * + * specific language governing permissions and limitations * + * under the License. * + ****************************************************************/ +package org.apache.james.mailbox.elasticsearch; + +import javax.inject.Inject; +import javax.inject.Named; + +import org.apache.james.backends.es.AliasName; +import org.apache.james.backends.es.DeleteByQueryPerformer; +import org.apache.james.backends.es.ElasticSearchConstants; +import org.apache.james.backends.es.Indexer; +import org.apache.james.backends.es.IndexerSupplier; +import org.apache.james.backends.es.TypeName; +import org.elasticsearch.client.Client; + +public class MailboxIndexerSupplier implements IndexerSupplier { + private final Indexer indexer; + + @Inject + public MailboxIndexerSupplier(Client client, DeleteByQueryPerformer deleteByQueryPerformer, + @Named(ElasticSearchConstants.WRITE_ALIAS) AliasName aliasName, + TypeName typeName) { + this.indexer = new Indexer(client, deleteByQueryPerformer, aliasName, typeName); + } + + @Override + public Indexer getIndexer() { + return indexer; + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/6013f913/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMessageSearchIndex.java ---------------------------------------------------------------------- diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMessageSearchIndex.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMessageSearchIndex.java index fb8c321..68d7af9 100644 --- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMessageSearchIndex.java +++ b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMessageSearchIndex.java @@ -31,7 +31,8 @@ import javax.inject.Inject; import javax.inject.Named; import org.apache.james.backends.es.ElasticSearchConstants; -import org.apache.james.backends.es.ElasticSearchIndexer; +import org.apache.james.backends.es.Indexer; +import org.apache.james.backends.es.IndexerSupplier; import org.apache.james.backends.es.UpdatedRepresentation; import org.apache.james.mailbox.MailboxManager.MessageCapabilities; import org.apache.james.mailbox.MailboxManager.SearchCapabilities; @@ -62,16 +63,16 @@ public class ElasticSearchListeningMessageSearchIndex extends ListeningMessageSe private static final Logger LOGGER = LoggerFactory.getLogger(ElasticSearchListeningMessageSearchIndex.class); private static final String ID_SEPARATOR = ":"; - private final ElasticSearchIndexer indexer; + private final Indexer indexer; private final ElasticSearchSearcher searcher; private final MessageToElasticSearchJson messageToElasticSearchJson; @Inject public ElasticSearchListeningMessageSearchIndex(MessageMapperFactory factory, - @Named(ElasticSearchConstants.MAILBOX_INDEX) ElasticSearchIndexer indexer, + @Named(ElasticSearchConstants.MAILBOX_INDEX) IndexerSupplier indexer, ElasticSearchSearcher searcher, MessageToElasticSearchJson messageToElasticSearchJson) { super(factory); - this.indexer = indexer; + this.indexer = indexer.getIndexer(); this.messageToElasticSearchJson = messageToElasticSearchJson; this.searcher = searcher; } http://git-wip-us.apache.org/repos/asf/james-project/blob/6013f913/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java ---------------------------------------------------------------------- diff --git a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java index 7cc78f2..cc5c679 100644 --- a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java +++ b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java @@ -109,7 +109,7 @@ public class ElasticSearchIntegrationTest extends AbstractMessageSearchIndexTest ElasticSearchListeningMessageSearchIndex elasticSearchListeningMessageSearchIndex = new ElasticSearchListeningMessageSearchIndex( storeMailboxManager.getMapperFactory(), - new ElasticSearchMailboxIndexer(client, + new MailboxIndexerSupplier(client, new DeleteByQueryPerformer(client, Executors.newSingleThreadExecutor(), BATCH_SIZE, http://git-wip-us.apache.org/repos/asf/james-project/blob/6013f913/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchMailboxIndexerTest.java ---------------------------------------------------------------------- diff --git a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchMailboxIndexerTest.java b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchMailboxIndexerTest.java deleted file mode 100644 index f33ac57..0000000 --- a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchMailboxIndexerTest.java +++ /dev/null @@ -1,266 +0,0 @@ -/**************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one * - * or more contributor license agreements. See the NOTICE file * - * distributed with this work for additional information * - * regarding copyright ownership. The ASF licenses this file * - * to you under the Apache License, Version 2.0 (the * - * "License"); you may not use this file except in compliance * - * with the License. You may obtain a copy of the License at * - * * - * http://www.apache.org/licenses/LICENSE-2.0 * - * * - * Unless required by applicable law or agreed to in writing, * - * software distributed under the License is distributed on an * - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * - * KIND, either express or implied. See the License for the * - * specific language governing permissions and limitations * - * under the License. * - ****************************************************************/ - -package org.apache.james.mailbox.elasticsearch; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.elasticsearch.index.query.QueryBuilders.termQuery; - -import java.io.IOException; -import java.util.concurrent.Executors; - -import org.apache.james.backends.es.AliasName; -import org.apache.james.backends.es.DeleteByQueryPerformer; -import org.apache.james.backends.es.ElasticSearchIndexer; -import org.apache.james.backends.es.EmbeddedElasticSearch; -import org.apache.james.backends.es.IndexCreationFactory; -import org.apache.james.backends.es.IndexName; -import org.apache.james.backends.es.TypeName; -import org.apache.james.backends.es.UpdatedRepresentation; -import org.apache.james.backends.es.utils.TestingClientProvider; -import org.apache.james.mailbox.elasticsearch.ElasticSearchMailboxIndexer; -import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.client.Client; -import org.elasticsearch.index.query.QueryBuilder; -import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.node.Node; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.RuleChain; -import org.junit.rules.TemporaryFolder; - -import com.google.common.collect.Lists; - -public class ElasticSearchMailboxIndexerTest { - - private static final int MINIMUM_BATCH_SIZE = 1; - private static final IndexName INDEX_NAME = new IndexName("index_name"); - private static final AliasName ALIAS_NAME = new AliasName("alias_name"); - private static final TypeName TYPE_NAME = new TypeName("type_name"); - private TemporaryFolder temporaryFolder = new TemporaryFolder(); - private EmbeddedElasticSearch embeddedElasticSearch = new EmbeddedElasticSearch(temporaryFolder, INDEX_NAME); - - @Rule - public RuleChain ruleChain = RuleChain.outerRule(temporaryFolder).around(embeddedElasticSearch); - - private Node node; - private ElasticSearchIndexer testee; - - @Before - public void setup() throws IOException { - node = embeddedElasticSearch.getNode(); - TestingClientProvider clientProvider = new TestingClientProvider(node); - new IndexCreationFactory() - .useIndex(INDEX_NAME) - .addAlias(ALIAS_NAME) - .createIndexAndAliases(clientProvider.get()); - DeleteByQueryPerformer deleteByQueryPerformer = new DeleteByQueryPerformer(clientProvider.get(), - Executors.newSingleThreadExecutor(), - MINIMUM_BATCH_SIZE, - ALIAS_NAME, - TYPE_NAME) { - @Override - public void perform(QueryBuilder queryBuilder) { - doDeleteByQuery(queryBuilder); - } - }; - testee = new ElasticSearchMailboxIndexer(clientProvider.get(), deleteByQueryPerformer, ALIAS_NAME, TYPE_NAME); - } - - @Test - public void indexMessageShouldWork() throws Exception { - String messageId = "1"; - String content = "{\"message\": \"trying out Elasticsearch\"}"; - - testee.indexMessage(messageId, content); - embeddedElasticSearch.awaitForElasticSearch(); - - try (Client client = node.client()) { - SearchResponse searchResponse = client.prepareSearch(INDEX_NAME.getValue()) - .setTypes(TYPE_NAME.getValue()) - .setQuery(QueryBuilders.matchQuery("message", "trying")) - .get(); - assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(1); - } - } - - @Test(expected = IllegalArgumentException.class) - public void indexMessageShouldThrowWhenJsonIsNull() throws InterruptedException { - testee.indexMessage("1", null); - } - - @Test - public void updateMessages() throws Exception { - String messageId = "1"; - String content = "{\"message\": \"trying out Elasticsearch\",\"field\":\"Should be unchanged\"}"; - - testee.indexMessage(messageId, content); - embeddedElasticSearch.awaitForElasticSearch(); - - testee.updateMessages(Lists.newArrayList(new UpdatedRepresentation(messageId, "{\"message\": \"mastering out Elasticsearch\"}"))); - embeddedElasticSearch.awaitForElasticSearch(); - - try (Client client = node.client()) { - SearchResponse searchResponse = client.prepareSearch(INDEX_NAME.getValue()) - .setTypes(TYPE_NAME.getValue()) - .setQuery(QueryBuilders.matchQuery("message", "mastering")) - .get(); - assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(1); - } - - try (Client client = node.client()) { - SearchResponse searchResponse = client.prepareSearch(INDEX_NAME.getValue()) - .setTypes(TYPE_NAME.getValue()) - .setQuery(QueryBuilders.matchQuery("field", "unchanged")) - .get(); - assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(1); - } - } - - @Test(expected = IllegalArgumentException.class) - public void updateMessageShouldThrowWhenJsonIsNull() throws InterruptedException { - testee.updateMessages(Lists.newArrayList(new UpdatedRepresentation("1", null))); - } - - @Test(expected = IllegalArgumentException.class) - public void updateMessageShouldThrowWhenIdIsNull() throws InterruptedException { - testee.updateMessages(Lists.newArrayList(new UpdatedRepresentation(null, "{\"message\": \"mastering out Elasticsearch\"}"))); - } - - @Test(expected = IllegalArgumentException.class) - public void updateMessageShouldThrowWhenJsonIsEmpty() throws InterruptedException { - testee.updateMessages(Lists.newArrayList(new UpdatedRepresentation("1", ""))); - } - - @Test(expected = IllegalArgumentException.class) - public void updateMessageShouldThrowWhenIdIsEmpty() throws InterruptedException { - testee.updateMessages(Lists.newArrayList(new UpdatedRepresentation("", "{\"message\": \"mastering out Elasticsearch\"}"))); - } - - @Test - public void deleteByQueryShouldWorkOnSingleMessage() throws Exception { - String messageId = "1:2"; - String content = "{\"message\": \"trying out Elasticsearch\", \"property\":\"1\"}"; - - testee.indexMessage(messageId, content); - embeddedElasticSearch.awaitForElasticSearch(); - - testee.deleteAllMatchingQuery(termQuery("property", "1")); - embeddedElasticSearch.awaitForElasticSearch(); - - try (Client client = node.client()) { - SearchResponse searchResponse = client.prepareSearch(INDEX_NAME.getValue()) - .setTypes(TYPE_NAME.getValue()) - .setQuery(QueryBuilders.matchAllQuery()) - .get(); - assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(0); - } - } - - @Test - public void deleteByQueryShouldWorkWhenMultipleMessages() throws Exception { - String messageId = "1:1"; - String content = "{\"message\": \"trying out Elasticsearch\", \"property\":\"1\"}"; - - testee.indexMessage(messageId, content); - - String messageId2 = "1:2"; - String content2 = "{\"message\": \"trying out Elasticsearch 2\", \"property\":\"1\"}"; - - testee.indexMessage(messageId2, content2); - - String messageId3 = "2:3"; - String content3 = "{\"message\": \"trying out Elasticsearch 3\", \"property\":\"2\"}"; - - testee.indexMessage(messageId3, content3); - embeddedElasticSearch.awaitForElasticSearch(); - - testee.deleteAllMatchingQuery(termQuery("property", "1")); - embeddedElasticSearch.awaitForElasticSearch(); - - try (Client client = node.client()) { - SearchResponse searchResponse = client.prepareSearch(INDEX_NAME.getValue()) - .setTypes(TYPE_NAME.getValue()) - .setQuery(QueryBuilders.matchAllQuery()) - .get(); - assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(1); - } - } - - @Test - public void deleteMessage() throws Exception { - String messageId = "1:2"; - String content = "{\"message\": \"trying out Elasticsearch\"}"; - - testee.indexMessage(messageId, content); - embeddedElasticSearch.awaitForElasticSearch(); - - testee.deleteMessages(Lists.newArrayList(messageId)); - embeddedElasticSearch.awaitForElasticSearch(); - - try (Client client = node.client()) { - SearchResponse searchResponse = client.prepareSearch(INDEX_NAME.getValue()) - .setTypes(TYPE_NAME.getValue()) - .setQuery(QueryBuilders.matchAllQuery()) - .get(); - assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(0); - } - } - - @Test - public void deleteShouldWorkWhenMultipleMessages() throws Exception { - String messageId = "1:1"; - String content = "{\"message\": \"trying out Elasticsearch\", \"mailboxId\":\"1\"}"; - - testee.indexMessage(messageId, content); - - String messageId2 = "1:2"; - String content2 = "{\"message\": \"trying out Elasticsearch 2\", \"mailboxId\":\"1\"}"; - - testee.indexMessage(messageId2, content2); - - String messageId3 = "2:3"; - String content3 = "{\"message\": \"trying out Elasticsearch 3\", \"mailboxId\":\"2\"}"; - - testee.indexMessage(messageId3, content3); - embeddedElasticSearch.awaitForElasticSearch(); - - testee.deleteMessages(Lists.newArrayList(messageId, messageId3)); - embeddedElasticSearch.awaitForElasticSearch(); - - try (Client client = node.client()) { - SearchResponse searchResponse = client.prepareSearch(INDEX_NAME.getValue()) - .setTypes(TYPE_NAME.getValue()) - .setQuery(QueryBuilders.matchAllQuery()) - .get(); - assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(1); - } - } - - @Test - public void updateMessagesShouldNotThrowWhenEmptyList() throws Exception { - testee.updateMessages(Lists.newArrayList()); - } - - @Test - public void deleteMessagesShouldNotThrowWhenEmptyList() throws Exception { - testee.deleteMessages(Lists.newArrayList()); - } -} http://git-wip-us.apache.org/repos/asf/james-project/blob/6013f913/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMessageSearchIndexTest.java ---------------------------------------------------------------------- diff --git a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMessageSearchIndexTest.java b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMessageSearchIndexTest.java index 30e600f..8a07886 100644 --- a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMessageSearchIndexTest.java +++ b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMessageSearchIndexTest.java @@ -32,7 +32,7 @@ import java.util.Optional; import javax.mail.Flags; -import org.apache.james.backends.es.ElasticSearchIndexer; +import org.apache.james.backends.es.Indexer; import org.apache.james.backends.es.UpdatedRepresentation; import org.apache.james.mailbox.MailboxSession; import org.apache.james.mailbox.MailboxSession.User; @@ -67,7 +67,7 @@ public class ElasticSearchListeningMessageSearchIndexTest { public static final String EXPECTED_JSON_CONTENT = "json content"; public static final String USERNAME = "username"; - private ElasticSearchIndexer indexer; + private Indexer indexer; private MessageToElasticSearchJson messageToElasticSearchJson; private ElasticSearchListeningMessageSearchIndex testee; private MailboxSession session; @@ -80,7 +80,7 @@ public class ElasticSearchListeningMessageSearchIndexTest { messageToElasticSearchJson = mock(MessageToElasticSearchJson.class); ElasticSearchSearcher elasticSearchSearcher = mock(ElasticSearchSearcher.class); - indexer = mock(ElasticSearchIndexer.class); + indexer = mock(Indexer.class); testee = new ElasticSearchListeningMessageSearchIndex(mapperFactory, indexer, elasticSearchSearcher, messageToElasticSearchJson); session = new MockMailboxSession(USERNAME); http://git-wip-us.apache.org/repos/asf/james-project/blob/6013f913/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java ---------------------------------------------------------------------- diff --git a/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java b/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java index d98f5b8..2356f61 100644 --- a/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java +++ b/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java @@ -37,9 +37,9 @@ import org.apache.james.imap.main.DefaultImapDecoderFactory; import org.apache.james.imap.processor.main.DefaultImapProcessorFactory; import org.apache.james.mailbox.MailboxManager; import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver; -import org.apache.james.mailbox.elasticsearch.ElasticSearchMailboxIndexer; import org.apache.james.mailbox.elasticsearch.IndexAttachments; import org.apache.james.mailbox.elasticsearch.MailboxElasticSearchConstants; +import org.apache.james.mailbox.elasticsearch.MailboxIndexerSupplier; import org.apache.james.mailbox.elasticsearch.MailboxMappingFactory; import org.apache.james.mailbox.elasticsearch.events.ElasticSearchListeningMessageSearchIndex; import org.apache.james.mailbox.elasticsearch.json.MessageToElasticSearchJson; @@ -105,7 +105,7 @@ public class ElasticSearchHostSystem extends JamesImapHostSystem { ElasticSearchListeningMessageSearchIndex searchIndex = new ElasticSearchListeningMessageSearchIndex( factory, - new ElasticSearchMailboxIndexer(client, + new MailboxIndexerSupplier(client, new DeleteByQueryPerformer(client, Executors.newSingleThreadExecutor(), MailboxElasticSearchConstants.DEFAULT_MAILBOX_WRITE_ALIAS, MailboxElasticSearchConstants.MESSAGE_TYPE), MailboxElasticSearchConstants.DEFAULT_MAILBOX_WRITE_ALIAS, MailboxElasticSearchConstants.MESSAGE_TYPE), http://git-wip-us.apache.org/repos/asf/james-project/blob/6013f913/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 2544c91..811bd96 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 @@ -31,14 +31,14 @@ import org.apache.commons.configuration.PropertiesConfiguration; 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.ElasticSearchIndexer; import org.apache.james.backends.es.IndexCreationFactory; import org.apache.james.backends.es.IndexName; +import org.apache.james.backends.es.IndexerSupplier; import org.apache.james.backends.es.NodeMappingFactory; import org.apache.james.backends.es.TypeName; -import org.apache.james.mailbox.elasticsearch.ElasticSearchMailboxIndexer; import org.apache.james.mailbox.elasticsearch.IndexAttachments; import org.apache.james.mailbox.elasticsearch.MailboxElasticSearchConstants; +import org.apache.james.mailbox.elasticsearch.MailboxIndexerSupplier; import org.apache.james.mailbox.elasticsearch.MailboxMappingFactory; import org.apache.james.mailbox.elasticsearch.events.ElasticSearchListeningMessageSearchIndex; import org.apache.james.mailbox.store.search.ListeningMessageSearchIndex; @@ -67,11 +67,10 @@ public class ElasticSearchMailboxModule extends AbstractModule { bind(ElasticSearchListeningMessageSearchIndex.class).in(Scopes.SINGLETON); bind(MessageSearchIndex.class).to(ElasticSearchListeningMessageSearchIndex.class); bind(ListeningMessageSearchIndex.class).to(ElasticSearchListeningMessageSearchIndex.class); - bind(ElasticSearchMailboxIndexer.class).in(Scopes.SINGLETON); - bind(ElasticSearchIndexer.class) + bind(MailboxIndexerSupplier.class).in(Scopes.SINGLETON); + bind(IndexerSupplier.class) .annotatedWith(Names.named(ElasticSearchConstants.MAILBOX_INDEX)) - .to(ElasticSearchMailboxIndexer.class); -; + .to(MailboxIndexerSupplier.class); } @Provides --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
