hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jg...@apache.org
Subject svn commit: r964570 [2/2] - in /hbase/branches/0.90_master_rewrite: ./ src/main/java/org/apache/hadoop/hbase/ src/main/java/org/apache/hadoop/hbase/avro/ src/main/java/org/apache/hadoop/hbase/client/ src/main/java/org/apache/hadoop/hbase/master/ src/ma...
Date Thu, 15 Jul 2010 20:32:32 GMT
Modified: hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcher.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcher.java?rev=964570&r1=964569&r2=964570&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcher.java
(original)
+++ hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcher.java
Thu Jul 15 20:32:31 2010
@@ -27,7 +27,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.HConstants;
-import org.apache.hadoop.hbase.ServerStatus;
+import org.apache.hadoop.hbase.ServerController;
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.WatchedEvent;
 import org.apache.zookeeper.Watcher;
@@ -36,32 +36,35 @@ import org.apache.zookeeper.ZooKeeper;
 /**
  * Acts as the single ZooKeeper Watcher.  One instance of this is instantiated
  * for each Master, RegionServer, and client process.
- * 
+ *
  * This is the only class that implements {@link Watcher}.  Other internal
  * classes which need to be notified of ZooKeeper events must register with
  * the local instance of this watcher via {@link #registerListener}.
- * 
+ *
  * This class also holds and manages the connection to ZooKeeper.  Code to deal
  * with connection related events and exceptions are handled here.
  */
 public class ZooKeeperWatcher extends ZooKeeperWrapper implements Watcher {
   private static final Log LOG = LogFactory.getLog(ZooKeeperWatcher.class);
-  
+
   // name of this watcher (for logging only)
   private String name;
-  
+
+  // zookeeper quorum
+  private String quorum;
+
   // zookeeper connection
   private ZooKeeper zooKeeper;
-  
+
   // server controller
-  private ServerStatus server;
-  
+  private ServerController server;
+
   // listeners to be notified
   private final Set<ZooKeeperListener> listeners =
     new CopyOnWriteArraySet<ZooKeeperListener>();
 
   // node names
-  
+
   // base znode for this cluster
   public String baseZNode;
   // znode containing location of server hosting root region
@@ -74,33 +77,39 @@ public class ZooKeeperWatcher extends Zo
   public String clusterStateZNode;
   // znode used for region transitioning and assignment
   public String assignmentZNode;
-  
+
   /**
    * Instantiate a ZooKeeper connection and watcher.
    * @param name name of this watcher, for logging/debug purposes only
-   * @throws IOException 
+   * @throws IOException
    */
-  public ZooKeeperWatcher(Configuration conf, String name, ServerStatus server)
+  public ZooKeeperWatcher(Configuration conf, String name,
+      ServerController server)
   throws IOException {
     super(conf, name);
     this.name = name;
-    this.zooKeeper = ZKUtil.connect(conf, this);
+    this.quorum = ZKConfig.getZKQuorumServersString(conf);
+    this.zooKeeper = ZKUtil.connect(conf, quorum, this);
     this.server = server;
     info("Connected to ZooKeeper");
     setNodeNames(conf);
     try {
+      // Create all the necessary "directories" of znodes
+      // TODO: Move this to an init method somewhere so not everyone calls it?
       ZKUtil.createIfNotExists(this, baseZNode);
+      ZKUtil.createIfNotExists(this, assignmentZNode);
+      ZKUtil.createIfNotExists(this, rsZNode);
     } catch (KeeperException e) {
       error("Unexpected KeeperException creating base node", e);
       throw new IOException(e);
     }
   }
-  
+
   /**
    * Set the local variable node names using the specified configuration.
    */
   private void setNodeNames(Configuration conf) {
-    baseZNode = conf.get(HConstants.ZOOKEEPER_ZNODE_PARENT, 
+    baseZNode = conf.get(HConstants.ZOOKEEPER_ZNODE_PARENT,
         HConstants.DEFAULT_ZOOKEEPER_ZNODE_PARENT);
     rootServerZNode = ZKUtil.joinZNode(baseZNode,
         conf.get("zookeeper.znode.rootserver", "root-region-server"));
@@ -113,7 +122,7 @@ public class ZooKeeperWatcher extends Zo
     assignmentZNode = ZKUtil.joinZNode(baseZNode,
         conf.get("zookeeper.znode.regionInTransition", "unassigned"));
   }
-  
+
   /**
    * Register the specified listener to receive ZooKeeper events.
    * @param listener
@@ -121,18 +130,27 @@ public class ZooKeeperWatcher extends Zo
   public void registerListener(ZooKeeperListener listener) {
     listeners.add(listener);
   }
-  
+
   /**
    * Get the connection to ZooKeeper.
    * @return connection reference to zookeeper
    */
+  @Override
   public ZooKeeper getZooKeeper() {
     return zooKeeper;
   }
-  
+
+  /**
+   * Get the quorum address of this instance.
+   * @returns quorum string of this zookeeper connection instance
+   */
+  public String getQuorum() {
+    return quorum;
+  }
+
   /**
    * Method called from ZooKeeper for events and connection status.
-   * 
+   *
    * Valid events are passed along to listeners.  Connection status changes
    * are dealt with locally.
    */
@@ -142,10 +160,10 @@ public class ZooKeeperWatcher extends Zo
         "type: " + event.getType() + ", " +
         "state:" + event.getState() + ", " +
         "path: " + event.getPath());
-    
+
     // While we are still using both ZKWs, need to call parent process()
     super.process(event);
-    
+
     switch(event.getType()) {
 
       // If event type is NONE, this is a connection status change
@@ -153,30 +171,30 @@ public class ZooKeeperWatcher extends Zo
         connectionEvent(event);
         break;
       }
-      
+
       // Otherwise pass along to the listeners
-      
+
       case NodeCreated: {
         for(ZooKeeperListener listener : listeners) {
           listener.nodeCreated(event.getPath());
         }
         break;
       }
-      
+
       case NodeDeleted: {
         for(ZooKeeperListener listener : listeners) {
           listener.nodeDeleted(event.getPath());
         }
         break;
       }
-      
+
       case NodeDataChanged: {
         for(ZooKeeperListener listener : listeners) {
           listener.nodeDataChanged(event.getPath());
         }
         break;
       }
-      
+
       case NodeChildrenChanged: {
         for(ZooKeeperListener listener : listeners) {
           listener.nodeChildrenChanged(event.getPath());
@@ -187,12 +205,12 @@ public class ZooKeeperWatcher extends Zo
   }
 
   // Connection management
-  
+
   /**
    * Called when there is a connection-related event via the Watcher callback.
-   * 
+   *
    * If Disconnected or Expired, this should shutdown the cluster.
-   * 
+   *
    * @param event
    */
   private void connectionEvent(WatchedEvent event) {
@@ -200,7 +218,7 @@ public class ZooKeeperWatcher extends Zo
       // SyncConnected is normal, ignore
       case SyncConnected:
         break;
-        
+
       // Abort the server if Disconnected or Expired
       // TODO: Åny reason to handle these two differently?
       case Disconnected:
@@ -214,32 +232,32 @@ public class ZooKeeperWatcher extends Zo
         break;
     }
   }
-  
+
   /**
    * Handles KeeperExceptions in client calls.
-   * 
+   *
    * This may be temporary but for now this gives one place to deal with these.
-   * 
+   *
    * TODO: Currently this method rethrows the exception to let the caller handle
-   * 
+   *
    * @param ke
-   * @throws KeeperException 
+   * @throws KeeperException
    */
   public void keeperException(KeeperException ke)
   throws KeeperException {
     error("Received unexpected KeeperException, re-throwing exception", ke);
     throw ke;
   }
-  
+
   /**
    * Handles InterruptedExceptions in client calls.
-   * 
+   *
    * This may be temporary but for now this gives one place to deal with these.
-   * 
+   *
    * TODO: Currently, this method does nothing.
    *       Is this ever expected to happen?  Do we abort or can we let it run?
    *       Maybe this should be logged as WARN?  It shouldn't happen?
-   * 
+   *
    * @param ie
    */
   public void interruptedException(InterruptedException ie) {
@@ -248,7 +266,7 @@ public class ZooKeeperWatcher extends Zo
   }
 
   // Logging methods
-  
+
   /**
    * Exposed info logging method so our zookeeper output is named.
    * @param string log line
@@ -309,8 +327,9 @@ public class ZooKeeperWatcher extends Zo
 
   /**
    * Close the connection to ZooKeeper.
-   * @throws InterruptedException 
+   * @throws InterruptedException
    */
+  @Override
   public void close() {
     try {
       if(zooKeeper != null) {

Modified: hbase/branches/0.90_master_rewrite/src/main/resources/hbase-webapps/master/zk.jsp
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/main/resources/hbase-webapps/master/zk.jsp?rev=964570&r1=964569&r2=964570&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/main/resources/hbase-webapps/master/zk.jsp (original)
+++ hbase/branches/0.90_master_rewrite/src/main/resources/hbase-webapps/master/zk.jsp Thu
Jul 15 20:32:31 2010
@@ -4,7 +4,8 @@
   import="org.apache.hadoop.hbase.client.HBaseAdmin"
   import="org.apache.hadoop.hbase.client.HConnection"
   import="org.apache.hadoop.hbase.HRegionInfo"
-  import="org.apache.hadoop.hbase.zookeeper.ZooKeeperWrapper"
+  import="org.apache.hadoop.hbase.zookeeper.ZKUtil"
+  import="org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher"
   import="org.apache.hadoop.hbase.HBaseConfiguration"
   import="org.apache.hadoop.hbase.master.HMaster" 
   import="org.apache.hadoop.hbase.HConstants"%><%
@@ -12,7 +13,7 @@
   Configuration conf = master.getConfiguration();
   HBaseAdmin hbadmin = new HBaseAdmin(conf);
   HConnection connection = hbadmin.getConnection();
-  ZooKeeperWrapper wrapper = connection.getZooKeeperWrapper();
+  ZooKeeperWatcher watcher = connection.getZooKeeperWatcher();
 %>
 
 <?xml version="1.0" encoding="UTF-8" ?>
@@ -29,7 +30,7 @@
 <p id="links_menu"><a href="/master.jsp">Master</a>, <a href="/logs/">Local
logs</a>, <a href="/stacks">Thread Dump</a>, <a href="/logLevel">Log
Level</a></p>
 <hr id="head_rule" />
 <pre>
-<%= wrapper.dump() %>
+<%= ZKUtil.dump(watcher) %>
 </pre>
 
 </body>

Modified: hbase/branches/0.90_master_rewrite/src/main/resources/hbase-webapps/regionserver/regionserver.jsp
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/main/resources/hbase-webapps/regionserver/regionserver.jsp?rev=964570&r1=964569&r2=964570&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/main/resources/hbase-webapps/regionserver/regionserver.jsp
(original)
+++ hbase/branches/0.90_master_rewrite/src/main/resources/hbase-webapps/regionserver/regionserver.jsp
Thu Jul 15 20:32:31 2010
@@ -42,7 +42,7 @@
 <tr><td>HBase Version</td><td><%= org.apache.hadoop.hbase.util.VersionInfo.getVersion()
%>, r<%= org.apache.hadoop.hbase.util.VersionInfo.getRevision() %></td><td>HBase
version and svn revision</td></tr>
 <tr><td>HBase Compiled</td><td><%= org.apache.hadoop.hbase.util.VersionInfo.getDate()
%>, <%= org.apache.hadoop.hbase.util.VersionInfo.getUser() %></td><td>When
HBase version was compiled and by whom</td></tr>
 <tr><td>Metrics</td><td><%= metrics.toString() %></td><td>RegionServer
Metrics; file and heap sizes are in megabytes</td></tr>
-<tr><td>Zookeeper Quorum</td><td><%= regionServer.getZooKeeper().getQuorumServers()
%></td><td>Addresses of all registered ZK servers</td></tr>
+<tr><td>Zookeeper Quorum</td><td><%= regionServer.getZooKeeper().getQuorum()
%></td><td>Addresses of all registered ZK servers</td></tr>
 </table>
 
 <h2>Online Regions</h2>

Modified: hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java?rev=964570&r1=964569&r2=964570&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
(original)
+++ hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
Thu Jul 15 20:32:31 2010
@@ -708,16 +708,13 @@ public class HBaseTestingUtility {
     expireSession(rs.getZooKeeper(), rs);
   }
 
-  public void expireSession(ZooKeeperWatcher nodeZK, ServerStatus server)
+  public void expireSession(ZooKeeperWatcher nodeZK, ServerController server)
   throws Exception {
-    ZooKeeperWatcher zkw = new ZooKeeperWatcher(conf, 
-        ZooKeeperWatcher.class.getName(), server);
-    zkw.registerListener(EmptyWatcher.instance);
     String quorumServers = ZKConfig.getZKQuorumServersString(conf);
     int sessionTimeout = 5 * 1000; // 5 seconds
 
-    byte[] password = nodeZK.getSessionPassword();
-    long sessionID = nodeZK.getSessionID();
+    byte[] password = nodeZK.getZooKeeper().getSessionPasswd();
+    long sessionID = nodeZK.getZooKeeper().getSessionId();
 
     ZooKeeper zk = new ZooKeeper(quorumServers,
         sessionTimeout, EmptyWatcher.instance, sessionID, password);
@@ -744,8 +741,10 @@ public class HBaseTestingUtility {
    *
    * @return The HBaseAdmin instance.
    * @throws MasterNotRunningException
+   * @throws ZooKeeperConnectionException
    */
-  public HBaseAdmin getHBaseAdmin() throws MasterNotRunningException {
+  public HBaseAdmin getHBaseAdmin()
+  throws MasterNotRunningException, ZooKeeperConnectionException {
     if (hbaseAdmin == null) {
       hbaseAdmin = new HBaseAdmin(getConfiguration());
     }

Modified: hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/TestZooKeeper.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/TestZooKeeper.java?rev=964570&r1=964569&r2=964570&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/TestZooKeeper.java
(original)
+++ hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/TestZooKeeper.java
Thu Jul 15 20:32:31 2010
@@ -29,6 +29,8 @@ import org.apache.hadoop.hbase.client.HC
 import org.apache.hadoop.hbase.client.HTable;
 import org.apache.hadoop.hbase.client.Put;
 import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.zookeeper.ZKConfig;
+import org.apache.hadoop.hbase.zookeeper.ZKUtil;
 import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
 import org.apache.hadoop.hbase.zookeeper.ZooKeeperWrapper;
 import org.apache.zookeeper.KeeperException;
@@ -92,15 +94,12 @@ public class TestZooKeeper {
       throws IOException, InterruptedException {
     new HTable(conf, HConstants.META_TABLE_NAME);
 
-    ZooKeeperWatcher zkw = new ZooKeeperWatcher(conf, 
-        TestZooKeeper.class.getName(), null);
-    zkw.registerListener(EmptyWatcher.instance);
-    String quorumServers = zkw.getQuorumServers();
+    String quorumServers = ZKConfig.getZKQuorumServersString(conf);
     int sessionTimeout = 5 * 1000; // 5 seconds
     HConnection connection = HConnectionManager.getConnection(conf);
-    ZooKeeperWrapper connectionZK = connection.getZooKeeperWrapper();
-    long sessionID = connectionZK.getSessionID();
-    byte[] password = connectionZK.getSessionPassword();
+    ZooKeeperWatcher connectionZK = connection.getZooKeeperWatcher();
+    long sessionID = connectionZK.getZooKeeper().getSessionId();
+    byte[] password = connectionZK.getZooKeeper().getSessionPasswd();
 
     ZooKeeper zk = new ZooKeeper(quorumServers, sessionTimeout,
         EmptyWatcher.instance, sessionID, password);
@@ -163,12 +162,11 @@ public class TestZooKeeper {
       ipMeta.exists(new Get(HConstants.LAST_ROW));
 
       // make sure they aren't the same
-      assertFalse(HConnectionManager.getClientZooKeeperWatcher(conf)
-          .getZooKeeperWrapper() == HConnectionManager.getClientZooKeeperWatcher(
-          otherConf).getZooKeeperWrapper());
+      assertFalse(HConnectionManager.getConnection(conf).getZooKeeperWatcher()
+          == HConnectionManager.getConnection(otherConf).getZooKeeperWatcher());
       assertFalse(HConnectionManager.getConnection(conf)
-          .getZooKeeperWrapper().getQuorumServers().equals(HConnectionManager
-          .getConnection(otherConf).getZooKeeperWrapper().getQuorumServers()));
+          .getZooKeeperWatcher().getQuorum().equals(HConnectionManager
+              .getConnection(otherConf).getZooKeeperWatcher().getQuorum()));
     } catch (Exception e) {
       e.printStackTrace();
       fail();
@@ -184,17 +182,16 @@ public class TestZooKeeper {
   public void testZNodeDeletes() throws Exception {
     ZooKeeperWatcher zkw = new ZooKeeperWatcher(conf, 
         TestZooKeeper.class.getName(), null);
-    zkw.registerListener(EmptyWatcher.instance);
-    zkw.ensureExists("/l1/l2/l3/l4");
+    ZKUtil.createWithParents(zkw, "/l1/l2/l3/l4");
     try {
-      zkw.deleteZNode("/l1/l2");
+      ZKUtil.deleteNode(zkw, "/l1/l2");
       fail("We should not be able to delete if znode has childs");
     } catch (KeeperException ex) {
-      assertNotNull(zkw.getData("/l1/l2/l3", "l4"));
+      assertNotNull(ZKUtil.getDataNoWatch(zkw, "/l1/l2/l3/l4", null));
     }
-    zkw.deleteZNode("/l1/l2", true);
-    assertNull(zkw.getData("/l1/l2/l3", "l4"));
-    zkw.deleteZNode("/l1");
-    assertNull(zkw.getData("/l1", "l2"));
+    ZKUtil.deleteNodeRecursively(zkw, "/l1/l2");
+    assertNull(ZKUtil.getDataNoWatch(zkw, "/l1/l2/l3/l4", null));
+    ZKUtil.deleteNode(zkw, "/l1");
+    assertNull(ZKUtil.getDataNoWatch(zkw, "/l1/l2", null));
   }
 }
\ No newline at end of file

Modified: hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/master/TestActiveMasterManager.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/master/TestActiveMasterManager.java?rev=964570&r1=964569&r2=964570&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/master/TestActiveMasterManager.java
(original)
+++ hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/master/TestActiveMasterManager.java
Thu Jul 15 20:32:31 2010
@@ -64,9 +64,9 @@ public class TestActiveMasterManager {
 
     ZooKeeperWatcher zk = new ZooKeeperWatcher(TEST_UTIL.getConfiguration(),
         "testActiveMasterManagerFromZK", null);
-    zk.createZNodeIfNotExists(zk.baseZNode);
+    ZKUtil.createIfNotExists(zk, zk.baseZNode);
     try {
-      zk.deleteZNode(zk.masterAddressZNode);
+      ZKUtil.deleteNode(zk, zk.masterAddressZNode);
     } catch(KeeperException.NoNodeException nne) {}
 
     // Create the master node with a dummy address
@@ -111,7 +111,7 @@ public class TestActiveMasterManager {
     zk.registerListener(listener);
 
     LOG.info("Deleting master node");
-    zk.deleteZNode(zk.masterAddressZNode);
+    ZKUtil.deleteNode(zk, zk.masterAddressZNode);
 
     // Wait for the node to be deleted
     LOG.info("Waiting for active master manager to be notified");

Modified: hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/master/TestRestartCluster.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/master/TestRestartCluster.java?rev=964570&r1=964569&r2=964570&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/master/TestRestartCluster.java
(original)
+++ hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/master/TestRestartCluster.java
Thu Jul 15 20:32:31 2010
@@ -31,6 +31,7 @@ import org.apache.hadoop.hbase.executor.
 import org.apache.hadoop.hbase.executor.HBaseEventHandler.HBaseEventType;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.Writables;
+import org.apache.hadoop.hbase.zookeeper.ZKUtil;
 import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
 import org.junit.AfterClass;
 import org.junit.Before;
@@ -62,8 +63,8 @@ public class TestRestartCluster {
     zooKeeper = new ZooKeeperWatcher(conf, "cluster1", null);
 
     // create the unassigned region, throw up a region opened state for META
-    String unassignedZNode = zooKeeper.getRegionInTransitionZNode();
-    zooKeeper.createZNodeIfNotExists(unassignedZNode);
+    String unassignedZNode = zooKeeper.assignmentZNode;
+    ZKUtil.createIfNotExists(zooKeeper, unassignedZNode);
     byte[] data = null;
     HBaseEventType hbEventType = HBaseEventType.RS2ZK_REGION_OPENED;
     try {

Modified: hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/regionserver/TestMasterAddressManager.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/regionserver/TestMasterAddressManager.java?rev=964570&r1=964569&r2=964570&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/regionserver/TestMasterAddressManager.java
(original)
+++ hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/regionserver/TestMasterAddressManager.java
Thu Jul 15 20:32:31 2010
@@ -29,6 +29,7 @@ import org.apache.commons.logging.LogFac
 import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.HServerAddress;
 import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.zookeeper.ZKUtil;
 import org.apache.hadoop.hbase.zookeeper.ZooKeeperListener;
 import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
 import org.apache.zookeeper.CreateMode;
@@ -60,7 +61,7 @@ public class TestMasterAddressManager {
 
     ZooKeeperWatcher zk = new ZooKeeperWatcher(TEST_UTIL.getConfiguration(),
         "testMasterAddressManagerFromZK", null);
-    zk.createZNodeIfNotExists(zk.baseZNode);
+    ZKUtil.createIfNotExists(zk, zk.baseZNode);
 
     // Should not have a master yet
     MasterAddressManager addressManager = new MasterAddressManager(zk, null);
@@ -77,8 +78,7 @@ public class TestMasterAddressManager {
     int port = 1234;
     HServerAddress dummyAddress = new HServerAddress(host, port);
     LOG.info("Creating master node");
-    zk.createZNodeIfNotExists(zk.masterAddressZNode,
-        Bytes.toBytes(dummyAddress.toString()), CreateMode.EPHEMERAL, false);
+    ZKUtil.setAddressAndWatch(zk, zk.masterAddressZNode, dummyAddress);
 
     // Wait for the node to be created
     LOG.info("Waiting for master address manager to be notified");



Mime
View raw message