hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdcry...@apache.org
Subject svn commit: r1484030 [2/2] - in /hbase/branches/0.95: hbase-client/src/main/java/org/apache/hadoop/hbase/replication/ hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/ hbase-serv...
Date Fri, 17 May 2013 23:57:29 GMT
Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationStateZKImpl.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationStateZKImpl.java?rev=1484030&r1=1484029&r2=1484030&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationStateZKImpl.java
(original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationStateZKImpl.java
Fri May 17 23:57:28 2013
@@ -23,16 +23,20 @@ import java.io.IOException;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.ClusterId;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.MediumTests;
 import org.apache.hadoop.hbase.Server;
 import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.catalog.CatalogTracker;
+import org.apache.hadoop.hbase.zookeeper.ZKClusterId;
 import org.apache.hadoop.hbase.zookeeper.ZKUtil;
 import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
 import org.apache.zookeeper.KeeperException;
 import org.junit.After;
 import org.junit.AfterClass;
+import static org.junit.Assert.*;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.experimental.categories.Category;
@@ -55,20 +59,42 @@ public class TestReplicationStateZKImpl 
     zkw = HBaseTestingUtility.getZooKeeperWatcher(utility);
     String replicationZNodeName = conf.get("zookeeper.znode.replication", "replication");
     replicationZNode = ZKUtil.joinZNode(zkw.baseZNode, replicationZNodeName);
+    KEY_ONE = initPeerClusterState("/hbase1");
+    KEY_TWO = initPeerClusterState("/hbase2");
+  }
+
+  private static String initPeerClusterState(String baseZKNode)
+      throws IOException, KeeperException {
+    // Set up state nodes of peer clusters
+    Configuration testConf = new Configuration(conf);
+    testConf.set(HConstants.ZOOKEEPER_ZNODE_PARENT, baseZKNode);
+    ZooKeeperWatcher zkw1 = new ZooKeeperWatcher(testConf, "test1", null);
+    ReplicationStateInterface rsi = new ReplicationStateImpl(zkw1, testConf, zkw1);
+    rsi.init();
+    rsi.setState(true);
+    rsi.close();
+    String fakeRs = ZKUtil.joinZNode(zkw1.rsZNode, "hostname1.example.org:1234");
+    ZKUtil.createWithParents(zkw1, fakeRs);
+    ZKClusterId.setClusterId(zkw1, new ClusterId());
+    return ZKUtil.getZooKeeperClusterKey(testConf);
   }
 
   @Before
