zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f..@apache.org
Subject svn commit: r1564946 [3/4] - in /zookeeper/bookkeeper/trunk: ./ bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/ bookkeeper-benchmark/src/test/java/org/apache/bookkeeper/benchmark/ bookkeeper-server/src/main/java/org/apache/bookkeepe...
Date Wed, 05 Feb 2014 21:43:40 GMT
Modified: zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestFencing.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestFencing.java?rev=1564946&r1=1564945&r2=1564946&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestFencing.java (original)
+++ zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestFencing.java Wed Feb  5 21:43:39 2014
@@ -21,20 +21,14 @@ package org.apache.bookkeeper.client;
  *
  */
 
-import org.junit.*;
-import java.net.InetSocketAddress;
-import java.util.Enumeration;
-import java.util.concurrent.CyclicBarrier;
 import java.util.concurrent.CountDownLatch;
-import org.apache.bookkeeper.conf.ClientConfiguration;
-import org.apache.bookkeeper.client.LedgerHandle;
-import org.apache.bookkeeper.client.LedgerEntry;
-import org.apache.bookkeeper.client.BookKeeper;
-import org.apache.bookkeeper.client.BookKeeperAdmin;
-import org.apache.bookkeeper.client.BKException;
+import java.util.concurrent.CyclicBarrier;
+
 import org.apache.bookkeeper.client.BookKeeper.DigestType;
+import org.apache.bookkeeper.conf.ClientConfiguration;
+import org.apache.bookkeeper.net.BookieSocketAddress;
 import org.apache.bookkeeper.test.BaseTestCase;
-
+import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -228,7 +222,7 @@ public class TestFencing extends BaseTes
         writelh.addEntry(tmp.getBytes());
         long numReadable = readlh.getLastAddConfirmed();
         LOG.error("numRead " + numReadable);
-        Enumeration<LedgerEntry> entries = readlh.readEntries(1, numReadable);
+        readlh.readEntries(1, numReadable);
         try {
             readlh.readEntries(numReadable+1, numReadable+1);
             fail("Shouldn't have been able to read this far");
@@ -266,7 +260,7 @@ public class TestFencing extends BaseTes
             writelh.addEntry(tmp.getBytes());
         }
 
-        InetSocketAddress bookieToKill 
+        BookieSocketAddress bookieToKill
             = writelh.getLedgerMetadata().getEnsemble(numEntries).get(0);
         killBookie(bookieToKill);
 
@@ -319,7 +313,7 @@ public class TestFencing extends BaseTes
         LedgerHandle readlh = bkc.openLedger(writelh.getId(), 
                                              digestType, "testPasswd".getBytes());
         // should be fenced by now
-        InetSocketAddress bookieToKill 
+        BookieSocketAddress bookieToKill
             = writelh.getLedgerMetadata().getEnsemble(numEntries).get(0);
         killBookie(bookieToKill);
         admin.recoverBookieData(bookieToKill, null);
@@ -356,7 +350,7 @@ public class TestFencing extends BaseTes
          * Try to open ledger.
          */
         try {
-            LedgerHandle readlh = bkc.openLedger(writelh.getId(), digestType, "badPassword".getBytes());
+            bkc.openLedger(writelh.getId(), digestType, "badPassword".getBytes());
             fail("Should not have been able to open with a bad password");
         } catch (BKException.BKUnauthorizedAccessException uue) {
             // correct behaviour

Modified: zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestLedgerChecker.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestLedgerChecker.java?rev=1564946&r1=1564945&r2=1564946&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestLedgerChecker.java (original)
+++ zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestLedgerChecker.java Wed Feb  5 21:43:39 2014
@@ -20,11 +20,11 @@
  */
 package org.apache.bookkeeper.client;
 
-import java.net.InetSocketAddress;
 import java.util.ArrayList;
 import java.util.Set;
 import java.util.concurrent.CountDownLatch;
 
+import org.apache.bookkeeper.net.BookieSocketAddress;
 import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.GenericCallback;
 import org.apache.bookkeeper.test.BookKeeperClusterTestCase;
 import org.junit.Test;
@@ -74,7 +74,7 @@ public class TestLedgerChecker extends B
         for (int i = 0; i < 10; i++) {
             lh.addEntry(TEST_LEDGER_ENTRY_DATA);
         }
-        InetSocketAddress replicaToKill = lh.getLedgerMetadata().getEnsembles()
+        BookieSocketAddress replicaToKill = lh.getLedgerMetadata().getEnsembles()
                 .get(0L).get(0);
         LOG.info("Killing {}", replicaToKill);
         killBookie(replicaToKill);
@@ -92,7 +92,7 @@ public class TestLedgerChecker extends B
         assertEquals("Fragment should be missing from first replica", result
                 .iterator().next().getAddress(), replicaToKill);
 
-        InetSocketAddress replicaToKill2 = lh.getLedgerMetadata()
+        BookieSocketAddress replicaToKill2 = lh.getLedgerMetadata()
                 .getEnsembles().get(0L).get(1);
         LOG.info("Killing {}", replicaToKill2);
         killBookie(replicaToKill2);
@@ -129,9 +129,9 @@ public class TestLedgerChecker extends B
         // Entry should have added in first 2 Bookies.
 
         // Kill the 3rd BK from ensemble.
-        ArrayList<InetSocketAddress> firstEnsemble = lh.getLedgerMetadata()
+        ArrayList<BookieSocketAddress> firstEnsemble = lh.getLedgerMetadata()
                 .getEnsembles().get(0L);
-        InetSocketAddress lastBookieFromEnsemble = firstEnsemble.get(2);
+        BookieSocketAddress lastBookieFromEnsemble = firstEnsemble.get(2);
         LOG.info("Killing " + lastBookieFromEnsemble + " from ensemble="
                 + firstEnsemble);
         killBookie(lastBookieFromEnsemble);
@@ -172,13 +172,13 @@ public class TestLedgerChecker extends B
         startNewBookie();
         lh.addEntry(TEST_LEDGER_ENTRY_DATA);
 
-        ArrayList<InetSocketAddress> firstEnsemble = lh.getLedgerMetadata()
+        ArrayList<BookieSocketAddress> firstEnsemble = lh.getLedgerMetadata()
                 .getEnsembles().get(0L);
 
-        InetSocketAddress firstBookieFromEnsemble = firstEnsemble.get(0);
+        BookieSocketAddress firstBookieFromEnsemble = firstEnsemble.get(0);
         killBookie(firstEnsemble, firstBookieFromEnsemble);
 
-        InetSocketAddress secondBookieFromEnsemble = firstEnsemble.get(1);
+        BookieSocketAddress secondBookieFromEnsemble = firstEnsemble.get(1);
         killBookie(firstEnsemble, secondBookieFromEnsemble);
         lh.addEntry(TEST_LEDGER_ENTRY_DATA);
         Set<LedgerFragment> result = getUnderReplicatedFragments(lh);
@@ -203,9 +203,9 @@ public class TestLedgerChecker extends B
         LedgerHandle lh = bkc.createLedger(3, 2, BookKeeper.DigestType.CRC32,
                 TEST_LEDGER_PASSWORD);
 
-        ArrayList<InetSocketAddress> firstEnsemble = lh.getLedgerMetadata()
+        ArrayList<BookieSocketAddress> firstEnsemble = lh.getLedgerMetadata()
                 .getEnsembles().get(0L);
-        InetSocketAddress firstBookieFromEnsemble = firstEnsemble.get(0);
+        BookieSocketAddress firstBookieFromEnsemble = firstEnsemble.get(0);
         killBookie(firstBookieFromEnsemble);
         startNewBookie();
         lh.addEntry(TEST_LEDGER_ENTRY_DATA);
@@ -235,9 +235,9 @@ public class TestLedgerChecker extends B
         }
 
         // Kill all three bookies
-        ArrayList<InetSocketAddress> firstEnsemble = lh.getLedgerMetadata()
+        ArrayList<BookieSocketAddress> firstEnsemble = lh.getLedgerMetadata()
                 .getEnsembles().get(0L);
