[jboss-cvs] JBossCache/src/org/jboss/cache/buddyreplication ...
Manik Surtani
manik at jboss.org
Thu Jun 28 12:53:36 EDT 2007
User: msurtani
Date: 07/06/28 12:53:36
Modified: src/org/jboss/cache/buddyreplication BuddyManager.java
Log:
Notification changes
Revision Changes Path
1.84 +33 -26 JBossCache/src/org/jboss/cache/buddyreplication/BuddyManager.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: BuddyManager.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/buddyreplication/BuddyManager.java,v
retrieving revision 1.83
retrieving revision 1.84
diff -u -b -r1.83 -r1.84
--- BuddyManager.java 26 Jun 2007 17:39:30 -0000 1.83
+++ BuddyManager.java 28 Jun 2007 16:53:36 -0000 1.84
@@ -8,10 +8,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.AbstractCacheListener;
import org.jboss.cache.CacheException;
import org.jboss.cache.CacheImpl;
-import org.jboss.cache.CacheListener;
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
import org.jboss.cache.config.BuddyReplicationConfig;
@@ -20,6 +18,9 @@
import org.jboss.cache.marshall.MethodCall;
import org.jboss.cache.marshall.MethodCallFactory;
import org.jboss.cache.marshall.MethodDeclarations;
+import org.jboss.cache.notifications.annotation.CacheListener;
+import org.jboss.cache.notifications.annotation.ViewChanged;
+import org.jboss.cache.notifications.event.ViewChangedEvent;
import org.jboss.cache.statetransfer.StateTransferManager;
import org.jboss.cache.util.ExposedByteArrayOutputStream;
import org.jboss.cache.util.concurrent.ConcurrentHashSet;
@@ -128,7 +129,7 @@
// threads to exit gracefully when the BuddyManager has been stopped.
private static final MembershipChange STOP_NOTIFIER = new MembershipChange(null, null);
- private CacheListener viewChangeListener; // the view-change viewChangeListener
+ private ViewChangeListener viewChangeListener; // the view-change viewChangeListener
public BuddyManager(BuddyReplicationConfig config)
{
@@ -226,30 +227,8 @@
initialisationLatch.countDown();
// register a CacheImpl Listener to reassign buddies as and when view changes occur
- viewChangeListener = new AbstractCacheListener()
- {
- private Vector<Address> oldMembers;
+ viewChangeListener = new ViewChangeListener();
- public void viewChange(View newView)
- {
- if (log.isTraceEnabled())
- log.trace("BuddyManager CacheListener - got view change with new view " + newView);
- Vector<Address> newMembers = newView.getMembers();
-
- // the whole 'oldMembers' concept is only used for buddy pool announcements.
- if (config.getBuddyPoolName() == null)
- {
- enqueueViewChange(null, newMembers);
- }
- else
- {
- enqueueViewChange(oldMembers == null ? null : new Vector<Address>(oldMembers), new Vector<Address>(newMembers));
- if (oldMembers == null) oldMembers = new Vector<Address>();
- oldMembers.clear();
- oldMembers.addAll(newMembers);
- }
- }
- };
cache.addCacheListener(viewChangeListener);
// assign buddies based on what we know now
@@ -1127,4 +1106,32 @@
if (t != null) t.interrupt();
}
}
+
+ @CacheListener
+ private class ViewChangeListener
+ {
+ private Vector<Address> oldMembers;
+
+ @ViewChanged
+ public void handleViewChange(ViewChangedEvent event)
+ {
+ View newView = event.getNewView();
+ if (log.isTraceEnabled())
+ log.trace("BuddyManager CacheListener - got view change with new view " + newView);
+ Vector<Address> newMembers = newView.getMembers();
+
+ // the whole 'oldMembers' concept is only used for buddy pool announcements.
+ if (config.getBuddyPoolName() == null)
+ {
+ enqueueViewChange(null, newMembers);
+ }
+ else
+ {
+ enqueueViewChange(oldMembers == null ? null : new Vector<Address>(oldMembers), new Vector<Address>(newMembers));
+ if (oldMembers == null) oldMembers = new Vector<Address>();
+ oldMembers.clear();
+ oldMembers.addAll(newMembers);
+ }
+ }
+ }
}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list