-  public void setUp() throws KeeperException {
+  @Override
+  public void setUp() {
+    super.setUp();
     DummyServer ds1 = new DummyServer(server1);
     DummyServer ds2 = new DummyServer(server2);
     DummyServer ds3 = new DummyServer(server3);
-    rq1 = new ReplicationQueuesZKImpl(zkw, conf, ds1);
-    rq2 = new ReplicationQueuesZKImpl(zkw, conf, ds2);
-    rq3 = new ReplicationQueuesZKImpl(zkw, conf, ds3);
-    rqc = new ReplicationQueuesClientZKImpl(zkw, conf, ds1);
-    String peersZnode = ZKUtil.joinZNode(replicationZNode, "peers");
-    for (int i = 1; i < 6; i++) {
-      ZKUtil.createWithParents(zkw, ZKUtil.joinZNode(peersZnode, "qId"+i));
+    try {
+      rq1 = new ReplicationQueuesZKImpl(zkw, conf, ds1);
+      rq2 = new ReplicationQueuesZKImpl(zkw, conf, ds2);
+      rq3 = new ReplicationQueuesZKImpl(zkw, conf, ds3);
+      rqc = new ReplicationQueuesClientZKImpl(zkw, conf, ds1);
+      rp = new ReplicationPeersZKImpl(zkw, conf, zkw);
+      OUR_KEY = ZKUtil.getZooKeeperClusterKey(conf);
+    } catch (KeeperException e) {
+      fail("Exception thrown: " + e);
     }
   }
 

Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationZookeeper.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationZookeeper.java?rev=1484030&r1=1484029&r2=1484030&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationZookeeper.java
(original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationZookeeper.java
Fri May 17 23:57:28 2013
@@ -53,6 +53,8 @@ public class TestReplicationZookeeper {
 
   private static String slaveClusterKey;
 
+  private static String peersZNode;
+
   @BeforeClass
   public static void setUpBeforeClass() throws Exception {
     utility = new HBaseTestingUtility();
@@ -63,6 +65,10 @@ public class TestReplicationZookeeper {
     repZk = new ReplicationZookeeper(server, new AtomicBoolean());
     slaveClusterKey = conf.get(HConstants.ZOOKEEPER_QUORUM) + ":" +
       conf.get("hbase.zookeeper.property.clientPort") + ":/1";
+    String replicationZNodeName = conf.get("zookeeper.znode.replication", "replication");
+    String peersZNodeName = conf.get("zookeeper.znode.replication.peers", "peers");
+    String replicationZNode = ZKUtil.joinZNode(zkw.baseZNode, replicationZNodeName);
+    peersZNode = ZKUtil.joinZNode(replicationZNode, peersZNodeName);
   }
 
   @AfterClass
@@ -80,19 +86,19 @@ public class TestReplicationZookeeper {
   
   @Test
   public void testIsPeerPath_PathToParentOfPeerNode() {
-    String peerParentNode = repZk.getPeersZNode();
+    String peerParentNode = peersZNode;
     assertFalse(repZk.isPeerPath(peerParentNode));
   }
   
   @Test
   public void testIsPeerPath_PathToChildOfPeerNode() {
-    String peerChild = ZKUtil.joinZNode(ZKUtil.joinZNode(repZk.getPeersZNode(), "1"), "child");
+    String peerChild = ZKUtil.joinZNode(ZKUtil.joinZNode(peersZNode, "1"), "child");
     assertFalse(repZk.isPeerPath(peerChild));
   }
   
   @Test
   public void testIsPeerPath_ActualPeerPath() {
-    String peerPath = ZKUtil.joinZNode(repZk.getPeersZNode(), "1");
+    String peerPath = ZKUtil.joinZNode(peersZNode, "1");
     assertTrue(repZk.isPeerPath(peerPath));
   }
 

Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSourceManager.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSourceManager.java?rev=1484030&r1=1484029&r2=1484030&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSourceManager.java
(original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSourceManager.java
Fri May 17 23:57:28 2013
@@ -53,6 +53,7 @@ import org.apache.hadoop.hbase.regionser
 import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
 import org.apache.hadoop.hbase.replication.ReplicationQueueInfo;
 import org.apache.hadoop.hbase.replication.ReplicationSourceDummy;
+import org.apache.hadoop.hbase.replication.ReplicationStateZKBase;
 import org.apache.hadoop.hbase.replication.ReplicationZookeeper;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.zookeeper.ZKUtil;
@@ -124,9 +125,9 @@ public class TestReplicationSourceManage
             + conf.get(HConstants.ZOOKEEPER_CLIENT_PORT) + ":/1"));
     ZKUtil.createWithParents(zkw, "/hbase/replication/peers/1/peer-state");
     ZKUtil.setData(zkw, "/hbase/replication/peers/1/peer-state",
-      ReplicationZookeeper.ENABLED_ZNODE_BYTES);
+      ReplicationStateZKBase.ENABLED_ZNODE_BYTES);
     ZKUtil.createWithParents(zkw, "/hbase/replication/state");
-    ZKUtil.setData(zkw, "/hbase/replication/state", ReplicationZookeeper.ENABLED_ZNODE_BYTES);
+    ZKUtil.setData(zkw, "/hbase/replication/state", ReplicationStateZKBase.ENABLED_ZNODE_BYTES);
 
     replication = new Replication(new DummyServer(), fs, logDir, oldLogDir);
     manager = replication.getReplicationManager();
@@ -277,6 +278,7 @@ public class TestReplicationSourceManage
     for (String file : files) {
       rz.addLogToList(file, "1");
     }
+
     // create 3 DummyServers
     Server s1 = new DummyServer("ip-10-8-101-114.ec2.internal");
     Server s2 = new DummyServer("ec2-107-20-52-47.compute-1.amazonaws.com");



Mime
View raw message