hadoop-zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ph...@apache.org
Subject svn commit: r1022642 [2/2] - in /hadoop/zookeeper/branches/ZOOKEEPER-823: ./ src/docs/src/documentation/content/xdocs/ src/java/main/org/apache/zookeeper/ src/java/main/org/apache/zookeeper/server/ src/java/test/config/ src/java/test/org/apache/zookeep...
Date Thu, 14 Oct 2010 18:45:49 GMT
Added: hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/ThreadUtil.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/ThreadUtil.java?rev=1022642&view=auto
==============================================================================
--- hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/ThreadUtil.java
(added)
+++ hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/ThreadUtil.java
Thu Oct 14 18:45:47 2010
@@ -0,0 +1,70 @@
+package org.apache.zookeeper;
+
+import java.lang.management.ManagementFactory;
+import java.lang.management.ThreadMXBean;
+import java.util.ArrayList;
+import java.util.List;
+
+public class ThreadUtil {
+
+    public static ThreadGroup getRootThreadGroup() {
+        ThreadGroup threadGroup = Thread.currentThread().getThreadGroup();
+        ThreadGroup parentThreadGroup;
+        while ( null != (parentThreadGroup = threadGroup.getParent()) ){
+            threadGroup = parentThreadGroup;          
+        }
+        return threadGroup;
+    }
+    
+    public static Thread[] getAllThreads() {
+        final ThreadGroup root = getRootThreadGroup();
+        int arraySize = ManagementFactory.getThreadMXBean().getThreadCount();
+        int returnedThreads = 0;
+        Thread[] threads;
+        do {
+            arraySize *= 2;
+            threads = new Thread[arraySize];
+            returnedThreads = root.enumerate( threads, true );
+        } while ( returnedThreads >= arraySize );
+        return java.util.Arrays.copyOf( threads, returnedThreads );
+    }
+    
+    public static List<Thread> getThreadsFiltered(String pattern) {
+        Thread[] allThreads = getAllThreads();
+        ArrayList<Thread> filteredThreads = new ArrayList<Thread>();
+        
+ 
+        for(int i=0;i<allThreads.length;++i){
+            Thread currentThread = allThreads[i];
+            if(currentThread.getName().contains(pattern)){
+                filteredThreads.add(currentThread);
+            }
+        }
+        return filteredThreads;
+    }
+    
+    public static List<Thread> getThreadsFiltered(String pattern, Thread exclude){
+        List<Thread> filteredThreads = getThreadsFiltered(pattern);
+        filteredThreads.remove(exclude);
+        return filteredThreads;
+    }
+    
+    public static String formatThread(Thread thread){
+        StringBuilder out = new StringBuilder();
+        out.append("Name: ")
+           .append(thread.getName())
+           .append(" State: ")
+           .append(thread.getState())
+           .append(" Prio: ")
+           .append(thread.getPriority())
+           .append("\nTrace:\n");
+        
+        StackTraceElement[] trace = thread.getStackTrace();
+        
+        for(int i=0;i<trace.length;++i){
+            out.append(trace[i]).append("\n");
+        }
+           
+        return out.toString();
+    }
+}

Modified: hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/test/AsyncHammerTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/test/AsyncHammerTest.java?rev=1022642&r1=1022641&r2=1022642&view=diff
==============================================================================
--- hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/test/AsyncHammerTest.java
(original)
+++ hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/test/AsyncHammerTest.java
Thu Oct 14 18:45:47 2010
@@ -181,7 +181,7 @@ public class AsyncHammerTest extends ZKT
         LOG.info("Stopping hammers");
         for (int i = 0; i < hammers.length; i++) {
             hammers[i].interrupt();
-            verifyThreadTerminated(hammers[i], 60000);
+            verifyThreadTerminated(hammers[i], i, 60000);
             Assert.assertFalse(hammers[i].failed);
         }
 
@@ -210,7 +210,7 @@ public class AsyncHammerTest extends ZKT
         bang = false;
         for (int i = 0; i < hammers.length; i++) {
             hammers[i].interrupt();
-            verifyThreadTerminated(hammers[i], 60000);
+            verifyThreadTerminated(hammers[i], i, 60000);
         }
         // before restart
         qb.verifyRootOfAllServersMatch(qb.hostPort);

Modified: hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/test/ClientBase.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/test/ClientBase.java?rev=1022642&r1=1022641&r2=1022642&view=diff
==============================================================================
--- hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/test/ClientBase.java
(original)
+++ hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/test/ClientBase.java
Thu Oct 14 18:45:47 2010
@@ -43,6 +43,7 @@ import org.apache.log4j.Priority;
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.PortAssignment;
 import org.apache.zookeeper.TestableZooKeeper;
