zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From an...@apache.org
Subject [12/51] [partial] zookeeper git commit: ZOOKEEPER-3032: MAVEN MIGRATION - branch-3.5 - move java server, client
Date Fri, 05 Oct 2018 13:36:40 GMT
http://git-wip-us.apache.org/repos/asf/zookeeper/blob/3ce1b18b/src/java/test/org/apache/zookeeper/server/NIOServerCnxnTest.java
----------------------------------------------------------------------
diff --git a/src/java/test/org/apache/zookeeper/server/NIOServerCnxnTest.java b/src/java/test/org/apache/zookeeper/server/NIOServerCnxnTest.java
deleted file mode 100644
index 4362b2c..0000000
--- a/src/java/test/org/apache/zookeeper/server/NIOServerCnxnTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/**
- * 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;
-
-
-import org.apache.zookeeper.CreateMode;
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.ZooDefs.Ids;
-import org.apache.zookeeper.ZooKeeper;
-import org.apache.zookeeper.server.quorum.BufferStats;
-import org.apache.zookeeper.test.ClientBase;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.greaterThan;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
-
-public class NIOServerCnxnTest extends ClientBase {
-    private static final Logger LOG = LoggerFactory
-                        .getLogger(NIOServerCnxnTest.class);
-
-    /**
-     * Test operations on ServerCnxn after socket closure.
-     */
-    @Test(timeout = 60000)
-    public void testOperationsAfterCnxnClose() throws IOException,
-            InterruptedException, KeeperException {
-        final ZooKeeper zk = createClient();
-
-        final String path = "/a";
-        try {
-            // make sure zkclient works
-            zk.create(path, "test".getBytes(), Ids.OPEN_ACL_UNSAFE,
-                    CreateMode.PERSISTENT);
-            assertNotNull("Didn't create znode:" + path,
-                    zk.exists(path, false));
-            // Defaults ServerCnxnFactory would be instantiated with
-            // NIOServerCnxnFactory
-            Assert.assertTrue(
-                    "Didn't instantiate ServerCnxnFactory with NIOServerCnxnFactory!",
-                    serverFactory instanceof NIOServerCnxnFactory);
-            Iterable<ServerCnxn> connections = serverFactory.getConnections();
-            for (ServerCnxn serverCnxn : connections) {
-                serverCnxn.close();
-                try {
-                    serverCnxn.toString();
-                } catch (Exception e) {
-                    LOG.error("Exception while getting connection details!", e);
-                    Assert.fail("Shouldn't throw exception while "
-                            + "getting connection details!");
-                }
-            }
-        } finally {
-            zk.close();
-        }
-
-    }
-
-    @Test
-    public void testClientResponseStatsUpdate() throws IOException, InterruptedException, KeeperException {
-        try (ZooKeeper zk = createClient()) {
-            BufferStats clientResponseStats = serverFactory.getZooKeeperServer().serverStats().getClientResponseStats();
-            assertThat("Last client response size should be initialized with INIT_VALUE",
-                    clientResponseStats.getLastBufferSize(), equalTo(BufferStats.INIT_VALUE));
-
-            zk.create("/a", "test".getBytes(), Ids.OPEN_ACL_UNSAFE,
-                    CreateMode.PERSISTENT);
-
-            assertThat("Last client response size should be greater then zero after client request was performed",
-                    clientResponseStats.getLastBufferSize(), greaterThan(0));
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/3ce1b18b/src/java/test/org/apache/zookeeper/server/NettyServerCnxnTest.java
----------------------------------------------------------------------
diff --git a/src/java/test/org/apache/zookeeper/server/NettyServerCnxnTest.java b/src/java/test/org/apache/zookeeper/server/NettyServerCnxnTest.java
deleted file mode 100644
index 2038d8b..0000000
--- a/src/java/test/org/apache/zookeeper/server/NettyServerCnxnTest.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/**
- * 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 org.apache.zookeeper.CreateMode;
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.ZooDefs.Ids;
-import org.apache.zookeeper.ZooKeeper;
-import org.apache.zookeeper.server.quorum.BufferStats;
-import org.apache.zookeeper.test.ClientBase;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.greaterThan;
-import static org.junit.Assert.assertThat;
-
-/**
- * Test verifies the behavior of NettyServerCnxn which represents a connection
- * from a client to the server.
- */
-public class NettyServerCnxnTest extends ClientBase {
-    private static final Logger LOG = LoggerFactory
-            .getLogger(NettyServerCnxnTest.class);
-
-    @Override
-    public void setUp() throws Exception {
-        System.setProperty(ServerCnxnFactory.ZOOKEEPER_SERVER_CNXN_FACTORY,
-                "org.apache.zookeeper.server.NettyServerCnxnFactory");
-        super.setUp();
-    }
-
-    /**
-     * Test verifies the channel closure - while closing the channel
-     * servercnxnfactory should remove all channel references to avoid
-     * duplicate channel closure. Duplicate closure may result in indefinite
-     * hanging due to netty open issue.
-     * 
-     * @see <a href="https://issues.jboss.org/browse/NETTY-412">NETTY-412</a>
-     */
-    @Test(timeout = 40000)
-    public void testSendCloseSession() throws Exception {
-        Assert.assertTrue(
-                "Didn't instantiate ServerCnxnFactory with NettyServerCnxnFactory!",
-                serverFactory instanceof NettyServerCnxnFactory);
-
-        final ZooKeeper zk = createClient();
-        final String path = "/a";
-        try {
-            // make sure zkclient works
-            zk.create(path, "test".getBytes(), Ids.OPEN_ACL_UNSAFE,
-                    CreateMode.PERSISTENT);
-            Assert.assertNotNull("Didn't create znode:" + path,
-                    zk.exists(path, false));
-            Iterable<ServerCnxn> connections = serverFactory.getConnections();
-            Assert.assertEquals("Mismatch in number of live connections!", 1,
-                    serverFactory.getNumAliveConnections());
-            for (ServerCnxn serverCnxn : connections) {
-                serverCnxn.sendCloseSession();
-            }
-            LOG.info("Waiting for the channel disconnected event");
-            int timeout = 0;
-            while (serverFactory.getNumAliveConnections() != 0) {
-                Thread.sleep(1000);
-                timeout += 1000;
-                if (timeout > CONNECTION_TIMEOUT) {
-                    Assert.fail("The number of live connections should be 0");
-                }
-            }
-        } finally {
-            zk.close();
-        }
-    }
-
-    @Test
-    public void testClientResponseStatsUpdate() throws IOException, InterruptedException, KeeperException {
-        try (ZooKeeper zk = createClient()) {
-            BufferStats clientResponseStats = serverFactory.getZooKeeperServer().serverStats().getClientResponseStats();
-            assertThat("Last client response size should be initialized with INIT_VALUE",
-                    clientResponseStats.getLastBufferSize(), equalTo(BufferStats.INIT_VALUE));
-
-            zk.create("/a", "test".getBytes(), Ids.OPEN_ACL_UNSAFE,
-                    CreateMode.PERSISTENT);
-
-            assertThat("Last client response size should be greater than 0 after client request was performed",
-                    clientResponseStats.getLastBufferSize(), greaterThan(0));
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/3ce1b18b/src/java/test/org/apache/zookeeper/server/PrepRequestProcessorTest.java
----------------------------------------------------------------------
diff --git a/src/java/test/org/apache/zookeeper/server/PrepRequestProcessorTest.java b/src/java/test/org/apache/zookeeper/server/PrepRequestProcessorTest.java
deleted file mode 100644
index 8223583..0000000
--- a/src/java/test/org/apache/zookeeper/server/PrepRequestProcessorTest.java
+++ /dev/null
@@ -1,285 +0,0 @@
-/**
- * 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 org.apache.jute.BinaryOutputArchive;
-import org.apache.jute.Record;
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.KeeperException.SessionExpiredException;
-import org.apache.zookeeper.KeeperException.SessionMovedException;
-import org.apache.zookeeper.MultiTransactionRecord;
-import org.apache.zookeeper.Op;
-import org.apache.zookeeper.PortAssignment;
-import org.apache.zookeeper.ZooDefs.Ids;
-import org.apache.zookeeper.ZooDefs.OpCode;
-import org.apache.zookeeper.data.Id;
-import org.apache.zookeeper.proto.SetDataRequest;
-import org.apache.zookeeper.server.ZooKeeperServer.ChangeRecord;
-import org.apache.zookeeper.test.ClientBase;
-import org.apache.zookeeper.txn.ErrorTxn;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.nio.ByteBuffer;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-public class PrepRequestProcessorTest extends ClientBase {
-    private static final Logger LOG = LoggerFactory.getLogger(PrepRequestProcessorTest.class);
-    private static final int CONNECTION_TIMEOUT = 3000;
-    private static String HOSTPORT = "127.0.0.1:" + PortAssignment.unique();
-    private CountDownLatch pLatch;
-
-    private ZooKeeperServer zks;
-    private ServerCnxnFactory servcnxnf;
-    private PrepRequestProcessor processor;
-    private Request outcome;
-
-    @Before
-    public void setup() throws Exception {
-        File tmpDir = ClientBase.createTmpDir();
-        ClientBase.setupTestEnv();
-        zks = new ZooKeeperServer(tmpDir, tmpDir, 3000);
-        SyncRequestProcessor.setSnapCount(100);
-        final int PORT = Integer.parseInt(HOSTPORT.split(":")[1]);
-
-        servcnxnf = ServerCnxnFactory.createFactory(PORT, -1);
-        servcnxnf.startup(zks);
-        Assert.assertTrue("waiting for server being up ",
-                ClientBase.waitForServerUp(HOSTPORT, CONNECTION_TIMEOUT));
-        zks.sessionTracker = new MySessionTracker();
-    }
-
-    @After
-    public void teardown() throws Exception {
-        if (servcnxnf != null) {
-            servcnxnf.shutdown();
-        }
-        if (zks != null) {
-            zks.shutdown();
-        }
-    }
-
-    @Test
-    public void testPRequest() throws Exception {
-        pLatch = new CountDownLatch(1);
-        processor = new PrepRequestProcessor(zks, new MyRequestProcessor());
-        Request foo = new Request(null, 1l, 1, OpCode.create, ByteBuffer.allocate(3), null);
-        processor.pRequest(foo);
-
-        Assert.assertEquals("Request should have marshalling error", new ErrorTxn(KeeperException.Code.MARSHALLINGERROR.intValue()),
-                outcome.getTxn());
-        Assert.assertTrue("request hasn't been processed in chain", pLatch.await(5, TimeUnit.SECONDS));
-    }
-
-    private Request createRequest(Record record, int opCode) throws IOException {
-        // encoding
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        BinaryOutputArchive boa = BinaryOutputArchive.getArchive(baos);
-        record.serialize(boa, "request");
-        baos.close();
-        // Id
-        List<Id> ids = Arrays.asList(Ids.ANYONE_ID_UNSAFE);
-        return new Request(null, 1l, 0, opCode, ByteBuffer.wrap(baos.toByteArray()), ids);
-    }
-
-    private void process(List<Op> ops) throws Exception {
-        pLatch = new CountDownLatch(1);
-        processor = new PrepRequestProcessor(zks, new MyRequestProcessor());
-
-        Record record = new MultiTransactionRecord(ops);
-        Request req = createRequest(record, OpCode.multi);
-
-        processor.pRequest(req);
-        Assert.assertTrue("request hasn't been processed in chain", pLatch.await(5, TimeUnit.SECONDS));
-    }
-
-    /**
-     * This test checks that a successful multi will change outstanding record
-     * and failed multi shouldn't change outstanding record.
-     */
-    @Test
-    public void testMultiOutstandingChange() throws Exception {
-        zks.getZKDatabase().dataTree.createNode("/foo", new byte[0], Ids.OPEN_ACL_UNSAFE, 0, 0, 0, 0);
-
-        Assert.assertNull(zks.outstandingChangesForPath.get("/foo"));
-
-        process(Arrays.asList(
-                Op.setData("/foo", new byte[0], -1)));
-
-        ChangeRecord cr = zks.outstandingChangesForPath.get("/foo");
-        Assert.assertNotNull("Change record wasn't set", cr);
-        Assert.assertEquals("Record zxid wasn't set correctly",
-                1, cr.zxid);
-
-        process(Arrays.asList(
-                Op.delete("/foo", -1)));
-        cr = zks.outstandingChangesForPath.get("/foo");
-        Assert.assertEquals("Record zxid wasn't set correctly",
-                2, cr.zxid);
-
-
-        // It should fail and shouldn't change outstanding record.
-        process(Arrays.asList(
-                Op.delete("/foo", -1)));
-        cr = zks.outstandingChangesForPath.get("/foo");
-        // zxid should still be previous result because record's not changed.
-        Assert.assertEquals("Record zxid wasn't set correctly",
-                2, cr.zxid);
-    }
-
-    /**
-     * ZOOKEEPER-2052:
-     * This test checks that if a multi operation aborted, and during the multi there is side effect
-     * that changed outstandingChangesForPath, after aborted the side effect should be removed and
-     * everything should be restored correctly.
-     */
-    @Test
-    public void testMultiRollbackNoLastChange() throws Exception {
-        zks.getZKDatabase().dataTree.createNode("/foo", new byte[0], Ids.OPEN_ACL_UNSAFE, 0, 0, 0, 0);
-        zks.getZKDatabase().dataTree.createNode("/foo/bar", new byte[0], Ids.OPEN_ACL_UNSAFE, 0, 0, 0, 0);
-
-        Assert.assertNull(zks.outstandingChangesForPath.get("/foo"));
-
-        // multi record:
-        //   set "/foo" => succeed, leave a outstanding change
-        //   delete "/foo" => fail, roll back change
-        process(Arrays.asList(
-                Op.setData("/foo", new byte[0], -1),
-                Op.delete("/foo", -1)));
-
-        // aborting multi shouldn't leave any record.
-        Assert.assertNull(zks.outstandingChangesForPath.get("/foo"));
-    }
-
-    /**
-     * It tests that PrepRequestProcessor will return BadArgument KeeperException
-     * if the request path (if it exists) is not valid, e.g. empty string.
-     */
-    @Test
-    public void testInvalidPath() throws Exception {
-        pLatch = new CountDownLatch(1);
-        processor = new PrepRequestProcessor(zks, new MyRequestProcessor());
-
-        SetDataRequest record = new SetDataRequest("", new byte[0], -1);
-        Request req = createRequest(record, OpCode.setData);
-        processor.pRequest(req);
-        pLatch.await();
-        Assert.assertEquals(outcome.getHdr().getType(), OpCode.error);
-        Assert.assertEquals(outcome.getException().code(), KeeperException.Code.BADARGUMENTS);
-    }
-
-    private class MyRequestProcessor implements RequestProcessor {
-        @Override
-        public void processRequest(Request request) {
-            // getting called by PrepRequestProcessor
-            outcome = request;
-            pLatch.countDown();
-        }
-        @Override
-        public void shutdown() {
-            // TODO Auto-generated method stub
-            
-        }
-    }
-    
-    private class MySessionTracker implements SessionTracker {
-        @Override
-        public boolean addGlobalSession(long id, int to) {
-            // TODO Auto-generated method stub
-            return false;
-        }
-        @Override
-        public boolean addSession(long id, int to) {
-            // TODO Auto-generated method stub
-            return false;
-        }
-        @Override
-        public void checkSession(long sessionId, Object owner)
-                throws SessionExpiredException, SessionMovedException {
-            // TODO Auto-generated method stub
-        }
-        @Override
-        public long createSession(int sessionTimeout) {
-            // TODO Auto-generated method stub
-            return 0;
-        }
-        @Override
-        public void dumpSessions(PrintWriter pwriter) {
-            // TODO Auto-generated method stub
-
-        }
-         @Override
-        public void removeSession(long sessionId) {
-            // TODO Auto-generated method stub
-
-        }
-        public int upgradeSession(long sessionId) {
-             // TODO Auto-generated method stub
-             return 0;
-        }
-        @Override
-        public void setOwner(long id, Object owner)
-                throws SessionExpiredException {
-            // TODO Auto-generated method stub
-
-        }
-        @Override
-        public void shutdown() {
-            // TODO Auto-generated method stub
-
-        }
-        @Override
-        public boolean touchSession(long sessionId, int sessionTimeout) {
-            // TODO Auto-generated method stub
-            return false;
-        }
-        @Override
-        public void setSessionClosing(long sessionId) {
-          // TODO Auto-generated method stub
-        }
-        @Override
-        public boolean isTrackingSession(long sessionId) {
-            // TODO Auto-generated method stub
-            return false;
-        }
-        @Override
-        public void checkGlobalSession(long sessionId, Object owner)
-                throws SessionExpiredException, SessionMovedException {
-            // TODO Auto-generated method stub
-        }
-        @Override
-        public Map<Long, Set<Long>> getSessionExpiryMap() {
-            return new HashMap<Long, Set<Long>>();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/3ce1b18b/src/java/test/org/apache/zookeeper/server/PurgeTxnTest.java
----------------------------------------------------------------------
diff --git a/src/java/test/org/apache/zookeeper/server/PurgeTxnTest.java b/src/java/test/org/apache/zookeeper/server/PurgeTxnTest.java
deleted file mode 100644
index 7898e6e..0000000
--- a/src/java/test/org/apache/zookeeper/server/PurgeTxnTest.java
+++ /dev/null
@@ -1,597 +0,0 @@
-/**
- * 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 static org.junit.Assert.assertEquals;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-import org.apache.zookeeper.data.Stat;
-
-import org.apache.zookeeper.CreateMode;
-import org.apache.zookeeper.PortAssignment;
-import org.apache.zookeeper.ZKTestCase;
-import org.apache.zookeeper.ZooDefs.Ids;
-import org.apache.zookeeper.ZooKeeper;
-import org.apache.zookeeper.server.PurgeTxnLog;
-import org.apache.zookeeper.server.ServerCnxnFactory;
-import org.apache.zookeeper.server.SyncRequestProcessor;
-import org.apache.zookeeper.server.ZooKeeperServer;
-import org.apache.zookeeper.server.persistence.FileTxnSnapLog;
-import org.apache.zookeeper.server.persistence.Util;
-import org.apache.zookeeper.test.ClientBase;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class PurgeTxnTest extends ZKTestCase {
-    private static final Logger LOG = LoggerFactory.getLogger(PurgeTxnTest.class);
-    private static String HOSTPORT = "127.0.0.1:" + PortAssignment.unique();
-    private static final int CONNECTION_TIMEOUT = 3000;
-    private static final long OP_TIMEOUT_IN_MILLIS = 90000;
-    private File tmpDir;
-
-    @After
-    public void teardown() {
-        if (null != tmpDir) {
-            ClientBase.recursiveDelete(tmpDir);
-        }
-    }
-
-    /**
-     * test the purge
-     * @throws Exception an exception might be thrown here
-     */
-    @Test
-    public void testPurge() throws Exception {
-        tmpDir = ClientBase.createTmpDir();
-        ClientBase.setupTestEnv();
-        ZooKeeperServer zks = new ZooKeeperServer(tmpDir, tmpDir, 3000);
-        SyncRequestProcessor.setSnapCount(100);
-        final int PORT = Integer.parseInt(HOSTPORT.split(":")[1]);
-        ServerCnxnFactory f = ServerCnxnFactory.createFactory(PORT, -1);
-        f.startup(zks);
-        Assert.assertTrue("waiting for server being up ",
-                ClientBase.waitForServerUp(HOSTPORT,CONNECTION_TIMEOUT));
-        ZooKeeper zk = ClientBase.createZKClient(HOSTPORT);
-        try {
-            for (int i = 0; i< 2000; i++) {
-                zk.create("/invalidsnap-" + i, new byte[0], Ids.OPEN_ACL_UNSAFE,
-                        CreateMode.PERSISTENT);
-            }
-        } finally {
-            zk.close();
-        }
-        f.shutdown();
-        zks.getTxnLogFactory().close();
-        Assert.assertTrue("waiting for server to shutdown",
-                ClientBase.waitForServerDown(HOSTPORT, CONNECTION_TIMEOUT));
-        // now corrupt the snapshot
-        PurgeTxnLog.purge(tmpDir, tmpDir, 3);
-        FileTxnSnapLog snaplog = new FileTxnSnapLog(tmpDir, tmpDir);
-        List<File> listLogs = snaplog.findNRecentSnapshots(4);
-        int numSnaps = 0;
-        for (File ff: listLogs) {
-            if (ff.getName().startsWith("snapshot")) {
-                numSnaps++;
-            }
-        }
-        Assert.assertTrue("exactly 3 snapshots ", (numSnaps == 3));
-        snaplog.close();
-        zks.shutdown();
-    }
-
-    /**
-     * Tests purge when logs are rolling or a new snapshot is created, then
-     * these newer files should alse be excluded in the current cycle.
-     *
-     * For frequent snapshotting, configured SnapCount to 30. There are three
-     * threads which will create 1000 znodes each and simultaneously do purge
-     * call
-     */
-    @Test
-    public void testPurgeWhenLogRollingInProgress() throws Exception {
-        tmpDir = ClientBase.createTmpDir();
-        ClientBase.setupTestEnv();
-        ZooKeeperServer zks = new ZooKeeperServer(tmpDir, tmpDir, 3000);
-        SyncRequestProcessor.setSnapCount(30);
-        final int PORT = Integer.parseInt(HOSTPORT.split(":")[1]);
-        ServerCnxnFactory f = ServerCnxnFactory.createFactory(PORT, -1);
-        f.startup(zks);
-        Assert.assertTrue("waiting for server being up ",
-                ClientBase.waitForServerUp(HOSTPORT, CONNECTION_TIMEOUT));
-        final ZooKeeper zk = ClientBase.createZKClient(HOSTPORT);
-        final CountDownLatch doPurge = new CountDownLatch(1);
-        final CountDownLatch purgeFinished = new CountDownLatch(1);
-        final AtomicBoolean opFailed = new AtomicBoolean(false);
-        new Thread() {
-            public void run() {
-                try {
-                    doPurge.await(OP_TIMEOUT_IN_MILLIS / 2,
-                            TimeUnit.MILLISECONDS);
-                    PurgeTxnLog.purge(tmpDir, tmpDir, 3);
-                } catch (IOException ioe) {
-                    LOG.error("Exception when purge", ioe);
-                    opFailed.set(true);
-                } catch (InterruptedException ie) {
-                    LOG.error("Exception when purge", ie);
-                    opFailed.set(true);
-                } finally {
-                    purgeFinished.countDown();
-                }
-            };
-        }.start();
-        final int thCount = 3;
-        List<String> znodes = manyClientOps(zk, doPurge, thCount,
-                "/invalidsnap");
-        Assert.assertTrue("Purging is not finished!", purgeFinished.await(
-                OP_TIMEOUT_IN_MILLIS, TimeUnit.MILLISECONDS));
-        Assert.assertFalse("Purging failed!", opFailed.get());
-        for (String znode : znodes) {
-            try {
-                zk.getData(znode, false, null);
-            } catch (Exception ke) {
-                LOG.error("Unexpected exception when visiting znode!", ke);
-                Assert.fail("Unexpected exception when visiting znode!");
-            }
-        }
-        zk.close();
-        f.shutdown();
-        zks.shutdown();
-        zks.getTxnLogFactory().close();
-    }
-
-    /**
-     * Tests finding n recent snapshots from set of snapshots and data logs
-     */
-    @Test
-    public void testFindNRecentSnapshots() throws Exception {
-        int nRecentSnap = 4; // n recent snap shots
-        int nRecentCount = 30;
-        int offset = 0;
-
-        tmpDir = ClientBase.createTmpDir();
-        File version2 = new File(tmpDir.toString(), "version-2");
-        Assert.assertTrue("Failed to create version_2 dir:" + version2.toString(),
-                version2.mkdir());
-
-        // Test that with no snaps, findNRecentSnapshots returns empty list
-        FileTxnSnapLog txnLog = new FileTxnSnapLog(tmpDir, tmpDir);
-        List<File> foundSnaps = txnLog.findNRecentSnapshots(1);
-        assertEquals(0, foundSnaps.size());
-
-        List<File> expectedNRecentSnapFiles = new ArrayList<File>();
-        int counter = offset + (2 * nRecentCount);
-        for (int i = 0; i < nRecentCount; i++) {
-            // simulate log file
-            File logFile = new File(version2 + "/log." + Long.toHexString(--counter));
-            Assert.assertTrue("Failed to create log File:" + logFile.toString(),
-                    logFile.createNewFile());
-            // simulate snapshot file
-            File snapFile = new File(version2 + "/snapshot."
-                    + Long.toHexString(--counter));
-            Assert.assertTrue("Failed to create snap File:" + snapFile.toString(),
-                    snapFile.createNewFile());
-            // add the n recent snap files for assertion
-            if(i < nRecentSnap){
-                expectedNRecentSnapFiles.add(snapFile);
-            }
-        }
-
-        // Test that when we ask for recent snaps we get the number we asked for and
-        // the files we expected
-        List<File> nRecentSnapFiles = txnLog.findNRecentSnapshots(nRecentSnap);
-        Assert.assertEquals("exactly 4 snapshots ", 4,
-                nRecentSnapFiles.size());
-        expectedNRecentSnapFiles.removeAll(nRecentSnapFiles);
-        Assert.assertEquals("Didn't get the recent snap files", 0,
-                expectedNRecentSnapFiles.size());
-
-        // Test that when asking for more snaps than we created, we still only get snaps
-        // not logs or anything else (per ZOOKEEPER-2420)
-        nRecentSnapFiles = txnLog.findNRecentSnapshots(nRecentCount + 5);
-        assertEquals(nRecentCount, nRecentSnapFiles.size());
-        for (File f: nRecentSnapFiles) {
-            Assert.assertTrue("findNRecentSnapshots() returned a non-snapshot: " + f.getPath(),
-                   (Util.getZxidFromName(f.getName(), "snapshot") != -1));
-        }
-
-        txnLog.close();
-    }
-
-    /**
-     * Tests purge where the data directory contains old snapshots and data
-     * logs, newest snapshots and data logs, (newest + n) snapshots and data
-     * logs
-     */
-    @Test
-    public void testSnapFilesGreaterThanToRetain() throws Exception {
-        int nRecentCount = 4;
-        int fileAboveRecentCount = 4;
-        int fileToPurgeCount = 2;
-        AtomicInteger offset = new AtomicInteger(0);
-        tmpDir = ClientBase.createTmpDir();
-        File version2 = new File(tmpDir.toString(), "version-2");
-        Assert.assertTrue("Failed to create version_2 dir:" + version2.toString(),
-                version2.mkdir());
-        List<File> snapsToPurge = new ArrayList<File>();
-        List<File> logsToPurge = new ArrayList<File>();
-        List<File> snaps = new ArrayList<File>();
-        List<File> logs = new ArrayList<File>();
-        List<File> snapsAboveRecentFiles = new ArrayList<File>();
-        List<File> logsAboveRecentFiles = new ArrayList<File>();
-        createDataDirFiles(offset, fileToPurgeCount, false, version2, snapsToPurge,
-                logsToPurge);
-        createDataDirFiles(offset, nRecentCount, false, version2, snaps, logs);
-        logs.add(logsToPurge.remove(0)); // log that precedes first retained snapshot is also retained
-        createDataDirFiles(offset, fileAboveRecentCount, false, version2,
-                snapsAboveRecentFiles, logsAboveRecentFiles);
-
-        /**
-         * The newest log file preceding the oldest retained snapshot is not removed as it may
-         * contain transactions newer than the oldest snapshot.
-         */
-        logsToPurge.remove(0);
-
-        FileTxnSnapLog txnLog = new FileTxnSnapLog(tmpDir, tmpDir);
-        PurgeTxnLog.purgeOlderSnapshots(txnLog, snaps.get(snaps.size() - 1));
-        txnLog.close();
-        verifyFilesAfterPurge(snapsToPurge, false);
-        verifyFilesAfterPurge(logsToPurge, false);
-        verifyFilesAfterPurge(snaps, true);
-        verifyFilesAfterPurge(logs, true);
-        verifyFilesAfterPurge(snapsAboveRecentFiles, true);
-        verifyFilesAfterPurge(logsAboveRecentFiles, true);
-    }
-
-    /**
-     * Tests purge where the data directory contains snap files and log files equals to the
-     * number of files to be retained
-     */
-    @Test
-    public void testSnapFilesEqualsToRetain() throws Exception {
-        internalTestSnapFilesEqualsToRetain(false);
-    }
-
-    /**
-     * Tests purge where the data directory contains snap files equals to the
-     * number of files to be retained, and a log file that precedes the earliest snapshot
-     */
-    @Test
-    public void testSnapFilesEqualsToRetainWithPrecedingLog() throws Exception {
-        internalTestSnapFilesEqualsToRetain(true);
-    }
-
-    public void internalTestSnapFilesEqualsToRetain(boolean testWithPrecedingLogFile) throws Exception {
-        int nRecentCount = 3;
-        AtomicInteger offset = new AtomicInteger(0);
-        tmpDir = ClientBase.createTmpDir();
-        File version2 = new File(tmpDir.toString(), "version-2");
-        Assert.assertTrue("Failed to create version_2 dir:" + version2.toString(),
-                version2.mkdir());
-        List<File> snaps = new ArrayList<File>();
-        List<File> logs = new ArrayList<File>();
-        createDataDirFiles(offset, nRecentCount, testWithPrecedingLogFile, version2, snaps, logs);
-
-        FileTxnSnapLog txnLog = new FileTxnSnapLog(tmpDir, tmpDir);
-        PurgeTxnLog.purgeOlderSnapshots(txnLog, snaps.get(snaps.size() - 1));
-        txnLog.close();
-        verifyFilesAfterPurge(snaps, true);
-        verifyFilesAfterPurge(logs, true);
-    }
-
-    /**
-     * Tests purge where the data directory contains old snapshots and data
-     * logs, newest snapshots and data logs
-     */
-    @Test
-    public void testSnapFilesLessThanToRetain() throws Exception {
-        int nRecentCount = 4;
-        int fileToPurgeCount = 2;
-        AtomicInteger offset = new AtomicInteger(0);
-        tmpDir = ClientBase.createTmpDir();
-        File version2 = new File(tmpDir.toString(), "version-2");
-        Assert.assertTrue("Failed to create version_2 dir:" + version2.toString(),
-                version2.mkdir());
-        List<File> snapsToPurge = new ArrayList<File>();
-        List<File> logsToPurge = new ArrayList<File>();
-        List<File> snaps = new ArrayList<File>();
-        List<File> logs = new ArrayList<File>();
-        createDataDirFiles(offset, fileToPurgeCount, false, version2, snapsToPurge,
-                logsToPurge);
-        createDataDirFiles(offset, nRecentCount, false, version2, snaps, logs);
-        logs.add(logsToPurge.remove(0)); // log that precedes first retained snapshot is also retained
-
-        /**
-         * The newest log file preceding the oldest retained snapshot is not removed as it may
-         * contain transactions newer than the oldest snapshot.
-         */
-        logsToPurge.remove(0);
-
-        FileTxnSnapLog txnLog = new FileTxnSnapLog(tmpDir, tmpDir);
-        PurgeTxnLog.purgeOlderSnapshots(txnLog, snaps.get(snaps.size() - 1));
-        txnLog.close();
-        verifyFilesAfterPurge(snapsToPurge, false);
-        verifyFilesAfterPurge(logsToPurge, false);
-        verifyFilesAfterPurge(snaps, true);
-        verifyFilesAfterPurge(logs, true);
-    }
-
-    /**
-     * PurgeTxnLog is called with dataLogDir snapDir -n count This test case
-     * verify these values are parsed properly and functionality works fine
-     */
-    @Test
-    public void testPurgeTxnLogWithDataDir()
-            throws Exception {
-        tmpDir = ClientBase.createTmpDir();
-        File dataDir = new File(tmpDir, "dataDir");
-        File dataLogDir = new File(tmpDir, "dataLogDir");
-
-        File dataDirVersion2 = new File(dataDir, "version-2");
-        dataDirVersion2.mkdirs();
-        File dataLogDirVersion2 = new File(dataLogDir, "version-2");
-        dataLogDirVersion2.mkdirs();
-
-        // create dummy log and transaction file
-        int totalFiles = 20;
-
-        // create transaction and snapshot files in different-different
-        // directories
-        for (int i = 0; i < totalFiles; i++) {
-            // simulate log file
-            File logFile = new File(dataLogDirVersion2, "log."
-                    + Long.toHexString(i));
-            logFile.createNewFile();
-            // simulate snapshot file
-            File snapFile = new File(dataDirVersion2, "snapshot."
-                    + Long.toHexString(i));
-            snapFile.createNewFile();
-        }
-
-        int numberOfSnapFilesToKeep = 10;
-        // scenario where four parameter are passed
-        String[] args = new String[] { dataLogDir.getAbsolutePath(),
-                dataDir.getAbsolutePath(), "-n",
-                Integer.toString(numberOfSnapFilesToKeep) };
-        PurgeTxnLog.main(args);
-
-        assertEquals(numberOfSnapFilesToKeep, dataDirVersion2.listFiles().length);
-        // Since for each snapshot we have a log file with same zxid, expect same # logs as snaps to be kept
-        assertEquals(numberOfSnapFilesToKeep, dataLogDirVersion2.listFiles().length);
-        ClientBase.recursiveDelete(tmpDir);
-
-    }
-
-    /**
-     * PurgeTxnLog is called with dataLogDir -n count This test case verify
-     * these values are parsed properly and functionality works fine
-     */
-    @Test
-    public void testPurgeTxnLogWithoutDataDir()
-            throws Exception {
-        tmpDir = ClientBase.createTmpDir();
-        File dataDir = new File(tmpDir, "dataDir");
-        File dataLogDir = new File(tmpDir, "dataLogDir");
-
-        File dataDirVersion2 = new File(dataDir, "version-2");
-        dataDirVersion2.mkdirs();
-        File dataLogDirVersion2 = new File(dataLogDir, "version-2");
-        dataLogDirVersion2.mkdirs();
-
-        // create dummy log and transaction file
-        int totalFiles = 20;
-
-        // create transaction and snapshot files in data directory
-        for (int i = 0; i < totalFiles; i++) {
-            // simulate log file
-            File logFile = new File(dataLogDirVersion2, "log."
-                    + Long.toHexString(i));
-            logFile.createNewFile();
-            // simulate snapshot file
-            File snapFile = new File(dataLogDirVersion2, "snapshot."
-                    + Long.toHexString(i));
-            snapFile.createNewFile();
-        }
-
-        int numberOfSnapFilesToKeep = 10;
-        // scenario where only three parameter are passed
-        String[] args = new String[] { dataLogDir.getAbsolutePath(), "-n",
-                Integer.toString(numberOfSnapFilesToKeep) };
-        PurgeTxnLog.main(args);
-        assertEquals(numberOfSnapFilesToKeep * 2, // Since for each snapshot we have a log file with same zxid, expect same # logs as snaps to be kept
-                dataLogDirVersion2.listFiles().length);
-        ClientBase.recursiveDelete(tmpDir);
-
-    }
-
-    /**
-     * Verifies that purge does not delete any log files which started before the oldest retained
-     * snapshot but which might extend beyond it.
-     * @throws Exception an exception might be thrown here
-     */
-    @Test
-    public void testPurgeDoesNotDeleteOverlappingLogFile() throws Exception {
-        // Setting used for snapRetainCount in this test.
-        final int SNAP_RETAIN_COUNT = 3;
-        // Number of znodes this test creates in each snapshot.
-        final int NUM_ZNODES_PER_SNAPSHOT = 100;
-        /**
-         * Set a sufficiently high snapCount to ensure that we don't rollover the log.  Normally,
-         * the default value (100K at time of this writing) would ensure this, but we make that
-         * dependence explicit here to make the test future-proof.  Not rolling over the log is
-         * important for this test since we are testing retention of the one and only log file which
-         * predates each retained snapshot.
-         */
-        SyncRequestProcessor.setSnapCount(SNAP_RETAIN_COUNT * NUM_ZNODES_PER_SNAPSHOT * 10);
-
-        // Create Zookeeper and connect to it.
-        tmpDir = ClientBase.createTmpDir();
-        ClientBase.setupTestEnv();
-        ZooKeeperServer zks = new ZooKeeperServer(tmpDir, tmpDir, 3000);
-        final int PORT = Integer.parseInt(HOSTPORT.split(":")[1]);
-        ServerCnxnFactory f = ServerCnxnFactory.createFactory(PORT, -1);
-        f.startup(zks);
-        Assert.assertTrue("waiting for server being up ",
-                ClientBase.waitForServerUp(HOSTPORT,CONNECTION_TIMEOUT));
-        ZooKeeper zk = ClientBase.createZKClient(HOSTPORT);
-
-        // Unique identifier for each znode that we create.
-        int unique = 0;
-        try {
-            /**
-             * Create some znodes and take a snapshot.  Repeat this until we have SNAP_RETAIN_COUNT
-             * snapshots.  Do not rollover the log.
-             */
-            for (int snapshotCount = 0; snapshotCount < SNAP_RETAIN_COUNT; snapshotCount++) {
-                for (int i = 0; i< 100; i++, unique++) {
-                    zk.create("/snap-" + unique, new byte[0], Ids.OPEN_ACL_UNSAFE,
-                            CreateMode.PERSISTENT);
-                }
-                zks.takeSnapshot();
-            }
-            // Create some additional znodes without taking a snapshot afterwards.
-            for (int i = 0; i< 100; i++, unique++) {
-                zk.create("/snap-" + unique, new byte[0], Ids.OPEN_ACL_UNSAFE,
-                        CreateMode.PERSISTENT);
-            }
-        } finally {
-            zk.close();
-        }
-
-        // Shutdown Zookeeper.
-        f.shutdown();
-        zks.getTxnLogFactory().close();
-        zks.shutdown();
-        Assert.assertTrue("waiting for server to shutdown",
-                ClientBase.waitForServerDown(HOSTPORT, CONNECTION_TIMEOUT));
-
-        // Purge snapshot and log files.
-        PurgeTxnLog.purge(tmpDir, tmpDir, SNAP_RETAIN_COUNT);
-
-        // Initialize Zookeeper again from the same dataDir.
-        zks = new ZooKeeperServer(tmpDir, tmpDir, 3000);
-        f = ServerCnxnFactory.createFactory(PORT, -1);
-        f.startup(zks);
-        zk = ClientBase.createZKClient(HOSTPORT);
-
-        /**
-         * Verify that the last znode that was created above exists.  This znode's creation was
-         * captured by the transaction log which was created before any of the above
-         * SNAP_RETAIN_COUNT snapshots were created, but it's not captured in any of these
-         * snapshots.  So for it it exist, the (only) existing log file should not have been purged.
-         */
-        final String lastZnode = "/snap-" + (unique - 1);
-        final Stat stat = zk.exists(lastZnode, false);
-        Assert.assertNotNull("Last znode does not exist: " + lastZnode, stat);
-
-        // Shutdown for the last time.
-        f.shutdown();
-        zks.getTxnLogFactory().close();
-        zks.shutdown();
-    }
-
-    private File createDataDirLogFile(File version_2, int Zxid) throws IOException {
-        File logFile = new File(version_2 + "/log." + Long.toHexString(Zxid));
-        Assert.assertTrue("Failed to create log File:" + logFile.toString(),
-                logFile.createNewFile());
-        return logFile;
-    }
-
-    private void createDataDirFiles(AtomicInteger offset, int limit, boolean createPrecedingLogFile,
-            File version_2, List<File> snaps, List<File> logs)
-            throws IOException {
-        int counter = offset.get() + (2 * limit);
-        if (createPrecedingLogFile) {
-            counter++;
-        }
-        offset.set(counter);
-        for (int i = 0; i < limit; i++) {
-            // simulate log file
-            logs.add(createDataDirLogFile(version_2, --counter));
-            // simulate snapshot file
-            File snapFile = new File(version_2 + "/snapshot."
-                    + Long.toHexString(--counter));
-            Assert.assertTrue("Failed to create snap File:" + snapFile.toString(),
-                    snapFile.createNewFile());
-            snaps.add(snapFile);
-        }
-        if (createPrecedingLogFile) {
-            logs.add(createDataDirLogFile(version_2, --counter));
-        }
-    }
-
-    private void verifyFilesAfterPurge(List<File> logs, boolean exists) {
-        for (File file : logs) {
-            Assert.assertEquals("After purging, file " + file, exists,
-                    file.exists());
-        }
-    }
-
-    private List<String> manyClientOps(final ZooKeeper zk,
-            final CountDownLatch doPurge, int thCount, final String prefix) {
-        Thread[] ths = new Thread[thCount];
-        final List<String> znodes = Collections
-                .synchronizedList(new ArrayList<String>());
-        final CountDownLatch finished = new CountDownLatch(thCount);
-        for (int indx = 0; indx < thCount; indx++) {
-            final String myprefix = prefix + "-" + indx;
-            Thread th = new Thread() {
-                public void run() {
-                    for (int i = 0; i < 1000; i++) {
-                        try {
-                            String mynode = myprefix + "-" + i;
-                            znodes.add(mynode);
-                            zk.create(mynode, new byte[0], Ids.OPEN_ACL_UNSAFE,
-                                    CreateMode.PERSISTENT);
-                        } catch (Exception e) {
-                            LOG.error("Unexpected exception occurred!", e);
-                        }
-                        if (i == 200) {
-                            doPurge.countDown();
-                        }
-                    }
-                    finished.countDown();
-                };
-            };
-            ths[indx] = th;
-        }
-
-        for (Thread thread : ths) {
-            thread.start();
-        }
-        try {
-            Assert.assertTrue("ZkClient ops is not finished!",
-                    finished.await(OP_TIMEOUT_IN_MILLIS, TimeUnit.MILLISECONDS));
-        } catch (InterruptedException ie) {
-            LOG.error("Unexpected exception occurred!", ie);
-            Assert.fail("Unexpected exception occurred!");
-        }
-        return znodes;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/3ce1b18b/src/java/test/org/apache/zookeeper/server/ReferenceCountedACLCacheTest.java
----------------------------------------------------------------------
diff --git a/src/java/test/org/apache/zookeeper/server/ReferenceCountedACLCacheTest.java b/src/java/test/org/apache/zookeeper/server/ReferenceCountedACLCacheTest.java
deleted file mode 100644
index 795472f..0000000
--- a/src/java/test/org/apache/zookeeper/server/ReferenceCountedACLCacheTest.java
+++ /dev/null
@@ -1,287 +0,0 @@
-/**
- * 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 org.apache.jute.BinaryInputArchive;
-import org.apache.jute.BinaryOutputArchive;
-import org.apache.jute.InputArchive;
-import org.apache.jute.OutputArchive;
-import org.apache.zookeeper.ZooDefs;
-import org.apache.zookeeper.data.ACL;
-import org.apache.zookeeper.data.Id;
-import org.junit.Test;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.junit.Assert.*;
-
-public class ReferenceCountedACLCacheTest {
-    @Test
-    public void testSameACLGivesSameID() {
-        List<ACL> testACL = createACL("myid");
-
-        ReferenceCountedACLCache cache = new ReferenceCountedACLCache();
-        Long aclId = cache.convertAcls(testACL);
-
-        List<ACL> testACL2 = createACL("myid");
-
-        assertEquals(aclId, cache.convertAcls(testACL2));
-    }
-
-    @Test
-    public void testWhetherOrderingMatters() {
-        List<ACL> testACL = new ArrayList<ACL>();
-        testACL.add(new ACL(ZooDefs.Perms.READ, new Id("scheme", "ro")));
-        testACL.add(new ACL(ZooDefs.Perms.WRITE, new Id("scheme", "rw")));
-
-        ReferenceCountedACLCache cache = new ReferenceCountedACLCache();
-        Long aclId = cache.convertAcls(testACL);
-
-        List<ACL> testACL2 = new ArrayList<ACL>();
-        testACL2.add(new ACL(ZooDefs.Perms.WRITE, new Id("scheme", "rw")));
-        testACL2.add(new ACL(ZooDefs.Perms.READ, new Id("scheme", "ro")));
-
-        assertFalse(aclId.equals(cache.convertAcls(testACL2)));
-    }
-
-    @Test
-    public void testBidirectionality() {
-        List<ACL> testACL = createACL("myid");
-
-        ReferenceCountedACLCache cache = new ReferenceCountedACLCache();
-        Long aclId = cache.convertAcls(testACL);
-
-        assertEquals(testACL, cache.convertLong(aclId));
-    }
-
-    @Test
-    public void testCacheSize() {
-        List<ACL> testACL = createACL("myid");
-
-        ReferenceCountedACLCache cache = new ReferenceCountedACLCache();
-        Long aclId = cache.convertAcls(testACL);
-        assertEquals(1, cache.size());
-
-        List<ACL> testACL2 = createACL("myid");
-
-        assertEquals(aclId, cache.convertAcls(testACL2));
-        assertEquals(1, cache.size());
-
-        List<ACL> testACL3 = createACL("differentId");
-
-        Long aclId3 = cache.convertAcls(testACL3);
-        assertFalse(aclId3.equals(aclId));
-        assertEquals(2, cache.size());
-    }
-
-    @Test
-    public void testAddThenRemove() {
-        List<ACL> testACL = createACL("myid");
-
-        ReferenceCountedACLCache cache = new ReferenceCountedACLCache();
-        Long aclId = cache.convertAcls(testACL);
-        assertEquals(1, cache.size());
-
-        cache.removeUsage(aclId);
-        assertEquals(0, cache.size());
-    }
-
-    @Test
-    public void testMultipleAddsAndRemove() {
-        List<ACL> testACL = createACL("myid");
-
-        ReferenceCountedACLCache cache = new ReferenceCountedACLCache();
-        Long aclId = cache.convertAcls(testACL);
-        assertEquals(1, cache.size());
-
-        cache.convertAcls(testACL);
-        assertEquals(1, cache.size());
-
-        List<ACL> testACL2 = createACL("anotherId");
-        cache.convertAcls(testACL2);
-
-        cache.removeUsage(aclId);
-        assertEquals(2, cache.size());
-        cache.removeUsage(aclId);
-        assertEquals(1, cache.size());
-
-        Long newId = cache.convertAcls(testACL);
-        assertFalse(aclId.equals(newId));
-    }
-
-    @Test
-    public void testAddUsage() {
-        List<ACL> testACL = createACL("myid");
-
-        ReferenceCountedACLCache cache = new ReferenceCountedACLCache();
-        Long aclId = cache.convertAcls(testACL);
-        assertEquals(1, cache.size());
-
-        cache.addUsage(aclId);
-        assertEquals(1, cache.size());
-
-        cache.removeUsage(aclId);
-        assertEquals(1, cache.size());
-        cache.removeUsage(aclId);
-        assertEquals(0, cache.size());
-    }
-
-    @Test
-    public void testAddNonExistentUsage() {
-        ReferenceCountedACLCache cache = new ReferenceCountedACLCache();
-        cache.addUsage(1L);
-
-        assertEquals(0, cache.size());
-        /*
-        On startup, it's possible that we'll try calling addUsage of an ID not in the cache.  This is safe to ignore
-        as it'll be added later when we traverse the tranlog.  See discussion here:
-        http://mail-archives.apache.org/mod_mbox/zookeeper-user/201507.mbox/%3CCAB5oV2_ujhvBA1sEkCG2WRakPjCy%2BNR10620WK2G1GGgmEO44g%40mail.gmail.com%3E
-
-        This test makes sure that we don't add the ID to the cache in this case as that would result in dupes later
-        and consequently incorrect counts and entries that will never be cleaned out.
-         */
-    }
-
-    @Test
-    public void testSerializeDeserialize() throws IOException {
-        ReferenceCountedACLCache cache = new ReferenceCountedACLCache();
-
-        List<ACL> acl1 = createACL("one");
-        List<ACL> acl2 = createACL("two");
-        List<ACL> acl3 = createACL("three");
-        List<ACL> acl4 = createACL("four");
-        List<ACL> acl5 = createACL("five");
-
-        Long aclId1 = convertACLsNTimes(cache, acl1, 1);
-        Long aclId2 = convertACLsNTimes(cache, acl2, 2);
-        Long aclId3 = convertACLsNTimes(cache, acl3, 3);
-        Long aclId4 = convertACLsNTimes(cache, acl4, 4);
-        Long aclId5 = convertACLsNTimes(cache, acl5, 5);
-
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        BinaryOutputArchive archive = BinaryOutputArchive.getArchive(baos);
-        cache.serialize(archive);
-
-        BinaryInputArchive inArchive = BinaryInputArchive.getArchive(new ByteArrayInputStream(baos.toByteArray()));
-        ReferenceCountedACLCache deserializedCache = new ReferenceCountedACLCache();
-        deserializedCache.deserialize(inArchive);
-        callAddUsageNTimes(deserializedCache, aclId1, 1);
-        callAddUsageNTimes(deserializedCache, aclId2, 2);
-        callAddUsageNTimes(deserializedCache, aclId3, 3);
-        callAddUsageNTimes(deserializedCache, aclId4, 4);
-        callAddUsageNTimes(deserializedCache, aclId5, 5);
-        assertCachesEqual(cache, deserializedCache);
-    }
-
-    @Test
-    public void testNPEInDeserialize() throws IOException {
-        ReferenceCountedACLCache serializeCache = new ReferenceCountedACLCache(){
-            @Override
-            public synchronized void serialize(OutputArchive oa) throws IOException {
-                oa.writeInt(1, "map");
-                oa.writeLong(1, "long");
-                oa.startVector(null, "acls");
-                oa.endVector(null, "acls");
-            }
-        };
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        BinaryOutputArchive archive = BinaryOutputArchive.getArchive(baos);
-        serializeCache.serialize(archive);
-        BinaryInputArchive inArchive = BinaryInputArchive.getArchive(new ByteArrayInputStream(baos.toByteArray()));
-        ReferenceCountedACLCache deserializedCache = new ReferenceCountedACLCache();
-        try {
-            deserializedCache.deserialize(inArchive);
-        } catch (NullPointerException e){
-            fail("should not throw NPE while do deserialized");
-        } catch (RuntimeException e) {
-            // do nothing.
-        }
-    }
-
-
-    private void assertCachesEqual(ReferenceCountedACLCache expected, ReferenceCountedACLCache actual){
-        assertEquals(expected.aclIndex, actual.aclIndex);
-        assertEquals(expected.aclKeyMap, actual.aclKeyMap);
-        assertEquals(expected.longKeyMap, actual.longKeyMap);
-        assertEquals(expected.referenceCounter, actual.referenceCounter);
-    }
-
-    @Test
-    public void testPurgeUnused() throws IOException {
-        ReferenceCountedACLCache cache = new ReferenceCountedACLCache();
-
-        List<ACL> acl1 = createACL("one");
-        List<ACL> acl2 = createACL("two");
-        List<ACL> acl3 = createACL("three");
-        List<ACL> acl4 = createACL("four");
-        List<ACL> acl5 = createACL("five");
-
-        Long aclId1 = convertACLsNTimes(cache, acl1, 1);
-        Long aclId2 = convertACLsNTimes(cache, acl2, 2);
-        Long aclId3 = convertACLsNTimes(cache, acl3, 3);
-        Long aclId4 = convertACLsNTimes(cache, acl4, 4);
-        Long aclId5 = convertACLsNTimes(cache, acl5, 5);
-
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        BinaryOutputArchive archive = BinaryOutputArchive.getArchive(baos);
-        cache.serialize(archive);
-
-        BinaryInputArchive inArchive = BinaryInputArchive.getArchive(new ByteArrayInputStream(baos.toByteArray()));
-        ReferenceCountedACLCache deserializedCache = new ReferenceCountedACLCache();
-        deserializedCache.deserialize(inArchive);
-        callAddUsageNTimes(deserializedCache, aclId1, 1);
-        callAddUsageNTimes(deserializedCache, aclId2, 2);
-        deserializedCache.purgeUnused();
-
-        assertEquals(2, deserializedCache.size());
-        assertEquals(aclId1, deserializedCache.convertAcls(acl1));
-        assertEquals(aclId2, deserializedCache.convertAcls(acl2));
-        assertFalse(acl3.equals(deserializedCache.convertAcls(acl3)));
-        assertFalse(acl4.equals(deserializedCache.convertAcls(acl4)));
-        assertFalse(acl5.equals(deserializedCache.convertAcls(acl5)));
-    }
-
-    private void callAddUsageNTimes(ReferenceCountedACLCache deserializedCache, Long aclId, int num) {
-        for (int i = 0; i < num; i++) {
-            deserializedCache.addUsage(aclId);
-        }
-    }
-
-    private Long convertACLsNTimes(ReferenceCountedACLCache cache, List<ACL> acl, int num) {
-        if (num <= 0) {
-            return -1L;
-        }
-
-        for (int i = 0; i < num -1; i++) {
-            cache.convertAcls(acl);
-        }
-
-        return cache.convertAcls(acl);
-    }
-
-    private List<ACL> createACL(String id) {
-        List<ACL> acl1 = new ArrayList<ACL>();
-        acl1.add(new ACL(ZooDefs.Perms.ADMIN, new Id("scheme", id)));
-        return acl1;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/3ce1b18b/src/java/test/org/apache/zookeeper/server/SerializationPerfTest.java
----------------------------------------------------------------------
diff --git a/src/java/test/org/apache/zookeeper/server/SerializationPerfTest.java b/src/java/test/org/apache/zookeeper/server/SerializationPerfTest.java
deleted file mode 100644
index 4398232..0000000
--- a/src/java/test/org/apache/zookeeper/server/SerializationPerfTest.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/**
- * 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;
-import java.io.OutputStream;
-
-import org.apache.jute.BinaryOutputArchive;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.ZKTestCase;
-import org.junit.Test;
-
-public class SerializationPerfTest extends ZKTestCase {
-    protected static final Logger LOG = LoggerFactory.getLogger(SerializationPerfTest.class);
-
-    private static class NullOutputStream extends OutputStream {
-        public void write(int b) {
-            // do nothing - exclude persistence from perf
-        }
-    }
-
-    static int createNodes(DataTree tree, String path, int depth,
-            int childcount, int parentCVersion, byte[] data) throws KeeperException.NodeExistsException, KeeperException.NoNodeException {
-        path += "node" + depth;
-        tree.createNode(path, data, null, -1, ++parentCVersion, 1, 1);
-
-        if (--depth == 0) {
-            return 1;
-        }
-
-        path += "/";
-
-        int count = 1;
-        for (int i = 0; i < childcount; i++) {
-            count += createNodes(tree, path + i, depth, childcount, 1, data);
-        }
-
-        return count;
-    }
-
-    private static void serializeTree(int depth, int width, int len)
-            throws InterruptedException, IOException, KeeperException.NodeExistsException, KeeperException.NoNodeException {
-        DataTree tree = new DataTree();
-        createNodes(tree, "/", depth, width, tree.getNode("/").stat.getCversion(), new byte[len]);
-        int count = tree.getNodeCount();
-
-        BinaryOutputArchive oa =
-            BinaryOutputArchive.getArchive(new NullOutputStream());
-        System.gc();
-        long start = System.nanoTime();
-        tree.serialize(oa, "test");
-        long end = System.nanoTime();
-        long durationms = (end - start)/1000000L;
-        long pernodeus = ((end - start)/1000L)/count;
-        LOG.info("Serialized " + count + " nodes in "
-                + durationms + " ms (" + pernodeus + "us/node), depth="
-                + depth + " width=" + width + " datalen=" + len);
-    }
-
-    @Test
-    public void testSingleSerialize()
-            throws InterruptedException, IOException, KeeperException.NodeExistsException, KeeperException.NoNodeException {
-        serializeTree(1, 0, 20);
-    }
-
-    @Test
-    public void testWideSerialize()
-            throws InterruptedException, IOException, KeeperException.NodeExistsException, KeeperException.NoNodeException {
-        serializeTree(2, 10000, 20);
-    }
-
-    @Test
-    public void testDeepSerialize()
-            throws InterruptedException, IOException, KeeperException.NodeExistsException, KeeperException.NoNodeException {
-        serializeTree(400, 1, 20);
-    }
-
-    @Test
-    public void test10Wide5DeepSerialize()
-            throws InterruptedException, IOException, KeeperException.NodeExistsException, KeeperException.NoNodeException {
-        serializeTree(5, 10, 20);
-    }
-
-    @Test
-    public void test15Wide5DeepSerialize()
-            throws InterruptedException, IOException, KeeperException.NodeExistsException, KeeperException.NoNodeException {
-        serializeTree(5, 15, 20);
-    }
-
-    @Test
-    public void test25Wide4DeepSerialize()
-            throws InterruptedException, IOException, KeeperException.NodeExistsException, KeeperException.NoNodeException {
-        serializeTree(4, 25, 20);
-    }
-
-    @Test
-    public void test40Wide4DeepSerialize()
-            throws InterruptedException, IOException, KeeperException.NodeExistsException, KeeperException.NoNodeException {
-        serializeTree(4, 40, 20);
-    }
-
-    @Test
-    public void test300Wide3DeepSerialize()
-            throws InterruptedException, IOException, KeeperException.NodeExistsException, KeeperException.NoNodeException {
-        serializeTree(3, 300, 20);
-    }
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/3ce1b18b/src/java/test/org/apache/zookeeper/server/ServerCnxnFactoryAccessor.java
----------------------------------------------------------------------
diff --git a/src/java/test/org/apache/zookeeper/server/ServerCnxnFactoryAccessor.java b/src/java/test/org/apache/zookeeper/server/ServerCnxnFactoryAccessor.java
deleted file mode 100644
index 0dfdcfe..0000000
--- a/src/java/test/org/apache/zookeeper/server/ServerCnxnFactoryAccessor.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * 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;
-
-public class ServerCnxnFactoryAccessor {
-    public static ZooKeeperServer getZkServer(ServerCnxnFactory fac) {
-	return fac.zkServer;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/3ce1b18b/src/java/test/org/apache/zookeeper/server/ServerIdTest.java
----------------------------------------------------------------------
diff --git a/src/java/test/org/apache/zookeeper/server/ServerIdTest.java b/src/java/test/org/apache/zookeeper/server/ServerIdTest.java
deleted file mode 100644
index a04c37b..0000000
--- a/src/java/test/org/apache/zookeeper/server/ServerIdTest.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/**
- * 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 org.apache.zookeeper.CreateMode;
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.TestableZooKeeper;
-import org.apache.zookeeper.ZKParameterized;
-import org.apache.zookeeper.ZooDefs;
-import org.apache.zookeeper.data.Stat;
-import org.apache.zookeeper.test.ClientBase;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-
-import java.util.ArrayList;
-import java.util.List;
-
-@RunWith(Parameterized.class)
-@Parameterized.UseParametersRunnerFactory(ZKParameterized.RunnerFactory.class)
-public class ServerIdTest extends ClientBase {
-    private final TestType testType;
-
-    private static class TestType {
-        final boolean ttlsEnabled;
-        final int serverId;
-
-        TestType(boolean ttlsEnabled, int serverId) {
-            this.ttlsEnabled = ttlsEnabled;
-            this.serverId = serverId;
-        }
-    }
-
-    @Parameterized.Parameters
-    public static List<TestType> data() {
-        List<TestType> testTypes = new ArrayList<>();
-        for ( boolean ttlsEnabled : new boolean[]{true, false} ) {
-            for ( int serverId = 0; serverId <= 255; ++serverId ) {
-                testTypes.add(new TestType(ttlsEnabled, serverId));
-            }
-        }
-        return testTypes;
-    }
-
-    @After
-    @Override
-    public void tearDown() throws Exception {
-        super.tearDown();
-        System.clearProperty("zookeeper.extendedTypesEnabled");
-    }
-
-    public ServerIdTest(TestType testType) {
-        this.testType = testType;
-    }
-
-    @Before
-    @Override
-    public void setUp() throws Exception {
-        System.setProperty("zookeeper.extendedTypesEnabled", Boolean.toString(testType.ttlsEnabled));
-        LOG.info("ttlsEnabled: {} - ServerId: {}", testType.ttlsEnabled, testType.serverId);
-        try {
-            super.setUpWithServerId(testType.serverId);
-        } catch (RuntimeException e) {
-            if ( testType.ttlsEnabled && (testType.serverId >= EphemeralType.MAX_EXTENDED_SERVER_ID) ) {
-                return; // expected
-            }
-            throw e;
-        }
-    }
-
-    @Test
-    public void doTest() throws Exception {
-        if ( testType.ttlsEnabled && (testType.serverId >= EphemeralType.MAX_EXTENDED_SERVER_ID) ) {
-            return;
-        }
-
-        TestableZooKeeper zk = null;
-        try {
-            zk = createClient();
-
-            zk.create("/foo", new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
-            zk.delete("/foo", -1);
-
-            if ( testType.ttlsEnabled ) {
-                zk.create("/foo", new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT_WITH_TTL, new Stat(), 1000);  // should work
-            } else {
-                try {
-                    zk.create("/foo", new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT_WITH_TTL, new Stat(), 1000);
-                    Assert.fail("Should have thrown KeeperException.UnimplementedException");
-                } catch (KeeperException.UnimplementedException e) {
-                    // expected
-                }
-            }
-        } finally {
-            if ( zk != null ) {
-                zk.close();
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/3ce1b18b/src/java/test/org/apache/zookeeper/server/ServerStatsTest.java
----------------------------------------------------------------------
diff --git a/src/java/test/org/apache/zookeeper/server/ServerStatsTest.java b/src/java/test/org/apache/zookeeper/server/ServerStatsTest.java
deleted file mode 100644
index aa207d1..0000000
--- a/src/java/test/org/apache/zookeeper/server/ServerStatsTest.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/**
- * 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 org.apache.zookeeper.ZKTestCase;
-import org.apache.zookeeper.common.Time;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.hamcrest.Matchers.lessThanOrEqualTo;
-
-public class ServerStatsTest extends ZKTestCase {
-
-    private ServerStats.Provider providerMock;
-
-    @Before
-    public void setUp() {
-        providerMock = mock(ServerStats.Provider.class);
-    }
-
-    @Test
-    public void testPacketsMetrics() {
-        // Given ...
-        ServerStats serverStats = new ServerStats(providerMock);
-        int incrementCount = 20;
-
-        // When increment ...
-        for (int i = 0; i < incrementCount; i++) {
-            serverStats.incrementPacketsSent();
-            serverStats.incrementPacketsReceived();
-            serverStats.incrementPacketsReceived();
-        }
-
-        // Then ...
-        Assert.assertEquals(incrementCount, serverStats.getPacketsSent());
-        Assert.assertEquals(incrementCount*2, serverStats.getPacketsReceived());
-
-        // When reset ...
-        serverStats.resetRequestCounters();
-
-        // Then ...
-        assertAllPacketsZero(serverStats);
-
-    }
-
-    @Test
-    public void testLatencyMetrics() {
-        // Given ...
-        ServerStats serverStats = new ServerStats(providerMock);
-
-        // When incremented...
-        serverStats.updateLatency(Time.currentElapsedTime()-1000);
-        serverStats.updateLatency(Time.currentElapsedTime()-2000);
-
-        // Then ...
-        assertThat("Max latency check", 2000L,
-                lessThanOrEqualTo(serverStats.getMaxLatency()));
-        assertThat("Min latency check", 1000L,
-                lessThanOrEqualTo(serverStats.getMinLatency()));
-        assertThat("Avg latency check", 1500L,
-                lessThanOrEqualTo(serverStats.getAvgLatency()));
-
-        // When reset...
-        serverStats.resetLatency();
-
-        // Then ...
-        assertAllLatencyZero(serverStats);
-    }
-
-    @Test
-    public void testFsyncThresholdExceedMetrics() {
-        // Given ...
-        ServerStats serverStats = new ServerStats(providerMock);
-        int incrementCount = 30;
-
-        // When increment ...
-        for (int i = 0; i < incrementCount; i++) {
-            serverStats.incrementFsyncThresholdExceedCount();
-        }
-
-        // Then ...
-        Assert.assertEquals(incrementCount, serverStats.getFsyncThresholdExceedCount());
-
-        // When reset ...
-        serverStats.resetFsyncThresholdExceedCount();
-
-        // Then ...
-        assertFsyncThresholdExceedCountZero(serverStats);
-
-    }
-
-    @Test
-    public void testReset() {
-        // Given ...
-        ServerStats serverStats = new ServerStats(providerMock);
-
-        assertAllPacketsZero(serverStats);
-        assertAllLatencyZero(serverStats);
-
-        // When ...
-        serverStats.incrementPacketsSent();
-        serverStats.incrementPacketsReceived();
-        serverStats.updateLatency(Time.currentElapsedTime()-1000);
-
-        serverStats.reset();
-
-        // Then ...
-        assertAllPacketsZero(serverStats);
-        assertAllLatencyZero(serverStats);
-    }
-
-    private void assertAllPacketsZero(ServerStats serverStats) {
-        Assert.assertEquals(0L, serverStats.getPacketsSent());
-        Assert.assertEquals(0L, serverStats.getPacketsReceived());
-    }
-
-    private void assertAllLatencyZero(ServerStats serverStats) {
-        Assert.assertEquals(0L, serverStats.getMaxLatency());
-        Assert.assertEquals(0L, serverStats.getMinLatency());
-        Assert.assertEquals(0L, serverStats.getAvgLatency());
-    }
-
-    private void assertFsyncThresholdExceedCountZero(ServerStats serverStats) {
-        Assert.assertEquals(0L, serverStats.getFsyncThresholdExceedCount());
-    }
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/3ce1b18b/src/java/test/org/apache/zookeeper/server/SessionTrackerTest.java
----------------------------------------------------------------------
diff --git a/src/java/test/org/apache/zookeeper/server/SessionTrackerTest.java b/src/java/test/org/apache/zookeeper/server/SessionTrackerTest.java
deleted file mode 100644
index 00e34fa..0000000
--- a/src/java/test/org/apache/zookeeper/server/SessionTrackerTest.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/**
- * 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;
-import java.io.IOException;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.ZKTestCase;
-import org.apache.zookeeper.ZooDefs.OpCode;
-import org.apache.zookeeper.server.SessionTrackerImpl.SessionImpl;
-import org.apache.zookeeper.test.ClientBase;
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- * Testing zk client session logic in sessiontracker
- */
-public class SessionTrackerTest extends ZKTestCase {
-
-    private final long sessionId = 339900;
-    private final int sessionTimeout = 3000;
-    private FirstProcessor firstProcessor;
-    private CountDownLatch latch;
-
-    /**
-     * Verify the create session call in the Leader.FinalRequestProcessor after
-     * the session expiration.
-     */
-    @Test(timeout = 20000)
-    public void testAddSessionAfterSessionExpiry() throws Exception {
-        ZooKeeperServer zks = setupSessionTracker();
-
-        latch = new CountDownLatch(1);
-        zks.sessionTracker.addSession(sessionId, sessionTimeout);
-        SessionTrackerImpl sessionTrackerImpl = (SessionTrackerImpl) zks.sessionTracker;
-        SessionImpl sessionImpl = sessionTrackerImpl.sessionsById
-                .get(sessionId);
-        Assert.assertNotNull("Sessionid:" + sessionId
-                + " doesn't exists in sessiontracker", sessionImpl);
-
-        // verify the session existence
-        Object sessionOwner = new Object();
-        sessionTrackerImpl.checkSession(sessionId, sessionOwner);
-
-        // waiting for the session expiry
-        latch.await(sessionTimeout * 2, TimeUnit.MILLISECONDS);
-
-        // Simulating FinalRequestProcessor logic: create session request has
-        // delayed and now reaches FinalRequestProcessor. Here the leader zk
-        // will do sessionTracker.addSession(id, timeout)
-        sessionTrackerImpl.addSession(sessionId, sessionTimeout);
-        try {
-            sessionTrackerImpl.checkSession(sessionId, sessionOwner);
-            Assert.fail("Should throw session expiry exception "
-                    + "as the session has expired and closed");
-        } catch (KeeperException.SessionExpiredException e) {
-            // expected behaviour
-        }
-        Assert.assertTrue("Session didn't expired", sessionImpl.isClosing());
-        Assert.assertFalse("Session didn't expired", sessionTrackerImpl
-                .touchSession(sessionId, sessionTimeout));
-        Assert.assertEquals(
-                "Duplicate session expiry request has been generated", 1,
-                firstProcessor.getCountOfCloseSessionReq());
-    }
-
-    /**
-     * Verify the session closure request has reached PrepRequestProcessor soon
-     * after session expiration by the session tracker
-     */
-    @Test(timeout = 20000)
-    public void testCloseSessionRequestAfterSessionExpiry() throws Exception {
-        ZooKeeperServer zks = setupSessionTracker();
-
-        latch = new CountDownLatch(1);
-        zks.sessionTracker.addSession(sessionId, sessionTimeout);
-        SessionTrackerImpl sessionTrackerImpl = (SessionTrackerImpl) zks.sessionTracker;
-        SessionImpl sessionImpl = sessionTrackerImpl.sessionsById
-                .get(sessionId);
-        Assert.assertNotNull("Sessionid:" + sessionId
-                + " doesn't exists in sessiontracker", sessionImpl);
-
-        // verify the session existence
-        Object sessionOwner = new Object();
-        sessionTrackerImpl.checkSession(sessionId, sessionOwner);
-
-        // waiting for the session expiry
-        latch.await(sessionTimeout * 2, TimeUnit.MILLISECONDS);
-
-        // Simulating close session request: removeSession() will be executed
-        // while OpCode.closeSession
-        sessionTrackerImpl.removeSession(sessionId);
-        SessionImpl actualSession = sessionTrackerImpl.sessionsById
-                .get(sessionId);
-        Assert.assertNull("Session:" + sessionId
-                + " still exists after removal", actualSession);
-    }
-
-    private ZooKeeperServer setupSessionTracker() throws IOException {
-        File tmpDir = ClientBase.createTmpDir();
-        ClientBase.setupTestEnv();
-        ZooKeeperServer zks = new ZooKeeperServer(tmpDir, tmpDir, 3000);
-        zks.setupRequestProcessors();
-        firstProcessor = new FirstProcessor(zks, null);
-        zks.firstProcessor = firstProcessor;
-
-        // setup session tracker
-        zks.createSessionTracker();
-        zks.startSessionTracker();
-        return zks;
-    }
-
-    // Mock processor used in zookeeper server
-    private class FirstProcessor extends PrepRequestProcessor {
-        private volatile int countOfCloseSessionReq = 0;
-
-        public FirstProcessor(ZooKeeperServer zks,
-                RequestProcessor nextProcessor) {
-            super(zks, nextProcessor);
-        }
-
-        @Override
-        public void processRequest(Request request) {
-            // check session close request
-            if (request.type == OpCode.closeSession) {
-                countOfCloseSessionReq++;
-                latch.countDown();
-            }
-        }
-
-        // return number of session expiry calls
-        int getCountOfCloseSessionReq() {
-            return countOfCloseSessionReq;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/3ce1b18b/src/java/test/org/apache/zookeeper/server/ToStringTest.java
----------------------------------------------------------------------
diff --git a/src/java/test/org/apache/zookeeper/server/ToStringTest.java b/src/java/test/org/apache/zookeeper/server/ToStringTest.java
deleted file mode 100644
index f19469b..0000000
--- a/src/java/test/org/apache/zookeeper/server/ToStringTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * 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 org.apache.zookeeper.ZKTestCase;
-import org.apache.zookeeper.proto.SetDataRequest;
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- * A misc place to verify toString methods - mainly to make sure they don't
- * fail.
- */
-public class ToStringTest extends ZKTestCase {
-    /** Verify jute - which we've had particular problems with in the past 
-     * wrt null fields */
-    @Test
-    public void testJuteToString() {
-        SetDataRequest req = new SetDataRequest(null, null, 0);
-        Assert.assertNotSame("ERROR", req.toString());
-    }
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/3ce1b18b/src/java/test/org/apache/zookeeper/server/WatchesPathReportTest.java
----------------------------------------------------------------------
diff --git a/src/java/test/org/apache/zookeeper/server/WatchesPathReportTest.java b/src/java/test/org/apache/zookeeper/server/WatchesPathReportTest.java
deleted file mode 100644
index c0b107d..0000000
--- a/src/java/test/org/apache/zookeeper/server/WatchesPathReportTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import org.apache.zookeeper.ZKTestCase;
-import org.junit.Before;
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-public class WatchesPathReportTest extends ZKTestCase {
-    private Map<String, Set<Long>> m;
-    private WatchesPathReport r;
-    @Before public void setUp() {
-        m = new HashMap<String, Set<Long>>();
-        Set<Long> s = new HashSet<Long>();
-        s.add(101L);
-        s.add(102L);
-        m.put("path1", s);
-        s = new HashSet<Long>();
-        s.add(201L);
-        m.put("path2", s);
-        r = new WatchesPathReport(m);
-    }
-    @Test public void testHasSessions() {
-        assertTrue(r.hasSessions("path1"));
-        assertTrue(r.hasSessions("path2"));
-        assertFalse(r.hasSessions("path3"));
-    }
-    @Test public void testGetSessions() {
-        Set<Long> s = r.getSessions("path1");
-        assertEquals(2, s.size());
-        assertTrue(s.contains(101L));
-        assertTrue(s.contains(102L));
-        s = r.getSessions("path2");
-        assertEquals(1, s.size());
-        assertTrue(s.contains(201L));
-        assertNull(r.getSessions("path3"));
-    }
-    @Test public void testToMap() {
-        assertEquals(m, r.toMap());
-    }
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/3ce1b18b/src/java/test/org/apache/zookeeper/server/WatchesReportTest.java
----------------------------------------------------------------------
diff --git a/src/java/test/org/apache/zookeeper/server/WatchesReportTest.java b/src/java/test/org/apache/zookeeper/server/WatchesReportTest.java
deleted file mode 100644
index 7f0343b..0000000
--- a/src/java/test/org/apache/zookeeper/server/WatchesReportTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import org.apache.zookeeper.ZKTestCase;
-import org.junit.Before;
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-public class WatchesReportTest extends ZKTestCase {
-    private Map<Long, Set<String>> m;
-    private WatchesReport r;
-    @Before public void setUp() {
-        m = new HashMap<Long, Set<String>>();
-        Set<String> s = new HashSet<String>();
-        s.add("path1a");
-        s.add("path1b");
-        m.put(1L, s);
-        s = new HashSet<String>();
-        s.add("path2a");
-        m.put(2L, s);
-        r = new WatchesReport(m);
-    }
-    @Test public void testHasPaths() {
-        assertTrue(r.hasPaths(1L));
-        assertTrue(r.hasPaths(2L));
-        assertFalse(r.hasPaths(3L));
-    }
-    @Test public void testGetPaths() {
-        Set<String> s = r.getPaths(1L);
-        assertEquals(2, s.size());
-        assertTrue(s.contains("path1a"));
-        assertTrue(s.contains("path1b"));
-        s = r.getPaths(2L);
-        assertEquals(1, s.size());
-        assertTrue(s.contains("path2a"));
-        assertNull(r.getPaths(3L));
-    }
-    @Test public void testToMap() {
-        assertEquals(m, r.toMap());
-    }
-}


Mime
View raw message