hadoop-zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maha...@apache.org
Subject svn commit: r789532 - in /hadoop/zookeeper/trunk: CHANGES.txt src/java/main/org/apache/zookeeper/server/PrepRequestProcessor.java src/java/test/org/apache/zookeeper/test/ClientBase.java src/java/test/org/apache/zookeeper/test/SessionTest.java
Date Tue, 30 Jun 2009 01:32:12 GMT
Author: mahadev
Date: Tue Jun 30 01:32:11 2009
New Revision: 789532

URL: http://svn.apache.org/viewvc?rev=789532&view=rev
Log:
ZOOKEEPER-450. emphemeral cleanup not happening with session timeout. (breed via mahadev)

Modified:
    hadoop/zookeeper/trunk/CHANGES.txt
    hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/PrepRequestProcessor.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ClientBase.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/SessionTest.java

Modified: hadoop/zookeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/CHANGES.txt?rev=789532&r1=789531&r2=789532&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/CHANGES.txt (original)
+++ hadoop/zookeeper/trunk/CHANGES.txt Tue Jun 30 01:32:11 2009
@@ -145,6 +145,9 @@
   ZOOKEEPER-452. zookeeper performance graph should have percentage of reads
 rather than percentage of writes - zkperfRW-3.2.jpg (mahadev)
 
+  ZOOKEEPER-450. emphemeral cleanup not happening with session timeout. (breed
+via mahadev)
+
 IMPROVEMENTS:
   ZOOKEEPER-308. improve the atomic broadcast performance 3x.
   (breed via mahadev)

Modified: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/PrepRequestProcessor.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/PrepRequestProcessor.java?rev=789532&r1=789531&r2=789532&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/PrepRequestProcessor.java
(original)
+++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/PrepRequestProcessor.java
Tue Jun 30 01:32:11 2009
@@ -361,7 +361,10 @@
             case OpCode.closeSession:
                 txnHeader = new TxnHeader(request.sessionId, request.cxid, zks
                         .getNextZxid(), zks.getTime(), OpCode.closeSession);
-                zks.sessionTracker.checkSession(request.sessionId, request.getOwner());
+                // We don't want to do this check since the session expiration thread
+                // queues up this operation without being the session owner.
+                // this request is the last of the session so it should be ok
+                //zks.sessionTracker.checkSession(request.sessionId, request.getOwner());
                 HashSet<String> es = zks.dataTree
                         .getEphemerals(request.sessionId);
                 synchronized (zks.outstandingChanges) {

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ClientBase.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ClientBase.java?rev=789532&r1=789531&r2=789532&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ClientBase.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ClientBase.java Tue Jun
30 01:32:11 2009
@@ -47,7 +47,7 @@
 public abstract class ClientBase extends TestCase {
     protected static final Logger LOG = Logger.getLogger(ClientBase.class);
 
-    public static final int CONNECTION_TIMEOUT = 30000;
+    public static int CONNECTION_TIMEOUT = 30000;
     static final File BASETEST =
         new File(System.getProperty("build.test.dir", "build"));
 

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/SessionTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/SessionTest.java?rev=789532&r1=789531&r2=789532&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/SessionTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/SessionTest.java Tue Jun
30 01:32:11 2009
@@ -50,11 +50,15 @@
     
     private CountDownLatch startSignal;
 
+    File tmpDir;
+    
     @Override
     protected void setUp() throws Exception {
         LOG.info("STARTING " + getName());
 
-        File tmpDir = ClientBase.createTmpDir();
+        if (tmpDir == null) {
+            tmpDir = ClientBase.createTmpDir();
+        }
 
         ClientBase.setupTestEnv();
         ZooKeeperServer zs = new ZooKeeperServer(tmpDir, tmpDir, 3000);
@@ -179,6 +183,35 @@
         zk.close();
     }
 
+    @Test
+    /**
+     * Make sure ephemerals get cleaned up when a session times out.
+     */
+    public void testSessionTimeout() throws Exception {
+        int oldTimeout = CONNECTION_TIMEOUT;
+        CONNECTION_TIMEOUT = 5000;
+        try {
+            DisconnectableZooKeeper zk = createClient();
+            zk.create("/stest", new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
+            zk.disconnect();
+            Thread.sleep(CONNECTION_TIMEOUT*2);
+            zk = createClient();
+            System.err.println("This test fails");
+            zk.create("/stest", new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
+            tearDown();
+            zk.close();
+            zk.disconnect();
+            setUp();
+            zk = createClient();
+            assertTrue(zk.exists("/stest", false) != null);
+            Thread.sleep(CONNECTION_TIMEOUT * 2);
+            assertTrue(zk.exists("/stest", false) == null);
+            zk.close();
+        } finally {
+            CONNECTION_TIMEOUT = oldTimeout;
+        }
+    }
+    
     /**
      * Make sure that we cannot have two connections with the same
      * session id.



Mime
View raw message