Author: phunt
Date: Tue Jul 15 16:49:31 2008
New Revision: 677109
URL: http://svn.apache.org/viewvc?rev=677109&view=rev
Log:
Fixed ZOOKEEPER-75, addressed some license issues and also removed the cobertura library (gpl). Moved from junit 4.1 to junit 4.4 at the same time (tests still pass).
Added:
hadoop/zookeeper/trunk/src/java/lib/cobertura/README.txt (with props)
hadoop/zookeeper/trunk/src/java/lib/junit-4.4.LICENSE.txt (with props)
hadoop/zookeeper/trunk/src/java/lib/junit-4.4.jar (with props)
hadoop/zookeeper/trunk/src/java/lib/log4j-1.2.15.LICENSE.txt
- copied unchanged from r677081, hadoop/zookeeper/trunk/src/java/lib/log4j-LICENSE
hadoop/zookeeper/trunk/src/java/lib/log4j-1.2.15.NOTICE.txt
- copied unchanged from r677081, hadoop/zookeeper/trunk/src/java/lib/log4j-NOTICE
hadoop/zookeeper/trunk/src/java/lib/svnant/README.txt
- copied unchanged from r677081, hadoop/zookeeper/trunk/src/java/lib/README.svnant
hadoop/zookeeper/trunk/src/java/lib/svnant/ganymed.LICENSE.txt
- copied unchanged from r677081, hadoop/zookeeper/trunk/src/java/lib/svnant/GANYMED-LICENSE
hadoop/zookeeper/trunk/src/java/lib/svnant/javasvn.LICENSE.txt
- copied unchanged from r677081, hadoop/zookeeper/trunk/src/java/lib/svnant/JAVASVN-LICENSE
hadoop/zookeeper/trunk/src/java/lib/svnant/svnClientAdapter.LICENSE.txt
- copied unchanged from r677081, hadoop/zookeeper/trunk/src/java/lib/svnant/SVNCLIENTADAPTER-LICENSE
hadoop/zookeeper/trunk/src/java/lib/svnant/svnant.LICENSE.txt
- copied unchanged from r677081, hadoop/zookeeper/trunk/src/java/lib/svnant/license.txt
hadoop/zookeeper/trunk/src/java/lib/svnant/svnjavahl.LICENSE.txt (with props)
Removed:
hadoop/zookeeper/trunk/src/java/lib/README.svnant
hadoop/zookeeper/trunk/src/java/lib/cobertura/cobertura.jar
hadoop/zookeeper/trunk/src/java/lib/cobertura/lib/
hadoop/zookeeper/trunk/src/java/lib/junit-4.1.jar
hadoop/zookeeper/trunk/src/java/lib/log4j-LICENSE
hadoop/zookeeper/trunk/src/java/lib/log4j-NOTICE
hadoop/zookeeper/trunk/src/java/lib/svnant/GANYMED-LICENSE
hadoop/zookeeper/trunk/src/java/lib/svnant/JAVAHL-LICENSE
hadoop/zookeeper/trunk/src/java/lib/svnant/JAVASVN-LICENSE
hadoop/zookeeper/trunk/src/java/lib/svnant/SVNCLIENTADAPTER-LICENSE
hadoop/zookeeper/trunk/src/java/lib/svnant/license.txt
Modified:
hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/Election.java
hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/DeserializationPerfTest.java
hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/SerializationPerfTest.java
hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/ZooKeeperServerTest.java
hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/AsyncTest.java
hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ClientBase.java
hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ClientTest.java
hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/DataTreeTest.java
hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/GenerateLoad.java
hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/IntegrityCheck.java
hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/OOMTest.java
hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumTest.java
hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/RecoveryTest.java
hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/SessionTest.java
hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/SledgeHammer.java
hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/TestHammer.java
hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/WatcherFuncTest.java
hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ZooKeeperTestClient.java
hadoop/zookeeper/trunk/src/zookeeper.jute
Added: hadoop/zookeeper/trunk/src/java/lib/cobertura/README.txt
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/lib/cobertura/README.txt?rev=677109&view=auto
==============================================================================
--- hadoop/zookeeper/trunk/src/java/lib/cobertura/README.txt (added)
+++ hadoop/zookeeper/trunk/src/java/lib/cobertura/README.txt Tue Jul 15 16:49:31 2008
@@ -0,0 +1,3 @@
+Download the cobertura binary from the following location and unpack it into this directory. Run "cobertura-report" target from build.xml to generate coverage report.
+
+http://cobertura.sourceforge.net/download.html
Propchange: hadoop/zookeeper/trunk/src/java/lib/cobertura/README.txt
------------------------------------------------------------------------------
svn:eol-style = native
Added: hadoop/zookeeper/trunk/src/java/lib/junit-4.4.LICENSE.txt
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/lib/junit-4.4.LICENSE.txt?rev=677109&view=auto
==============================================================================
--- hadoop/zookeeper/trunk/src/java/lib/junit-4.4.LICENSE.txt (added)
+++ hadoop/zookeeper/trunk/src/java/lib/junit-4.4.LICENSE.txt Tue Jul 15 16:49:31 2008
@@ -0,0 +1,27 @@
+BSD License
+
+Copyright (c) 2000-2006, www.hamcrest.org
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of
+conditions and the following disclaimer. Redistributions in binary form must reproduce
+the above copyright notice, this list of conditions and the following disclaimer in
+the documentation and/or other materials provided with the distribution.
+
+Neither the name of Hamcrest nor the names of its contributors may be used to endorse
+or promote products derived from this software without specific prior written
+permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
+WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGE.
Propchange: hadoop/zookeeper/trunk/src/java/lib/junit-4.4.LICENSE.txt
------------------------------------------------------------------------------
svn:eol-style = native
Added: hadoop/zookeeper/trunk/src/java/lib/junit-4.4.jar
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/lib/junit-4.4.jar?rev=677109&view=auto
==============================================================================
Binary file - no diff available.
Propchange: hadoop/zookeeper/trunk/src/java/lib/junit-4.4.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: hadoop/zookeeper/trunk/src/java/lib/svnant/svnjavahl.LICENSE.txt
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/lib/svnant/svnjavahl.LICENSE.txt?rev=677109&view=auto
==============================================================================
--- hadoop/zookeeper/trunk/src/java/lib/svnant/svnjavahl.LICENSE.txt (added)
+++ hadoop/zookeeper/trunk/src/java/lib/svnant/svnjavahl.LICENSE.txt Tue Jul 15 16:49:31 2008
@@ -0,0 +1,55 @@
+This license applies to all portions of Subversion which are not
+externally-maintained libraries (e.g. apr/, apr-util/, and neon/).
+Such libraries have their own licenses; we recommend you read them, as
+their terms may differ from the terms below.
+
+This is version 1 of this license. It is also available online at
+http://subversion.tigris.org/license-1.html. If newer versions of
+this license are posted there (the same URL, but with the version
+number incremented: .../license-2.html, .../license-3.html, and so
+on), you may use a newer version instead, at your option.
+
+====================================================================
+Copyright (c) 2000-2005 CollabNet. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+1. Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+
+3. The end-user documentation included with the redistribution, if
+any, must include the following acknowledgment: "This product includes
+software developed by CollabNet (http://www.Collab.Net/)."
+Alternately, this acknowledgment may appear in the software itself, if
+and wherever such third-party acknowledgments normally appear.
+
+4. The hosted project names must not be used to endorse or promote
+products derived from this software without prior written
+permission. For written permission, please contact info@collab.net.
+
+5. Products derived from this software may not use the "Tigris" name
+nor may "Tigris" appear in their names without prior written
+permission of CollabNet.
+
+THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL COLLABNET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+====================================================================
+
+This software consists of voluntary contributions made by many
+individuals on behalf of CollabNet.
+
Propchange: hadoop/zookeeper/trunk/src/java/lib/svnant/svnjavahl.LICENSE.txt
------------------------------------------------------------------------------
svn:eol-style = native
Modified: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/Election.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/Election.java?rev=677109&r1=677108&r2=677109&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/Election.java (original)
+++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/Election.java Tue Jul 15 16:49:31 2008
@@ -1,3 +1,21 @@
+/**
+ * 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.server.quorum;
Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/DeserializationPerfTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/DeserializationPerfTest.java?rev=677109&r1=677108&r2=677109&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/DeserializationPerfTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/DeserializationPerfTest.java Tue Jul 15 16:49:31 2008
@@ -1,3 +1,21 @@
+/**
+ * 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.server;
import java.io.ByteArrayInputStream;
@@ -24,7 +42,7 @@
BinaryOutputArchive oa = BinaryOutputArchive.getArchive(baos);
tree.serialize(oa, "test");
baos.flush();
-
+
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
ia = BinaryInputArchive.getArchive(bais);
}
@@ -37,9 +55,9 @@
long end = System.nanoTime();
long durationms = (end - start) / 1000000L;
long pernodeus = ((end - start) / 1000L) / count;
-
+
assertEquals(count, dserTree.getNodeCount());
-
+
System.out.println("Deserialized " + count + " nodes in " + durationms
+ " ms (" + pernodeus + "us/node), depth=" + depth + " width="
+ width + " datalen=" + len);
Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/SerializationPerfTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/SerializationPerfTest.java?rev=677109&r1=677108&r2=677109&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/SerializationPerfTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/SerializationPerfTest.java Tue Jul 15 16:49:31 2008
@@ -1,3 +1,21 @@
+/**
+ * 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.server;
import java.io.IOException;
@@ -22,14 +40,14 @@
if (--depth == 0) {
return 1;
}
-
+
path += "/";
-
+
int count = 1;
for (int i = 0; i < childcount; i++) {
count += createNodes(tree, path + i, depth, childcount, data);
}
-
+
return count;
}
@@ -38,8 +56,8 @@
DataTree tree = new DataTree();
createNodes(tree, "/", depth, width, new byte[len]);
int count = tree.getNodeCount();
-
- BinaryOutputArchive oa =
+
+ BinaryOutputArchive oa =
BinaryOutputArchive.getArchive(new NullOutputStream());
System.gc();
long start = System.nanoTime();
@@ -48,7 +66,7 @@
long durationms = (end - start)/1000000L;
long pernodeus = ((end - start)/1000L)/count;
System.out.println("Serialized " + count + " nodes in "
- + durationms + " ms (" + pernodeus + "us/node), depth="
+ + durationms + " ms (" + pernodeus + "us/node), depth="
+ depth + " width=" + width + " datalen=" + len);
}
@@ -66,7 +84,7 @@
throws InterruptedException, IOException, KeeperException.NodeExistsException, KeeperException.NoNodeException {
serializeTree(1000, 1, 20);
}
-
+
public void test10Wide5DeepSerialize()
throws InterruptedException, IOException, KeeperException.NodeExistsException, KeeperException.NoNodeException {
serializeTree(5, 10, 20);
Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/ZooKeeperServerTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/ZooKeeperServerTest.java?rev=677109&r1=677108&r2=677109&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/ZooKeeperServerTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/ZooKeeperServerTest.java Tue Jul 15 16:49:31 2008
@@ -1,3 +1,21 @@
+/**
+ * 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.server;
import java.io.File;
@@ -8,17 +26,17 @@
public class ZooKeeperServerTest extends TestCase {
public void testSortDataDirAscending() {
File[] files = new File[5];
-
+
files[0] = new File("foo.10027c6de");
files[1] = new File("foo.10027c6df");
files[2] = new File("bar.10027c6dd");
files[3] = new File("foo.10027c6dc");
files[4] = new File("foo.20027c6dc");
-
+
File[] orig = files.clone();
List<File> filelist = ZooKeeperServer.sortDataDir(files, "foo", true);
-
+
assertEquals(orig[2], filelist.get(0));
assertEquals(orig[3], filelist.get(1));
assertEquals(orig[0], filelist.get(2));
@@ -28,7 +46,7 @@
public void testSortDataDirDescending() {
File[] files = new File[5];
-
+
files[0] = new File("foo.10027c6de");
files[1] = new File("foo.10027c6df");
files[2] = new File("bar.10027c6dd");
@@ -38,17 +56,17 @@
File[] orig = files.clone();
List<File> filelist = ZooKeeperServer.sortDataDir(files, "foo", false);
-
+
assertEquals(orig[4], filelist.get(0));
assertEquals(orig[1], filelist.get(1));
assertEquals(orig[0], filelist.get(2));
assertEquals(orig[3], filelist.get(3));
assertEquals(orig[2], filelist.get(4));
}
-
+
public void testGetLogFiles() {
File[] files = new File[5];
-
+
files[0] = new File("log.10027c6de");
files[1] = new File("log.10027c6df");
files[2] = new File("snapshot.10027c6dd");
@@ -57,10 +75,10 @@
File[] orig = files.clone();
- File[] filelist =
+ File[] filelist =
ZooKeeperServer.getLogFiles(files,
Long.parseLong("10027c6de", 16));
-
+
assertEquals(3, filelist.length);
assertEquals(orig[0], filelist[0]);
assertEquals(orig[1], filelist[1]);
Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/AsyncTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/AsyncTest.java?rev=677109&r1=677108&r2=677109&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/AsyncTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/AsyncTest.java Tue Jul 15 16:49:31 2008
@@ -1,3 +1,21 @@
+/**
+ * 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 java.io.File;
@@ -47,29 +65,29 @@
protected void restart() throws Exception {
qt.startServers();
}
-
+
@After
protected void tearDown() throws Exception {
qt.tearDown();
- LOG.error("Client test shutdown");
+ LOG.error("Client test shutdown");
if (f != null) {
f.shutdown();
}
clientConnected=null;
LOG.error("Client test shutdown finished");
}
-
+
private ZooKeeper createClient() throws IOException,InterruptedException{
clientConnected=new CountDownLatch(1);
- ZooKeeper zk = new ZooKeeper(hostPort, 30000, this);
- if(!clientConnected.await(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS)){
- fail("Unable to connect to server");
- }
- return zk;
+ ZooKeeper zk = new ZooKeeper(hostPort, 30000, this);
+ if(!clientConnected.await(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS)){
+ fail("Unable to connect to server");
+ }
+ return zk;
}
boolean bang;
-
+
class HammerThread extends Thread implements Watcher, StringCallback, VoidCallback {
ZooKeeper zk;
public void run() {
@@ -110,78 +128,78 @@
public void processResult(int rc, String path, Object ctx) {
}
}
-
+
@Test
public void testHammer() throws Exception {
- Thread.sleep(1000);
- bang = true;
- for (int i = 0; i < 100; i++) {
- new HammerThread().start();
- }
- Thread.sleep(5000);
- tearDown();
- bang = false;
- restart();
- Thread.sleep(5000);
- String parts[] = hostPort.split(",");
- String prevList[] = null;
- for (String hp : parts) {
- ZooKeeper zk = createClient();
- String list[] = zk.getChildren("/", false).toArray(new String[0]);
- if (prevList != null) {
- assertEquals(prevList.length, list.length);
- for (int i = 0; i < list.length; i++) {
- assertEquals(prevList[i], list[i]);
- }
- }
- prevList = list;
- }
- }
-
+ Thread.sleep(1000);
+ bang = true;
+ for (int i = 0; i < 100; i++) {
+ new HammerThread().start();
+ }
+ Thread.sleep(5000);
+ tearDown();
+ bang = false;
+ restart();
+ Thread.sleep(5000);
+ String parts[] = hostPort.split(",");
+ String prevList[] = null;
+ for (String hp : parts) {
+ ZooKeeper zk = createClient();
+ String list[] = zk.getChildren("/", false).toArray(new String[0]);
+ if (prevList != null) {
+ assertEquals(prevList.length, list.length);
+ for (int i = 0; i < list.length; i++) {
+ assertEquals(prevList[i], list[i]);
+ }
+ }
+ prevList = list;
+ }
+ }
+
LinkedList<Integer> results = new LinkedList<Integer>();
@Test
public void testAsync() throws IOException,
InterruptedException, KeeperException {
- ZooKeeper zk = null;
- zk = createClient();
- zk.addAuthInfo("digest", "ben:passwd".getBytes());
- zk.create("/ben", new byte[0], Ids.READ_ACL_UNSAFE, 0, this, results);
- zk.create("/ben/2", new byte[0], Ids.CREATOR_ALL_ACL, 0, this, results);
- zk.delete("/ben", -1, this, results);
- zk.create("/ben2", new byte[0], Ids.CREATOR_ALL_ACL, 0, this, results);
- zk.getData("/ben2", false, this, results);
- synchronized (results) {
- while (results.size() < 5) {
- results.wait();
- }
- }
- assertEquals(0, (int) results.get(0));
- assertEquals(Code.NoAuth, (int) results.get(1));
- assertEquals(0, (int) results.get(2));
- assertEquals(0, (int) results.get(3));
- assertEquals(0, (int) results.get(4));
- zk.close();
-
- zk =createClient();
- zk.addAuthInfo("digest", "ben:passwd2".getBytes());
- try {
- zk.getData("/ben2", false, new Stat());
- fail("Should have received a permission error");
- } catch (KeeperException e) {
- assertEquals(Code.NoAuth, e.getCode());
- }
- zk.close();
-
- zk =createClient();
- zk.addAuthInfo("digest", "ben:passwd".getBytes());
- zk.getData("/ben2", false, new Stat());
- zk.close();
- }
+ ZooKeeper zk = null;
+ zk = createClient();
+ zk.addAuthInfo("digest", "ben:passwd".getBytes());
+ zk.create("/ben", new byte[0], Ids.READ_ACL_UNSAFE, 0, this, results);
+ zk.create("/ben/2", new byte[0], Ids.CREATOR_ALL_ACL, 0, this, results);
+ zk.delete("/ben", -1, this, results);
+ zk.create("/ben2", new byte[0], Ids.CREATOR_ALL_ACL, 0, this, results);
+ zk.getData("/ben2", false, this, results);
+ synchronized (results) {
+ while (results.size() < 5) {
+ results.wait();
+ }
+ }
+ assertEquals(0, (int) results.get(0));
+ assertEquals(Code.NoAuth, (int) results.get(1));
+ assertEquals(0, (int) results.get(2));
+ assertEquals(0, (int) results.get(3));
+ assertEquals(0, (int) results.get(4));
+ zk.close();
+
+ zk =createClient();
+ zk.addAuthInfo("digest", "ben:passwd2".getBytes());
+ try {
+ zk.getData("/ben2", false, new Stat());
+ fail("Should have received a permission error");
+ } catch (KeeperException e) {
+ assertEquals(Code.NoAuth, e.getCode());
+ }
+ zk.close();
+
+ zk =createClient();
+ zk.addAuthInfo("digest", "ben:passwd".getBytes());
+ zk.getData("/ben2", false, new Stat());
+ zk.close();
+ }
public void process(WatcherEvent event) {
- if(event.getState()==Event.KeeperStateSyncConnected){
- clientConnected.countDown();
- }
+ if(event.getState()==Event.KeeperStateSyncConnected){
+ clientConnected.countDown();
+ }
}
public void processResult(int rc, String path, Object ctx, String name) {
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=677109&r1=677108&r2=677109&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 Jul 15 16:49:31 2008
@@ -1,3 +1,21 @@
+/**
+ * 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 java.io.File;
@@ -21,7 +39,7 @@
protected static final int CONNECTION_TIMEOUT = 30000;
protected NIOServerCnxn.Factory f = null;
protected File tmpDir = null;
- protected static File baseTest =
+ protected static File baseTest =
new File(System.getProperty("build.test.dir", "build"));
public ClientBase() {
@@ -56,7 +74,7 @@
ServerStats.unregister();
LOG.info("Client test shutdown finished");
}
-
+
private static void recursiveDelete(File d) {
if (d.isDirectory()) {
File children[] = d.listFiles();
Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ClientTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ClientTest.java?rev=677109&r1=677108&r2=677109&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ClientTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ClientTest.java Tue Jul 15 16:49:31 2008
@@ -1,3 +1,21 @@
+/**
+ * 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 java.io.File;
@@ -19,23 +37,23 @@
import org.apache.zookeeper.ZooDefs.Ids;
import org.apache.zookeeper.data.Stat;
import org.apache.zookeeper.proto.WatcherEvent;
-
+
public class ClientTest extends ClientBase implements Watcher {
- LinkedBlockingQueue<WatcherEvent> events =
+ LinkedBlockingQueue<WatcherEvent> events =
new LinkedBlockingQueue<WatcherEvent>();
protected volatile CountDownLatch clientConnected;
- protected ZooKeeper createClient(Watcher watcher)
+ protected ZooKeeper createClient(Watcher watcher)
throws IOException, InterruptedException
{
clientConnected=new CountDownLatch(1);
ZooKeeper zk = new ZooKeeper(hostPort, 20000, watcher);
- if(!clientConnected.await(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS)){
- fail("Unable to connect to server");
- }
- return zk;
+ if(!clientConnected.await(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS)){
+ fail("Unable to connect to server");
+ }
+ return zk;
}
-
+
protected void tearDown() throws Exception {
clientConnected = null;
super.tearDown();
@@ -88,14 +106,14 @@
InterruptedException, KeeperException {
ZooKeeper zk = null;
try {
- zk =createClient(this);
+ zk =createClient(this);
//System.out.println("Created client: " + zk.describeCNXN());
System.out.println("Before create /benwashere");
zk.create("/benwashere", "".getBytes(), Ids.OPEN_ACL_UNSAFE, 0);
System.out.println("After create /benwashere");
try {
- zk.setData("/benwashere", "hi".getBytes(), 57);
- fail("Should have gotten BadVersion exception");
+ zk.setData("/benwashere", "hi".getBytes(), 57);
+ fail("Should have gotten BadVersion exception");
} catch(KeeperException.BadVersionException e) {
// expected that
} catch (KeeperException e) {
@@ -110,7 +128,7 @@
zk = createClient(this);
//System.out.println("Created a new client: " + zk.describeCNXN());
System.out.println("Before delete /");
-
+
try {
zk.delete("/", -1);
fail("deleted root!");
@@ -194,7 +212,7 @@
//} catch(KeeperException e) {
// assertEquals(KeeperException.Code.BadArguments, e.getCode());
//}
-
+
zk.create("/duplicate", "".getBytes(), Ids.OPEN_ACL_UNSAFE, 0);
try {
zk.create("/duplicate", "".getBytes(), Ids.OPEN_ACL_UNSAFE, 0);
@@ -301,12 +319,12 @@
LOG.error("******************* Connected to ZooKeeper" + new Date());
for (int i = 0; i < threadCount; i++) {
System.err.println("Doing thread: " + i + " " + new Date());
- List<String> children =
+ List<String> children =
zk.getChildren("/test-" + i, false);
assertEquals(childCount, children.size());
}
for (int i = 0; i < threadCount; i++) {
- List<String> children =
+ List<String> children =
zk.getChildren("/test-" + i, false);
assertEquals(childCount, children.size());
}
@@ -322,15 +340,15 @@
}
public void process(WatcherEvent event) {
- if (event.getState() == Event.KeeperStateSyncConnected) {
- clientConnected.countDown();
- }
- if (event.getType() != Event.EventNone) {
- try {
- events.put(event);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
+ if (event.getState() == Event.KeeperStateSyncConnected) {
+ clientConnected.countDown();
+ }
+ if (event.getType() != Event.EventNone) {
+ try {
+ events.put(event);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
}
Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/DataTreeTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/DataTreeTest.java?rev=677109&r1=677108&r2=677109&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/DataTreeTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/DataTreeTest.java Tue Jul 15 16:49:31 2008
@@ -15,6 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.apache.zookeeper.test;
import static org.junit.Assert.*;
@@ -31,7 +32,7 @@
public class DataTreeTest extends TestCase {
DataTree dt;
-
+
public void setUp() throws Exception {
dt=new DataTree();
}
@@ -40,7 +41,7 @@
dt=null;
}
-
+
public void testRootWatchTriggered() throws Exception {
class MyWatcher implements Watcher{
boolean fired=false;
Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/GenerateLoad.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/GenerateLoad.java?rev=677109&r1=677108&r2=677109&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/GenerateLoad.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/GenerateLoad.java Tue Jul 15 16:49:31 2008
@@ -1,3 +1,21 @@
+/**
+ * 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 java.io.BufferedReader;
@@ -31,7 +49,7 @@
public class GenerateLoad {
static ServerSocket ss;
-
+
static Set<SlaveThread> slaves = Collections
.synchronizedSet(new HashSet<SlaveThread>());
@@ -50,9 +68,9 @@
e.printStackTrace();
}
}
-
+
static final int INTERVAL = 6000;
-
+
synchronized static void add(long time, int count, Socket s) {
long interval = time / INTERVAL;
if (currentInterval == 0 || currentInterval > interval) {
@@ -236,23 +254,23 @@
static String host;
static Socket s;
-
+
static int errors;
-
+
static final Object statSync = new Object();
-
+
static int finished;
-
+
static int reads;
-
+
static int writes;
-
+
static int rlatency;
-
+
static int wlatency;
static int outstanding;
-
+
static class ZooKeeperThread extends Thread implements Watcher, DataCallback,
StatCallback {
ZooKeeperThread() {
@@ -397,13 +415,13 @@
} catch (Exception e) {
e.printStackTrace();
}
-
+
}
}
-
+
/**
* @param args
- * @throws InterruptedException
+ * @throws InterruptedException
*/
public static void main(String[] args) throws InterruptedException {
if (args.length == 1) {
Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/IntegrityCheck.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/IntegrityCheck.java?rev=677109&r1=677108&r2=677109&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/IntegrityCheck.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/IntegrityCheck.java Tue Jul 15 16:49:31 2008
@@ -1,10 +1,28 @@
+/**
+ * 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;
/**
* This is a simple test to check the integrity of ZooKeeper servers. The client
* simply cycles through blasting changes to ZooKeeper and the checking what it
* gets back.
- *
+ *
* The check is very simple. The value of the last successful read or write is
* stored in lastValue. When we issue a request, that value becomes a possible
* value. The difficulty is that when a communication error happens, the client
@@ -81,7 +99,7 @@
waitOutstanding();
}
}finally{
- LOG.warn("Test loop terminated for "+path);
+ LOG.warn("Test loop terminated for "+path);
}
}
@@ -145,7 +163,7 @@
}
}
}
-
+
/**
* @param args
*/
@@ -175,7 +193,7 @@
ctest.run();
} catch (Exception e) {
e.printStackTrace();
- }
+ }
}
} catch (Exception e) {
e.printStackTrace();
Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/OOMTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/OOMTest.java?rev=677109&r1=677108&r2=677109&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/OOMTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/OOMTest.java Tue Jul 15 16:49:31 2008
@@ -1,6 +1,21 @@
/**
- *
+ * 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 java.io.File;
@@ -20,7 +35,7 @@
/**
* @author breed
- *
+ *
*/
public class OOMTest extends TestCase implements Watcher {
public void testOOM() throws IOException, InterruptedException, KeeperException {
@@ -114,7 +129,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.zookeeper.Watcher#process(org.apache.zookeeper.proto.WatcherEvent)
*/
public void process(WatcherEvent event) {
Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumTest.java?rev=677109&r1=677108&r2=677109&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumTest.java Tue Jul 15 16:49:31 2008
@@ -1,3 +1,21 @@
+/**
+ * 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 java.io.File;
@@ -40,7 +58,7 @@
LOG.warn("Setup finished");
}
void startServers() throws IOException, InterruptedException {
- QuorumStats.registerAsConcrete();
+ QuorumStats.registerAsConcrete();
int tickTime = 2000;
int initLimit = 3;
int syncLimit = 3;
@@ -83,6 +101,6 @@
s4.shutdown();
s5.shutdown();
Thread.sleep(5000);
- QuorumStats.unregister();
+ QuorumStats.unregister();
}
}
Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/RecoveryTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/RecoveryTest.java?rev=677109&r1=677108&r2=677109&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/RecoveryTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/RecoveryTest.java Tue Jul 15 16:49:31 2008
@@ -1,6 +1,21 @@
/**
- *
+ * 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 java.io.File;
@@ -21,18 +36,18 @@
/**
* @author breed
- *
+ *
*/
public class RecoveryTest extends TestCase implements Watcher {
- static File baseTest = new File(System.getProperty("build.test.dir",
+ static File baseTest = new File(System.getProperty("build.test.dir",
"build"));
protected void setUp() throws Exception {
- ServerStats.registerAsConcrete();
+ ServerStats.registerAsConcrete();
+ }
+ protected void tearDown() throws Exception {
+ ServerStats.unregister();
}
- protected void tearDown() throws Exception {
- ServerStats.unregister();
- }
-
+
@Test
public void testRecovery() throws Exception {
File tmpDir = File.createTempFile("test", ".junit", baseTest);
@@ -119,7 +134,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.zookeeper.Watcher#process(org.apache.zookeeper.proto.WatcherEvent)
*/
public void process(WatcherEvent event) {
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=677109&r1=677108&r2=677109&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 Jul 15 16:49:31 2008
@@ -1,3 +1,21 @@
+/**
+ * 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 java.io.File;
@@ -19,15 +37,15 @@
static File baseTest = new File(System.getProperty("build.test.dir",
"build"));
- protected void setUp() throws Exception {
- ServerStats.registerAsConcrete();
- }
- protected void tearDown() throws Exception {
- ServerStats.unregister();
- }
- /**
- * this test checks to see if the sessionid that was created for the
- * first zookeeper client can be reused for the second one immidiately
+ protected void setUp() throws Exception {
+ ServerStats.registerAsConcrete();
+ }
+ protected void tearDown() throws Exception {
+ ServerStats.unregister();
+ }
+ /**
+ * this test checks to see if the sessionid that was created for the
+ * first zookeeper client can be reused for the second one immidiately
* after the first client closes and the new client resues them.
* @throws IOException
* @throws InterruptedException
@@ -42,7 +60,7 @@
f.startup(zs);
Thread.sleep(4000);
ZooKeeper zk = new ZooKeeper("127.0.0.1:33299", 3000, this);
-
+
long sessionId = zk.getSessionId();
byte[] passwd = zk.getSessionPasswd();
zk.close();
@@ -51,7 +69,7 @@
zk.close();
zs.shutdown();
f.shutdown();
-
+
}
@Test
public void testSession() throws IOException, InterruptedException, KeeperException {
Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/SledgeHammer.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/SledgeHammer.java?rev=677109&r1=677108&r2=677109&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/SledgeHammer.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/SledgeHammer.java Tue Jul 15 16:49:31 2008
@@ -1,3 +1,21 @@
+/**
+ * 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 java.io.IOException;
@@ -44,7 +62,7 @@
for (int i = 0; i < count; i++) {
try {
System.out.print(i + "\r");
- List<String> childs =
+ List<String> childs =
zk.getChildren("/hammers", false);
Collections.shuffle(childs);
for (String s : childs) {
Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/TestHammer.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/TestHammer.java?rev=677109&r1=677108&r2=677109&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/TestHammer.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/TestHammer.java Tue Jul 15 16:49:31 2008
@@ -1,3 +1,21 @@
+/**
+ * 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 java.io.IOException;
@@ -37,7 +55,7 @@
public void processResult(int rc, String path, Object ctx) {
// TODO Auto-generated method stub
-
+
}
}
Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/WatcherFuncTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/WatcherFuncTest.java?rev=677109&r1=677108&r2=677109&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/WatcherFuncTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/WatcherFuncTest.java Tue Jul 15 16:49:31 2008
@@ -1,3 +1,21 @@
+/**
+ * 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 java.io.IOException;
@@ -15,10 +33,10 @@
public class WatcherFuncTest extends ClientBase {
private static class SimpleWatcher implements Watcher {
- private LinkedBlockingQueue<WatcherEvent> events =
+ private LinkedBlockingQueue<WatcherEvent> events =
new LinkedBlockingQueue<WatcherEvent>();
private CountDownLatch latch;
-
+
public SimpleWatcher(CountDownLatch latch) {
this.latch = latch;
}
@@ -43,7 +61,7 @@
WatcherEvent event;
int count = 0;
while (count < expected.size()
- && (event = events.poll(30, TimeUnit.SECONDS)) != null)
+ && (event = events.poll(30, TimeUnit.SECONDS)) != null)
{
assertEquals(expected.get(count).intValue(), event.getType());
count++;
@@ -58,20 +76,20 @@
private SimpleWatcher lsnr_dwatch;
private volatile CountDownLatch lsnr_latch;
private ZooKeeper lsnr;
-
+
private List<Integer> expected;
-
+
protected void setUp() throws Exception {
super.setUp();
-
+
client_latch = new CountDownLatch(1);
- client_dwatch = new SimpleWatcher(client_latch);
+ client_dwatch = new SimpleWatcher(client_latch);
client = createClient(client_dwatch, client_latch);
lsnr_latch = new CountDownLatch(1);
lsnr_dwatch = new SimpleWatcher(lsnr_latch);
lsnr = createClient(lsnr_dwatch, lsnr_latch);
-
+
expected = new ArrayList<Integer>();
}
protected void tearDown() throws Exception {
@@ -80,8 +98,8 @@
Thread.sleep(5000);
super.tearDown();
}
-
- protected ZooKeeper createClient(Watcher watcher, CountDownLatch latch)
+
+ protected ZooKeeper createClient(Watcher watcher, CountDownLatch latch)
throws IOException, InterruptedException
{
ZooKeeper zk = new ZooKeeper(hostPort, 20000, watcher);
@@ -95,7 +113,7 @@
lsnr_dwatch.verify(expected);
expected.clear();
}
- public void testExistsSync()
+ public void testExistsSync()
throws IOException, InterruptedException, KeeperException
{
assertNull(lsnr.exists("/foo", true));
@@ -107,7 +125,7 @@
expected.add(Watcher.Event.EventNodeCreated);
verify();
-
+
assertNotNull(lsnr.exists("/foo", true));
assertNotNull(lsnr.exists("/foo/bar", true));
@@ -118,7 +136,7 @@
} catch (KeeperException e) {
assertEquals(KeeperException.Code.NoNode, e.getCode());
}
-
+
try {
assertNull(lsnr.exists("/foo/car", true));
client.setData("/foo/car", "missing".getBytes(), -1);
@@ -126,7 +144,7 @@
} catch (KeeperException e) {
assertEquals(KeeperException.Code.NoNode, e.getCode());
}
-
+
client.setData("/foo", "parent".getBytes(), -1);
expected.add(Watcher.Event.EventNodeDataChanged);
client.setData("/foo/bar", "child".getBytes(), -1);
@@ -144,7 +162,7 @@
verify();
}
-
+
public void testGetDataSync()
throws IOException, InterruptedException, KeeperException
{
@@ -183,7 +201,7 @@
verify();
}
-
+
public void testGetChildrenSync()
throws IOException, InterruptedException, KeeperException
{
@@ -211,7 +229,7 @@
client.setData("/foo", "parent".getBytes(), -1);
client.setData("/foo/bar", "child".getBytes(), -1);
-
+
assertNotNull(lsnr.exists("/foo", true));
assertNotNull(lsnr.getChildren("/foo", true));
@@ -226,16 +244,16 @@
verify();
}
- public void testExistsSyncWObj()
+ public void testExistsSyncWObj()
throws IOException, InterruptedException, KeeperException
{
SimpleWatcher w1 = new SimpleWatcher(null);
SimpleWatcher w2 = new SimpleWatcher(null);
SimpleWatcher w3 = new SimpleWatcher(null);
SimpleWatcher w4 = new SimpleWatcher(null);
-
+
List<Integer> e2 = new ArrayList<Integer>();
-
+
assertNull(lsnr.exists("/foo", true));
assertNull(lsnr.exists("/foo", w1));
@@ -243,12 +261,12 @@
assertNull(lsnr.exists("/foo/bar", w3));
assertNull(lsnr.exists("/foo/bar", w3));
assertNull(lsnr.exists("/foo/bar", w4));
-
+
client.create("/foo", "parent".getBytes(), Ids.OPEN_ACL_UNSAFE, 0);
expected.add(Watcher.Event.EventNodeCreated);
client.create("/foo/bar", "child".getBytes(), Ids.OPEN_ACL_UNSAFE, 0);
e2.add(Watcher.Event.EventNodeCreated);
-
+
lsnr_dwatch.verify(expected);
w1.verify(expected);
w2.verify(e2);
@@ -256,7 +274,7 @@
w4.verify(e2);
expected.clear();
e2.clear();
-
+
// default not registered
assertNotNull(lsnr.exists("/foo", w1));
@@ -264,12 +282,12 @@
assertNotNull(lsnr.exists("/foo/bar", w3));
assertNotNull(lsnr.exists("/foo/bar", w4));
assertNotNull(lsnr.exists("/foo/bar", w4));
-
+
client.setData("/foo", "parent".getBytes(), -1);
expected.add(Watcher.Event.EventNodeDataChanged);
client.setData("/foo/bar", "child".getBytes(), -1);
e2.add(Watcher.Event.EventNodeDataChanged);
-
+
lsnr_dwatch.verify(new ArrayList<Integer>()); // not reg so should = 0
w1.verify(expected);
w2.verify(e2);
@@ -277,7 +295,7 @@
w4.verify(e2);
expected.clear();
e2.clear();
-
+
assertNotNull(lsnr.exists("/foo", true));
assertNotNull(lsnr.exists("/foo", w1));
assertNotNull(lsnr.exists("/foo", w1));
@@ -286,12 +304,12 @@
assertNotNull(lsnr.exists("/foo/bar", w2));
assertNotNull(lsnr.exists("/foo/bar", w3));
assertNotNull(lsnr.exists("/foo/bar", w4));
-
+
client.delete("/foo/bar", -1);
expected.add(Watcher.Event.EventNodeDeleted);
client.delete("/foo", -1);
e2.add(Watcher.Event.EventNodeDeleted);
-
+
lsnr_dwatch.verify(expected);
w1.verify(expected);
w2.verify(e2);
@@ -309,7 +327,7 @@
SimpleWatcher w2 = new SimpleWatcher(null);
SimpleWatcher w3 = new SimpleWatcher(null);
SimpleWatcher w4 = new SimpleWatcher(null);
-
+
List<Integer> e2 = new ArrayList<Integer>();
try {
@@ -324,7 +342,7 @@
} catch (KeeperException e) {
assertEquals(KeeperException.Code.NoNode, e.getCode());
}
-
+
client.create("/foo", "parent".getBytes(), Ids.OPEN_ACL_UNSAFE, 0);
assertNotNull(lsnr.getData("/foo", true, null));
assertNotNull(lsnr.getData("/foo", w1, null));
@@ -333,12 +351,12 @@
assertNotNull(lsnr.getData("/foo/bar", w3, null));
assertNotNull(lsnr.getData("/foo/bar", w4, null));
assertNotNull(lsnr.getData("/foo/bar", w4, null));
-
+
client.setData("/foo", "parent".getBytes(), -1);
expected.add(Watcher.Event.EventNodeDataChanged);
client.setData("/foo/bar", "child".getBytes(), -1);
e2.add(Watcher.Event.EventNodeDataChanged);
-
+
lsnr_dwatch.verify(expected);
w1.verify(expected);
w2.verify(e2);
@@ -346,19 +364,19 @@
w4.verify(e2);
expected.clear();
e2.clear();
-
+
assertNotNull(lsnr.getData("/foo", true, null));
assertNotNull(lsnr.getData("/foo", w1, null));
assertNotNull(lsnr.getData("/foo/bar", w2, null));
assertNotNull(lsnr.getData("/foo/bar", w3, null));
assertNotNull(lsnr.getData("/foo/bar", w3, null));
assertNotNull(lsnr.getData("/foo/bar", w4, null));
-
+
client.delete("/foo/bar", -1);
expected.add(Watcher.Event.EventNodeDeleted);
client.delete("/foo", -1);
e2.add(Watcher.Event.EventNodeDeleted);
-
+
lsnr_dwatch.verify(expected);
w1.verify(expected);
w2.verify(e2);
@@ -367,7 +385,7 @@
expected.clear();
e2.clear();
}
-
+
public void testGetChildrenSyncWObj()
throws IOException, InterruptedException, KeeperException
{
@@ -375,7 +393,7 @@
SimpleWatcher w2 = new SimpleWatcher(null);
SimpleWatcher w3 = new SimpleWatcher(null);
SimpleWatcher w4 = new SimpleWatcher(null);
-
+
List<Integer> e2 = new ArrayList<Integer>();
try {
@@ -390,41 +408,41 @@
} catch (KeeperException e) {
assertEquals(KeeperException.Code.NoNode, e.getCode());
}
-
+
client.create("/foo", "parent".getBytes(), Ids.OPEN_ACL_UNSAFE, 0);
assertNotNull(lsnr.getChildren("/foo", true));
assertNotNull(lsnr.getChildren("/foo", w1));
-
+
client.create("/foo/bar", "child".getBytes(), Ids.OPEN_ACL_UNSAFE, 0);
expected.add(Watcher.Event.EventNodeChildrenChanged); // /foo
assertNotNull(lsnr.getChildren("/foo/bar", w2));
assertNotNull(lsnr.getChildren("/foo/bar", w2));
assertNotNull(lsnr.getChildren("/foo/bar", w3));
assertNotNull(lsnr.getChildren("/foo/bar", w4));
-
-
+
+
client.setData("/foo", "parent".getBytes(), -1);
client.setData("/foo/bar", "child".getBytes(), -1);
-
-
+
+
assertNotNull(lsnr.exists("/foo", true));
assertNotNull(lsnr.exists("/foo", w1));
assertNotNull(lsnr.exists("/foo", true));
assertNotNull(lsnr.exists("/foo", w1));
-
+
assertNotNull(lsnr.getChildren("/foo", true));
assertNotNull(lsnr.getChildren("/foo", w1));
assertNotNull(lsnr.getChildren("/foo/bar", w2));
assertNotNull(lsnr.getChildren("/foo/bar", w3));
assertNotNull(lsnr.getChildren("/foo/bar", w4));
assertNotNull(lsnr.getChildren("/foo/bar", w4));
-
+
client.delete("/foo/bar", -1);
e2.add(Watcher.Event.EventNodeDeleted); // /foo/bar childwatch
expected.add(Watcher.Event.EventNodeChildrenChanged); // /foo
client.delete("/foo", -1);
expected.add(Watcher.Event.EventNodeDeleted);
-
+
lsnr_dwatch.verify(expected);
w1.verify(expected);
w2.verify(e2);
Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ZooKeeperTestClient.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ZooKeeperTestClient.java?rev=677109&r1=677108&r2=677109&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ZooKeeperTestClient.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ZooKeeperTestClient.java Tue Jul 15 16:49:31 2008
@@ -1,3 +1,21 @@
+/**
+ * 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 java.io.IOException;
@@ -240,18 +258,18 @@
System.out.println("session id of zk: " + zk.getSessionId());
System.out.println("session id of zk_1: " + zk_1.getSessionId());
zk.close();
-
+
stat = zk_1.exists("nosuchnode", false);
-
+
event = this.getEvent(10);
if (event == null) {
fail("First event was not delivered promptly");
}
- if (!((event.getType() == Watcher.Event.EventNodeChildrenChanged &&
+ if (!((event.getType() == Watcher.Event.EventNodeChildrenChanged &&
event.getPath().equalsIgnoreCase(parentName)) ||
- (event.getType() == Watcher.Event.EventNodeDeleted &&
+ (event.getType() == Watcher.Event.EventNodeDeleted &&
event.getPath().equalsIgnoreCase(nodeName)))) {
- System.out.print(parentName + " "
+ System.out.print(parentName + " "
+ Watcher.Event.EventNodeChildrenChanged + " " + nodeName + " " + Watcher.Event.EventNodeDeleted);
fail("Unexpected first event was delivered: " + event.toString());
}
@@ -261,11 +279,11 @@
if (event == null) {
fail("Second event was not delivered promptly");
}
- if (!((event.getType() == Watcher.Event.EventNodeChildrenChanged &&
+ if (!((event.getType() == Watcher.Event.EventNodeChildrenChanged &&
event.getPath().equalsIgnoreCase(parentName)) ||
- (event.getType() == Watcher.Event.EventNodeDeleted &&
+ (event.getType() == Watcher.Event.EventNodeDeleted &&
event.getPath().equalsIgnoreCase(nodeName)))) {
- System.out.print(parentName + " "
+ System.out.print(parentName + " "
+ Watcher.Event.EventNodeChildrenChanged + " " + nodeName + " " + Watcher.Event.EventNodeDeleted);
fail("Unexpected second event was delivered: " + event.toString());
}
Modified: hadoop/zookeeper/trunk/src/zookeeper.jute
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/zookeeper.jute?rev=677109&r1=677108&r2=677109&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/zookeeper.jute (original)
+++ hadoop/zookeeper/trunk/src/zookeeper.jute Tue Jul 15 16:49:31 2008
@@ -1,3 +1,21 @@
+/**
+ * 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.
+ */
+
module org.apache.zookeeper.data {
class Id {
ustring scheme;
|