+import org.apache.zookeeper.ThreadUtil;
 import org.apache.zookeeper.WatchedEvent;
 import org.apache.zookeeper.Watcher;
 import org.apache.zookeeper.Watcher.Event.KeeperState;
@@ -298,15 +299,27 @@ public abstract class ClientBase extends
         return false;
     }
 
-    static void verifyThreadTerminated(Thread thread, long millis)
+    static void verifyThreadTerminated(Thread thread, int index, long millis)
         throws InterruptedException
     {
+        long start = java.lang.System.currentTimeMillis();
         thread.join(millis);
+        long end = java.lang.System.currentTimeMillis();
         if (thread.isAlive()) {
-            LOG.error("Thread " + thread.getName() + " : "
-                    + Arrays.toString(thread.getStackTrace()));
-            Assert.assertFalse("thread " + thread.getName()
-                    + " still alive after join", true);
+            List<Thread> otherThreads = ThreadUtil.getThreadsFiltered(String.valueOf(index),
thread);
+            StringBuilder err = new StringBuilder();
+            err.append("Thread that did not join:\n")
+               .append(ThreadUtil.formatThread(thread))
+               .append("other Threads:\n");
+            for(Thread otherThread : otherThreads){
+                err.append(ThreadUtil.formatThread(otherThread));
+            }
+            
+            LOG.error(err);
+            Assert.fail("thread " + thread.getName()
+                    + " still alive after waiting "
+                    + (end - start)
+                    +" milliseconds for join");
         }
     }
 

Modified: hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/test/ClientHammerTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/test/ClientHammerTest.java?rev=1022642&r1=1022641&r2=1022642&view=diff
==============================================================================
--- hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/test/ClientHammerTest.java
(original)
+++ hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/test/ClientHammerTest.java
Thu Oct 14 18:45:47 2010
@@ -210,9 +210,10 @@ public class ClientHammerTest extends Cl
             LOG.info("Hammer threads completed creation operations");
         }
 
