activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r679329 - in /activemq/sandbox/zookeeper/zookeeper-protocols/src: main/java/org/apache/zookeeper/protocols/WriteLock.java test/java/org/apache/zookeeper/protocols/WriteLockTest.java
Date Thu, 24 Jul 2008 09:40:45 GMT
Author: jstrachan
Date: Thu Jul 24 02:40:43 2008
New Revision: 679329

URL: http://svn.apache.org/viewvc?rev=679329&view=rev
Log:
made the WhenOwnerListener mandatory for use of the WriteLock as any leader has to know when
it is no longer the leader and act accordingly

Modified:
    activemq/sandbox/zookeeper/zookeeper-protocols/src/main/java/org/apache/zookeeper/protocols/WriteLock.java
    activemq/sandbox/zookeeper/zookeeper-protocols/src/test/java/org/apache/zookeeper/protocols/WriteLockTest.java

Modified: activemq/sandbox/zookeeper/zookeeper-protocols/src/main/java/org/apache/zookeeper/protocols/WriteLock.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/zookeeper/zookeeper-protocols/src/main/java/org/apache/zookeeper/protocols/WriteLock.java?rev=679329&r1=679328&r2=679329&view=diff
==============================================================================
--- activemq/sandbox/zookeeper/zookeeper-protocols/src/main/java/org/apache/zookeeper/protocols/WriteLock.java
(original)
+++ activemq/sandbox/zookeeper/zookeeper-protocols/src/main/java/org/apache/zookeeper/protocols/WriteLock.java
Thu Jul 24 02:40:43 2008
@@ -48,12 +48,7 @@
     private String ownerId;
     private String lastChildId;
     private byte[] data = {0x12, 0x34};
-    private WhenOwnerListener whenOwnerListener;
-
-    public WriteLock(ZooKeeperFacade zookeeper, String dir) {
-        super(zookeeper);
-        this.dir = dir;
-    }
+    private final WhenOwnerListener whenOwnerListener;
 
     public WriteLock(ZooKeeperFacade zookeeper, String dir, WhenOwnerListener whenOwnerListener)
{
         super(zookeeper);
@@ -212,12 +207,6 @@
         return whenOwnerListener;
     }
 
-    /**
-     * Allows a WhenOwnerListener to be associated when this node becomes the owner of the
lock
-     */
-    public void setWhenOwnerListener(WhenOwnerListener whenOwnerListener) {
-        this.whenOwnerListener = whenOwnerListener;
-    }
 
     // Implementation methods
     //-------------------------------------------------------------------------

Modified: activemq/sandbox/zookeeper/zookeeper-protocols/src/test/java/org/apache/zookeeper/protocols/WriteLockTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/zookeeper/zookeeper-protocols/src/test/java/org/apache/zookeeper/protocols/WriteLockTest.java?rev=679329&r1=679328&r2=679329&view=diff
==============================================================================
--- activemq/sandbox/zookeeper/zookeeper-protocols/src/test/java/org/apache/zookeeper/protocols/WriteLockTest.java
(original)
+++ activemq/sandbox/zookeeper/zookeeper-protocols/src/test/java/org/apache/zookeeper/protocols/WriteLockTest.java
Thu Jul 24 02:40:43 2008
@@ -53,8 +53,7 @@
                     LOG.info("ZooKeeper Event for znode: " + nodeId + " on path: " + event.getPath()
+ " state: " + event.getState() + " type: " + event.getType());
                 }
             });
-            WriteLock leader = new WriteLock(keeper, dir);
-            leader.setWhenOwnerListener(new WhenOwnerListener() {
+            WriteLock leader = new WriteLock(keeper, dir, new WhenOwnerListener() {
                 public void whenOwner() {
                     latch.countDown();
                 }



Mime
View raw message