This is an automated email from the ASF dual-hosted git repository. btellier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 18b0733d12698c37ed559c5b438c87746733825b Author: Benoit Tellier <[email protected]> AuthorDate: Tue Sep 10 10:04:20 2019 +0700 JAMES-2703 Remove mailbox/caching --- mailbox/caching/pom.xml | 60 -------- .../caching/CacheInvalidatingMailboxListener.java | 83 ----------- .../mailbox/caching/CacheLoaderFromUnderlying.java | 11 -- .../mailbox/caching/CachingMailboxMapper.java | 138 ----------------- .../CachingMailboxSessionMapperFactory.java | 77 ---------- .../mailbox/caching/CachingMessageMapper.java | 163 --------------------- .../james/mailbox/caching/MailboxByPathCache.java | 30 ---- .../mailbox/caching/MailboxMetadataCache.java | 38 ----- .../mailbox/caching/guava/AbstractGuavaCache.java | 22 --- .../mailbox/caching/guava/GuavaCacheWrapper.java | 44 ------ .../caching/guava/GuavaMailboxByPathCache.java | 68 --------- .../caching/guava/GuavaMailboxMetadataCache.java | 153 ------------------- .../CacheInvalidatingMailboxListenerTest.java | 37 ----- mailbox/pom.xml | 1 - 14 files changed, 925 deletions(-) diff --git a/mailbox/caching/pom.xml b/mailbox/caching/pom.xml deleted file mode 100644 index 280bb1d..0000000 --- a/mailbox/caching/pom.xml +++ /dev/null @@ -1,60 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - 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. ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.james</groupId> - <artifactId>apache-james-mailbox</artifactId> - <version>3.5.0-SNAPSHOT</version> - <relativePath>../pom.xml</relativePath> - </parent> - - <artifactId>apache-james-mailbox-caching</artifactId> - <packaging>jar</packaging> - <name>Apache James :: Mailbox :: Caching</name> - - <description>JAMES-2703 This maven module is deprecated and will be removed straight after upcoming James 3.4.0 release, unless it finds a maintainer. - This module lacks tests and is not used in James products hence the choice to deprecate it.</description> - - <dependencies> - <dependency> - <groupId>${james.groupId}</groupId> - <artifactId>apache-james-mailbox-api</artifactId> - </dependency> - <dependency> - <groupId>${james.groupId}</groupId> - <artifactId>apache-james-mailbox-store</artifactId> - </dependency> - <dependency> - <groupId>${james.groupId}</groupId> - <artifactId>testing-base</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>com.google.guava</groupId> - <artifactId>guava</artifactId> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - </dependency> - </dependencies> -</project> diff --git a/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CacheInvalidatingMailboxListener.java b/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CacheInvalidatingMailboxListener.java deleted file mode 100644 index 327a85f..0000000 --- a/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CacheInvalidatingMailboxListener.java +++ /dev/null @@ -1,83 +0,0 @@ -package org.apache.james.mailbox.caching; - -import org.apache.james.mailbox.events.Event; -import org.apache.james.mailbox.events.EventBus; -import org.apache.james.mailbox.events.Group; -import org.apache.james.mailbox.events.MailboxListener; -import org.apache.james.mailbox.exception.MailboxException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * A MailboxListener that invalidates the configured caches in response to Events - * - * @deprecated JAMES-2703 This class is deprecated and will be removed straight after upcoming James 3.4.0 release, unless it finds a maintainer - * - * This module lacks tests and is not used in James products hence the choice to deprecate it. - */ -@Deprecated -public class CacheInvalidatingMailboxListener implements MailboxListener.GroupMailboxListener { - public static class CacheInvalidatingMailboxListenerGroup extends Group { - - } - - private static final Logger LOGGER = LoggerFactory.getLogger(CacheInvalidatingMailboxListener.class); - private static final Group GROUP = new CacheInvalidatingMailboxListenerGroup(); - - private final MailboxByPathCache mailboxCacheByPath; - private final MailboxMetadataCache mailboxMetadataCache; - - public CacheInvalidatingMailboxListener(MailboxByPathCache mailboxCacheByPath, MailboxMetadataCache mailboxMetadataCache) { - this.mailboxCacheByPath = mailboxCacheByPath; - this.mailboxMetadataCache = mailboxMetadataCache; - } - - @Override - public Group getDefaultGroup() { - return GROUP; - } - - /** - * Used to register the CacheInvalidatingMailboxListener as a global listener - * into the main MailboxListener - * - * @param eventBus - */ - public void register(EventBus eventBus) { - eventBus.register(this); - } - - @Override - public boolean isHandling(Event event) { - return event instanceof MailboxEvent; - } - - @Override - public void event(Event event) { - mailboxEvent((MailboxEvent) event); - } - - private void mailboxEvent(MailboxEvent event) { - // TODO this needs for sure to be smarter - try { - if (event instanceof MessageEvent) { - // invalidate the metadata caches - invalidateMetadata(event); - } - invalidateMailbox(event); - } catch (MailboxException e) { - LOGGER.error("Error while invalidation cache", e); - } - } - - private void invalidateMetadata(MailboxEvent event) throws MailboxException { - //HMM, race conditions welcome? - mailboxMetadataCache.invalidate(mailboxCacheByPath.findMailboxByPath(event.getMailboxPath(), null)); - - } - - private void invalidateMailbox(MailboxEvent event) { - mailboxCacheByPath.invalidate(event.getMailboxPath()); - } - -} diff --git a/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CacheLoaderFromUnderlying.java b/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CacheLoaderFromUnderlying.java deleted file mode 100644 index fb0bc35..0000000 --- a/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CacheLoaderFromUnderlying.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.apache.james.mailbox.caching; - -/** - * @deprecated JAMES-2703 This class is deprecated and will be removed straight after upcoming James 3.4.0 release, unless it finds a maintainer - * - * This module lacks tests and is not used in James products hence the choice to deprecate it. - */ -@Deprecated -public interface CacheLoaderFromUnderlying<KeyT, ValueT, UnderlyingT, ExceptT extends Throwable> { - ValueT load(KeyT key, UnderlyingT underlying) throws ExceptT; -} diff --git a/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CachingMailboxMapper.java b/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CachingMailboxMapper.java deleted file mode 100644 index 757ebd8..0000000 --- a/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CachingMailboxMapper.java +++ /dev/null @@ -1,138 +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.caching; - -import java.util.List; - -import org.apache.james.mailbox.acl.ACLDiff; -import org.apache.james.mailbox.exception.MailboxException; -import org.apache.james.mailbox.exception.MailboxNotFoundException; -import org.apache.james.mailbox.model.Mailbox; -import org.apache.james.mailbox.model.MailboxACL; -import org.apache.james.mailbox.model.MailboxACL.Right; -import org.apache.james.mailbox.model.MailboxId; -import org.apache.james.mailbox.model.MailboxPath; -import org.apache.james.mailbox.store.mail.MailboxMapper; - -/** - * A MailboxMapper implementation that uses a MailboxByPathCache to cache the information - * from the underlying MailboxMapper - * - * @deprecated JAMES-2703 This class is deprecated and will be removed straight after upcoming James 3.4.0 release, unless it finds a maintainer - * - * This module lacks tests and is not used in James products hence the choice to deprecate it. - */ -@Deprecated -public class CachingMailboxMapper implements MailboxMapper { - - private final MailboxMapper underlying; - private final MailboxByPathCache cache; - - public CachingMailboxMapper(MailboxMapper underlying, MailboxByPathCache cache) { - this.underlying = underlying; - this.cache = cache; - } - - @Override - public void endRequest() { - underlying.endRequest(); - } - - @Override - public <T> T execute(Transaction<T> transaction) throws MailboxException { - return underlying.execute(transaction); - } - - @Override - public MailboxId save(Mailbox mailbox) throws MailboxException { - invalidate(mailbox); - return underlying.save(mailbox); - } - - @Override - public void delete(Mailbox mailbox) throws MailboxException { - invalidate(mailbox); - underlying.delete(mailbox); - } - - @Override - public Mailbox findMailboxByPath(MailboxPath mailboxName) - throws MailboxException, MailboxNotFoundException { - try { - return cache.findMailboxByPath(mailboxName, underlying); - } catch (MailboxNotFoundException e) { - cache.invalidate(mailboxName); - throw e; - } - } - - @Override - public Mailbox findMailboxById(MailboxId mailboxId) - throws MailboxException { - // TODO possible to meaningfully cache it? - return underlying.findMailboxById(mailboxId); - } - - - @Override - public List<Mailbox> findMailboxWithPathLike(MailboxPath mailboxPath) - throws MailboxException { - // TODO possible to meaningfully cache it? - return underlying.findMailboxWithPathLike(mailboxPath); - } - - @Override - public boolean hasChildren(Mailbox mailbox, char delimiter) - throws MailboxException, MailboxNotFoundException { - // TODO possible to meaningfully cache it? - return underlying.hasChildren(mailbox, delimiter); - } - - @Override - public List<Mailbox> list() throws MailboxException { - // TODO possible to meaningfully cache it? is it used at all? - return underlying.list(); - } - - @Override - public ACLDiff updateACL(Mailbox mailbox, MailboxACL.ACLCommand mailboxACLCommand) throws MailboxException { - MailboxACL oldACL = mailbox.getACL(); - MailboxACL newACL = mailbox.getACL().apply(mailboxACLCommand); - mailbox.setACL(newACL); - return ACLDiff.computeDiff(oldACL, newACL); - } - - @Override - public ACLDiff setACL(Mailbox mailbox, MailboxACL mailboxACL) throws MailboxException { - MailboxACL oldMailboxAcl = mailbox.getACL(); - mailbox.setACL(mailboxACL); - return ACLDiff.computeDiff(oldMailboxAcl, mailboxACL); - } - - private void invalidate(Mailbox mailbox) { - cache.invalidate(mailbox); - } - - @Override - public List<Mailbox> findNonPersonalMailboxes(String userName, Right right) throws MailboxException { - return underlying.findNonPersonalMailboxes(userName, right); - } - -} diff --git a/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CachingMailboxSessionMapperFactory.java b/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CachingMailboxSessionMapperFactory.java deleted file mode 100644 index c443f2c..0000000 --- a/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CachingMailboxSessionMapperFactory.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.apache.james.mailbox.caching; - -import org.apache.commons.lang3.NotImplementedException; -import org.apache.james.mailbox.MailboxSession; -import org.apache.james.mailbox.exception.MailboxException; -import org.apache.james.mailbox.exception.SubscriptionException; -import org.apache.james.mailbox.store.MailboxSessionMapperFactory; -import org.apache.james.mailbox.store.mail.AnnotationMapper; -import org.apache.james.mailbox.store.mail.MailboxMapper; -import org.apache.james.mailbox.store.mail.MessageIdMapper; -import org.apache.james.mailbox.store.mail.MessageMapper; -import org.apache.james.mailbox.store.mail.ModSeqProvider; -import org.apache.james.mailbox.store.mail.UidProvider; -import org.apache.james.mailbox.store.user.SubscriptionMapper; - -/** - * A MailboxSessionMapperFactory that uses the underlying MailboxSessionMapperFactory to provide - * caching variants of MessageMapper and MailboxMapper built around the MessageMapper and MailboxMapper - * provided by it - * - * @deprecated JAMES-2703 This class is deprecated and will be removed straight after upcoming James 3.4.0 release, unless it finds a maintainer - * - * This module lacks tests and is not used in James products hence the choice to deprecate it. - */ -@Deprecated -public class CachingMailboxSessionMapperFactory extends - MailboxSessionMapperFactory { - - private final MailboxSessionMapperFactory underlying; - private final MailboxByPathCache mailboxByPathCache; - private final MailboxMetadataCache mailboxMetadataCache; - - public CachingMailboxSessionMapperFactory(MailboxSessionMapperFactory underlying, MailboxByPathCache mailboxByPathCache, MailboxMetadataCache mailboxMetadataCache) { - this.underlying = underlying; - this.mailboxByPathCache = mailboxByPathCache; - this.mailboxMetadataCache = mailboxMetadataCache; - } - - @Override - public MessageMapper createMessageMapper(MailboxSession session) - throws MailboxException { - return new CachingMessageMapper(underlying.createMessageMapper(session), mailboxMetadataCache); - } - - @Override - public MailboxMapper createMailboxMapper(MailboxSession session) - throws MailboxException { - return new CachingMailboxMapper(underlying.createMailboxMapper(session), mailboxByPathCache); - } - - @Override - public SubscriptionMapper createSubscriptionMapper(MailboxSession session) - throws SubscriptionException { - return underlying.createSubscriptionMapper(session); - } - - @Override - public AnnotationMapper createAnnotationMapper(MailboxSession session) - throws MailboxException { - throw new NotImplementedException("Not implemented"); - } - - @Override - public UidProvider getUidProvider() { - return underlying.getUidProvider(); - } - - @Override - public ModSeqProvider getModSeqProvider() { - return underlying.getModSeqProvider(); - } - - @Override - public MessageIdMapper createMessageIdMapper(MailboxSession session) throws MailboxException { - throw new NotImplementedException("Not implemented"); - } -} diff --git a/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CachingMessageMapper.java b/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CachingMessageMapper.java deleted file mode 100644 index f6d617b..0000000 --- a/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CachingMessageMapper.java +++ /dev/null @@ -1,163 +0,0 @@ -package org.apache.james.mailbox.caching; - -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Optional; - -import javax.mail.Flags; - -import org.apache.james.mailbox.MessageUid; -import org.apache.james.mailbox.exception.MailboxException; -import org.apache.james.mailbox.model.Mailbox; -import org.apache.james.mailbox.model.MailboxCounters; -import org.apache.james.mailbox.model.MessageMetaData; -import org.apache.james.mailbox.model.MessageRange; -import org.apache.james.mailbox.model.UpdatedFlags; -import org.apache.james.mailbox.store.FlagsUpdateCalculator; -import org.apache.james.mailbox.store.mail.MessageMapper; -import org.apache.james.mailbox.store.mail.model.MailboxMessage; - -/** - * A MessageMapper implementation that uses a MailboxMetadataCache to cache the information - * from the underlying MessageMapper - * - * @deprecated JAMES-2703 This class is deprecated and will be removed straight after upcoming James 3.4.0 release, unless it finds a maintainer - * - * This module lacks tests and is not used in James products hence the choice to deprecate it. - */ -@Deprecated -public class CachingMessageMapper implements MessageMapper { - - private final MessageMapper underlying; - private final MailboxMetadataCache cache; - - public CachingMessageMapper(MessageMapper underlying, MailboxMetadataCache cache) { - this.underlying = underlying; - this.cache = cache; - } - - @Override - public Iterator<MessageUid> listAllMessageUids(Mailbox mailbox) throws MailboxException { - return underlying.listAllMessageUids(mailbox); - } - - @Override - public void endRequest() { - underlying.endRequest(); - } - - @Override - public <T> T execute(Transaction<T> transaction) throws MailboxException { - return underlying.execute(transaction); - } - - @Override - public Iterator<MailboxMessage> findInMailbox(Mailbox mailbox, - MessageRange set, - org.apache.james.mailbox.store.mail.MessageMapper.FetchType type, - int limit) throws MailboxException { - return underlying.findInMailbox(mailbox, set, type, limit); - } - - @Override - public List<MessageUid> retrieveMessagesMarkedForDeletion(Mailbox mailbox, MessageRange messageRange) throws MailboxException { - return underlying.retrieveMessagesMarkedForDeletion(mailbox, messageRange); - } - - @Override - public Map<MessageUid, MessageMetaData> deleteMessages(Mailbox mailbox, List<MessageUid> uids) throws MailboxException { - invalidateMetadata(mailbox); - return underlying.deleteMessages(mailbox, uids); - } - - @Override - public long countMessagesInMailbox(Mailbox mailbox) - throws MailboxException { - return cache.countMessagesInMailbox(mailbox, underlying); - } - - @Override - public long countUnseenMessagesInMailbox(Mailbox mailbox) - throws MailboxException { - return cache.countUnseenMessagesInMailbox(mailbox, underlying); - } - - @Override - public MailboxCounters getMailboxCounters(Mailbox mailbox) throws MailboxException { - return MailboxCounters.builder() - .count(countMessagesInMailbox(mailbox)) - .unseen(countUnseenMessagesInMailbox(mailbox)) - .build(); - } - - @Override - public void delete(Mailbox mailbox, MailboxMessage message) - throws MailboxException { - invalidateMetadata(mailbox); - underlying.delete(mailbox, message); - - } - - @Override - public MessageUid findFirstUnseenMessageUid(Mailbox mailbox) - throws MailboxException { - return cache.findFirstUnseenMessageUid(mailbox, underlying); - } - - @Override - public List<MessageUid> findRecentMessageUidsInMailbox(Mailbox mailbox) - throws MailboxException { - // TODO can be meaningfully cached? - return underlying.findRecentMessageUidsInMailbox(mailbox); - } - - @Override - public MessageMetaData add(Mailbox mailbox, MailboxMessage message) - throws MailboxException { - invalidateMetadata(mailbox); - return underlying.add(mailbox, message); - } - - @Override - public Iterator<UpdatedFlags> updateFlags(Mailbox mailbox, FlagsUpdateCalculator calculator, MessageRange set) - throws MailboxException { - //check if there are in fact any updates - if (set.iterator().hasNext()) { - invalidateMetadata(mailbox); - } - return underlying.updateFlags(mailbox, calculator, set); - } - - - @Override - public MessageMetaData copy(Mailbox mailbox, MailboxMessage original) - throws MailboxException { - invalidateMetadata(mailbox); - return underlying.copy(mailbox, original); - } - - @Override - public Optional<MessageUid> getLastUid(Mailbox mailbox) throws MailboxException { - return cache.getLastUid(mailbox, underlying); - } - - @Override - public long getHighestModSeq(Mailbox mailbox) throws MailboxException { - return cache.getHighestModSeq(mailbox, underlying); - } - - private void invalidateMetadata(Mailbox mailbox) { - cache.invalidate(mailbox); - } - - @Override - public MessageMetaData move(Mailbox mailbox, MailboxMessage original) throws MailboxException { - throw new UnsupportedOperationException("Move is not yet supported"); - } - - @Override - public Flags getApplicableFlag(Mailbox mailbox) throws MailboxException { - return underlying.getApplicableFlag(mailbox); - } -} diff --git a/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/MailboxByPathCache.java b/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/MailboxByPathCache.java deleted file mode 100644 index 664e1f2..0000000 --- a/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/MailboxByPathCache.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.apache.james.mailbox.caching; - -import org.apache.james.mailbox.exception.MailboxException; -import org.apache.james.mailbox.exception.MailboxNotFoundException; -import org.apache.james.mailbox.model.Mailbox; -import org.apache.james.mailbox.model.MailboxPath; -import org.apache.james.mailbox.store.mail.MailboxMapper; - -/** - * Caches the MailboxPath -> Mailbox mapping - * - * @deprecated JAMES-2703 This class is deprecated and will be removed straight after upcoming James 3.4.0 release, unless it finds a maintainer - * - * This module lacks tests and is not used in James products hence the choice to deprecate it. - */ -@Deprecated -public interface MailboxByPathCache { - - Mailbox findMailboxByPath(MailboxPath mailboxName, - MailboxMapper underlying) throws MailboxNotFoundException, - MailboxException; - - void invalidate(Mailbox mailbox); - - void invalidate(MailboxPath mailboxPath); - - // for the purpose of cascading the invalidations; does it make sense? - //public void connectTo(MailboxMetadataCache<Id> mailboxMetadataCache); - -} diff --git a/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/MailboxMetadataCache.java b/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/MailboxMetadataCache.java deleted file mode 100644 index a183eae..0000000 --- a/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/MailboxMetadataCache.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.apache.james.mailbox.caching; - -import java.util.Optional; - -import org.apache.james.mailbox.MessageUid; -import org.apache.james.mailbox.exception.MailboxException; -import org.apache.james.mailbox.model.Mailbox; -import org.apache.james.mailbox.store.mail.MessageMapper; - -/** - * Caches the simple yet possibly expensive to compute metadata info - * about a Mailbox like all/unseen messages count and similar - * - * @deprecated JAMES-2703 This class is deprecated and will be removed straight after upcoming James 3.4.0 release, unless it finds a maintainer - * - * This module lacks tests and is not used in James products hence the choice to deprecate it. - */ -@Deprecated -public interface MailboxMetadataCache { - - long countMessagesInMailbox(Mailbox mailbox, - MessageMapper underlying) throws MailboxException; - - long countUnseenMessagesInMailbox(Mailbox mailbox, - MessageMapper underlying) throws MailboxException; - - MessageUid findFirstUnseenMessageUid(Mailbox mailbox, - MessageMapper underlying) throws MailboxException; - - Optional<MessageUid> getLastUid(Mailbox mailbox, - MessageMapper underlying) throws MailboxException; - - long getHighestModSeq(Mailbox mailbox, - MessageMapper underlying) throws MailboxException; - - void invalidate(Mailbox mailbox); - -} \ No newline at end of file diff --git a/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/guava/AbstractGuavaCache.java b/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/guava/AbstractGuavaCache.java deleted file mode 100644 index 3647dd7..0000000 --- a/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/guava/AbstractGuavaCache.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.apache.james.mailbox.caching.guava; - -import java.util.concurrent.TimeUnit; - -import com.google.common.cache.CacheBuilder; - -/** - * @deprecated JAMES-2703 This class is deprecated and will be removed straight after upcoming James 3.4.0 release, unless it finds a maintainer - * - * This module lacks tests and is not used in James products hence the choice to deprecate it. - */ -@Deprecated -public class AbstractGuavaCache { - - // TODO this can probably be instantiated more elegant way - protected static final CacheBuilder<Object, Object> BUILDER = - CacheBuilder.newBuilder() - .maximumSize(100000) - .recordStats() - .expireAfterWrite(15, TimeUnit.MINUTES); - -} diff --git a/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/guava/GuavaCacheWrapper.java b/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/guava/GuavaCacheWrapper.java deleted file mode 100644 index a8226e0..0000000 --- a/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/guava/GuavaCacheWrapper.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.apache.james.mailbox.caching.guava; - -import org.apache.james.mailbox.caching.CacheLoaderFromUnderlying; - -import com.google.common.cache.Cache; - -/** - * @deprecated JAMES-2703 This class is deprecated and will be removed straight after upcoming James 3.4.0 release, unless it finds a maintainer - * - * This module lacks tests and is not used in James products hence the choice to deprecate it. - */ -@Deprecated -public abstract class GuavaCacheWrapper<KeyT, ValueT, UnderlyingT, KeyRepresentationT, ExceptT extends Throwable> - implements CacheLoaderFromUnderlying<KeyT, ValueT, UnderlyingT, ExceptT> { - - private final Cache<KeyRepresentationT, ValueT> cache; - - public GuavaCacheWrapper(Cache<KeyRepresentationT, ValueT> cache/*, CacheLoaderFromUnderlying<Key, Value, Underlying, Except> loader*/) { - this.cache = cache; - } - - public ValueT get(KeyT key, UnderlyingT underlying) throws ExceptT { - ValueT value = cache.getIfPresent(getKeyRepresentation(key)); - if (value != null) { - return value; - } else { - value = load(key, underlying); - if (value != null) { - cache.put(getKeyRepresentation(key), value); - } - return value; - } - - } - - public void invalidate(KeyT key) { - if (key != null) { //needed? - cache.invalidate(getKeyRepresentation(key)); - } - } - - public abstract KeyRepresentationT getKeyRepresentation(KeyT key); - -} diff --git a/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/guava/GuavaMailboxByPathCache.java b/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/guava/GuavaMailboxByPathCache.java deleted file mode 100644 index ae1cce9..0000000 --- a/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/guava/GuavaMailboxByPathCache.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.apache.james.mailbox.caching.guava; - -import org.apache.james.mailbox.caching.MailboxByPathCache; -import org.apache.james.mailbox.exception.MailboxException; -import org.apache.james.mailbox.exception.MailboxNotFoundException; -import org.apache.james.mailbox.model.Mailbox; -import org.apache.james.mailbox.model.MailboxPath; -import org.apache.james.mailbox.store.mail.MailboxMapper; - -import com.google.common.cache.Cache; - -/** - * Guava-based implementation of MailboxByPathCache. - * Note: for efficiency/simplicity reasons the cache key is MailboxPath.toString() - * That may help also make it compatible with other cache backends in the future. - * - * @deprecated JAMES-2703 This class is deprecated and will be removed straight after upcoming James 3.4.0 release, unless it finds a maintainer - * - * This module lacks tests and is not used in James products hence the choice to deprecate it. - */ -@Deprecated -public class GuavaMailboxByPathCache extends AbstractGuavaCache implements MailboxByPathCache { - - private final Cache<String, Mailbox> findMailboxByPathCache = BUILDER.build(); - - private final MailboxByPathCacheWrapper wrapper; - - - public GuavaMailboxByPathCache() { - this.wrapper = new MailboxByPathCacheWrapper(findMailboxByPathCache); - } - - @Override - public Mailbox findMailboxByPath(MailboxPath mailboxName, MailboxMapper underlying) throws MailboxNotFoundException, MailboxException { - - return wrapper.get(mailboxName, underlying); - } - - @Override - public void invalidate(Mailbox mailbox) { - invalidate(mailbox.generateAssociatedPath()); - } - - @Override - public void invalidate(MailboxPath mailboxPath) { - wrapper.invalidate(mailboxPath); - } - - class MailboxByPathCacheWrapper extends GuavaCacheWrapper<MailboxPath, Mailbox, MailboxMapper, String, MailboxException> { - - public MailboxByPathCacheWrapper( - Cache<String, Mailbox> cache/*, - MailboxByPathCacheLoaderFromUnderlying loader*/) { - super(cache); - } - - @Override - public Mailbox load(MailboxPath mailboxName, MailboxMapper underlying) throws MailboxException { - return underlying.findMailboxByPath(mailboxName); - } - - @Override - public String getKeyRepresentation(MailboxPath key) { - return key.toString(); - } - - } -} diff --git a/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/guava/GuavaMailboxMetadataCache.java b/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/guava/GuavaMailboxMetadataCache.java deleted file mode 100644 index ee7586b..0000000 --- a/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/guava/GuavaMailboxMetadataCache.java +++ /dev/null @@ -1,153 +0,0 @@ -package org.apache.james.mailbox.caching.guava; - -import java.util.Optional; - -import org.apache.james.mailbox.MessageUid; -import org.apache.james.mailbox.caching.MailboxMetadataCache; -import org.apache.james.mailbox.exception.MailboxException; -import org.apache.james.mailbox.model.Mailbox; -import org.apache.james.mailbox.model.MailboxId; -import org.apache.james.mailbox.store.mail.MessageMapper; - -import com.google.common.cache.Cache; - -/** - * Guava-based implementation of MailboxMetadataCache. - * Note: for efficiency/simplicity reasons the cache key is Mailbox.getMailboxId() - * - * @deprecated JAMES-2703 This class is deprecated and will be removed straight after upcoming James 3.4.0 release, unless it finds a maintainer - * - * This module lacks tests and is not used in James products hence the choice to deprecate it. - */ -@Deprecated -public class GuavaMailboxMetadataCache extends AbstractGuavaCache implements MailboxMetadataCache { - - // TODO these can probably be instantiated more elegant way - private final Cache<MailboxId, Long> cacheCountMessagesInMailbox = BUILDER.build(); - private final Cache<MailboxId, Long> cacheCountUnseenMessagesInMailbox = BUILDER.build(); - private final Cache<MailboxId, MessageUid> cacheFindFirstUnseenMessageUid = BUILDER.build(); - private final Cache<MailboxId, Optional<MessageUid>> cacheGetLastUid = BUILDER.build(); - private final Cache<MailboxId, Long> cacheGetHighestModSeq = BUILDER.build(); - - private final MetadataCacheWrapper<Long> countMessagesInMailboxWrapper = new CountMessagesInMailboxWrapper(cacheCountMessagesInMailbox); - private final MetadataCacheWrapper<Long> countUnseenMessagesInMailboxWrapper = new CountUnseenMessagesInMailboxWrapper(cacheCountUnseenMessagesInMailbox); - private final MetadataCacheWrapper<MessageUid> findFirstUnseenMessageUid = new FindFirstUnseenMessageUidWrapper(cacheFindFirstUnseenMessageUid); - private final MetadataCacheWrapper<Long> highestModSeqWrapper = new HighestModseqCacheWrapper(cacheGetHighestModSeq); - private final MetadataCacheWrapper<Optional<MessageUid>> lastUidWrapper = new LastUidCacheWrapper(cacheGetLastUid); - - @Override - public long countMessagesInMailbox(Mailbox mailbox, MessageMapper underlying) throws MailboxException { - return countMessagesInMailboxWrapper.get(mailbox, underlying); - } - - @Override - public long countUnseenMessagesInMailbox(Mailbox mailbox, MessageMapper underlying) - throws MailboxException { - return countUnseenMessagesInMailboxWrapper.get(mailbox, underlying); - } - - @Override - public MessageUid findFirstUnseenMessageUid(Mailbox mailbox, MessageMapper underlying) - throws MailboxException { - return findFirstUnseenMessageUid.get(mailbox, underlying); - } - - @Override - public Optional<MessageUid> getLastUid(Mailbox mailbox, MessageMapper underlying) throws MailboxException { - return lastUidWrapper.get(mailbox, underlying); - - } - - @Override - public long getHighestModSeq(Mailbox mailbox, MessageMapper underlying) throws MailboxException { - return highestModSeqWrapper.get(mailbox, underlying); - } - - @Override - public void invalidate(Mailbox mailbox) { - cacheCountMessagesInMailbox.invalidate(mailbox); - cacheCountUnseenMessagesInMailbox.invalidate(mailbox); - cacheFindFirstUnseenMessageUid.invalidate(mailbox); - lastUidWrapper.invalidate(mailbox); - highestModSeqWrapper.invalidate(mailbox); - } - - - abstract class MetadataCacheWrapper<ValueT> extends GuavaCacheWrapper<Mailbox, ValueT, MessageMapper, MailboxId, MailboxException> { - - public MetadataCacheWrapper(Cache<MailboxId, ValueT> cache) { - super(cache); - } - - @Override - public MailboxId getKeyRepresentation(Mailbox key) { - return key.getMailboxId(); - } - - } - - class CountMessagesInMailboxWrapper extends MetadataCacheWrapper<Long> { - - public CountMessagesInMailboxWrapper(Cache<MailboxId, Long> cache) { - super(cache); - } - - @Override - public Long load(Mailbox mailbox, MessageMapper underlying) - throws MailboxException { - return underlying.countMessagesInMailbox(mailbox); - } - - } - - class CountUnseenMessagesInMailboxWrapper extends MetadataCacheWrapper<Long> { - - public CountUnseenMessagesInMailboxWrapper(Cache<MailboxId, Long> cache) { - super(cache); - } - - @Override - public Long load(Mailbox mailbox, MessageMapper underlying) - throws MailboxException { - return underlying.countUnseenMessagesInMailbox(mailbox); - } - - } - - class FindFirstUnseenMessageUidWrapper extends MetadataCacheWrapper<MessageUid> { - - public FindFirstUnseenMessageUidWrapper(Cache<MailboxId, MessageUid> cache) { - super(cache); - } - - @Override - public MessageUid load(Mailbox mailbox, MessageMapper underlying) - throws MailboxException { - return underlying.findFirstUnseenMessageUid(mailbox); - } - - } - - class LastUidCacheWrapper extends MetadataCacheWrapper<Optional<MessageUid>> { - public LastUidCacheWrapper(Cache<MailboxId, Optional<MessageUid>> cache) { - super(cache); - } - - @Override - public Optional<MessageUid> load(Mailbox mailbox, MessageMapper underlying) throws MailboxException { - return underlying.getLastUid(mailbox); - } - } - - class HighestModseqCacheWrapper extends MetadataCacheWrapper<Long> { - public HighestModseqCacheWrapper(Cache<MailboxId, Long> cache) { - super(cache); - } - - @Override - public Long load(Mailbox mailbox, MessageMapper underlying) throws MailboxException { - return underlying.getHighestModSeq(mailbox); - } - } - -} diff --git a/mailbox/caching/src/test/java/org/apache/james/mailbox/caching/CacheInvalidatingMailboxListenerTest.java b/mailbox/caching/src/test/java/org/apache/james/mailbox/caching/CacheInvalidatingMailboxListenerTest.java deleted file mode 100644 index 1b7a79e..0000000 --- a/mailbox/caching/src/test/java/org/apache/james/mailbox/caching/CacheInvalidatingMailboxListenerTest.java +++ /dev/null @@ -1,37 +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.caching; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.apache.james.mailbox.events.Group; -import org.junit.jupiter.api.Test; - -/** - * @deprecated JAMES-2703 This class is deprecated and will be removed straight after upcoming James 3.4.0 release, unless it finds a maintainer - */ -@Deprecated -class CacheInvalidatingMailboxListenerTest { - @Test - void deserializeCacheInvalidatingMailboxListenerGroup() throws Exception { - assertThat(Group.deserialize("org.apache.james.mailbox.caching.CacheInvalidatingMailboxListener$CacheInvalidatingMailboxListenerGroup")) - .isEqualTo(new CacheInvalidatingMailboxListener.CacheInvalidatingMailboxListenerGroup()); - } -} \ No newline at end of file diff --git a/mailbox/pom.xml b/mailbox/pom.xml index de41a82..d2d85a8 100644 --- a/mailbox/pom.xml +++ b/mailbox/pom.xml @@ -37,7 +37,6 @@ <modules> <module>api</module> <module>backup</module> - <module>caching</module> <module>cassandra</module> <module>elasticsearch</module> --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