-        for (HammerThread h : threads) {
+        for (int i=0;i<threads.length;++i) {
+            HammerThread h = threads[i];
             final int safetyFactor = 3;
-            verifyThreadTerminated(h,
+            verifyThreadTerminated(h, i,
                     threads.length * childCount
                     * HAMMERTHREAD_LATENCY * safetyFactor);
         }

Modified: hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/test/ClientTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/test/ClientTest.java?rev=1022642&r1=1022641&r2=1022642&view=diff
==============================================================================
--- hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/test/ClientTest.java
(original)
+++ hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/test/ClientTest.java
Thu Oct 14 18:45:47 2010
@@ -32,15 +32,15 @@ import org.apache.log4j.Logger;
 import org.apache.log4j.Priority;
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.TestableZooKeeper;
-import org.apache.zookeeper.WatchedEvent;
-import org.apache.zookeeper.ZooKeeper;
 import org.apache.zookeeper.KeeperException.Code;
 import org.apache.zookeeper.KeeperException.InvalidACLException;
+import org.apache.zookeeper.TestableZooKeeper;
+import org.apache.zookeeper.WatchedEvent;
 import org.apache.zookeeper.Watcher.Event.EventType;
 import org.apache.zookeeper.Watcher.Event.KeeperState;
 import org.apache.zookeeper.ZooDefs.Ids;
 import org.apache.zookeeper.ZooDefs.Perms;
+import org.apache.zookeeper.ZooKeeper;
 import org.apache.zookeeper.data.ACL;
 import org.apache.zookeeper.data.Id;
 import org.apache.zookeeper.data.Stat;
@@ -726,6 +726,8 @@ public class ClientTest extends ClientBa
             Assert.assertTrue(threads[i].current == threads[i].count);
         }
 
+        long currentlyOpen = unixos.getOpenFileDescriptorCount();
+        LOG.info("initial:" + initialFdCount + " currentlyOpen:" + currentlyOpen);
         // if this Assert.fails it means we are not cleaning up after the closed
         // sessions.
         long currentCount = unixos.getOpenFileDescriptorCount();

Added: hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/test/NettyNettySuiteBase.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/test/NettyNettySuiteBase.java?rev=1022642&view=auto
==============================================================================
--- hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/test/NettyNettySuiteBase.java
(added)
+++ hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/test/NettyNettySuiteBase.java
Thu Oct 14 18:45:47 2010
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.zookeeper.test;
+
+import org.apache.zookeeper.ClientCnxnSocketNetty;
+import org.apache.zookeeper.ZooKeeper;
+import org.apache.zookeeper.server.NettyServerCnxnFactory;
+import org.apache.zookeeper.server.ServerCnxnFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * Run tests with: Netty Client against Netty server
+ */
+@RunWith(Suite.class)
+public class NettyNettySuiteBase {
+    @BeforeClass
+    public static void setUp() {
+        System.setProperty(ZooKeeper.ZOOKEEPER_CLIENT_CNXN_SOCKET,
+                ClientCnxnSocketNetty.class.getName());
+        System.setProperty(ServerCnxnFactory.ZOOKEEPER_SERVER_CNXN_FACTORY,
+                NettyServerCnxnFactory.class.getName());
+    }
+
+    @AfterClass
+    public static void tearDown() {
+        System.clearProperty(ZooKeeper.ZOOKEEPER_CLIENT_CNXN_SOCKET);
+        System.clearProperty(ServerCnxnFactory.ZOOKEEPER_SERVER_CNXN_FACTORY);
+    }
+}

Added: hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/test/NettyNettySuiteHammerTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/test/NettyNettySuiteHammerTest.java?rev=1022642&view=auto
==============================================================================
--- hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/test/NettyNettySuiteHammerTest.java
(added)
+++ hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/test/NettyNettySuiteHammerTest.java
Thu Oct 14 18:45:47 2010
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.zookeeper.test;
+
+import org.junit.runners.Suite;
+
+/**
+ * Run tests with: Netty Client against Netty server
+ */
+@Suite.SuiteClasses({
+        AsyncHammerTest.class
+        })
+public class NettyNettySuiteHammerTest extends NettyNettySuiteBase {
+}

Added: hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/test/NettyNettySuiteTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/test/NettyNettySuiteTest.java?rev=1022642&view=auto
==============================================================================
--- hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/test/NettyNettySuiteTest.java
(added)
+++ hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/test/NettyNettySuiteTest.java
Thu Oct 14 18:45:47 2010
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.zookeeper.test;
+
+import org.junit.runners.Suite;
+
+/**
+ * Run tests with: Netty Client against Netty server
+ */
+@Suite.SuiteClasses({
+        ACLTest.class,
+        AsyncOpsTest.class,
+        ChrootClientTest.class,
+        ClientTest.class,
+        FourLetterWordsTest.class,
+        NullDataTest.class,
+        SessionTest.class,
+        WatcherTest.class
+        })
+public class NettyNettySuiteTest extends NettyNettySuiteBase {
+}

Added: hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/test/NettyNioSuiteBase.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/test/NettyNioSuiteBase.java?rev=1022642&view=auto
==============================================================================
--- hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/test/NettyNioSuiteBase.java
(added)
+++ hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/test/NettyNioSuiteBase.java
Thu Oct 14 18:45:47 2010
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.zookeeper.test;
+
+import org.apache.zookeeper.ClientCnxnSocketNIO;
+import org.apache.zookeeper.ZooKeeper;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * Run tests with: Netty Client against Nio server
+ */
+@RunWith(Suite.class)
+public class NettyNioSuiteBase {
+    @BeforeClass
+    public static void setUp() {
+        System.setProperty(ZooKeeper.ZOOKEEPER_CLIENT_CNXN_SOCKET,
+                ClientCnxnSocketNIO.class.getName());
+    }
+
+    @AfterClass
+    public static void tearDown() {
+        System.clearProperty(ZooKeeper.ZOOKEEPER_CLIENT_CNXN_SOCKET);
+    }
+}

Added: hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/test/NettyNioSuiteHammerTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/test/NettyNioSuiteHammerTest.java?rev=1022642&view=auto
==============================================================================
--- hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/test/NettyNioSuiteHammerTest.java
(added)
+++ hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/test/NettyNioSuiteHammerTest.java
Thu Oct 14 18:45:47 2010
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.zookeeper.test;
+
+import org.junit.runners.Suite;
+
+/**
+ * Run tests with: Netty Client against Nio server
+ */
+@Suite.SuiteClasses({
+        AsyncHammerTest.class
+        })
+public class NettyNioSuiteHammerTest extends NettyNioSuiteBase {
+}

Added: hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/test/NettyNioSuiteTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/test/NettyNioSuiteTest.java?rev=1022642&view=auto
==============================================================================
--- hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/test/NettyNioSuiteTest.java
(added)
+++ hadoop/zookeeper/branches/ZOOKEEPER-823/src/java/test/org/apache/zookeeper/test/NettyNioSuiteTest.java
Thu Oct 14 18:45:47 2010
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.zookeeper.test;
+
+import org.junit.runners.Suite;
+
+/**
+ * Run tests with: Netty Client against Nio server
+ */
+@Suite.SuiteClasses({
+        ACLTest.class,
+        AsyncOpsTest.class,
+        ChrootClientTest.class,
+        ClientTest.class,
+        FourLetterWordsTest.class,
+        NullDataTest.class,
+        SessionTest.class,
+        WatcherTest.class
+        })
+public class NettyNioSuiteTest extends NettyNioSuiteBase {
+}



Mime
View raw message