001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.cache.invalidation;
023:
024: import org.jboss.system.ServiceMBean;
025: import java.util.Collection;
026:
027: /** Main service dealing with cache invalidation. While more than one instance may
028: * be running at the same time, most of the time, only one will be used.
029: * Each InvalidationManager (IM) gives access to a set of InvalidationGroup (IG).
030: * Each IG concerns a particular cache and links subscribers that listen for cache
031: * invalidations messages with cache invaliders that will create invalidation
032: * messages.
033: * Thus, to start, a given service will first ask for a specific IG to work with. This
034: * is an in-VM operation: each cache and invalider works with a *locally* bound IM. If
035: * you want to extend the in-VM mode of operation, you need to provide (possibly
036: * dynamically), your IM-Bridge. A bridge forwards cache-invalidation messages on other
037: * nodes. It may select which IG are bridged. More than one cache can be bound to a
038: * given IM.
039: *
040: * As some applications needs to be able to send in batch invalidation messages that concern
041: * more than one cache. To satisfy this need, a global batchInvalidate method is available
042: * at the IM level.
043: * @see org.jboss.cache.invalidation.InvalidationManager
044: * @author <a href="mailto:sacha.labourey@cogito-info.ch">Sacha Labourey</a>.
045: * @version $Revision: 57209 $
046: *
047: * <p><b>Revisions:</b>
048: *
049: * <p><b>21 septembre 2002 Sacha Labourey:</b>
050: * <ul>
051: * <li> First implementation </li>
052: * </ul>
053: */
054:
055: public interface InvalidationManagerMBean extends ServiceMBean {
056: /**
057: * Get the is default asynchronous replication mode flag
058: * @return
059: */
060: public boolean getIsAsynchByDefault();
061:
062: /**
063: * Set the is default asynchronous replication mode flag
064: * @param flag - true for asynch by default
065: */
066: public void setIsAsynchByDefault(boolean flag);
067:
068: /**
069: * Returns a given InvalidationGroup instance that is associated with the group name.
070: * All caches that will share the same cache invalidation messages must share the
071: * same group name => the group name (or the IG) represents the identifier of
072: * a set of caches and invaliders.
073: * NOTE: InvalidationGroup.addReference is automatically called when calling this method
074: * Thus, there is no need to call it again on the IG. Nevertheless,
075: * you are still responsible for calling removeReference to GC IG.
076: * @param groupName Name of the group (of the cache for example).
077: * @return The InvalidationGroup associated to the group name i.e. the identifier of the set
078: */
079: public InvalidationGroup getInvalidationGroup(String groupName);
080:
081: /**
082: * Return the set of all InvalidationGroup currently managed by this IM
083: * @return A collection of InvalidationGroup instances
084: */
085: public Collection getInvalidationGroups();
086:
087: /**
088: * Allow the subscription of a given Bridge to this IM
089: * @param listener The Bridge registring for invalidation messages
090: * @return A BridgeInvalidationSubscription instance that can is used by the bridge
091: * to communicate with the local IM.
092: * @see BridgeInvalidationSubscription
093: */
094: public BridgeInvalidationSubscription registerBridgeListener(
095: InvalidationBridgeListener listener);
096:
097: /**
098: * Invalidate a set of IG managed by this IM. This can be used as an optimisation
099: * if a bridge will forward requests accross a cluster. In this case, a single message
100: * containing all invocations is send accross the wire (it only costs a single network
101: * latency). The IM will manage the dispatching of the invalidation messages to the
102: * Bridges and to the concerned InvalidationGroups.
103: * @param invalidations A set of BatchcInvalidations. Each BatchInvalidation instance contains invalidations
104: * for a given InvalidationGroup.
105: */
106:
107: public void batchInvalidate(BatchInvalidation[] invalidations);
108:
109: /**
110: * Identical as previous method. In this case though, it is override the default
111: * "asynchronous" tag of each InvalidationGroup and explicitly state if the invalidation
112: * messages should be, if possible, be done asynchronously (if implemented by the
113: * bridges for example).
114: * @param invalidations Invalidation messages
115: * @param asynchronous Indicates if the briges should try to do asynchronous invalidations (accross the
116: * network for example) or if a synchronous behaviour is required.
117: */
118: public void batchInvalidate(BatchInvalidation[] invalidations,
119: boolean asynchronous);
120:
121: /**
122: * Invalidate all entries for the specified group name.
123: * @param groupName invalidation group name
124: */
125: public void invalidateAll(String groupName);
126:
127: /**
128: * Invalidate all entries for the specified group name using the specified mode.
129: * @param groupName invalidate group name
130: * @param async mode
131: */
132: public void invalidateAll(String groupName, boolean async);
133: }
|