MAILBOX-266 Deletes should be bulked
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/aea76c8d Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/aea76c8d Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/aea76c8d Branch: refs/heads/master Commit: aea76c8d32c167590912c4d8b5e93c499467aa7d Parents: 1bfa390 Author: Benoit Tellier <btell...@linagora.com> Authored: Fri Mar 25 14:27:03 2016 +0700 Committer: Benoit Tellier <btell...@linagora.com> Committed: Wed Apr 6 16:18:45 2016 +0700 ---------------------------------------------------------------------- .../elasticsearch/ElasticSearchIndexer.java | 12 +-- ...lasticSearchListeningMessageSearchIndex.java | 32 ++++--- .../elasticsearch/ElasticSearchIndexerTest.java | 32 ++++++- ...hListeningMailboxMessageSearchIndexTest.java | 99 +++++++++++++------- .../lucene/search/LuceneMessageSearchIndex.java | 19 +++- .../store/search/LazyMessageSearchIndex.java | 9 +- .../search/ListeningMessageSearchIndex.java | 36 +++---- .../james/mailbox/indexer/ReIndexerImpl.java | 2 +- .../mailbox/indexer/ReIndexerImplTest.java | 2 +- 9 files changed, 164 insertions(+), 79 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/aea76c8d/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIndexer.java ---------------------------------------------------------------------- diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIndexer.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIndexer.java index f4bbec4..1292b28 100644 --- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIndexer.java +++ b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIndexer.java @@ -24,7 +24,6 @@ import javax.inject.Inject; import org.elasticsearch.action.bulk.BulkRequestBuilder; import org.elasticsearch.action.bulk.BulkResponse; -import org.elasticsearch.action.delete.DeleteResponse; import org.elasticsearch.action.index.IndexResponse; import org.elasticsearch.client.Client; import org.elasticsearch.common.Strings; @@ -85,15 +84,16 @@ public class ElasticSearchIndexer { } } - public DeleteResponse deleteMessage(String id) { + public BulkResponse deleteMessages(List<String> ids) { try (Client client = clientProvider.get()) { - return client.prepareDelete(MAILBOX_INDEX, MESSAGE_TYPE, id) - .get(); + BulkRequestBuilder bulkRequestBuilder = client.prepareBulk(); + ids.forEach(id -> bulkRequestBuilder.add(client.prepareDelete(MAILBOX_INDEX, MESSAGE_TYPE, id))); + return bulkRequestBuilder.get(); } } - public void deleteAllMatchingQuery(QueryBuilder queryBuilder) { - deleteByQueryPerformer.perform(queryBuilder); + public Void deleteAllMatchingQuery(QueryBuilder queryBuilder) { + return deleteByQueryPerformer.perform(queryBuilder); } private void checkArgument(String content) { http://git-wip-us.apache.org/repos/asf/james-project/blob/aea76c8d/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 68d9fd6..4e1ddec 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 @@ -32,8 +32,6 @@ import org.apache.james.mailbox.elasticsearch.json.JsonMessageConstants; import org.apache.james.mailbox.elasticsearch.json.MessageToElasticSearchJson; import org.apache.james.mailbox.elasticsearch.search.ElasticSearchSearcher; import org.apache.james.mailbox.exception.MailboxException; -import org.apache.james.mailbox.model.MessageRange; -import org.apache.james.mailbox.model.MessageRange.Type; import org.apache.james.mailbox.model.SearchQuery; import org.apache.james.mailbox.model.UpdatedFlags; import org.apache.james.mailbox.store.mail.MessageMapperFactory; @@ -84,17 +82,25 @@ public class ElasticSearchListeningMessageSearchIndex<Id extends MailboxId> exte } @Override - public void delete(MailboxSession session, Mailbox<Id> mailbox, MessageRange range) throws MailboxException { - if (range.getType() == Type.ALL) { - indexer.deleteAllMatchingQuery(termQuery(JsonMessageConstants.MAILBOX_ID, mailbox.getMailboxId().serialize())); - } else { - range.forEach(messageId -> { - try { - indexer.deleteMessage(indexIdFor(mailbox, messageId)); - } catch (Exception e) { - LOGGER.error("Error when deleting index for message " + messageId, e); - } - }); + public void delete(MailboxSession session, Mailbox<Id> mailbox, List<Long> expungedUids) throws MailboxException { + try { + indexer.deleteMessages(expungedUids.stream() + .map(uid -> indexIdFor(mailbox, uid)) + .collect(Collectors.toList())); + } catch (Exception e) { + LOGGER.error("Error when deleting messages {} in mailbox {} from index", mailbox.getMailboxId().serialize(), expungedUids, e); + } + } + + @Override + public void deleteAll(MailboxSession session, Mailbox<Id> mailbox) throws MailboxException { + try { + indexer.deleteAllMatchingQuery( + termQuery( + JsonMessageConstants.MAILBOX_ID, + mailbox.getMailboxId().serialize())); + } catch (Exception e) { + LOGGER.error("Error when deleting all messages in mailbox {}", mailbox.getMailboxId().serialize(), e); } } http://git-wip-us.apache.org/repos/asf/james-project/blob/aea76c8d/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIndexerTest.java ---------------------------------------------------------------------- diff --git a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIndexerTest.java b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIndexerTest.java index 43fc26b..f5e30c8 100644 --- a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIndexerTest.java +++ b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIndexerTest.java @@ -194,7 +194,7 @@ public class ElasticSearchIndexerTest { testee.indexMessage(messageId, content); embeddedElasticSearch.awaitForElasticSearch(); - testee.deleteMessage(messageId); + testee.deleteMessages(Lists.newArrayList(messageId)); embeddedElasticSearch.awaitForElasticSearch(); try (Client client = node.client()) { @@ -206,4 +206,34 @@ public class ElasticSearchIndexerTest { } } + @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(ElasticSearchIndexer.MAILBOX_INDEX) + .setTypes(ElasticSearchIndexer.MESSAGE_TYPE) + .setQuery(QueryBuilders.matchAllQuery()) + .get(); + assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(1); + } + } + } http://git-wip-us.apache.org/repos/asf/james-project/blob/aea76c8d/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMailboxMessageSearchIndexTest.java ---------------------------------------------------------------------- diff --git a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMailboxMessageSearchIndexTest.java b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMailboxMessageSearchIndexTest.java index f15b1ad..79691d1 100644 --- a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMailboxMessageSearchIndexTest.java +++ b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMailboxMessageSearchIndexTest.java @@ -27,7 +27,6 @@ import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.expectLastCall; import java.io.IOException; -import java.util.stream.LongStream; import java.util.List; import javax.mail.Flags; @@ -36,7 +35,6 @@ import org.apache.james.mailbox.MailboxSession; import org.apache.james.mailbox.elasticsearch.ElasticSearchIndexer; import org.apache.james.mailbox.elasticsearch.json.MessageToElasticSearchJson; import org.apache.james.mailbox.elasticsearch.search.ElasticSearchSearcher; -import org.apache.james.mailbox.model.MessageRange; import org.apache.james.mailbox.model.UpdatedFlags; import org.apache.james.mailbox.store.TestId; import org.apache.james.mailbox.store.mail.MessageMapperFactory; @@ -45,8 +43,8 @@ import org.apache.james.mailbox.store.mail.model.MailboxMessage; import org.easymock.IMocksControl; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.action.bulk.BulkResponse; -import org.elasticsearch.action.delete.DeleteResponse; import org.elasticsearch.action.index.IndexResponse; +import org.elasticsearch.index.query.QueryBuilder; import org.junit.Before; import org.junit.Test; @@ -57,26 +55,23 @@ public class ElasticSearchListeningMailboxMessageSearchIndexTest { public static final long MODSEQ = 18L; private IMocksControl control; - - private MessageMapperFactory<TestId> mapperFactory; + private ElasticSearchIndexer indexer; - private MessageToElasticSearchJson messageToElasticSearchJson; - private ElasticSearchSearcher<TestId> elasticSearchSearcher; - private ElasticSearchListeningMessageSearchIndex<TestId> testee; @Before @SuppressWarnings("unchecked") public void setup() throws JsonProcessingException { control = createControl(); - - mapperFactory = control.createMock(MessageMapperFactory.class); + + MessageMapperFactory<TestId> mapperFactory = control.createMock(MessageMapperFactory.class); + MessageToElasticSearchJson messageToElasticSearchJson = control.createMock(MessageToElasticSearchJson.class); + ElasticSearchSearcher<TestId> elasticSearchSearcher = control.createMock(ElasticSearchSearcher.class); + indexer = control.createMock(ElasticSearchIndexer.class); - messageToElasticSearchJson = control.createMock(MessageToElasticSearchJson.class); + expect(messageToElasticSearchJson.convertToJson(anyObject(MailboxMessage.class))).andReturn("json content").anyTimes(); expect(messageToElasticSearchJson.getUpdatedJsonMessagePart(anyObject(Flags.class), anyLong())).andReturn("json updated content").anyTimes(); - - elasticSearchSearcher = control.createMock(ElasticSearchSearcher.class); testee = new ElasticSearchListeningMessageSearchIndex<>(mapperFactory, indexer, elasticSearchSearcher, messageToElasticSearchJson); } @@ -133,16 +128,15 @@ public class ElasticSearchListeningMailboxMessageSearchIndexTest { MailboxSession session = control.createMock(MailboxSession.class); Mailbox<TestId> mailbox = control.createMock(Mailbox.class); long messageId = 1; - MessageRange messageRange = MessageRange.one(messageId); TestId mailboxId = TestId.of(12); expect(mailbox.getMailboxId()).andReturn(mailboxId); - DeleteResponse expectedDeleteResponse = control.createMock(DeleteResponse.class); - expect(indexer.deleteMessage(mailboxId.serialize() + ":" + messageId)) - .andReturn(expectedDeleteResponse); + BulkResponse expectedBulkResponse = control.createMock(BulkResponse.class); + expect(indexer.deleteMessages(anyObject(List.class))) + .andReturn(expectedBulkResponse); control.replay(); - testee.delete(session, mailbox, messageRange); + testee.delete(session, mailbox, Lists.newArrayList(messageId)); control.verify(); } @@ -151,21 +145,20 @@ public class ElasticSearchListeningMailboxMessageSearchIndexTest { public void deleteShouldWorkWhenMultipleMessageIds() throws Exception { MailboxSession session = control.createMock(MailboxSession.class); Mailbox<TestId> mailbox = control.createMock(Mailbox.class); - long firstMessageId = 1; - long lastMessageId = 10; - MessageRange messageRange = MessageRange.range(firstMessageId, lastMessageId); + long messageId1 = 1; + long messageId2 = 2; + long messageId3 = 3; + long messageId4 = 4; + long messageId5 = 5; TestId mailboxId = TestId.of(12); - expect(mailbox.getMailboxId()).andReturn(mailboxId).times(10); - - LongStream.rangeClosed(firstMessageId, lastMessageId) - .forEach(messageId -> { - DeleteResponse expectedDeleteResponse = control.createMock(DeleteResponse.class); - expect(indexer.deleteMessage(mailboxId.serialize() + ":" + messageId)) - .andReturn(expectedDeleteResponse); - }); + expect(mailbox.getMailboxId()).andReturn(mailboxId).times(5); + + BulkResponse expectedBulkResponse = control.createMock(BulkResponse.class); + expect(indexer.deleteMessages(anyObject(List.class))) + .andReturn(expectedBulkResponse); control.replay(); - testee.delete(session, mailbox, messageRange); + testee.delete(session, mailbox, Lists.newArrayList(messageId1, messageId2, messageId3, messageId4, messageId5)); control.verify(); } @@ -175,15 +168,14 @@ public class ElasticSearchListeningMailboxMessageSearchIndexTest { MailboxSession session = control.createMock(MailboxSession.class); Mailbox<TestId> mailbox = control.createMock(Mailbox.class); long messageId = 1; - MessageRange messageRange = MessageRange.one(messageId); TestId mailboxId = TestId.of(12); - expect(mailbox.getMailboxId()).andReturn(mailboxId); + expect(mailbox.getMailboxId()).andReturn(mailboxId).times(2); - expect(indexer.deleteMessage(mailboxId.serialize() + ":" + messageId)) + expect(indexer.deleteMessages(anyObject(List.class))) .andThrow(new ElasticsearchException("")); control.replay(); - testee.delete(session, mailbox, messageRange); + testee.delete(session, mailbox, Lists.newArrayList(messageId)); control.verify(); } @@ -232,4 +224,43 @@ public class ElasticSearchListeningMailboxMessageSearchIndexTest { testee.update(session, mailbox, Lists.newArrayList(updatedFlags)); control.verify(); } + + @Test + @SuppressWarnings("unchecked") + public void deleteAllShouldWork() throws Exception { + MailboxSession session = control.createMock(MailboxSession.class); + + Mailbox<TestId> mailbox = control.createMock(Mailbox.class); + + TestId mailboxId = TestId.of(12); + + expectLastCall(); + expect(mailbox.getMailboxId()).andReturn(mailboxId); + + expect(indexer.deleteAllMatchingQuery(anyObject(QueryBuilder.class))) + .andReturn(null); + + control.replay(); + testee.deleteAll(session, mailbox); + control.verify(); + } + + @Test + @SuppressWarnings("unchecked") + public void deleteAllShouldNotPropagateExceptionWhenExceptionOccurs() throws Exception { + MailboxSession session = control.createMock(MailboxSession.class); + + Mailbox<TestId> mailbox = control.createMock(Mailbox.class); + TestId mailboxId = TestId.of(12); + + expectLastCall(); + expect(mailbox.getMailboxId()).andReturn(mailboxId).times(2); + + expect(indexer.deleteAllMatchingQuery(anyObject(QueryBuilder.class))) + .andThrow(new ElasticsearchException("")); + + control.replay(); + testee.deleteAll(session, mailbox); + control.verify(); + } } http://git-wip-us.apache.org/repos/asf/james-project/blob/aea76c8d/mailbox/lucene/src/main/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndex.java ---------------------------------------------------------------------- diff --git a/mailbox/lucene/src/main/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndex.java b/mailbox/lucene/src/main/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndex.java index 2382399..05c7f6b 100644 --- a/mailbox/lucene/src/main/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndex.java +++ b/mailbox/lucene/src/main/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndex.java @@ -1301,10 +1301,21 @@ public class LuceneMessageSearchIndex<Id extends MailboxId> extends ListeningMes return NumericRangeQuery.newLongRange(UID_FIELD, 0L, Long.MAX_VALUE, true, true); } } - /** - * @see org.apache.james.mailbox.store.search.ListeningMessageSearchIndex#delete(org.apache.james.mailbox.MailboxSession, org.apache.james.mailbox.store.mail.model.Mailbox, org.apache.james.mailbox.model.MessageRange) - */ - public void delete(MailboxSession session, Mailbox<Id> mailbox, MessageRange range) throws MailboxException { + + @Override + public void delete(MailboxSession session, Mailbox<Id> mailbox, List<Long> expungedUids) throws MailboxException { + Collection<MessageRange> messageRanges = MessageRange.toRanges(expungedUids); + for (MessageRange messageRange : messageRanges) { + delete(mailbox, messageRange); + } + } + + @Override + public void deleteAll(MailboxSession session, Mailbox<Id> mailbox) throws MailboxException { + delete(mailbox, MessageRange.all()); + } + + public void delete(Mailbox<Id> mailbox, MessageRange range) throws MailboxException { BooleanQuery query = new BooleanQuery(); query.add(new TermQuery(new Term(MAILBOX_ID_FIELD, mailbox.getMailboxId().serialize())), BooleanClause.Occur.MUST); query.add(createQuery(range), BooleanClause.Occur.MUST); http://git-wip-us.apache.org/repos/asf/james-project/blob/aea76c8d/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/LazyMessageSearchIndex.java ---------------------------------------------------------------------- diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/LazyMessageSearchIndex.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/LazyMessageSearchIndex.java index 3f80259..f9e1bd8 100644 --- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/LazyMessageSearchIndex.java +++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/LazyMessageSearchIndex.java @@ -64,8 +64,13 @@ public class LazyMessageSearchIndex<Id extends MailboxId> extends ListeningMessa } @Override - public void delete(MailboxSession session, Mailbox<Id> mailbox, MessageRange range) throws MailboxException { - index.delete(session, mailbox, range); + public void delete(MailboxSession session, Mailbox<Id> mailbox, List<Long> expungedUids) throws MailboxException { + index.delete(session, mailbox, expungedUids); + } + + @Override + public void deleteAll(MailboxSession session, Mailbox<Id> mailbox) throws MailboxException { + index.deleteAll(session, mailbox); } /** http://git-wip-us.apache.org/repos/asf/james-project/blob/aea76c8d/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/ListeningMessageSearchIndex.java ---------------------------------------------------------------------- diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/ListeningMessageSearchIndex.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/ListeningMessageSearchIndex.java index b894319..52541bf 100644 --- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/ListeningMessageSearchIndex.java +++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/ListeningMessageSearchIndex.java @@ -92,15 +92,10 @@ public abstract class ListeningMessageSearchIndex<Id extends MailboxId> implemen } } else if (event instanceof EventFactory.ExpungedImpl) { EventFactory.ExpungedImpl expunged = (EventFactory.ExpungedImpl) event; - final Mailbox<Id> mailbox = expunged.getMailbox(); - List<Long> uids = expunged.getUids(); - List<MessageRange> ranges = MessageRange.toRanges(uids); - for (MessageRange range : ranges) { - try { - delete(session, mailbox, range); - } catch (MailboxException e) { - session.getLog().debug("Unable to deleted range " + range.toString() + " from index for mailbox " + mailbox, e); - } + try { + delete(session, expunged.getMailbox(), expunged.getUids()); + } catch (MailboxException e) { + session.getLog().debug("Unable to deleted messages " + expunged.getUids() + " from index for mailbox " + expunged.getMailbox(), e); } } else if (event instanceof EventFactory.FlagsUpdatedImpl) { EventFactory.FlagsUpdatedImpl flagsUpdated = (EventFactory.FlagsUpdatedImpl) event; @@ -113,8 +108,7 @@ public abstract class ListeningMessageSearchIndex<Id extends MailboxId> implemen } } } else if (event instanceof EventFactory.MailboxDeletionImpl) { - // delete all indexed messages for the mailbox - delete(session, ((EventFactory.MailboxDeletionImpl) event).getMailbox(), MessageRange.all()); + deleteAll(session, ((EventFactory.MailboxDeletionImpl) event).getMailbox()); } } catch (MailboxException e) { session.getLog().debug("Unable to update index", e); @@ -133,15 +127,23 @@ public abstract class ListeningMessageSearchIndex<Id extends MailboxId> implemen public abstract void add(MailboxSession session, Mailbox<Id> mailbox, MailboxMessage<Id> message) throws MailboxException; /** - * Delete the {@link MessageRange} for the given {@link Mailbox} from the index + * Delete the concerned UIDs for the given {@link Mailbox} from the index * - * @param session - * @param mailbox - * @param range + * @param session The mailbox session performing the expunge + * @param mailbox mailbox on which the expunge was performed + * @param expungedUids UIDS to be deleted * @throws MailboxException */ - public abstract void delete(MailboxSession session, Mailbox<Id> mailbox, MessageRange range) throws MailboxException; - + public abstract void delete(MailboxSession session, Mailbox<Id> mailbox, List<Long> expungedUids) throws MailboxException; + + /** + * Delete the messages contained in the given {@link Mailbox} from the index + * + * @param session The mailbox session performing the expunge + * @param mailbox mailbox on which the expunge was performed + * @throws MailboxException + */ + public abstract void deleteAll(MailboxSession session, Mailbox<Id> mailbox) throws MailboxException; /** * Update the messages concerned by the updated flags list for the given {@link Mailbox} http://git-wip-us.apache.org/repos/asf/james-project/blob/aea76c8d/mailbox/tool/src/main/java/org/apache/james/mailbox/indexer/ReIndexerImpl.java ---------------------------------------------------------------------- diff --git a/mailbox/tool/src/main/java/org/apache/james/mailbox/indexer/ReIndexerImpl.java b/mailbox/tool/src/main/java/org/apache/james/mailbox/indexer/ReIndexerImpl.java index 3fddf76..7efd7d5 100644 --- a/mailbox/tool/src/main/java/org/apache/james/mailbox/indexer/ReIndexerImpl.java +++ b/mailbox/tool/src/main/java/org/apache/james/mailbox/indexer/ReIndexerImpl.java @@ -97,7 +97,7 @@ public class ReIndexerImpl<Id extends MailboxId> implements ReIndexer { MailboxRegistration mailboxRegistration = new MailboxRegistration(path); LOGGER.info("Intend to reindex {}",path); Mailbox<Id> mailbox = mailboxSessionMapperFactory.getMailboxMapper(mailboxSession).findMailboxByPath(path); - messageSearchIndex.delete(mailboxSession, mailbox, MessageRange.all()); + messageSearchIndex.deleteAll(mailboxSession, mailbox); mailboxManager.addListener(path, mailboxRegistration, mailboxSession); try { handleMailboxIndexingIterations(mailboxSession, http://git-wip-us.apache.org/repos/asf/james-project/blob/aea76c8d/mailbox/tool/src/test/java/org/apache/james/mailbox/indexer/ReIndexerImplTest.java ---------------------------------------------------------------------- diff --git a/mailbox/tool/src/test/java/org/apache/james/mailbox/indexer/ReIndexerImplTest.java b/mailbox/tool/src/test/java/org/apache/james/mailbox/indexer/ReIndexerImplTest.java index 70cb3f5..6e09361 100644 --- a/mailbox/tool/src/test/java/org/apache/james/mailbox/indexer/ReIndexerImplTest.java +++ b/mailbox/tool/src/test/java/org/apache/james/mailbox/indexer/ReIndexerImplTest.java @@ -117,7 +117,7 @@ public class ReIndexerImplTest { verify(mailboxManager).addListener(eq(INBOX), any(MailboxListener.class), any(MailboxSession.class)); verify(mailboxManager).removeListener(eq(INBOX), any(MailboxListener.class), any(MailboxSession.class)); verify(messageSearchIndex).add(any(MailboxSession.class), eq(mailbox), eq(message)); - verify(messageSearchIndex).delete(any(MailboxSession.class), eq(mailbox), eq(MessageRange.all())); + verify(messageSearchIndex).deleteAll(any(MailboxSession.class), eq(mailbox)); verifyNoMoreInteractions(mailboxMapper, mailboxSessionMapperFactory, messageSearchIndex, messageMapper, mailboxMapper); } } --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org