hadoop-zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maha...@apache.org
Subject svn commit: r761126 - in /hadoop/zookeeper/trunk: CHANGES.txt src/java/test/org/apache/zookeeper/test/FLENewEpochTest.java
Date Thu, 02 Apr 2009 00:35:57 GMT
Author: mahadev
Date: Thu Apr  2 00:35:57 2009
New Revision: 761126

URL: http://svn.apache.org/viewvc?rev=761126&view=rev
Log:
ZOOKEEPER-305.  Replace timers with semaphores in FLENewEpochTest. (flavio via mahadev)

Modified:
    hadoop/zookeeper/trunk/CHANGES.txt
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLENewEpochTest.java

Modified: hadoop/zookeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/CHANGES.txt?rev=761126&r1=761125&r2=761126&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/CHANGES.txt (original)
+++ hadoop/zookeeper/trunk/CHANGES.txt Thu Apr  2 00:35:57 2009
@@ -60,6 +60,9 @@
   ZOOKEEPER-349. to automate patch testing. (giridharan kesavan via mahadev)
 
   ZOOKEEPER-288. Cleanup and fixes to BookKeeper (flavio via mahadev)
+ 
+  ZOOKEEPER-305.  Replace timers with semaphores in FLENewEpochTest.
+(flavio via mahadev)
 
 NEW FEATURES:
 

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLENewEpochTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLENewEpochTest.java?rev=761126&r1=761125&r2=761126&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLENewEpochTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLENewEpochTest.java Thu
Apr  2 00:35:57 2009
@@ -22,6 +22,7 @@
 import java.net.InetSocketAddress;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.concurrent.Semaphore;
 
 import junit.framework.TestCase;
 
@@ -45,6 +46,9 @@
     int port[];
     volatile int [] round;
     
+    Semaphore start0;
+    Semaphore finish3;
+    
     @Override
     public void setUp() throws Exception {
         count = 3;
@@ -60,6 +64,10 @@
         round[0] = 0;
         round[1] = 0;
         round[2] = 0;
+        
+        start0 = new Semaphore(0);
+        finish3 = new Semaphore(0);
+        
         LOG.info("SetUp " + getName());
     }
 
@@ -115,9 +123,8 @@
             			LOG.info("Second entering case");
             			if(round[1] != 0) flag = false;
             			else{
-            				while(round[2] == 0){
-            					Thread.sleep(200);
-            				}
+            				finish3.acquire();
+            				start0.release();
             			}
             			LOG.info("Second is going to start second round");
             			round[1]++;
@@ -128,6 +135,7 @@
             			peer.shutdown();
             			flag = false;
             			round[2] = 1;
+            			finish3.release();
             			LOG.info("Third leaving");
             			break;
             		}
@@ -159,7 +167,8 @@
               thread.start();
               threads.add(thread);
           }
-          Thread.sleep(2000);
+          start0.acquire();
+
           QuorumPeer peer = new QuorumPeer(peers, tmpdir[0], tmpdir[0], port[0], 3, 0, 2,
2, 2);
           peer.startLeaderElection();
           LEThread thread = new LEThread(peer, 0);



Mime
View raw message