-        for (InetSocketAddress bkAddr : firstEnsemble) {
+        for (BookieSocketAddress bkAddr : firstEnsemble) {
             killBookie(firstEnsemble, bkAddr);
         }
 
@@ -277,7 +277,7 @@ public class TestLedgerChecker extends B
     public void testShouldGet2FragmentsWithEmptyLedgerButBookiesDead() throws Exception {
         LedgerHandle lh = bkc.createLedger(3, 2, BookKeeper.DigestType.CRC32,
                 TEST_LEDGER_PASSWORD);
-        for (InetSocketAddress b : lh.getLedgerMetadata().getEnsembles().get(0L)) {
+        for (BookieSocketAddress b : lh.getLedgerMetadata().getEnsembles().get(0L)) {
             killBookie(b);
         }
         Set<LedgerFragment> result = getUnderReplicatedFragments(lh);
@@ -294,9 +294,9 @@ public class TestLedgerChecker extends B
         LedgerHandle lh = bkc.createLedger(3, 3, BookKeeper.DigestType.CRC32,
                 TEST_LEDGER_PASSWORD);
         lh.addEntry(TEST_LEDGER_ENTRY_DATA);
-        ArrayList<InetSocketAddress> firstEnsemble = lh.getLedgerMetadata()
+        ArrayList<BookieSocketAddress> firstEnsemble = lh.getLedgerMetadata()
                 .getEnsembles().get(0L);
-        InetSocketAddress lastBookieFromEnsemble = firstEnsemble.get(0);
+        BookieSocketAddress lastBookieFromEnsemble = firstEnsemble.get(0);
         LOG.info("Killing " + lastBookieFromEnsemble + " from ensemble="
                 + firstEnsemble);
         killBookie(lastBookieFromEnsemble);
@@ -326,9 +326,9 @@ public class TestLedgerChecker extends B
         for (int i = 0; i < 10; i++) {
             lh.addEntry(TEST_LEDGER_ENTRY_DATA);
         }
-        ArrayList<InetSocketAddress> firstEnsemble = lh.getLedgerMetadata()
+        ArrayList<BookieSocketAddress> firstEnsemble = lh.getLedgerMetadata()
                 .getEnsembles().get(0L);
-        InetSocketAddress lastBookieFromEnsemble = firstEnsemble.get(
+        BookieSocketAddress lastBookieFromEnsemble = firstEnsemble.get(
                 lh.getDistributionSchedule().getWriteSet(lh.getLastAddPushed()).get(0));
         LOG.info("Killing " + lastBookieFromEnsemble + " from ensemble="
                 + firstEnsemble);
@@ -361,11 +361,11 @@ public class TestLedgerChecker extends B
     public void testClosedEmptyLedger() throws Exception {
         LedgerHandle lh = bkc.createLedger(3, 3, BookKeeper.DigestType.CRC32,
                 TEST_LEDGER_PASSWORD);
-        ArrayList<InetSocketAddress> firstEnsemble = lh.getLedgerMetadata()
+        ArrayList<BookieSocketAddress> firstEnsemble = lh.getLedgerMetadata()
                 .getEnsembles().get(0L);
         lh.close();
 
-        InetSocketAddress lastBookieFromEnsemble = firstEnsemble.get(0);
+        BookieSocketAddress lastBookieFromEnsemble = firstEnsemble.get(0);
         LOG.info("Killing " + lastBookieFromEnsemble + " from ensemble="
                 + firstEnsemble);
         killBookie(lastBookieFromEnsemble);
@@ -388,13 +388,13 @@ public class TestLedgerChecker extends B
     public void testClosedSingleEntryLedger() throws Exception {
         LedgerHandle lh = bkc.createLedger(3, 2, BookKeeper.DigestType.CRC32,
                 TEST_LEDGER_PASSWORD);
-        ArrayList<InetSocketAddress> firstEnsemble = lh.getLedgerMetadata()
+        ArrayList<BookieSocketAddress> firstEnsemble = lh.getLedgerMetadata()
             .getEnsembles().get(0L);
         lh.addEntry(TEST_LEDGER_ENTRY_DATA);
         lh.close();
 
         // kill bookie 2
-        InetSocketAddress lastBookieFromEnsemble = firstEnsemble.get(2);
+        BookieSocketAddress lastBookieFromEnsemble = firstEnsemble.get(2);
         LOG.info("Killing " + lastBookieFromEnsemble + " from ensemble="
                 + firstEnsemble);
         killBookie(lastBookieFromEnsemble);
@@ -453,8 +453,8 @@ public class TestLedgerChecker extends B
         return result;
     }
 
-    private void killBookie(ArrayList<InetSocketAddress> firstEnsemble,
-            InetSocketAddress ensemble) throws Exception {
+    private void killBookie(ArrayList<BookieSocketAddress> firstEnsemble, BookieSocketAddress ensemble)
+            throws Exception {
         LOG.info("Killing " + ensemble + " from ensemble=" + firstEnsemble);
         killBookie(ensemble);
     }

Modified: zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestLedgerFragmentReplication.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestLedgerFragmentReplication.java?rev=1564946&r1=1564945&r2=1564946&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestLedgerFragmentReplication.java (original)
+++ zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestLedgerFragmentReplication.java Wed Feb  5 21:43:39 2014
@@ -20,15 +20,15 @@
 package org.apache.bookkeeper.client;
 
 import java.net.InetAddress;
-import java.net.InetSocketAddress;
 import java.util.ArrayList;
 import java.util.Enumeration;
+import java.util.Map.Entry;
 import java.util.Set;
 import java.util.SortedMap;
-import java.util.Map.Entry;
 import java.util.concurrent.CountDownLatch;
 
 import org.apache.bookkeeper.client.BookKeeper.DigestType;
+import org.apache.bookkeeper.net.BookieSocketAddress;
 import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.GenericCallback;
 import org.apache.bookkeeper.test.BookKeeperClusterTestCase;
 import org.junit.Test;
@@ -81,7 +81,7 @@ public class TestLedgerFragmentReplicati
         for (int i = 0; i < 10; i++) {
             lh.addEntry(data);
         }
-        InetSocketAddress replicaToKill = lh.getLedgerMetadata().getEnsembles()
+        BookieSocketAddress replicaToKill = lh.getLedgerMetadata().getEnsembles()
                 .get(0L).get(0);
 
         LOG.info("Killing Bookie", replicaToKill);
@@ -92,7 +92,7 @@ public class TestLedgerFragmentReplicati
             lh.addEntry(data);
         }
 
-        InetSocketAddress newBkAddr = new InetSocketAddress(InetAddress
+        BookieSocketAddress newBkAddr = new BookieSocketAddress(InetAddress
                 .getLocalHost().getHostAddress(), startNewBookie);
         LOG.info("New Bookie addr :" + newBkAddr);
         Set<LedgerFragment> result = getFragmentsToReplicate(lh);
@@ -106,13 +106,13 @@ public class TestLedgerFragmentReplicati
         }
 
         // Killing all bookies except newly replicated bookie
-        SortedMap<Long, ArrayList<InetSocketAddress>> allBookiesBeforeReplication = lh
+        SortedMap<Long, ArrayList<BookieSocketAddress>> allBookiesBeforeReplication = lh
                 .getLedgerMetadata().getEnsembles();
-        Set<Entry<Long, ArrayList<InetSocketAddress>>> entrySet = allBookiesBeforeReplication
+        Set<Entry<Long, ArrayList<BookieSocketAddress>>> entrySet = allBookiesBeforeReplication
                 .entrySet();
-        for (Entry<Long, ArrayList<InetSocketAddress>> entry : entrySet) {
-            ArrayList<InetSocketAddress> bookies = entry.getValue();
-            for (InetSocketAddress bookie : bookies) {
+        for (Entry<Long, ArrayList<BookieSocketAddress>> entry : entrySet) {
+            ArrayList<BookieSocketAddress> bookies = entry.getValue();
+            for (BookieSocketAddress bookie : bookies) {
                 if (newBkAddr.equals(bookie)) {
                     continue;
                 }
@@ -138,7 +138,7 @@ public class TestLedgerFragmentReplicati
         for (int i = 0; i < 10; i++) {
             lh.addEntry(data);
         }
-        InetSocketAddress replicaToKill = lh.getLedgerMetadata().getEnsembles()
+        BookieSocketAddress replicaToKill = lh.getLedgerMetadata().getEnsembles()
                 .get(0L).get(0);
 
         startNewBookie();
@@ -150,14 +150,14 @@ public class TestLedgerFragmentReplicati
             lh.addEntry(data);
         }
 
-        InetSocketAddress replicaToKill2 = lh.getLedgerMetadata()
+        BookieSocketAddress replicaToKill2 = lh.getLedgerMetadata()
                 .getEnsembles().get(0L).get(1);
 
         int startNewBookie2 = startNewBookie();
         LOG.info("Killing Bookie", replicaToKill2);
         killBookie(replicaToKill2);
 
-        InetSocketAddress newBkAddr = new InetSocketAddress(InetAddress
+        BookieSocketAddress newBkAddr = new BookieSocketAddress(InetAddress
                 .getLocalHost().getHostAddress(), startNewBookie2);
         LOG.info("New Bookie addr :" + newBkAddr);
         Set<LedgerFragment> result = getFragmentsToReplicate(lh);
@@ -198,7 +198,7 @@ public class TestLedgerFragmentReplicati
         }
 
         // Kill the first Bookie
-        InetSocketAddress replicaToKill = lh.getLedgerMetadata().getEnsembles()
+        BookieSocketAddress replicaToKill = lh.getLedgerMetadata().getEnsembles()
                 .get(0L).get(0);
         killBookie(replicaToKill);
         LOG.info("Killed Bookie =" + replicaToKill);
@@ -215,7 +215,7 @@ public class TestLedgerFragmentReplicati
         Set<LedgerFragment> fragments = getFragmentsToReplicate(lh);
         BookKeeperAdmin admin = new BookKeeperAdmin(baseClientConf);
         int startNewBookie = startNewBookie();
-        InetSocketAddress additionalBK = new InetSocketAddress(InetAddress
+        BookieSocketAddress additionalBK = new BookieSocketAddress(InetAddress
                 .getLocalHost().getHostAddress(), startNewBookie);
         for (LedgerFragment lf : fragments) {
             try {
@@ -236,7 +236,7 @@ public class TestLedgerFragmentReplicati
         LedgerMetadata metadata = new LedgerMetadata(3, 3, 3, TEST_DIGEST_TYPE,
                 TEST_PSSWD) {
             @Override
-            ArrayList<InetSocketAddress> getEnsemble(long entryId) {
+            ArrayList<BookieSocketAddress> getEnsemble(long entryId) {
                 return null;
             }
 

Modified: zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestRackawareEnsemblePlacementPolicy.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestRackawareEnsemblePlacementPolicy.java?rev=1564946&r1=1564945&r2=1564946&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestRackawareEnsemblePlacementPolicy.java (original)
+++ zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestRackawareEnsemblePlacementPolicy.java Wed Feb  5 21:43:39 2014
@@ -20,7 +20,6 @@ package org.apache.bookkeeper.client;
 import static org.apache.bookkeeper.client.RackawareEnsemblePlacementPolicy.REPP_DNS_RESOLVER_CLASS;
 
 import java.net.InetAddress;
-import java.net.InetSocketAddress;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.Set;
@@ -28,6 +27,7 @@ import java.util.Set;
 import junit.framework.TestCase;
 
 import org.apache.bookkeeper.client.BKException.BKNotEnoughBookiesException;
+import org.apache.bookkeeper.net.BookieSocketAddress;
 import org.apache.bookkeeper.net.NetworkTopology;
 import org.apache.bookkeeper.util.StaticDNSResolver;
 import org.apache.commons.configuration.CompositeConfiguration;
@@ -64,49 +64,51 @@ public class TestRackawareEnsemblePlacem
 
     @Test(timeout = 60000)
     public void testReplaceBookieWithEnoughBookiesInSameRack() throws Exception {
-        InetSocketAddress addr1 = new InetSocketAddress("127.0.0.1", 3181);
-        InetSocketAddress addr2 = new InetSocketAddress("127.0.0.2", 3181);
-        InetSocketAddress addr3 = new InetSocketAddress("127.0.0.3", 3181);
-        InetSocketAddress addr4 = new InetSocketAddress("127.0.0.4", 3181);
+        BookieSocketAddress addr1 = new BookieSocketAddress("127.0.0.1", 3181);
+        BookieSocketAddress addr2 = new BookieSocketAddress("127.0.0.2", 3181);
+        BookieSocketAddress addr3 = new BookieSocketAddress("127.0.0.3", 3181);
+        BookieSocketAddress addr4 = new BookieSocketAddress("127.0.0.4", 3181);
         // update dns mapping
-        StaticDNSResolver.addNodeToRack(addr1.getAddress().getHostAddress(), NetworkTopology.DEFAULT_RACK);
-        StaticDNSResolver.addNodeToRack(addr2.getAddress().getHostAddress(), "/r2");
-        StaticDNSResolver.addNodeToRack(addr3.getAddress().getHostAddress(), "/r2");
-        StaticDNSResolver.addNodeToRack(addr4.getAddress().getHostAddress(), "/r3");
+        StaticDNSResolver.addNodeToRack(addr1.getSocketAddress().getAddress().getHostAddress(),
+                NetworkTopology.DEFAULT_RACK);
+        StaticDNSResolver.addNodeToRack(addr2.getSocketAddress().getAddress().getHostAddress(), "/r2");
+        StaticDNSResolver.addNodeToRack(addr3.getSocketAddress().getAddress().getHostAddress(), "/r2");
+        StaticDNSResolver.addNodeToRack(addr4.getSocketAddress().getAddress().getHostAddress(), "/r3");
         // Update cluster
-        Set<InetSocketAddress> addrs = new HashSet<InetSocketAddress>();
+        Set<BookieSocketAddress> addrs = new HashSet<BookieSocketAddress>();
         addrs.add(addr1);
         addrs.add(addr2);
         addrs.add(addr3);
         addrs.add(addr4);
-        repp.onClusterChanged(addrs, new HashSet<InetSocketAddress>());
+        repp.onClusterChanged(addrs, new HashSet<BookieSocketAddress>());
         // replace node under r2
-        InetSocketAddress replacedBookie = repp.replaceBookie(addr2, new HashSet<InetSocketAddress>());
+        BookieSocketAddress replacedBookie = repp.replaceBookie(addr2, new HashSet<BookieSocketAddress>());
         assertEquals(addr3, replacedBookie);
     }
 
     @Test(timeout = 60000)
     public void testReplaceBookieWithEnoughBookiesInDifferentRack() throws Exception {
-        InetSocketAddress addr1 = new InetSocketAddress("127.0.0.1", 3181);
-        InetSocketAddress addr2 = new InetSocketAddress("127.0.0.2", 3181);
-        InetSocketAddress addr3 = new InetSocketAddress("127.0.0.3", 3181);
-        InetSocketAddress addr4 = new InetSocketAddress("127.0.0.4", 3181);
+        BookieSocketAddress addr1 = new BookieSocketAddress("127.0.0.1", 3181);
+        BookieSocketAddress addr2 = new BookieSocketAddress("127.0.0.2", 3181);
+        BookieSocketAddress addr3 = new BookieSocketAddress("127.0.0.3", 3181);
+        BookieSocketAddress addr4 = new BookieSocketAddress("127.0.0.4", 3181);
         // update dns mapping
-        StaticDNSResolver.addNodeToRack(addr1.getAddress().getHostAddress(), NetworkTopology.DEFAULT_RACK);
-        StaticDNSResolver.addNodeToRack(addr2.getAddress().getHostAddress(), "/r2");
-        StaticDNSResolver.addNodeToRack(addr3.getAddress().getHostAddress(), "/r3");
-        StaticDNSResolver.addNodeToRack(addr4.getAddress().getHostAddress(), "/r4");
+        StaticDNSResolver.addNodeToRack(addr1.getSocketAddress().getAddress().getHostAddress(),
+                NetworkTopology.DEFAULT_RACK);
+        StaticDNSResolver.addNodeToRack(addr2.getSocketAddress().getAddress().getHostAddress(), "/r2");
+        StaticDNSResolver.addNodeToRack(addr3.getSocketAddress().getAddress().getHostAddress(), "/r3");
+        StaticDNSResolver.addNodeToRack(addr4.getSocketAddress().getAddress().getHostAddress(), "/r4");
         // Update cluster
-        Set<InetSocketAddress> addrs = new HashSet<InetSocketAddress>();
+        Set<BookieSocketAddress> addrs = new HashSet<BookieSocketAddress>();
         addrs.add(addr1);
         addrs.add(addr2);
         addrs.add(addr3);
         addrs.add(addr4);
-        repp.onClusterChanged(addrs, new HashSet<InetSocketAddress>());
+        repp.onClusterChanged(addrs, new HashSet<BookieSocketAddress>());
         // replace node under r2
-        Set<InetSocketAddress> excludedAddrs = new HashSet<InetSocketAddress>();
+        Set<BookieSocketAddress> excludedAddrs = new HashSet<BookieSocketAddress>();
         excludedAddrs.add(addr1);
-        InetSocketAddress replacedBookie = repp.replaceBookie(addr2, excludedAddrs);
+        BookieSocketAddress replacedBookie = repp.replaceBookie(addr2, excludedAddrs);
 
         assertFalse(addr1.equals(replacedBookie));
         assertTrue(addr3.equals(replacedBookie) || addr4.equals(replacedBookie));
@@ -114,24 +116,25 @@ public class TestRackawareEnsemblePlacem
 
     @Test(timeout = 60000)
     public void testReplaceBookieWithNotEnoughBookies() throws Exception {
-        InetSocketAddress addr1 = new InetSocketAddress("127.0.0.1", 3181);
-        InetSocketAddress addr2 = new InetSocketAddress("127.0.0.2", 3181);
-        InetSocketAddress addr3 = new InetSocketAddress("127.0.0.3", 3181);
-        InetSocketAddress addr4 = new InetSocketAddress("127.0.0.4", 3181);
+        BookieSocketAddress addr1 = new BookieSocketAddress("127.0.0.1", 3181);
+        BookieSocketAddress addr2 = new BookieSocketAddress("127.0.0.2", 3181);
+        BookieSocketAddress addr3 = new BookieSocketAddress("127.0.0.3", 3181);
+        BookieSocketAddress addr4 = new BookieSocketAddress("127.0.0.4", 3181);
         // update dns mapping
-        StaticDNSResolver.addNodeToRack(addr1.getAddress().getHostAddress(), NetworkTopology.DEFAULT_RACK);
-        StaticDNSResolver.addNodeToRack(addr2.getAddress().getHostAddress(), "/r2");
-        StaticDNSResolver.addNodeToRack(addr3.getAddress().getHostAddress(), "/r3");
-        StaticDNSResolver.addNodeToRack(addr4.getAddress().getHostAddress(), "/r4");
+        StaticDNSResolver.addNodeToRack(addr1.getSocketAddress().getAddress().getHostAddress(),
+                NetworkTopology.DEFAULT_RACK);
+        StaticDNSResolver.addNodeToRack(addr2.getSocketAddress().getAddress().getHostAddress(), "/r2");
+        StaticDNSResolver.addNodeToRack(addr3.getSocketAddress().getAddress().getHostAddress(), "/r3");
+        StaticDNSResolver.addNodeToRack(addr4.getSocketAddress().getAddress().getHostAddress(), "/r4");
         // Update cluster
-        Set<InetSocketAddress> addrs = new HashSet<InetSocketAddress>();
+        Set<BookieSocketAddress> addrs = new HashSet<BookieSocketAddress>();
         addrs.add(addr1);
         addrs.add(addr2);
         addrs.add(addr3);
         addrs.add(addr4);
-        repp.onClusterChanged(addrs, new HashSet<InetSocketAddress>());
+        repp.onClusterChanged(addrs, new HashSet<BookieSocketAddress>());
         // replace node under r2
-        Set<InetSocketAddress> excludedAddrs = new HashSet<InetSocketAddress>();
+        Set<BookieSocketAddress> excludedAddrs = new HashSet<BookieSocketAddress>();
         excludedAddrs.add(addr1);
         excludedAddrs.add(addr3);
         excludedAddrs.add(addr4);
@@ -145,21 +148,21 @@ public class TestRackawareEnsemblePlacem
 
     @Test(timeout = 60000)
     public void testNewEnsembleWithSingleRack() throws Exception {
-        InetSocketAddress addr1 = new InetSocketAddress("127.0.0.1", 3181);
-        InetSocketAddress addr2 = new InetSocketAddress("127.0.0.2", 3181);
-        InetSocketAddress addr3 = new InetSocketAddress("127.0.0.3", 3181);
-        InetSocketAddress addr4 = new InetSocketAddress("127.0.0.4", 3181);
+        BookieSocketAddress addr1 = new BookieSocketAddress("127.0.0.1", 3181);
+        BookieSocketAddress addr2 = new BookieSocketAddress("127.0.0.2", 3181);
+        BookieSocketAddress addr3 = new BookieSocketAddress("127.0.0.3", 3181);
+        BookieSocketAddress addr4 = new BookieSocketAddress("127.0.0.4", 3181);
         // Update cluster
-        Set<InetSocketAddress> addrs = new HashSet<InetSocketAddress>();
+        Set<BookieSocketAddress> addrs = new HashSet<BookieSocketAddress>();
         addrs.add(addr1);
         addrs.add(addr2);
         addrs.add(addr3);
         addrs.add(addr4);
-        repp.onClusterChanged(addrs, new HashSet<InetSocketAddress>());
+        repp.onClusterChanged(addrs, new HashSet<BookieSocketAddress>());
         try {
-            ArrayList<InetSocketAddress> ensemble = repp.newEnsemble(3, 2, new HashSet<InetSocketAddress>());
+            ArrayList<BookieSocketAddress> ensemble = repp.newEnsemble(3, 2, new HashSet<BookieSocketAddress>());
             assertEquals(0, getNumCoveredWriteQuorums(ensemble, 2));
-            ArrayList<InetSocketAddress> ensemble2 = repp.newEnsemble(4, 2, new HashSet<InetSocketAddress>());
+            ArrayList<BookieSocketAddress> ensemble2 = repp.newEnsemble(4, 2, new HashSet<BookieSocketAddress>());
             assertEquals(0, getNumCoveredWriteQuorums(ensemble2, 2));
         } catch (BKNotEnoughBookiesException bnebe) {
             fail("Should not get not enough bookies exception even there is only one rack.");
@@ -168,27 +171,28 @@ public class TestRackawareEnsemblePlacem
 
     @Test(timeout = 60000)
     public void testNewEnsembleWithMultipleRacks() throws Exception {
-        InetSocketAddress addr1 = new InetSocketAddress("127.0.0.1", 3181);
-        InetSocketAddress addr2 = new InetSocketAddress("127.0.0.2", 3181);
-        InetSocketAddress addr3 = new InetSocketAddress("127.0.0.3", 3181);
-        InetSocketAddress addr4 = new InetSocketAddress("127.0.0.4", 3181);
+        BookieSocketAddress addr1 = new BookieSocketAddress("127.0.0.1", 3181);
+        BookieSocketAddress addr2 = new BookieSocketAddress("127.0.0.2", 3181);
+        BookieSocketAddress addr3 = new BookieSocketAddress("127.0.0.3", 3181);
+        BookieSocketAddress addr4 = new BookieSocketAddress("127.0.0.4", 3181);
         // update dns mapping
-        StaticDNSResolver.addNodeToRack(addr1.getAddress().getHostAddress(), NetworkTopology.DEFAULT_RACK);
-        StaticDNSResolver.addNodeToRack(addr2.getAddress().getHostAddress(), "/r2");
-        StaticDNSResolver.addNodeToRack(addr3.getAddress().getHostAddress(), "/r2");
-        StaticDNSResolver.addNodeToRack(addr4.getAddress().getHostAddress(), "/r2");
+        StaticDNSResolver.addNodeToRack(addr1.getSocketAddress().getAddress().getHostAddress(),
+                NetworkTopology.DEFAULT_RACK);
+        StaticDNSResolver.addNodeToRack(addr2.getSocketAddress().getAddress().getHostAddress(), "/r2");
+        StaticDNSResolver.addNodeToRack(addr3.getSocketAddress().getAddress().getHostAddress(), "/r2");
+        StaticDNSResolver.addNodeToRack(addr4.getSocketAddress().getAddress().getHostAddress(), "/r2");
         // Update cluster
-        Set<InetSocketAddress> addrs = new HashSet<InetSocketAddress>();
+        Set<BookieSocketAddress> addrs = new HashSet<BookieSocketAddress>();
         addrs.add(addr1);
         addrs.add(addr2);
         addrs.add(addr3);
         addrs.add(addr4);
-        repp.onClusterChanged(addrs, new HashSet<InetSocketAddress>());
+        repp.onClusterChanged(addrs, new HashSet<BookieSocketAddress>());
         try {
-            ArrayList<InetSocketAddress> ensemble = repp.newEnsemble(3, 2, new HashSet<InetSocketAddress>());
+            ArrayList<BookieSocketAddress> ensemble = repp.newEnsemble(3, 2, new HashSet<BookieSocketAddress>());
             int numCovered = getNumCoveredWriteQuorums(ensemble, 2);
             assertTrue(numCovered >= 1 && numCovered < 3);
-            ArrayList<InetSocketAddress> ensemble2 = repp.newEnsemble(4, 2, new HashSet<InetSocketAddress>());
+            ArrayList<BookieSocketAddress> ensemble2 = repp.newEnsemble(4, 2, new HashSet<BookieSocketAddress>());
             numCovered = getNumCoveredWriteQuorums(ensemble2, 2);
             assertTrue(numCovered >= 1 && numCovered < 3);
         } catch (BKNotEnoughBookiesException bnebe) {
@@ -198,25 +202,27 @@ public class TestRackawareEnsemblePlacem
 
     @Test(timeout = 90000)
     public void testNewEnsembleWithEnoughRacks() throws Exception {
-        InetSocketAddress addr1 = new InetSocketAddress("127.0.0.1", 3181);
-        InetSocketAddress addr2 = new InetSocketAddress("127.0.0.2", 3181);
-        InetSocketAddress addr3 = new InetSocketAddress("127.0.0.3", 3181);
-        InetSocketAddress addr4 = new InetSocketAddress("127.0.0.4", 3181);
-        InetSocketAddress addr5 = new InetSocketAddress("127.0.0.5", 3181);
-        InetSocketAddress addr6 = new InetSocketAddress("127.0.0.6", 3181);
-        InetSocketAddress addr7 = new InetSocketAddress("127.0.0.7", 3181);
-        InetSocketAddress addr8 = new InetSocketAddress("127.0.0.8", 3181);
+        BookieSocketAddress addr1 = new BookieSocketAddress("127.0.0.1", 3181);
+        BookieSocketAddress addr2 = new BookieSocketAddress("127.0.0.2", 3181);
+        BookieSocketAddress addr3 = new BookieSocketAddress("127.0.0.3", 3181);
+        BookieSocketAddress addr4 = new BookieSocketAddress("127.0.0.4", 3181);
+        BookieSocketAddress addr5 = new BookieSocketAddress("127.0.0.5", 3181);
+        BookieSocketAddress addr6 = new BookieSocketAddress("127.0.0.6", 3181);
+        BookieSocketAddress addr7 = new BookieSocketAddress("127.0.0.7", 3181);
+        BookieSocketAddress addr8 = new BookieSocketAddress("127.0.0.8", 3181);
         // update dns mapping
-        StaticDNSResolver.addNodeToRack(addr1.getAddress().getHostAddress(), NetworkTopology.DEFAULT_RACK);
-        StaticDNSResolver.addNodeToRack(addr2.getAddress().getHostAddress(), "/r2");
-        StaticDNSResolver.addNodeToRack(addr3.getAddress().getHostAddress(), "/r3");
-        StaticDNSResolver.addNodeToRack(addr4.getAddress().getHostAddress(), "/r4");
-        StaticDNSResolver.addNodeToRack(addr5.getAddress().getHostAddress(), NetworkTopology.DEFAULT_RACK);
-        StaticDNSResolver.addNodeToRack(addr6.getAddress().getHostAddress(), "/r2");
-        StaticDNSResolver.addNodeToRack(addr7.getAddress().getHostAddress(), "/r3");
-        StaticDNSResolver.addNodeToRack(addr8.getAddress().getHostAddress(), "/r4");
+        StaticDNSResolver.addNodeToRack(addr1.getSocketAddress().getAddress().getHostAddress(),
+                NetworkTopology.DEFAULT_RACK);
+        StaticDNSResolver.addNodeToRack(addr2.getSocketAddress().getAddress().getHostAddress(), "/r2");
+        StaticDNSResolver.addNodeToRack(addr3.getSocketAddress().getAddress().getHostAddress(), "/r3");
+        StaticDNSResolver.addNodeToRack(addr4.getSocketAddress().getAddress().getHostAddress(), "/r4");
+        StaticDNSResolver.addNodeToRack(addr5.getSocketAddress().getAddress().getHostAddress(),
+                NetworkTopology.DEFAULT_RACK);
+        StaticDNSResolver.addNodeToRack(addr6.getSocketAddress().getAddress().getHostAddress(), "/r2");
+        StaticDNSResolver.addNodeToRack(addr7.getSocketAddress().getAddress().getHostAddress(), "/r3");
+        StaticDNSResolver.addNodeToRack(addr8.getSocketAddress().getAddress().getHostAddress(), "/r4");
         // Update cluster
-        Set<InetSocketAddress> addrs = new HashSet<InetSocketAddress>();
+        Set<BookieSocketAddress> addrs = new HashSet<BookieSocketAddress>();
         addrs.add(addr1);
         addrs.add(addr2);
         addrs.add(addr3);
@@ -225,11 +231,11 @@ public class TestRackawareEnsemblePlacem
         addrs.add(addr6);
         addrs.add(addr7);
         addrs.add(addr8);
-        repp.onClusterChanged(addrs, new HashSet<InetSocketAddress>());
+        repp.onClusterChanged(addrs, new HashSet<BookieSocketAddress>());
         try {
-            ArrayList<InetSocketAddress> ensemble1 = repp.newEnsemble(3, 2, new HashSet<InetSocketAddress>());
+            ArrayList<BookieSocketAddress> ensemble1 = repp.newEnsemble(3, 2, new HashSet<BookieSocketAddress>());
             assertEquals(3, getNumCoveredWriteQuorums(ensemble1, 2));
-            ArrayList<InetSocketAddress> ensemble2 = repp.newEnsemble(4, 2, new HashSet<InetSocketAddress>());
+            ArrayList<BookieSocketAddress> ensemble2 = repp.newEnsemble(4, 2, new HashSet<BookieSocketAddress>());
             assertEquals(4, getNumCoveredWriteQuorums(ensemble2, 2));
         } catch (BKNotEnoughBookiesException bnebe) {
             fail("Should not get not enough bookies exception even there is only one rack.");
@@ -241,27 +247,28 @@ public class TestRackawareEnsemblePlacem
      */
     @Test(timeout = 60000)
     public void testRemoveBookieFromCluster() {
-        InetSocketAddress addr1 = new InetSocketAddress("127.0.0.1", 3181);
-        InetSocketAddress addr2 = new InetSocketAddress("127.0.0.2", 3181);
-        InetSocketAddress addr3 = new InetSocketAddress("127.0.0.3", 3181);
-        InetSocketAddress addr4 = new InetSocketAddress("127.0.0.4", 3181);
+        BookieSocketAddress addr1 = new BookieSocketAddress("127.0.0.1", 3181);
+        BookieSocketAddress addr2 = new BookieSocketAddress("127.0.0.2", 3181);
+        BookieSocketAddress addr3 = new BookieSocketAddress("127.0.0.3", 3181);
+        BookieSocketAddress addr4 = new BookieSocketAddress("127.0.0.4", 3181);
         // update dns mapping
-        StaticDNSResolver.addNodeToRack(addr1.getAddress().getHostAddress(), NetworkTopology.DEFAULT_RACK);
-        StaticDNSResolver.addNodeToRack(addr2.getAddress().getHostAddress(), "/r2");
-        StaticDNSResolver.addNodeToRack(addr3.getAddress().getHostAddress(), "/r2");
-        StaticDNSResolver.addNodeToRack(addr4.getAddress().getHostAddress(), "/r3");
+        StaticDNSResolver.addNodeToRack(addr1.getSocketAddress().getAddress().getHostAddress(),
+                NetworkTopology.DEFAULT_RACK);
+        StaticDNSResolver.addNodeToRack(addr2.getSocketAddress().getAddress().getHostAddress(), "/r2");
+        StaticDNSResolver.addNodeToRack(addr3.getSocketAddress().getAddress().getHostAddress(), "/r2");
+        StaticDNSResolver.addNodeToRack(addr4.getSocketAddress().getAddress().getHostAddress(), "/r3");
         // Update cluster
-        Set<InetSocketAddress> addrs = new HashSet<InetSocketAddress>();
+        Set<BookieSocketAddress> addrs = new HashSet<BookieSocketAddress>();
         addrs.add(addr1);
         addrs.add(addr2);
         addrs.add(addr3);
         addrs.add(addr4);
-        repp.onClusterChanged(addrs, new HashSet<InetSocketAddress>());
+        repp.onClusterChanged(addrs, new HashSet<BookieSocketAddress>());
         addrs.remove(addr1);
-        repp.onClusterChanged(addrs, new HashSet<InetSocketAddress>());
+        repp.onClusterChanged(addrs, new HashSet<BookieSocketAddress>());
     }
 
-    private int getNumCoveredWriteQuorums(ArrayList<InetSocketAddress> ensemble, int writeQuorumSize)
+    private int getNumCoveredWriteQuorums(ArrayList<BookieSocketAddress> ensemble, int writeQuorumSize)
             throws Exception {
         int ensembleSize = ensemble.size();
         int numCoveredWriteQuorums = 0;
@@ -269,8 +276,8 @@ public class TestRackawareEnsemblePlacem
             Set<String> racks = new HashSet<String>();
             for (int j = 0; j < writeQuorumSize; j++) {
                 int bookieIdx = (i + j) % ensembleSize;
-                InetSocketAddress addr = ensemble.get(bookieIdx);
-                racks.add(StaticDNSResolver.getRack(addr.getAddress().getHostAddress()));
+                BookieSocketAddress addr = ensemble.get(bookieIdx);
+                racks.add(StaticDNSResolver.getRack(addr.getSocketAddress().getAddress().getHostAddress()));
             }
             numCoveredWriteQuorums += (racks.size() > 1 ? 1 : 0);
         }

Modified: zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestReadTimeout.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestReadTimeout.java?rev=1564946&r1=1564945&r2=1564946&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestReadTimeout.java (original)
+++ zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestReadTimeout.java Wed Feb  5 21:43:39 2014
@@ -21,25 +21,17 @@ package org.apache.bookkeeper.client;
  *
  */
 
-import org.junit.*;
-import java.net.InetSocketAddress;
-import java.util.Enumeration;
-import java.util.concurrent.CyclicBarrier;
+import java.util.HashSet;
+import java.util.Set;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.atomic.AtomicBoolean;
-import org.apache.bookkeeper.conf.ClientConfiguration;
-import org.apache.bookkeeper.client.AsyncCallback.AddCallback;
 
-import org.apache.bookkeeper.client.LedgerHandle;
-import org.apache.bookkeeper.client.LedgerEntry;
-import org.apache.bookkeeper.client.BookKeeper;
-import org.apache.bookkeeper.client.BookKeeperAdmin;
-import org.apache.bookkeeper.client.BKException;
+import org.apache.bookkeeper.client.AsyncCallback.AddCallback;
 import org.apache.bookkeeper.client.BookKeeper.DigestType;
+import org.apache.bookkeeper.net.BookieSocketAddress;
 import org.apache.bookkeeper.test.BookKeeperClusterTestCase;
-import java.util.HashSet;
-import java.util.Set;
-
+import org.junit.Assert;
+import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -70,12 +62,12 @@ public class TestReadTimeout extends Boo
             writelh.addEntry(tmp.getBytes());
         }
         
-        Set<InetSocketAddress> beforeSet = new HashSet<InetSocketAddress>();
-        for (InetSocketAddress addr : writelh.getLedgerMetadata().getEnsemble(numEntries)) {
+        Set<BookieSocketAddress> beforeSet = new HashSet<BookieSocketAddress>();
+        for (BookieSocketAddress addr : writelh.getLedgerMetadata().getEnsemble(numEntries)) {
             beforeSet.add(addr);
         }
 
-        final InetSocketAddress bookieToSleep 
+        final BookieSocketAddress bookieToSleep
             = writelh.getLedgerMetadata().getEnsemble(numEntries).get(0);
         int sleeptime = baseClientConf.getReadTimeout()*3;
         CountDownLatch latch = sleepBookie(bookieToSleep, sleeptime);
@@ -91,8 +83,8 @@ public class TestReadTimeout extends Boo
         Thread.sleep((baseClientConf.getReadTimeout()*3)*1000);
         Assert.assertTrue("Write request did not finish", completed.get());
 
-        Set<InetSocketAddress> afterSet = new HashSet<InetSocketAddress>();
-        for (InetSocketAddress addr : writelh.getLedgerMetadata().getEnsemble(numEntries+1)) {
+        Set<BookieSocketAddress> afterSet = new HashSet<BookieSocketAddress>();
+        for (BookieSocketAddress addr : writelh.getLedgerMetadata().getEnsemble(numEntries + 1)) {
             afterSet.add(addr);
         }
         beforeSet.removeAll(afterSet);

Modified: zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestSpeculativeRead.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestSpeculativeRead.java?rev=1564946&r1=1564945&r2=1564946&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestSpeculativeRead.java (original)
+++ zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestSpeculativeRead.java Wed Feb  5 21:43:39 2014
@@ -21,23 +21,19 @@ package org.apache.bookkeeper.client;
  *
  */
 
-import org.junit.*;
-import java.net.InetSocketAddress;
 import java.util.ArrayList;
-import java.util.Set;
-import java.util.HashSet;
 import java.util.Enumeration;
-import java.util.concurrent.TimeUnit;
+import java.util.HashSet;
+import java.util.Set;
 import java.util.concurrent.CountDownLatch;
-import org.apache.bookkeeper.conf.ClientConfiguration;
-import org.apache.bookkeeper.client.LedgerHandle;
-import org.apache.bookkeeper.client.LedgerEntry;
-import org.apache.bookkeeper.client.BookKeeper;
-import org.apache.bookkeeper.client.BKException;
+import java.util.concurrent.TimeUnit;
+
 import org.apache.bookkeeper.client.AsyncCallback.ReadCallback;
 import org.apache.bookkeeper.client.BookKeeper.DigestType;
+import org.apache.bookkeeper.conf.ClientConfiguration;
+import org.apache.bookkeeper.net.BookieSocketAddress;
 import org.apache.bookkeeper.test.BaseTestCase;
-
+import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -132,7 +128,7 @@ public class TestSpeculativeRead extends
 
         // sleep second bookie
         CountDownLatch sleepLatch = new CountDownLatch(1);
-        InetSocketAddress second = lnospec.getLedgerMetadata().getEnsembles().get(0L).get(1);
+        BookieSocketAddress second = lnospec.getLedgerMetadata().getEnsembles().get(0L).get(1);
         sleepBookie(second, sleepLatch);
 
         try {
@@ -287,10 +283,10 @@ public class TestSpeculativeRead extends
 
         LedgerHandle l = bkspec.openLedger(id, digestType, passwd);
 
-        ArrayList<InetSocketAddress> ensemble = l.getLedgerMetadata().getEnsembles().get(0L);
-        Set<InetSocketAddress> allHosts = new HashSet<InetSocketAddress>(ensemble);
-        Set<InetSocketAddress> noHost = new HashSet<InetSocketAddress>();
-        Set<InetSocketAddress> secondHostOnly = new HashSet<InetSocketAddress>();
+        ArrayList<BookieSocketAddress> ensemble = l.getLedgerMetadata().getEnsembles().get(0L);
+        Set<BookieSocketAddress> allHosts = new HashSet<BookieSocketAddress>(ensemble);
+        Set<BookieSocketAddress> noHost = new HashSet<BookieSocketAddress>();
+        Set<BookieSocketAddress> secondHostOnly = new HashSet<BookieSocketAddress>();
         secondHostOnly.add(ensemble.get(1));
         PendingReadOp.LedgerEntryRequest req0 = null, req2 = null, req4 = null;
         try {

Modified: zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestWatchEnsembleChange.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestWatchEnsembleChange.java?rev=1564946&r1=1564945&r2=1564946&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestWatchEnsembleChange.java (original)
+++ zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestWatchEnsembleChange.java Wed Feb  5 21:43:39 2014
@@ -21,12 +21,12 @@
 package org.apache.bookkeeper.client;
 
 import org.apache.bookkeeper.client.BookKeeper.DigestType;
+import org.apache.bookkeeper.net.BookieSocketAddress;
 import org.apache.bookkeeper.test.BookKeeperClusterTestCase;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.net.InetSocketAddress;
 import java.util.ArrayList;
 import java.util.concurrent.TimeUnit;
 
@@ -52,9 +52,9 @@ public class TestWatchEnsembleChange ext
         LedgerHandle readLh = bkc.openLedgerNoRecovery(lh.getId(), digestType, "".getBytes());
         long lastLAC = readLh.getLastAddConfirmed();
         assertEquals(numEntries - 2, lastLAC);
-        ArrayList<InetSocketAddress> ensemble =
+        ArrayList<BookieSocketAddress> ensemble =
                 lh.getLedgerMetadata().currentEnsemble;
-        for (InetSocketAddress addr : ensemble) {
+        for (BookieSocketAddress addr : ensemble) {
             killBookie(addr);
         }
         // write another batch of entries, which will trigger ensemble change

Modified: zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/proto/TestPerChannelBookieClient.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/proto/TestPerChannelBookieClient.java?rev=1564946&r1=1564945&r2=1564946&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/proto/TestPerChannelBookieClient.java (original)
+++ zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/proto/TestPerChannelBookieClient.java Wed Feb  5 21:43:39 2014
@@ -1,5 +1,3 @@
-package org.apache.bookkeeper.proto;
-
 /*
  *
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -20,35 +18,34 @@ package org.apache.bookkeeper.proto;
  * under the License.
  *
  */
+package org.apache.bookkeeper.proto;
 
-import org.junit.*;
-import java.net.InetSocketAddress;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.Executors;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import java.nio.ByteBuffer;
-import java.io.IOException;
-
-import org.apache.bookkeeper.conf.ServerConfiguration;
 import org.apache.bookkeeper.bookie.Bookie;
 import org.apache.bookkeeper.client.BKException;
+import org.apache.bookkeeper.conf.ServerConfiguration;
+import org.apache.bookkeeper.net.BookieSocketAddress;
 import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.GenericCallback;
 import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.ReadEntryCallback;
 import org.apache.bookkeeper.proto.PerChannelBookieClient.ConnectionState;
 import org.apache.bookkeeper.test.BookKeeperClusterTestCase;
-import org.apache.bookkeeper.util.SafeRunnable;
 import org.apache.bookkeeper.util.OrderedSafeExecutor;
-import org.jboss.netty.channel.Channel;
+import org.apache.bookkeeper.util.SafeRunnable;
 import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.channel.Channel;
 import org.jboss.netty.channel.socket.ClientSocketChannelFactory;
 import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory;
-
+import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicLong;
+
 /**
  * Tests for PerChannelBookieClient. Historically, this class has
  * had a few race conditions, so this is what these tests focus on.
@@ -75,7 +72,7 @@ public class TestPerChannelBookieClient 
         OrderedSafeExecutor executor = new OrderedSafeExecutor(1,
                 "BKClientOrderedSafeExecutor");
 
-        InetSocketAddress addr = getBookie(0);
+        BookieSocketAddress addr = getBookie(0);
         AtomicLong bytesOutstanding = new AtomicLong(0);
         for (int i = 0; i < 1000; i++) {
             PerChannelBookieClient client = new PerChannelBookieClient(executor, channelFactory,
@@ -113,7 +110,7 @@ public class TestPerChannelBookieClient 
         OrderedSafeExecutor executor = new OrderedSafeExecutor(1,
                 "BKClientOrderedSafeExecutor");
 
-        InetSocketAddress addr = getBookie(0);
+        BookieSocketAddress addr = getBookie(0);
         AtomicLong bytesOutstanding = new AtomicLong(0);
         for (int i = 0; i < 100; i++) {
             PerChannelBookieClient client = new PerChannelBookieClient(executor, channelFactory,
@@ -148,7 +145,7 @@ public class TestPerChannelBookieClient 
                                                 Executors.newCachedThreadPool());
         OrderedSafeExecutor executor = new OrderedSafeExecutor(1,
                 "BKClientOrderedSafeExecutor");
-        InetSocketAddress addr = getBookie(0);
+        BookieSocketAddress addr = getBookie(0);
 
         AtomicLong bytesOutstanding = new AtomicLong(0);
         final PerChannelBookieClient client = new PerChannelBookieClient(executor,
@@ -247,7 +244,7 @@ public class TestPerChannelBookieClient 
                                                 Executors.newCachedThreadPool());
         final OrderedSafeExecutor executor = new OrderedSafeExecutor(1,
                 "BKClientOrderedSafeExecutor");
-        InetSocketAddress addr = getBookie(0);
+        BookieSocketAddress addr = getBookie(0);
         AtomicLong bytesOutstanding = new AtomicLong(0);
 
         final PerChannelBookieClient client = new PerChannelBookieClient(executor, channelFactory,

Modified: zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/proto/TestProtoVersions.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/proto/TestProtoVersions.java?rev=1564946&r1=1564945&r2=1564946&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/proto/TestProtoVersions.java (original)
+++ zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/proto/TestProtoVersions.java Wed Feb  5 21:43:39 2014
@@ -21,28 +21,23 @@
 
 package org.apache.bookkeeper.proto;
 
-import org.apache.bookkeeper.util.OrderedSafeExecutor;
-import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory;
-import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.GenericCallback;
-import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.ReadEntryCallback;
-import org.jboss.netty.buffer.ChannelBuffer;
-
-import org.apache.bookkeeper.client.BKException;
-
-import org.apache.bookkeeper.test.BaseTestCase;
-import org.apache.bookkeeper.test.BookieClientTest;
-import static org.junit.Assert.*;
-import org.junit.Test;
-import org.junit.Before;
-import org.junit.After;
-
-import java.util.concurrent.TimeUnit;
+import static org.junit.Assert.assertEquals;
 
+import java.net.InetAddress;
 import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicLong;
-import java.net.InetSocketAddress;
-import java.net.InetAddress;
+
+import org.apache.bookkeeper.client.BKException;
+import org.apache.bookkeeper.net.BookieSocketAddress;
+import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.GenericCallback;
+import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.ReadEntryCallback;
+import org.apache.bookkeeper.test.BookieClientTest;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 
 public class TestProtoVersions {
     private BookieClientTest base;
@@ -60,7 +55,8 @@ public class TestProtoVersions {
 
     private void testVersion(byte version, int expectedresult) throws Exception {
         PerChannelBookieClient bc = new PerChannelBookieClient(base.executor, base.channelFactory, 
-                new InetSocketAddress(InetAddress.getLocalHost(), base.port), new AtomicLong(0));
+                new BookieSocketAddress(InetAddress.getLocalHost().getHostAddress(), base.port),
+                new AtomicLong(0));
         final AtomicInteger outerrc = new AtomicInteger(-1);
         final CountDownLatch connectLatch = new CountDownLatch(1);
         bc.connectIfNeededAndDoOp(new GenericCallback<Void>() {

Modified: zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/AuditorBookieTest.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/AuditorBookieTest.java?rev=1564946&r1=1564945&r2=1564946&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/AuditorBookieTest.java (original)
+++ zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/AuditorBookieTest.java Wed Feb  5 21:43:39 2014
@@ -28,12 +28,9 @@ import junit.framework.Assert;
 
 import org.apache.bookkeeper.conf.ServerConfiguration;
 import org.apache.bookkeeper.proto.BookieServer;
+import org.apache.bookkeeper.test.BookKeeperClusterTestCase;
 import org.apache.bookkeeper.util.ZkUtils;
 import org.apache.bookkeeper.zookeeper.ZooKeeperWatcherBase;
-
-import org.apache.bookkeeper.test.BookKeeperClusterTestCase;
-import org.apache.bookkeeper.util.StringUtils;
-import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.ZooKeeper;
 import org.junit.Test;
 import org.slf4j.Logger;
@@ -166,7 +163,7 @@ public class AuditorBookieTest extends B
         for (String child : children) {
             byte[] data = zkc.getData(electionPath + '/' + child, false, null);
             String bookieIP = new String(data);
-            String addr = StringUtils.addrToString(auditor.getLocalAddress());
+            String addr = auditor.getLocalAddress().toString();
             Assert.assertFalse("AuditorElection cleanup fails", bookieIP
                     .contains(addr));
         }
@@ -181,7 +178,7 @@ public class AuditorBookieTest extends B
         BookieServer auditor = verifyAuditor();
 
         shutdownBookie(auditor);
-        String addr = StringUtils.addrToString(auditor.getLocalAddress());
+        String addr = auditor.getLocalAddress().toString();
 
         // restarting Bookie with same configurations.
         int indexOfDownBookie = bs.indexOf(auditor);
@@ -222,7 +219,7 @@ public class AuditorBookieTest extends B
 
     private void startAuditorElectors() throws Exception {
         for (BookieServer bserver : bs) {
-            String addr = StringUtils.addrToString(bserver.getLocalAddress());
+            String addr = bserver.getLocalAddress().toString();
             startAuditorElector(addr);
         }
     }
@@ -255,7 +252,7 @@ public class AuditorBookieTest extends B
     }
 
     private void shutdownBookie(BookieServer bkServer) throws Exception {
-        String addr = StringUtils.addrToString(bkServer.getLocalAddress());
+        String addr = bkServer.getLocalAddress().toString();
         LOG.debug("Shutting down bookie:" + addr);
 
         // shutdown bookie which is an auditor

Modified: zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/AuditorLedgerCheckerTest.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/AuditorLedgerCheckerTest.java?rev=1564946&r1=1564945&r2=1564946&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/AuditorLedgerCheckerTest.java (original)
+++ zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/AuditorLedgerCheckerTest.java Wed Feb  5 21:43:39 2014
@@ -30,14 +30,14 @@ import java.util.List;
 import java.util.Map;
 import java.util.Random;
 import java.util.Set;
-import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.bookkeeper.client.AsyncCallback.AddCallback;
 import org.apache.bookkeeper.client.BKException;
-import org.apache.bookkeeper.client.LedgerHandle;
 import org.apache.bookkeeper.client.BookKeeper.DigestType;
+import org.apache.bookkeeper.client.LedgerHandle;
 import org.apache.bookkeeper.conf.ServerConfiguration;
 import org.apache.bookkeeper.meta.LedgerUnderreplicationManager;
 import org.apache.bookkeeper.meta.ZkLedgerUnderreplicationManager;
@@ -45,7 +45,6 @@ import org.apache.bookkeeper.proto.Booki
 import org.apache.bookkeeper.replication.ReplicationException.CompatibilityException;
 import org.apache.bookkeeper.replication.ReplicationException.UnavailableException;
 import org.apache.bookkeeper.test.MultiLedgerManagerTestCase;
-import org.apache.bookkeeper.util.StringUtils;
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.WatchedEvent;
 import org.apache.zookeeper.Watcher;
@@ -111,7 +110,7 @@ public class AuditorLedgerCheckerTest ex
 
     private void startAuditorElectors() throws Exception {
         for (BookieServer bserver : bs) {
-            String addr = StringUtils.addrToString(bserver.getLocalAddress());
+            String addr = bserver.getLocalAddress().toString();
             AuditorElector auditorElector = new AuditorElector(addr,
                     baseConf, zkc);
             auditorElectors.put(addr, auditorElector);
@@ -346,7 +345,7 @@ public class AuditorLedgerCheckerTest ex
 
     private String shutdownBookie(int bkShutdownIndex) throws Exception {
         BookieServer bkServer = bs.get(bkShutdownIndex);
-        String bookieAddr = StringUtils.addrToString(bkServer.getLocalAddress());
+        String bookieAddr = bkServer.getLocalAddress().toString();
         LOG.debug("Shutting down bookie:" + bookieAddr);
         killBookie(bkShutdownIndex);
         auditorElectors.get(bookieAddr).shutdown();

Modified: zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/AuditorPeriodicCheckTest.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/AuditorPeriodicCheckTest.java?rev=1564946&r1=1564945&r2=1564946&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/AuditorPeriodicCheckTest.java (original)
+++ zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/AuditorPeriodicCheckTest.java Wed Feb  5 21:43:39 2014
@@ -20,19 +20,6 @@
  */
 package org.apache.bookkeeper.replication;
 
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-
 import org.apache.bookkeeper.bookie.Bookie;
 import org.apache.bookkeeper.bookie.BookieAccessor;
 import org.apache.bookkeeper.bookie.IndexPersistenceMgr;
@@ -44,7 +31,6 @@ import org.apache.bookkeeper.conf.Server
 import org.apache.bookkeeper.meta.LedgerManagerFactory;
 import org.apache.bookkeeper.meta.LedgerUnderreplicationManager;
 import org.apache.bookkeeper.test.BookKeeperClusterTestCase;
-import org.apache.bookkeeper.util.StringUtils;
 import org.apache.bookkeeper.util.ZkUtils;
 import org.apache.bookkeeper.zookeeper.ZooKeeperWatcherBase;
 import org.apache.zookeeper.ZooKeeper;
@@ -54,6 +40,19 @@ import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+
 /**
  * This test verifies that the period check on the auditor
  * will pick up on missing data in the client
@@ -81,7 +80,7 @@ public class AuditorPeriodicCheckTest ex
             ServerConfiguration conf = new ServerConfiguration(bsConfs.get(i));
             conf.setAuditorPeriodicCheckInterval(CHECK_INTERVAL);
 
-            String addr = StringUtils.addrToString(bs.get(i).getLocalAddress());
+            String addr = bs.get(i).getLocalAddress().toString();
 
             ZooKeeperWatcherBase w = new ZooKeeperWatcherBase(10000);
             ZooKeeper zk = ZkUtils.createConnectedZookeeperClient(
@@ -309,7 +308,7 @@ public class AuditorPeriodicCheckTest ex
             lh.close();
         }
         final Auditor auditor = new Auditor(
-                StringUtils.addrToString(Bookie.getBookieAddress(bsConfs.get(0))),
+                Bookie.getBookieAddress(bsConfs.get(0)).toString(),
                 bsConfs.get(0), zkc);
         final AtomicBoolean exceptionCaught = new AtomicBoolean(false);
         final CountDownLatch latch = new CountDownLatch(1);

Modified: zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/BookieAutoRecoveryTest.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/BookieAutoRecoveryTest.java?rev=1564946&r1=1564945&r2=1564946&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/BookieAutoRecoveryTest.java (original)
+++ zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/BookieAutoRecoveryTest.java Wed Feb  5 21:43:39 2014
@@ -20,7 +20,6 @@
 package org.apache.bookkeeper.replication;
 
 import java.io.IOException;
-import java.net.InetSocketAddress;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.SortedMap;
@@ -34,6 +33,7 @@ import org.apache.bookkeeper.meta.Ledger
 import org.apache.bookkeeper.meta.LedgerManagerFactory;
 import org.apache.bookkeeper.meta.LedgerUnderreplicationManager;
 import org.apache.bookkeeper.meta.ZkLedgerUnderreplicationManager;
+import org.apache.bookkeeper.net.BookieSocketAddress;
 import org.apache.bookkeeper.proto.BookieServer;
 import org.apache.bookkeeper.replication.ReplicationException.CompatibilityException;
 import org.apache.bookkeeper.replication.ReplicationException.UnavailableException;
@@ -120,7 +120,7 @@ public class BookieAutoRecoveryTest exte
         List<LedgerHandle> listOfLedgerHandle = createLedgersAndAddEntries(1, 5);
         LedgerHandle lh = listOfLedgerHandle.get(0);
         int ledgerReplicaIndex = 0;
-        InetSocketAddress replicaToKillAddr = LedgerHandleAdapter
+        BookieSocketAddress replicaToKillAddr = LedgerHandleAdapter
                 .getLedgerMetadata(lh).getEnsembles().get(0L).get(0);
 
         final String urLedgerZNode = getUrLedgerZNode(lh);
@@ -169,7 +169,7 @@ public class BookieAutoRecoveryTest exte
         closeLedgers(listOfLedgerHandle);
         LedgerHandle lhandle = listOfLedgerHandle.get(0);
         int ledgerReplicaIndex = 0;
-        InetSocketAddress replicaToKillAddr = LedgerHandleAdapter
+        BookieSocketAddress replicaToKillAddr = LedgerHandleAdapter
                 .getLedgerMetadata(lhandle).getEnsembles().get(0L).get(0);
 
         CountDownLatch latch = new CountDownLatch(listOfLedgerHandle.size());
@@ -231,7 +231,7 @@ public class BookieAutoRecoveryTest exte
                 numberOfLedgers, 5);
         closeLedgers(listOfLedgerHandle);
         LedgerHandle handle = listOfLedgerHandle.get(0);
-        InetSocketAddress replicaToKillAddr = LedgerHandleAdapter
+        BookieSocketAddress replicaToKillAddr = LedgerHandleAdapter
                 .getLedgerMetadata(handle).getEnsembles().get(0L).get(0);
         LOG.info("Killing Bookie:" + replicaToKillAddr);
 
@@ -310,7 +310,7 @@ public class BookieAutoRecoveryTest exte
             assertNull("UrLedger already exists!",
                     watchUrLedgerNode(getUrLedgerZNode(lh), latch));
         }
-        InetSocketAddress replicaToKillAddr = LedgerHandleAdapter
+        BookieSocketAddress replicaToKillAddr = LedgerHandleAdapter
                 .getLedgerMetadata(listOfLedgerHandle.get(0)).getEnsembles()
                 .get(0L).get(0);
         killBookie(replicaToKillAddr);
@@ -343,11 +343,11 @@ public class BookieAutoRecoveryTest exte
     }
 
     private int getReplicaIndexInLedger(LedgerHandle lh,
-            InetSocketAddress replicaToKill) {
-        SortedMap<Long, ArrayList<InetSocketAddress>> ensembles = LedgerHandleAdapter
+ BookieSocketAddress replicaToKill) {
+        SortedMap<Long, ArrayList<BookieSocketAddress>> ensembles = LedgerHandleAdapter
                 .getLedgerMetadata(lh).getEnsembles();
         int ledgerReplicaIndex = -1;
-        for (InetSocketAddress addr : ensembles.get(0L)) {
+        for (BookieSocketAddress addr : ensembles.get(0L)) {
             ++ledgerReplicaIndex;
             if (addr.equals(replicaToKill)) {
                 break;
@@ -362,7 +362,7 @@ public class BookieAutoRecoveryTest exte
         LedgerHandle openLedger = bkc
                 .openLedger(lh.getId(), digestType, PASSWD);
 
-        InetSocketAddress inetSocketAddress = LedgerHandleAdapter
+        BookieSocketAddress inetSocketAddress = LedgerHandleAdapter
                 .getLedgerMetadata(openLedger).getEnsembles().get(0L)
                 .get(ledgerReplicaIndex);
         assertEquals("Rereplication has been failed and ledgerReplicaIndex :"

Modified: zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/TestAutoRecoveryAlongWithBookieServers.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/TestAutoRecoveryAlongWithBookieServers.java?rev=1564946&r1=1564945&r2=1564946&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/TestAutoRecoveryAlongWithBookieServers.java (original)
+++ zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/TestAutoRecoveryAlongWithBookieServers.java Wed Feb  5 21:43:39 2014
@@ -21,16 +21,16 @@
 package org.apache.bookkeeper.replication;
 
 import java.net.InetAddress;
-import java.net.InetSocketAddress;
 import java.util.ArrayList;
 import java.util.Enumeration;
-import java.util.Set;
 import java.util.Map.Entry;
+import java.util.Set;
 
 import org.apache.bookkeeper.client.BookKeeper;
 import org.apache.bookkeeper.client.LedgerEntry;
 import org.apache.bookkeeper.client.LedgerHandle;
 import org.apache.bookkeeper.client.LedgerHandleAdapter;
+import org.apache.bookkeeper.net.BookieSocketAddress;
 import org.apache.bookkeeper.test.BookKeeperClusterTestCase;
 import org.apache.bookkeeper.util.BookKeeperConstants;
 import org.junit.Test;
@@ -59,13 +59,13 @@ public class TestAutoRecoveryAlongWithBo
             lh.addEntry(testData);
         }
         lh.close();
-        InetSocketAddress replicaToKill = LedgerHandleAdapter
+        BookieSocketAddress replicaToKill = LedgerHandleAdapter
                 .getLedgerMetadata(lh).getEnsembles().get(0L).get(0);
 
         killBookie(replicaToKill);
 
         int startNewBookie = startNewBookie();
-        InetSocketAddress newBkAddr = new InetSocketAddress(InetAddress
+        BookieSocketAddress newBkAddr = new BookieSocketAddress(InetAddress
                 .getLocalHost().getHostAddress(), startNewBookie);
 
         while (ReplicationTestUtil.isLedgerInUnderReplication(zkc, lh.getId(),
@@ -74,11 +74,11 @@ public class TestAutoRecoveryAlongWithBo
         }
 
         // Killing all bookies except newly replicated bookie
-        Set<Entry<Long, ArrayList<InetSocketAddress>>> entrySet = LedgerHandleAdapter
+        Set<Entry<Long, ArrayList<BookieSocketAddress>>> entrySet = LedgerHandleAdapter
                 .getLedgerMetadata(lh).getEnsembles().entrySet();
-        for (Entry<Long, ArrayList<InetSocketAddress>> entry : entrySet) {
-            ArrayList<InetSocketAddress> bookies = entry.getValue();
-            for (InetSocketAddress bookie : bookies) {
+        for (Entry<Long, ArrayList<BookieSocketAddress>> entry : entrySet) {
+            ArrayList<BookieSocketAddress> bookies = entry.getValue();
+            for (BookieSocketAddress bookie : bookies) {
                 if (bookie.equals(newBkAddr)) {
                     continue;
                 }

Modified: zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/TestReplicationWorker.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/TestReplicationWorker.java?rev=1564946&r1=1564945&r2=1564946&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/TestReplicationWorker.java (original)
+++ zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/TestReplicationWorker.java Wed Feb  5 21:43:39 2014
@@ -1,31 +1,24 @@
 /**
- * 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. 
- * 
+ * 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.bookkeeper.replication;
 
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.Set;
-import java.util.Map.Entry;
-
 import org.apache.bookkeeper.client.BKException;
 import org.apache.bookkeeper.client.BookKeeper;
 import org.apache.bookkeeper.client.ClientUtil;
@@ -35,6 +28,7 @@ import org.apache.bookkeeper.client.Ledg
 import org.apache.bookkeeper.conf.ServerConfiguration;
 import org.apache.bookkeeper.meta.LedgerManagerFactory;
 import org.apache.bookkeeper.meta.LedgerUnderreplicationManager;
+import org.apache.bookkeeper.net.BookieSocketAddress;
 import org.apache.bookkeeper.proto.BookieServer;
 import org.apache.bookkeeper.test.MultiLedgerManagerTestCase;
 import org.apache.bookkeeper.util.BookKeeperConstants;
@@ -45,6 +39,12 @@ import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Map.Entry;
+import java.util.Set;
+
 /**
  * Test the ReplicationWroker, where it has to replicate the fragments from
  * failed Bookies to given target Bookie.
@@ -93,7 +93,7 @@ public class TestReplicationWorker exten
             underReplicationManager = null;
         }
     }
-    
+
     /**
      * Tests that replication worker should replicate the failed bookie
      * fragments to target bookie given to the worker.
@@ -106,7 +106,7 @@ public class TestReplicationWorker exten
         for (int i = 0; i < 10; i++) {
             lh.addEntry(data);
         }
-        InetSocketAddress replicaToKill = LedgerHandleAdapter
+        BookieSocketAddress replicaToKill = LedgerHandleAdapter
                 .getLedgerMetadata(lh).getEnsembles().get(0L).get(0);
 
         LOG.info("Killing Bookie", replicaToKill);
@@ -117,7 +117,7 @@ public class TestReplicationWorker exten
             lh.addEntry(data);
         }
 
-        InetSocketAddress newBkAddr = new InetSocketAddress(InetAddress
+        BookieSocketAddress newBkAddr = new BookieSocketAddress(InetAddress
                 .getLocalHost().getHostAddress(), startNewBookie);
         LOG.info("New Bookie addr :" + newBkAddr);
 
@@ -157,13 +157,13 @@ public class TestReplicationWorker exten
             lh.addEntry(data);
         }
         lh.close();
-        InetSocketAddress replicaToKill = LedgerHandleAdapter
+        BookieSocketAddress replicaToKill = LedgerHandleAdapter
                 .getLedgerMetadata(lh).getEnsembles().get(0L).get(0);
         LOG.info("Killing Bookie", replicaToKill);
         ServerConfiguration killedBookieConfig = killBookie(replicaToKill);
 
         int startNewBookie = startNewBookie();
-        InetSocketAddress newBkAddr = new InetSocketAddress(InetAddress
+        BookieSocketAddress newBkAddr = new BookieSocketAddress(InetAddress
                 .getLocalHost().getHostAddress(), startNewBookie);
         LOG.info("New Bookie addr :" + newBkAddr);
 
@@ -209,7 +209,7 @@ public class TestReplicationWorker exten
             lh.addEntry(data);
         }
         lh.close();
-        InetSocketAddress replicaToKill = LedgerHandleAdapter
+        BookieSocketAddress replicaToKill = LedgerHandleAdapter
                 .getLedgerMetadata(lh).getEnsembles().get(0L).get(0);
         LOG.info("Killing Bookie", replicaToKill);
         ServerConfiguration killedBookieConfig = killBookie(replicaToKill);
@@ -217,14 +217,14 @@ public class TestReplicationWorker exten
         killAllBookies(lh, null);
         // Starte RW1
         int startNewBookie1 = startNewBookie();
-        InetSocketAddress newBkAddr1 = new InetSocketAddress(InetAddress
+        BookieSocketAddress newBkAddr1 = new BookieSocketAddress(InetAddress
                 .getLocalHost().getHostAddress(), startNewBookie1);
         LOG.info("New Bookie addr :" + newBkAddr1);
         ReplicationWorker rw1 = new ReplicationWorker(zkc, baseConf, newBkAddr1);
 
         // Starte RW2
         int startNewBookie2 = startNewBookie();
-        InetSocketAddress newBkAddr2 = new InetSocketAddress(InetAddress
+        BookieSocketAddress newBkAddr2 = new BookieSocketAddress(InetAddress
                 .getLocalHost().getHostAddress(), startNewBookie2);
         LOG.info("New Bookie addr :" + newBkAddr2);
         ZooKeeperWatcherBase w = new ZooKeeperWatcherBase(10000);
@@ -275,13 +275,13 @@ public class TestReplicationWorker exten
             lh.addEntry(data);
         }
         lh.close();
-        InetSocketAddress replicaToKill = LedgerHandleAdapter
+        BookieSocketAddress replicaToKill = LedgerHandleAdapter
                 .getLedgerMetadata(lh).getEnsembles().get(0L).get(0);
         LOG.info("Killing Bookie", replicaToKill);
         killBookie(replicaToKill);
 
         int startNewBookie = startNewBookie();
-        InetSocketAddress newBkAddr = new InetSocketAddress(InetAddress
+        BookieSocketAddress newBkAddr = new BookieSocketAddress(InetAddress
                 .getLocalHost().getHostAddress(), startNewBookie);
         LOG.info("New Bookie addr :" + newBkAddr);
         ReplicationWorker rw = new ReplicationWorker(zkc, baseConf, newBkAddr);
@@ -312,7 +312,7 @@ public class TestReplicationWorker exten
         for (int i = 0; i < 10; i++) {
             lh1.addEntry(data);
         }
-        InetSocketAddress replicaToKillFromFirstLedger = LedgerHandleAdapter
+        BookieSocketAddress replicaToKillFromFirstLedger = LedgerHandleAdapter
                 .getLedgerMetadata(lh1).getEnsembles().get(0L).get(0);
 
         LOG.info("Killing Bookie", replicaToKillFromFirstLedger);
@@ -324,7 +324,7 @@ public class TestReplicationWorker exten
         for (int i = 0; i < 10; i++) {
             lh2.addEntry(data);
         }
-        InetSocketAddress replicaToKillFromSecondLedger = LedgerHandleAdapter
+        BookieSocketAddress replicaToKillFromSecondLedger = LedgerHandleAdapter
                 .getLedgerMetadata(lh2).getEnsembles().get(0L).get(0);
 
         LOG.info("Killing Bookie", replicaToKillFromSecondLedger);
@@ -338,7 +338,7 @@ public class TestReplicationWorker exten
 
         int startNewBookie = startNewBookie();
 
-        InetSocketAddress newBkAddr = new InetSocketAddress(InetAddress
+        BookieSocketAddress newBkAddr = new BookieSocketAddress(InetAddress
                 .getLocalHost().getHostAddress(), startNewBookie);
         LOG.info("New Bookie addr :" + newBkAddr);
 
@@ -373,7 +373,7 @@ public class TestReplicationWorker exten
         }
 
     }
-    
+
     /**
      * Tests that ReplicationWorker should fence the ledger and release ledger
      * lock after timeout. Then replication should happen normally.
@@ -387,7 +387,7 @@ public class TestReplicationWorker exten
         for (int i = 0; i < 10; i++) {
             lh.addEntry(data);
         }
-        InetSocketAddress replicaToKill = LedgerHandleAdapter
+        BookieSocketAddress replicaToKill = LedgerHandleAdapter
                 .getLedgerMetadata(lh).getEnsembles().get(0L).get(0);
 
         LOG.info("Killing Bookie", replicaToKill);
@@ -395,7 +395,7 @@ public class TestReplicationWorker exten
 
         int startNewBookie = startNewBookie();
 
-        InetSocketAddress newBkAddr = new InetSocketAddress(InetAddress
+        BookieSocketAddress newBkAddr = new BookieSocketAddress(InetAddress
                 .getLocalHost().getHostAddress(), startNewBookie);
         LOG.info("New Bookie addr :" + newBkAddr);
 
@@ -444,7 +444,7 @@ public class TestReplicationWorker exten
         for (int i = 0; i < 10; i++) {
             lh.addEntry(data);
         }
-        InetSocketAddress replicaToKill = LedgerHandleAdapter
+        BookieSocketAddress replicaToKill = LedgerHandleAdapter
                 .getLedgerMetadata(lh).getEnsembles().get(0L).get(0);
 
         LOG.info("Killing Bookie", replicaToKill);
@@ -458,7 +458,7 @@ public class TestReplicationWorker exten
             lh.addEntry(data);
         }
 
-        InetSocketAddress newBkAddr = new InetSocketAddress(InetAddress
+        BookieSocketAddress newBkAddr = new BookieSocketAddress(InetAddress
                 .getLocalHost().getHostAddress(), startNewBookie);
         LOG.info("New Bookie addr :" + newBkAddr);
 
@@ -506,7 +506,8 @@ public class TestReplicationWorker exten
         for (int i = 0; i < 10; i++) {
             lh.addEntry(data);
         }
-        InetSocketAddress replicaToKill = LedgerHandleAdapter.getLedgerMetadata(lh).getEnsembles().get(0L).get(0);
+        BookieSocketAddress replicaToKill =
+                LedgerHandleAdapter.getLedgerMetadata(lh).getEnsembles().get(0L).get(0);
 
         LOG.info("Killing Bookie", replicaToKill);
         killBookie(replicaToKill);
@@ -516,7 +517,7 @@ public class TestReplicationWorker exten
             lh.addEntry(data);
         }
 
-        InetSocketAddress newBkAddr = new InetSocketAddress(InetAddress.getLocalHost().getHostAddress(), newBkPort);
+        BookieSocketAddress newBkAddr = new BookieSocketAddress(InetAddress.getLocalHost().getHostAddress(), newBkPort);
         LOG.info("New Bookie addr :" + newBkAddr);
 
         ReplicationWorker rw = new ReplicationWorker(zkc, baseConf, newBkAddr);
@@ -569,14 +570,14 @@ public class TestReplicationWorker exten
         }
     }
 
-    private void killAllBookies(LedgerHandle lh, InetSocketAddress excludeBK)
+    private void killAllBookies(LedgerHandle lh, BookieSocketAddress excludeBK)
             throws Exception {
         // Killing all bookies except newly replicated bookie
-        Set<Entry<Long, ArrayList<InetSocketAddress>>> entrySet = LedgerHandleAdapter
+        Set<Entry<Long, ArrayList<BookieSocketAddress>>> entrySet = LedgerHandleAdapter
                 .getLedgerMetadata(lh).getEnsembles().entrySet();
-        for (Entry<Long, ArrayList<InetSocketAddress>> entry : entrySet) {
-            ArrayList<InetSocketAddress> bookies = entry.getValue();
-            for (InetSocketAddress bookie : bookies) {
+        for (Entry<Long, ArrayList<BookieSocketAddress>> entry : entrySet) {
+            ArrayList<BookieSocketAddress> bookies = entry.getValue();
+            for (BookieSocketAddress bookie : bookies) {
                 if (bookie.equals(excludeBK)) {
                     continue;
                 }

Modified: zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/BookKeeperClusterTestCase.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/BookKeeperClusterTestCase.java?rev=1564946&r1=1564945&r2=1564946&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/BookKeeperClusterTestCase.java (original)
+++ zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/BookKeeperClusterTestCase.java Wed Feb  5 21:43:39 2014
@@ -24,7 +24,6 @@ package org.apache.bookkeeper.test;
 import java.io.File;
 import java.io.IOException;
 import java.net.InetAddress;
-import java.net.InetSocketAddress;
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
@@ -42,6 +41,7 @@ import org.apache.bookkeeper.conf.Client
 import org.apache.bookkeeper.conf.ServerConfiguration;
 import org.apache.bookkeeper.conf.TestBKConfiguration;
 import org.apache.bookkeeper.metastore.InMemoryMetaStore;
+import org.apache.bookkeeper.net.BookieSocketAddress;
 import org.apache.bookkeeper.proto.BookieServer;
 import org.apache.bookkeeper.replication.AutoRecoveryMain;
 import org.apache.bookkeeper.replication.ReplicationException.CompatibilityException;
@@ -204,7 +204,7 @@ public abstract class BookKeeperClusterT
     /**
      * Get bookie address for bookie at index
      */
-    public InetSocketAddress getBookie(int index) throws Exception {
+    public BookieSocketAddress getBookie(int index) throws Exception {
         if (bs.size() <= index || index < 0) {
             throw new IllegalArgumentException("Invalid index, there are only " + bs.size()
                                                + " bookies. Asked for " + index);
@@ -221,7 +221,7 @@ public abstract class BookKeeperClusterT
      * @return the configuration of killed bookie
      * @throws InterruptedException
      */
-    public ServerConfiguration killBookie(InetSocketAddress addr) throws Exception {
+    public ServerConfiguration killBookie(BookieSocketAddress addr) throws Exception {
         BookieServer toRemove = null;
         int toRemoveIndex = 0;
         for (BookieServer server : bs) {
@@ -272,7 +272,7 @@ public abstract class BookKeeperClusterT
      * @throws InterruptedException
      * @throws IOException
      */
-    public CountDownLatch sleepBookie(InetSocketAddress addr, final int seconds)
+    public CountDownLatch sleepBookie(BookieSocketAddress addr, final int seconds)
             throws Exception {
         for (final BookieServer bookie : bs) {
             if (bookie.getLocalAddress().equals(addr)) {
@@ -307,7 +307,7 @@ public abstract class BookKeeperClusterT
      * @throws InterruptedException
      * @throws IOException
      */
-    public void sleepBookie(InetSocketAddress addr, final CountDownLatch l)
+    public void sleepBookie(BookieSocketAddress addr, final CountDownLatch l)
             throws Exception {
         for (final BookieServer bookie : bs) {
             if (bookie.getLocalAddress().equals(addr)) {



Mime
View raw message