hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject svn commit: r956748 - in /hbase/branches/0.89.20100621: ./ src/main/java/org/apache/hadoop/hbase/client/ src/main/java/org/apache/hadoop/hbase/executor/ src/main/java/org/apache/hadoop/hbase/master/ src/main/java/org/apache/hadoop/hbase/master/handler/...
Date Tue, 22 Jun 2010 00:21:03 GMT
Author: todd
Date: Tue Jun 22 00:21:03 2010
New Revision: 956748

URL: http://svn.apache.org/viewvc?rev=956748&view=rev
Log:
Revert "HBASE-2694  Move RS to Master region open/close messaging into ZooKeeper"

Removed:
    hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/executor/HBaseEventHandler.java
    hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/executor/HBaseExecutorService.java
    hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/executor/NamedThreadFactory.java
    hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/executor/RegionTransitionEventData.java
    hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/master/ZKUnassignedWatcher.java
    hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/master/handler/MasterCloseRegionHandler.java
    hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/master/handler/MasterOpenRegionHandler.java
    hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/regionserver/RSZookeeperUpdater.java
    hbase/branches/0.89.20100621/src/test/java/org/apache/hadoop/hbase/master/TestZKBasedCloseRegion.java
    hbase/branches/0.89.20100621/src/test/java/org/apache/hadoop/hbase/master/TestZKBasedReopenRegion.java
Modified:
    hbase/branches/0.89.20100621/CHANGES.txt
    hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
    hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
    hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/master/ProcessRegionClose.java
    hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/master/ProcessRegionOpen.java
    hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/master/ProcessRegionStatusChange.java
    hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/master/RegionManager.java
    hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java
    hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/master/ZKMasterAddressWatcher.java
    hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
    hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/zookeeper/HQuorumPeer.java
    hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWrapper.java
    hbase/branches/0.89.20100621/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
    hbase/branches/0.89.20100621/src/test/java/org/apache/hadoop/hbase/TestZooKeeper.java
    hbase/branches/0.89.20100621/src/test/java/org/apache/hadoop/hbase/master/TestMaster.java

Modified: hbase/branches/0.89.20100621/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/branches/0.89.20100621/CHANGES.txt?rev=956748&r1=956747&r2=956748&view=diff
==============================================================================
--- hbase/branches/0.89.20100621/CHANGES.txt (original)
+++ hbase/branches/0.89.20100621/CHANGES.txt Tue Jun 22 00:21:03 2010
@@ -710,7 +710,6 @@ Release 0.21.0 - Unreleased
    HBASE-2618  Don't inherit from HConstants (Benoit Sigoure via Stack)
    HBASE-2208  TableServers # processBatchOfRows - converts from List to [ ]
                - Expensive copy 
-   HBASE-2694  Move RS to Master region open/close messaging into ZooKeeper
    HBASE-2716  Make HBase's maven artifacts configurable with -D
                (Alex Newman via Stack)
    HBASE-2718  Update .gitignore for trunk after removal of contribs

Modified: hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java?rev=956748&r1=956747&r2=956748&view=diff
==============================================================================
--- hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java (original)
+++ hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java Tue Jun 22 00:21:03 2010
@@ -222,16 +222,13 @@ public class HConnectionManager {
     }
 
     /**
-     * Get this watcher's ZKW, instantiate it if necessary.
+     * Get this watcher's ZKW, instanciate it if necessary.
      * @return ZKW
      * @throws java.io.IOException if a remote or network exception occurs
      */
     public synchronized ZooKeeperWrapper getZooKeeperWrapper() throws IOException {
       if(zooKeeperWrapper == null) {
-        String zkWrapperName = HConnectionManager.class.getName() + "-" + 
-                               ZooKeeperWrapper.getZookeeperClusterKey(conf);
-        zooKeeperWrapper = ZooKeeperWrapper.createInstance(conf, zkWrapperName);
-        zooKeeperWrapper.registerListener(this);
+        zooKeeperWrapper = new ZooKeeperWrapper(conf, this);
       }
       return zooKeeperWrapper;
     }

Modified: hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/master/HMaster.java?rev=956748&r1=956747&r2=956748&view=diff
==============================================================================
--- hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/master/HMaster.java (original)
+++ hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/master/HMaster.java Tue Jun 22 00:21:03 2010
@@ -68,9 +68,6 @@ import org.apache.hadoop.hbase.client.Me
 import org.apache.hadoop.hbase.client.Scan;
 import org.apache.hadoop.hbase.client.ServerConnection;
 import org.apache.hadoop.hbase.client.ServerConnectionManager;
-import org.apache.hadoop.hbase.executor.HBaseEventHandler;
-import org.apache.hadoop.hbase.executor.HBaseExecutorService;
-import org.apache.hadoop.hbase.executor.HBaseEventHandler.HBaseEventType;
 import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
 import org.apache.hadoop.hbase.ipc.HBaseRPC;
 import org.apache.hadoop.hbase.ipc.HBaseRPCProtocolVersion;
@@ -206,31 +203,14 @@ public class HMaster extends Thread impl
     // We'll succeed if we are only  master or if we win the race when many
     // masters.  Otherwise we park here inside in writeAddressToZooKeeper.
     // TODO: Bring up the UI to redirect to active Master.
-    zooKeeperWrapper = ZooKeeperWrapper.createInstance(conf, HMaster.class.getName());
-    zooKeeperWrapper.registerListener(this);
+    this.zooKeeperWrapper = new ZooKeeperWrapper(conf, this);
     this.zkMasterAddressWatcher =
       new ZKMasterAddressWatcher(this.zooKeeperWrapper, this.shutdownRequested);
-    zooKeeperWrapper.registerListener(zkMasterAddressWatcher);
     this.zkMasterAddressWatcher.writeAddressToZooKeeper(this.address, true);
     this.regionServerOperationQueue =
       new RegionServerOperationQueue(this.conf, this.closed);
 
     serverManager = new ServerManager(this);
-
-    
-    // Start the unassigned watcher - which will create the unassgined region 
-    // in ZK. This is needed before RegionManager() constructor tries to assign 
-    // the root region.
-    ZKUnassignedWatcher.start();
-    // init the various event handlers
-    HBaseEventHandler.init(serverManager);
-    // start the "close region" executor service
-    HBaseEventType.RS2ZK_REGION_CLOSED.startMasterExecutorService(MASTER);
-    // start the "open region" executor service
-    HBaseEventType.RS2ZK_REGION_OPENED.startMasterExecutorService(MASTER);
-
-    
-    // start the region manager
     regionManager = new RegionManager(this);
 
     setName(MASTER);
@@ -436,7 +416,7 @@ public class HMaster extends Thread impl
     return this.serverManager.getAverageLoad();
   }
 
-  public RegionServerOperationQueue getRegionServerOperationQueue () {
+  RegionServerOperationQueue getRegionServerOperationQueue () {
     return this.regionServerOperationQueue;
   }
 
@@ -516,7 +496,6 @@ public class HMaster extends Thread impl
     this.rpcServer.stop();
     this.regionManager.stop();
     this.zooKeeperWrapper.close();
-    HBaseExecutorService.shutdown();
     LOG.info("HMaster main thread exiting");
   }
 
@@ -1132,9 +1111,7 @@ public class HMaster extends Thread impl
    */
   @Override
   public void process(WatchedEvent event) {
-    LOG.debug("Event " + event.getType() + 
-              " with state " + event.getState() +  
-              " with path " + event.getPath());
+    LOG.debug(("Event " + event.getType() +  " with path " + event.getPath()));
     // Master should kill itself if its session expired or if its
     // znode was deleted manually (usually for testing purposes)
     if(event.getState() == KeeperState.Expired ||
@@ -1148,8 +1125,7 @@ public class HMaster extends Thread impl
 
       zooKeeperWrapper.close();
       try {
-        zooKeeperWrapper = ZooKeeperWrapper.createInstance(conf, HMaster.class.getName());
-        zooKeeperWrapper.registerListener(this);
+        zooKeeperWrapper = new ZooKeeperWrapper(conf, this);
         this.zkMasterAddressWatcher.setZookeeper(zooKeeperWrapper);
         if(!this.zkMasterAddressWatcher.
             writeAddressToZooKeeper(this.address,false)) {

Modified: hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/master/ProcessRegionClose.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/master/ProcessRegionClose.java?rev=956748&r1=956747&r2=956748&view=diff
==============================================================================
--- hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/master/ProcessRegionClose.java (original)
+++ hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/master/ProcessRegionClose.java Tue Jun 22 00:21:03 2010
@@ -32,7 +32,7 @@ import java.io.IOException;
  * or deleted doesn't actually require post processing, it's no longer
  * necessary.
  */
-public class ProcessRegionClose extends ProcessRegionStatusChange {
+class ProcessRegionClose extends ProcessRegionStatusChange {
   protected final boolean offlineRegion;
   protected final boolean reassignRegion;
 

Modified: hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/master/ProcessRegionOpen.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/master/ProcessRegionOpen.java?rev=956748&r1=956747&r2=956748&view=diff
==============================================================================
--- hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/master/ProcessRegionOpen.java (original)
+++ hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/master/ProcessRegionOpen.java Tue Jun 22 00:21:03 2010
@@ -26,7 +26,6 @@ import org.apache.hadoop.hbase.HServerIn
 import org.apache.hadoop.hbase.client.Put;
 import org.apache.hadoop.hbase.ipc.HRegionInterface;
 import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.hadoop.hbase.zookeeper.ZooKeeperWrapper;
 
 import java.io.IOException;
 
@@ -35,7 +34,7 @@ import java.io.IOException;
  * serving a region. This applies to all meta and user regions except the
  * root region which is handled specially.
  */
-public class ProcessRegionOpen extends ProcessRegionStatusChange {
+class ProcessRegionOpen extends ProcessRegionStatusChange {
   protected final HServerInfo serverInfo;
 
   /**
@@ -115,8 +114,6 @@ public class ProcessRegionOpen extends P
       } else {
         master.getRegionManager().removeRegion(regionInfo);
       }
-      ZooKeeperWrapper zkWrapper = ZooKeeperWrapper.getInstance(HMaster.class.getName());
-      zkWrapper.deleteUnassignedRegion(regionInfo.getEncodedName());
       return true;
     }
   }

Modified: hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/master/ProcessRegionStatusChange.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/master/ProcessRegionStatusChange.java?rev=956748&r1=956747&r2=956748&view=diff
==============================================================================
--- hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/master/ProcessRegionStatusChange.java (original)
+++ hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/master/ProcessRegionStatusChange.java Tue Jun 22 00:21:03 2010
@@ -78,8 +78,4 @@ abstract class ProcessRegionStatusChange
     }
     return this.metaRegion;
   }
-  
-  public HRegionInfo getRegionInfo() {
-    return regionInfo;
-  }
 }
\ No newline at end of file

Modified: hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/master/RegionManager.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/master/RegionManager.java?rev=956748&r1=956747&r2=956748&view=diff
==============================================================================
--- hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/master/RegionManager.java (original)
+++ hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/master/RegionManager.java Tue Jun 22 00:21:03 2010
@@ -32,9 +32,6 @@ import org.apache.hadoop.hbase.HServerAd
 import org.apache.hadoop.hbase.HServerInfo;
 import org.apache.hadoop.hbase.HServerLoad;
 import org.apache.hadoop.hbase.client.Put;
-import org.apache.hadoop.hbase.executor.RegionTransitionEventData;
-import org.apache.hadoop.hbase.executor.HBaseEventHandler;
-import org.apache.hadoop.hbase.executor.HBaseEventHandler.HBaseEventType;
 import org.apache.hadoop.hbase.ipc.HRegionInterface;
 import org.apache.hadoop.hbase.regionserver.HRegion;
 import org.apache.hadoop.hbase.regionserver.wal.HLog;
@@ -42,8 +39,6 @@ import org.apache.hadoop.hbase.util.Byte
 import org.apache.hadoop.hbase.util.Pair;
 import org.apache.hadoop.hbase.util.Threads;
 import org.apache.hadoop.hbase.util.Writables;
-import org.apache.hadoop.hbase.zookeeper.ZooKeeperWrapper;
-import org.apache.hadoop.io.WritableUtils;
 
 import java.io.IOException;
 import java.util.ArrayList;
@@ -99,9 +94,6 @@ public class RegionManager {
    */
    final SortedMap<String, RegionState> regionsInTransition =
     Collections.synchronizedSortedMap(new TreeMap<String, RegionState>());
-   
-   // regions in transition are also recorded in ZK using the zk wrapper
-   final ZooKeeperWrapper zkWrapper;
 
   // How many regions to assign a server at a time.
   private final int maxAssignInOneGo;
@@ -132,11 +124,10 @@ public class RegionManager {
   private final int zooKeeperNumRetries;
   private final int zooKeeperPause;
 
-  RegionManager(HMaster master) throws IOException {
+  RegionManager(HMaster master) {
     Configuration conf = master.getConfiguration();
 
     this.master = master;
-    this.zkWrapper = ZooKeeperWrapper.getInstance(HMaster.class.getName());
     this.maxAssignInOneGo = conf.getInt("hbase.regions.percheckin", 10);
     this.loadBalancer = new LoadBalancer(conf);
 
@@ -174,17 +165,10 @@ public class RegionManager {
     unsetRootRegion();
     if (!master.getShutdownRequested().get()) {
       synchronized (regionsInTransition) {
-        String regionName = HRegionInfo.ROOT_REGIONINFO.getRegionNameAsString();
-        byte[] data = null;
-        try {
-          data = Writables.getBytes(new RegionTransitionEventData(HBaseEventType.M2ZK_REGION_OFFLINE, HMaster.MASTER));
-        } catch (IOException e) {
-          LOG.error("Error creating event data for " + HBaseEventType.M2ZK_REGION_OFFLINE, e);
-        }
-        zkWrapper.createUnassignedRegion(HRegionInfo.ROOT_REGIONINFO.getEncodedName(), data);
-        LOG.debug("Created UNASSIGNED zNode " + regionName + " in state " + HBaseEventType.M2ZK_REGION_OFFLINE);
-        RegionState s = new RegionState(HRegionInfo.ROOT_REGIONINFO, RegionState.State.UNASSIGNED);
-        regionsInTransition.put(regionName, s);
+        RegionState s = new RegionState(HRegionInfo.ROOT_REGIONINFO,
+            RegionState.State.UNASSIGNED);
+        regionsInTransition.put(
+            HRegionInfo.ROOT_REGIONINFO.getRegionNameAsString(), s);
         LOG.info("ROOT inserted into regionsInTransition");
       }
     }
@@ -346,14 +330,6 @@ public class RegionManager {
     LOG.info("Assigning region " + regionName + " to " + sinfo.getServerName());
     rs.setPendingOpen(sinfo.getServerName());
     synchronized (this.regionsInTransition) {
-      byte[] data = null;
-      try {
-        data = Writables.getBytes(new RegionTransitionEventData(HBaseEventType.M2ZK_REGION_OFFLINE, HMaster.MASTER));
-      } catch (IOException e) {
-        LOG.error("Error creating event data for " + HBaseEventType.M2ZK_REGION_OFFLINE, e);
-      }
-      zkWrapper.createUnassignedRegion(rs.getRegionInfo().getEncodedName(), data);
-      LOG.debug("Created UNASSIGNED zNode " + regionName + " in state " + HBaseEventType.M2ZK_REGION_OFFLINE);
       this.regionsInTransition.put(regionName, rs);
     }
 
@@ -993,16 +969,6 @@ public class RegionManager {
     synchronized(this.regionsInTransition) {
       s = regionsInTransition.get(info.getRegionNameAsString());
       if (s == null) {
-        byte[] data = null;
-        try {
-          data = Writables.getBytes(new RegionTransitionEventData(HBaseEventType.M2ZK_REGION_OFFLINE, HMaster.MASTER));
-        } catch (IOException e) {
-          // TODO: Review what we should do here.  If Writables work this
-          //       should never happen
-          LOG.error("Error creating event data for " + HBaseEventType.M2ZK_REGION_OFFLINE, e);
-        }
-        zkWrapper.createUnassignedRegion(info.getEncodedName(), data);
-        LOG.debug("Created UNASSIGNED zNode " + info.getRegionNameAsString() + " in state " + HBaseEventType.M2ZK_REGION_OFFLINE);
         s = new RegionState(info, RegionState.State.UNASSIGNED);
         regionsInTransition.put(info.getRegionNameAsString(), s);
       }
@@ -1247,9 +1213,8 @@ public class RegionManager {
    */
   public void setRootRegionLocation(HServerAddress address) {
     writeRootRegionLocationToZooKeeper(address);
+
     synchronized (rootRegionLocation) {
-      // the root region has been assigned, remove it from transition in ZK
-      zkWrapper.deleteUnassignedRegion(HRegionInfo.ROOT_REGIONINFO.getEncodedName());
       rootRegionLocation.set(new HServerAddress(address));
       rootRegionLocation.notifyAll();
     }

Modified: hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java?rev=956748&r1=956747&r2=956748&view=diff
==============================================================================
--- hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java (original)
+++ hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java Tue Jun 22 00:21:03 2010
@@ -564,7 +564,7 @@ public class ServerManager {
    * @param region
    * @param returnMsgs
    */
-  public void processRegionOpen(HServerInfo serverInfo,
+  private void processRegionOpen(HServerInfo serverInfo,
       HRegionInfo region, ArrayList<HMsg> returnMsgs) {
     boolean duplicateAssignment = false;
     synchronized (master.getRegionManager()) {
@@ -633,7 +633,7 @@ public class ServerManager {
    * @param region
    * @throws Exception
    */
-  public void processRegionClose(HRegionInfo region) {
+  private void processRegionClose(HRegionInfo region) {
     synchronized (this.master.getRegionManager()) {
       if (region.isRootRegion()) {
         // Root region

Modified: hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/master/ZKMasterAddressWatcher.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/master/ZKMasterAddressWatcher.java?rev=956748&r1=956747&r2=956748&view=diff
==============================================================================
--- hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/master/ZKMasterAddressWatcher.java (original)
+++ hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/master/ZKMasterAddressWatcher.java Tue Jun 22 00:21:03 2010
@@ -74,7 +74,7 @@ class ZKMasterAddressWatcher implements 
     } else if(type.equals(EventType.NodeCreated) &&
         event.getPath().equals(this.zookeeper.clusterStateZNode)) {
       LOG.debug("Resetting watch on cluster state node.");
-      this.zookeeper.setClusterStateWatch();
+      this.zookeeper.setClusterStateWatch(this);
     }
   }
 
@@ -87,7 +87,7 @@ class ZKMasterAddressWatcher implements 
       try {
         LOG.debug("Waiting for master address ZNode to be deleted " +
           "(Also watching cluster state node)");
-        this.zookeeper.setClusterStateWatch();
+        this.zookeeper.setClusterStateWatch(this);
         wait();
       } catch (InterruptedException e) {
       }
@@ -110,7 +110,7 @@ class ZKMasterAddressWatcher implements 
       }
       if(this.zookeeper.writeMasterAddress(address)) {
         this.zookeeper.setClusterState(true);
-        this.zookeeper.setClusterStateWatch();
+        this.zookeeper.setClusterStateWatch(this);
         // Watch our own node
         this.zookeeper.readMasterAddress(this);
         return true;

Modified: hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java?rev=956748&r1=956747&r2=956748&view=diff
==============================================================================
--- hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (original)
+++ hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java Tue Jun 22 00:21:03 2010
@@ -321,8 +321,7 @@ public class HRegionServer implements HR
   }
 
   private void reinitializeZooKeeper() throws IOException {
-    zooKeeperWrapper = ZooKeeperWrapper.createInstance(conf, serverInfo.getServerName());
-    zooKeeperWrapper.registerListener(this);
+    zooKeeperWrapper = new ZooKeeperWrapper(conf, this);
     watchMasterAddress();
   }
 
@@ -1229,7 +1228,14 @@ public class HRegionServer implements HR
         if (LOG.isDebugEnabled())
           LOG.debug("sending initial server load: " + hsl);
         lastMsg = System.currentTimeMillis();
-        zooKeeperWrapper.writeRSLocation(this.serverInfo);
+        boolean startCodeOk = false;
+        while(!startCodeOk) {
+          this.serverInfo = createServerInfoWithNewStartCode(this.serverInfo);
+          startCodeOk = zooKeeperWrapper.writeRSLocation(this.serverInfo);
+          if(!startCodeOk) {
+           LOG.debug("Start code already taken, trying another one");
+          }
+        }
         result = this.hbaseMaster.regionServerStartup(this.serverInfo);
         break;
       } catch (IOException e) {
@@ -1239,6 +1245,26 @@ public class HRegionServer implements HR
     }
     return result;
   }
+  
+  private HServerInfo createServerInfoWithNewStartCode(final HServerInfo hsi) {
+    return new HServerInfo(hsi.getServerAddress(), hsi.getInfoPort(),
+      hsi.getHostname());
+  }
+
+  /* Add to the outbound message buffer */
+  private void reportOpen(HRegionInfo region) {
+    this.outboundMsgs.add(new HMsg(HMsg.Type.MSG_REPORT_OPEN, region));
+  }
+
+  /* Add to the outbound message buffer */
+  private void reportClose(HRegionInfo region) {
+    reportClose(region, null);
+  }
+
+  /* Add to the outbound message buffer */
+  private void reportClose(final HRegionInfo region, final byte[] message) {
+    this.outboundMsgs.add(new HMsg(HMsg.Type.MSG_REPORT_CLOSE, region, message));
+  }
 
   /**
    * Add to the outbound message buffer
@@ -1404,11 +1430,8 @@ public class HRegionServer implements HR
   void openRegion(final HRegionInfo regionInfo) {
     Integer mapKey = Bytes.mapKey(regionInfo.getRegionName());
     HRegion region = this.onlineRegions.get(mapKey);
-    RSZookeeperUpdater zkUpdater = 
-      new RSZookeeperUpdater(serverInfo.getServerName(), regionInfo.getEncodedName());
     if (region == null) {
       try {
-        zkUpdater.startRegionOpenEvent(null, true);
         region = instantiateRegion(regionInfo, this.hlog);
         // Startup a compaction early if one is needed, if region has references
         // or if a store has too many store files
@@ -1423,15 +1446,7 @@ public class HRegionServer implements HR
         // TODO: add an extra field in HRegionInfo to indicate that there is
         // an error. We can't do that now because that would be an incompatible
         // change that would require a migration
-        try {
-          HMsg hmsg = new HMsg(HMsg.Type.MSG_REPORT_CLOSE, 
-                               regionInfo, 
-                               StringUtils.stringifyException(t).getBytes());
-          zkUpdater.abortOpenRegion(hmsg);
-        } catch (IOException e1) {
-          // TODO: Can we recover? Should be throw RTE?
-          LOG.error("Failed to abort open region " + regionInfo.getRegionNameAsString(), e1);
-        }
+        reportClose(regionInfo, StringUtils.stringifyException(t).getBytes());
         return;
       }
       this.lock.writeLock().lock();
@@ -1441,12 +1456,7 @@ public class HRegionServer implements HR
         this.lock.writeLock().unlock();
       }
     }
-    try {
-      HMsg hmsg = new HMsg(HMsg.Type.MSG_REPORT_OPEN, regionInfo);
-      zkUpdater.finishRegionOpenEvent(hmsg);
-    } catch (IOException e) {
-      LOG.error("Failed to mark region " + regionInfo.getRegionNameAsString() + " as opened", e);
-    }
+    reportOpen(regionInfo);
   }
 
   /*
@@ -1487,19 +1497,11 @@ public class HRegionServer implements HR
 
   protected void closeRegion(final HRegionInfo hri, final boolean reportWhenCompleted)
   throws IOException {
-    RSZookeeperUpdater zkUpdater = null;
-    if(reportWhenCompleted) {
-      zkUpdater = new RSZookeeperUpdater(serverInfo.getServerName(), hri.getEncodedName());
-      zkUpdater.startRegionCloseEvent(null, false);
-    }
     HRegion region = this.removeFromOnlineRegions(hri);
     if (region != null) {
       region.close();
       if(reportWhenCompleted) {
-        if(zkUpdater != null) {
-          HMsg hmsg = new HMsg(HMsg.Type.MSG_REPORT_CLOSE, hri, null);
-          zkUpdater.finishRegionCloseEvent(hmsg);
-        }
+        reportClose(hri);
       }
     }
   }
@@ -2500,4 +2502,4 @@ public class HRegionServer implements HR
         HRegionServer.class);
     doMain(args, regionServerClass);
   }
-}
\ No newline at end of file
+}

Modified: hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/zookeeper/HQuorumPeer.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/zookeeper/HQuorumPeer.java?rev=956748&r1=956747&r2=956748&view=diff
==============================================================================
--- hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/zookeeper/HQuorumPeer.java (original)
+++ hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/zookeeper/HQuorumPeer.java Tue Jun 22 00:21:03 2010
@@ -220,68 +220,6 @@ public class HQuorumPeer {
 
     return zkProperties;
   }
-  
-  /**
-   * Return the ZK Quorum servers string given zk properties returned by 
-   * makeZKProps
-   * @param properties
-   * @return
-   */
-  public static String getZKQuorumServersString(Properties properties) {
-    String clientPort = null;
-    List<String> servers = new ArrayList<String>();
-
-    // The clientPort option may come after the server.X hosts, so we need to
-    // grab everything and then create the final host:port comma separated list.
-    boolean anyValid = false;
-    for (Entry<Object,Object> property : properties.entrySet()) {
-      String key = property.getKey().toString().trim();
-      String value = property.getValue().toString().trim();
-      if (key.equals("clientPort")) {
-        clientPort = value;
-      }
-      else if (key.startsWith("server.")) {
-        String host = value.substring(0, value.indexOf(':'));
-        servers.add(host);
-        try {
-          //noinspection ResultOfMethodCallIgnored
-          InetAddress.getByName(host);
-          anyValid = true;
-        } catch (UnknownHostException e) {
-          LOG.warn(StringUtils.stringifyException(e));
-        }
-      }
-    }
-
-    if (!anyValid) {
-      LOG.error("no valid quorum servers found in " + HConstants.ZOOKEEPER_CONFIG_NAME);
-      return null;
-    }
-
-    if (clientPort == null) {
-      LOG.error("no clientPort found in " + HConstants.ZOOKEEPER_CONFIG_NAME);
-      return null;
-    }
-
-    if (servers.isEmpty()) {
-      LOG.fatal("No server.X lines found in conf/zoo.cfg. HBase must have a " +
-                "ZooKeeper cluster configured for its operation.");
-      return null;
-    }
-
-    StringBuilder hostPortBuilder = new StringBuilder();
-    for (int i = 0; i < servers.size(); ++i) {
-      String host = servers.get(i);
-      if (i > 0) {
-        hostPortBuilder.append(',');
-      }
-      hostPortBuilder.append(host);
-      hostPortBuilder.append(':');
-      hostPortBuilder.append(clientPort);
-    }
-
-    return hostPortBuilder.toString();
-  }
 
   /**
    * Parse ZooKeeper's zoo.cfg, injecting HBase Configuration variables in.

Modified: hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWrapper.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWrapper.java?rev=956748&r1=956747&r2=956748&view=diff
==============================================================================
--- hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWrapper.java (original)
+++ hbase/branches/0.89.20100621/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWrapper.java Tue Jun 22 00:21:03 2010
@@ -1,5 +1,5 @@
 /**
- * Copyright 2009 The Apache Software Foundation
+ * Copyright 2010 The Apache Software Foundation
  *
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -19,225 +19,152 @@
  */
 package org.apache.hadoop.hbase.zookeeper;
 
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.PrintWriter;
-import java.net.Socket;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-
 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.HServerAddress;
 import org.apache.hadoop.hbase.HServerInfo;
-import org.apache.hadoop.hbase.executor.HBaseEventHandler.HBaseEventType;
 import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.util.StringUtils;
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.WatchedEvent;
 import org.apache.zookeeper.Watcher;
-import org.apache.zookeeper.ZooKeeper;
 import org.apache.zookeeper.ZooDefs.Ids;
+import org.apache.zookeeper.ZooKeeper;
 import org.apache.zookeeper.ZooKeeper.States;
 import org.apache.zookeeper.data.Stat;
 
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map.Entry;
+import java.util.Properties;
+
 /**
  * Wraps a ZooKeeper instance and adds HBase specific functionality.
  *
  * This class provides methods to:
  * - read/write/delete the root region location in ZooKeeper.
  * - set/check out of safe mode flag.
- * 
- * ------------------------------------------
- * The following STATIC ZNodes are created:
- * ------------------------------------------
- * - parentZNode     : All the HBase directories are hosted under this parent 
- *                     node, default = "/hbase"
- * - rsZNode         : This is the directory where the RS's create ephemeral 
- *                     nodes. The master watches these nodes, and their expiry 
- *                     indicates RS death. The default location is "/hbase/rs"
- * 
- * ------------------------------------------
- * The following DYNAMIC ZNodes are created:
- * ------------------------------------------
- * - rootRegionZNode     : Specifies the RS hosting root.
- * - masterElectionZNode : ZNode used for election of the primary master when 
- *                         there are secondaries. All the masters race to write 
- *                         their addresses into this location, the one that 
- *                         succeeds is the primary. Others block.
- * - clusterStateZNode   : Determines if the cluster is running. Its default 
- *                         location is "/hbase/shutdown". It always has a value 
- *                         of "up". If present with the valus, cluster is up 
- *                         and running. If deleted, the cluster is shutting 
- *                         down.
- * - rgnsInTransitZNode  : All the nodes under this node are names of regions 
- *                         in transition. The first byte of the data for each 
- *                         of these nodes is the event type. This is used to 
- *                         deserialize the rest of the data.
  */
-public class ZooKeeperWrapper implements Watcher {
+public class ZooKeeperWrapper {
   protected static final Log LOG = LogFactory.getLog(ZooKeeperWrapper.class);
 
-  // instances of the watcher
-  private static Map<String,ZooKeeperWrapper> INSTANCES = 
-    new HashMap<String,ZooKeeperWrapper>();
-  // lock for ensuring a singleton per instance type
-  private static Lock createLock = new ReentrantLock();
-  // name of this instance
-  private String instanceName;
-
   // TODO: Replace this with ZooKeeper constant when ZOOKEEPER-277 is resolved.
   private static final char ZNODE_PATH_SEPARATOR = '/';
 
   private String quorumServers = null;
-  private final int sessionTimeout;
-  private ZooKeeper zooKeeper;
 
-  /*
-   * All the HBase directories are hosted under this parent
-   */
-  public final String parentZNode;
-  /*
-   * Specifies the RS hosting root
-   */
+  private final ZooKeeper zooKeeper;
+
+  private final String parentZNode;
   private final String rootRegionZNode;
-  /* 
-   * This is the directory where the RS's create ephemeral nodes. The master 
-   * watches these nodes, and their expiry indicates RS death. 
-   */
   private final String rsZNode;
-  /*
-   * ZNode used for election of the primary master when there are secondaries. 
-   */
   private final String masterElectionZNode;
-  /*
-   * State of the cluster - if up and running or shutting down
-   */
   public final String clusterStateZNode;
-  /*
-   * Regions that are in transition
-   */  
-  private final String rgnsInTransitZNode;
-  /*
-   * List of ZNodes in the unassgined region that are already being watched
-   */
-  private Set<String> unassignedZNodesWatched = new HashSet<String>();
-
-  private List<Watcher> listeners = Collections.synchronizedList(new ArrayList<Watcher>());
-
-  // return the singleton given the name of the instance
-  public static ZooKeeperWrapper getInstance(String name) {
-    return INSTANCES.get(name);
-  }
-  // creates only one instance
-  public static ZooKeeperWrapper createInstance(Configuration conf, String name) {
-    if (getInstance(name) != null) {
-      return getInstance(name);
-    }
-    ZooKeeperWrapper.createLock.lock();
-    try {
-      if (getInstance(name) == null) {
-        try {
-          ZooKeeperWrapper instance = new ZooKeeperWrapper(conf, name);
-          INSTANCES.put(name, instance);
-        }
-        catch (Exception e) {
-          LOG.error("<" + name + ">" + "Error creating a ZooKeeperWrapper " + e);
-        }
-      }
-    }
-    finally {
-      createLock.unlock();
-    }
-    return getInstance(name);
-  }
 
   /**
-   * Create a ZooKeeperWrapper. The Zookeeper wrapper listens to all messages
-   * from Zookeeper, and notifies all the listeners about all the messages. Any
-   * component can subscribe to these messages by adding itself as a listener,
-   * and remove itself from being a listener.
-   *
-   * @param conf HBaseConfiguration to read settings from.
+   * Create a ZooKeeperWrapper.
+   * @param conf Configuration to read settings from.
+   * @param watcher ZooKeeper watcher to register.
    * @throws IOException If a connection error occurs.
    */
-  private ZooKeeperWrapper(Configuration conf, String instanceName)
+  public ZooKeeperWrapper(Configuration conf, Watcher watcher)
   throws IOException {
-    this.instanceName = instanceName;
     Properties properties = HQuorumPeer.makeZKProps(conf);
-    quorumServers = HQuorumPeer.getZKQuorumServersString(properties);
+    setQuorumServers(properties);
     if (quorumServers == null) {
       throw new IOException("Could not read quorum servers from " +
                             HConstants.ZOOKEEPER_CONFIG_NAME);
     }
-    sessionTimeout = conf.getInt("zookeeper.session.timeout", 60 * 1000);
-    reconnectToZk();
-    
-    parentZNode = conf.get(HConstants.ZOOKEEPER_ZNODE_PARENT, HConstants.DEFAULT_ZOOKEEPER_ZNODE_PARENT);
-
-    String rootServerZNodeName = conf.get("zookeeper.znode.rootserver", "root-region-server");
-    String rsZNodeName         = conf.get("zookeeper.znode.rs", "rs");
-    String masterAddressZNodeName = conf.get("zookeeper.znode.master", "master");
-    String stateZNodeName      = conf.get("zookeeper.znode.state", "shutdown");
-    String regionsInTransitZNodeName = conf.get("zookeeper.znode.regionInTransition", "UNASSIGNED");
-
-    rootRegionZNode     = getZNode(parentZNode, rootServerZNodeName);
-    rsZNode             = getZNode(parentZNode, rsZNodeName);
-    rgnsInTransitZNode  = getZNode(parentZNode, regionsInTransitZNodeName);
-    masterElectionZNode = getZNode(parentZNode, masterAddressZNodeName);
-    clusterStateZNode   = getZNode(parentZNode, stateZNodeName);
-  }
-  
-  public void reconnectToZk() throws IOException {
+
+    int sessionTimeout = conf.getInt("zookeeper.session.timeout", 60 * 1000);
     try {
-      LOG.info("Reconnecting to zookeeper");
-      if(zooKeeper != null) {
-        zooKeeper.close();
-        LOG.debug("<" + instanceName + ">" + "Closed existing zookeeper client");
-      }
-      zooKeeper = new ZooKeeper(quorumServers, sessionTimeout, this);
-      LOG.debug("<" + instanceName + ">" + "Connected to zookeeper again");
+      zooKeeper = new ZooKeeper(quorumServers, sessionTimeout, watcher);
     } catch (IOException e) {
-      LOG.error("<" + instanceName + ">" + "Failed to create ZooKeeper object: " + e);
+      LOG.error("Failed to create ZooKeeper object: " + e);
       throw new IOException(e);
-    } catch (InterruptedException e) {
-      LOG.error("<" + instanceName + ">" + "Error closing ZK connection: " + e);
-      throw new IOException(e);
-    }    
-  }
+    }
 
-  public synchronized void registerListener(Watcher watcher) {
-    listeners.add(watcher);
-  }
+    parentZNode = conf.get(HConstants.ZOOKEEPER_ZNODE_PARENT,
+        HConstants.DEFAULT_ZOOKEEPER_ZNODE_PARENT);
+
+    String rootServerZNodeName = conf.get("zookeeper.znode.rootserver",
+                                          "root-region-server");
+    String rsZNodeName = conf.get("zookeeper.znode.rs", "rs");
+    String masterAddressZNodeName = conf.get("zookeeper.znode.master",
+      "master");
+    String stateZNodeName = conf.get("zookeeper.znode.state",
+    "shutdown");
 
-  public synchronized void unregisterListener(Watcher watcher) {
-    listeners.remove(watcher);
+    rootRegionZNode = getZNode(parentZNode, rootServerZNodeName);
+    rsZNode = getZNode(parentZNode, rsZNodeName);
+    masterElectionZNode = getZNode(parentZNode, masterAddressZNodeName);
+    clusterStateZNode = getZNode(parentZNode, stateZNodeName);
   }
+  
+  private void setQuorumServers(Properties properties) {
+    String clientPort = null;
+    List<String> servers = new ArrayList<String>();
+
+    // The clientPort option may come after the server.X hosts, so we need to
+    // grab everything and then create the final host:port comma separated list.
+    boolean anyValid = false;
+    for (Entry<Object,Object> property : properties.entrySet()) {
+      String key = property.getKey().toString().trim();
+      String value = property.getValue().toString().trim();
+      if (key.equals("clientPort")) {
+        clientPort = value;
+      }
+      else if (key.startsWith("server.")) {
+        String host = value.substring(0, value.indexOf(':'));
+        servers.add(host);
+        try {
+          //noinspection ResultOfMethodCallIgnored
+          InetAddress.getByName(host);
+          anyValid = true;
+        } catch (UnknownHostException e) {
+          LOG.warn(StringUtils.stringifyException(e));
+        }
+      }
+    }
 
-  /**
-   * This is the primary ZK watcher
-   * @see org.apache.zookeeper.Watcher#process(org.apache.zookeeper.WatchedEvent)
-   */
-  @Override
-  public synchronized void process(WatchedEvent event) {
-    for(Watcher w : listeners) {
-      try {
-        w.process(event);
-      } catch (Throwable t) {
-        LOG.error("<"+instanceName+">" + "ZK updates listener threw an exception in process()", t);
+    if (!anyValid) {
+      LOG.error("no valid quorum servers found in "
+                + HConstants.ZOOKEEPER_CONFIG_NAME);
+      return;
+    }
+
+    if (clientPort == null) {
+      LOG.error("no clientPort found in " + HConstants.ZOOKEEPER_CONFIG_NAME);
+      return;
+    }
+
+    if (servers.isEmpty()) {
+      LOG.fatal("No server.X lines found in conf/zoo.cfg. HBase must have a " +
+                "ZooKeeper cluster configured for its operation.");
+      return;
+    }
+
+    StringBuilder hostPortBuilder = new StringBuilder();
+    for (int i = 0; i < servers.size(); ++i) {
+      String host = servers.get(i);
+      if (i > 0) {
+        hostPortBuilder.append(',');
       }
+      hostPortBuilder.append(host);
+      hostPortBuilder.append(':');
+      hostPortBuilder.append(clientPort);
     }
+
+    quorumServers = hostPortBuilder.toString();
   }
 
   /** @return String dump of everything in ZooKeeper. */
@@ -245,7 +172,7 @@ public class ZooKeeperWrapper implements
   public String dump() {
     StringBuilder sb = new StringBuilder();
     sb.append("\nHBase tree in ZooKeeper is rooted at ").append(parentZNode);
-    sb.append("\n  Cluster up? ").append(exists(clusterStateZNode, true));
+    sb.append("\n  Cluster up? ").append(exists(clusterStateZNode));
     sb.append("\n  Master address: ").append(readMasterAddress(null));
     sb.append("\n  Region server holding ROOT: ").append(readRootRegionLocation());
     sb.append("\n  Region servers:");
@@ -309,25 +236,9 @@ public class ZooKeeperWrapper implements
     return res.toArray(new String[res.size()]);
   }
 
-  public boolean exists(String znode, boolean watch) {
+  private boolean exists(String znode) {
     try {
-      return zooKeeper.exists(getZNode(parentZNode, znode), watch?this:null) != null;
-    } catch (KeeperException.SessionExpiredException e) {
-      // if the session has expired try to reconnect to ZK, then perform query
-      try {
-        // TODO: ZK-REFACTOR: We should not reconnect - we should just quit and restart.
-        reconnectToZk();
-        return zooKeeper.exists(getZNode(parentZNode, znode), watch?this:null) != null;
-      } catch (IOException e1) {
-        LOG.error("Error reconnecting to zookeeper", e1);
-        throw new RuntimeException("Error reconnecting to zookeeper", e1);
-      } catch (KeeperException e1) {
-        LOG.error("Error reading after reconnecting to zookeeper", e1);
-        throw new RuntimeException("Error reading after reconnecting to zookeeper", e1);
-      } catch (InterruptedException e1) {
-        LOG.error("Error reading after reconnecting to zookeeper", e1);
-        throw new RuntimeException("Error reading after reconnecting to zookeeper", e1);
-      }
+      return zooKeeper.exists(znode, null) != null;
     } catch (KeeperException e) {
       return false;
     } catch (InterruptedException e) {
@@ -400,13 +311,13 @@ public class ZooKeeperWrapper implements
    * Watch the state of the cluster, up or down
    * @param watcher Watcher to set on cluster state node
    */
-  public void setClusterStateWatch() {
+  public void setClusterStateWatch(Watcher watcher) {
     try {
-      zooKeeper.exists(clusterStateZNode, this);
+      zooKeeper.exists(clusterStateZNode, watcher);
     } catch (InterruptedException e) {
-      LOG.warn("<" + instanceName + ">" + "Failed to check on ZNode " + clusterStateZNode, e);
+      LOG.warn("Failed to check on ZNode " + clusterStateZNode, e);
     } catch (KeeperException e) {
-      LOG.warn("<" + instanceName + ">" + "Failed to check on ZNode " + clusterStateZNode, e);
+      LOG.warn("Failed to check on ZNode " + clusterStateZNode, e);
     }
   }
 
@@ -424,19 +335,19 @@ public class ZooKeeperWrapper implements
         byte[] data = Bytes.toBytes("up");
         zooKeeper.create(clusterStateZNode, data,
             Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
-        LOG.debug("<" + instanceName + ">" + "State node wrote in ZooKeeper");
+        LOG.debug("State node wrote in ZooKeeper");
       } else {
         zooKeeper.delete(clusterStateZNode, -1);
-        LOG.debug("<" + instanceName + ">" + "State node deleted in ZooKeeper");
+        LOG.debug("State node deleted in ZooKeeper");
       }
       return true;
     } catch (InterruptedException e) {
-      LOG.warn("<" + instanceName + ">" + "Failed to set state node in ZooKeeper", e);
+      LOG.warn("Failed to set state node in ZooKeeper", e);
     } catch (KeeperException e) {
       if(e.code() == KeeperException.Code.NODEEXISTS) {
-        LOG.debug("<" + instanceName + ">" + "State node exists.");
+        LOG.debug("State node exists.");
       } else {
-        LOG.warn("<" + instanceName + ">" + "Failed to set state node in ZooKeeper", e);
+        LOG.warn("Failed to set state node in ZooKeeper", e);
       }
     }
 
@@ -453,13 +364,13 @@ public class ZooKeeperWrapper implements
     try {
       zooKeeper.exists(masterElectionZNode, watcher);
     } catch (KeeperException e) {
-      LOG.warn("<" + instanceName + ">" + "Failed to set watcher on ZNode " + masterElectionZNode, e);
+      LOG.warn("Failed to set watcher on ZNode " + masterElectionZNode, e);
       return false;
     } catch (InterruptedException e) {
-      LOG.warn("<" + instanceName + ">" + "Failed to set watcher on ZNode " + masterElectionZNode, e);
+      LOG.warn("Failed to set watcher on ZNode " + masterElectionZNode, e);
       return false;
     }
-    LOG.debug("<" + instanceName + ">" + "Set watcher on master address ZNode " + masterElectionZNode);
+    LOG.debug("Set watcher on master address ZNode " + masterElectionZNode);
     return true;
   }
 
@@ -467,7 +378,7 @@ public class ZooKeeperWrapper implements
     try {
       return readAddressOrThrow(znode, watcher);
     } catch (IOException e) {
-      LOG.debug("<" + instanceName + ">" + "Failed to read " + e.getMessage());
+      LOG.debug("Failed to read " + e.getMessage());
       return null;
     }
   }
@@ -483,7 +394,7 @@ public class ZooKeeperWrapper implements
     }
 
     String addressString = Bytes.toString(data);
-    LOG.debug("<" + instanceName + ">" + "Read ZNode " + znode + " got " + addressString);
+    LOG.debug("Read ZNode " + znode + " got " + addressString);
     return new HServerAddress(addressString);
   }
 
@@ -500,17 +411,17 @@ public class ZooKeeperWrapper implements
       }
       zooKeeper.create(znode, new byte[0],
                        Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
-      LOG.debug("<" + instanceName + ">" + "Created ZNode " + znode);
+      LOG.debug("Created ZNode " + znode);
       return true;
     } catch (KeeperException.NodeExistsException e) {
       return true;      // ok, move on.
     } catch (KeeperException.NoNodeException e) {
       return ensureParentExists(znode) && ensureExists(znode);
     } catch (KeeperException e) {
-      LOG.warn("<" + instanceName + ">" + "Failed to create " + znode +
+      LOG.warn("Failed to create " + znode +
         " -- check quorum servers, currently=" + this.quorumServers, e);
     } catch (InterruptedException e) {
-      LOG.warn("<" + instanceName + ">" + "Failed to create " + znode +
+      LOG.warn("Failed to create " + znode +
         " -- check quorum servers, currently=" + this.quorumServers, e);
     }
     return false;
@@ -539,9 +450,9 @@ public class ZooKeeperWrapper implements
     } catch (KeeperException.NoNodeException e) {
       return true;    // ok, move on.
     } catch (KeeperException e) {
-      LOG.warn("<" + instanceName + ">" + "Failed to delete " + rootRegionZNode + ": " + e);
+      LOG.warn("Failed to delete " + rootRegionZNode + ": " + e);
     } catch (InterruptedException e) {
-      LOG.warn("<" + instanceName + ">" + "Failed to delete " + rootRegionZNode + ": " + e);
+      LOG.warn("Failed to delete " + rootRegionZNode + ": " + e);
     }
 
     return false;
@@ -568,18 +479,18 @@ public class ZooKeeperWrapper implements
   public void deleteZNode(String znode, boolean recursive)
     throws KeeperException, InterruptedException {
     if (recursive) {
-      LOG.info("<" + instanceName + ">" + "deleteZNode get children for " + znode);
+      LOG.info("deleteZNode get children for " + znode);
       List<String> znodes = this.zooKeeper.getChildren(znode, false);
       if (znodes.size() > 0) {
         for (String child : znodes) {
           String childFullPath = getZNode(znode, child);
-          LOG.info("<" + instanceName + ">" + "deleteZNode recursive call " + childFullPath);
+          LOG.info("deleteZNode recursive call " + childFullPath);
           this.deleteZNode(childFullPath, true);
         }
       }
     }
     this.zooKeeper.delete(znode, -1);
-    LOG.debug("<" + instanceName + ">" + "Deleted ZNode " + znode);
+    LOG.debug("Deleted ZNode " + znode);
   }
 
   private boolean createRootRegionLocation(String address) {
@@ -587,12 +498,12 @@ public class ZooKeeperWrapper implements
     try {
       zooKeeper.create(rootRegionZNode, data, Ids.OPEN_ACL_UNSAFE,
                        CreateMode.PERSISTENT);
-      LOG.debug("<" + instanceName + ">" + "Created ZNode " + rootRegionZNode + " with data " + address);
+      LOG.debug("Created ZNode " + rootRegionZNode + " with data " + address);
       return true;
     } catch (KeeperException e) {
-      LOG.warn("<" + instanceName + ">" + "Failed to create root region in ZooKeeper: " + e);
+      LOG.warn("Failed to create root region in ZooKeeper: " + e);
     } catch (InterruptedException e) {
-      LOG.warn("<" + instanceName + ">" + "Failed to create root region in ZooKeeper: " + e);
+      LOG.warn("Failed to create root region in ZooKeeper: " + e);
     }
 
     return false;
@@ -602,12 +513,12 @@ public class ZooKeeperWrapper implements
     byte[] data = Bytes.toBytes(address);
     try {
       zooKeeper.setData(rootRegionZNode, data, -1);
-      LOG.debug("<" + instanceName + ">" + "SetData of ZNode " + rootRegionZNode + " with " + address);
+      LOG.debug("SetData of ZNode " + rootRegionZNode + " with " + address);
       return true;
     } catch (KeeperException e) {
-      LOG.warn("<" + instanceName + ">" + "Failed to set root region location in ZooKeeper: " + e);
+      LOG.warn("Failed to set root region location in ZooKeeper: " + e);
     } catch (InterruptedException e) {
-      LOG.warn("<" + instanceName + ">" + "Failed to set root region location in ZooKeeper: " + e);
+      LOG.warn("Failed to set root region location in ZooKeeper: " + e);
     }
 
     return false;
@@ -643,22 +554,20 @@ public class ZooKeeperWrapper implements
    * @return true if operation succeeded, false otherwise.
    */
   public boolean writeMasterAddress(final HServerAddress address) {
-    LOG.debug("<" + instanceName + ">" + "Writing master address " + address.toString() + " to znode " + masterElectionZNode);
     if (!ensureParentExists(masterElectionZNode)) {
       return false;
     }
-    LOG.debug("<" + instanceName + ">" + "Znode exists : " + masterElectionZNode);
 
     String addressStr = address.toString();
     byte[] data = Bytes.toBytes(addressStr);
     try {
       zooKeeper.create(masterElectionZNode, data, Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
-      LOG.debug("<" + instanceName + ">" + "Wrote master address " + address + " to ZooKeeper");
+      LOG.debug("Wrote master address " + address + " to ZooKeeper");
       return true;
     } catch (InterruptedException e) {
-      LOG.warn("<" + instanceName + ">" + "Failed to write master address " + address + " to ZooKeeper", e);
+      LOG.warn("Failed to write master address " + address + " to ZooKeeper", e);
     } catch (KeeperException e) {
-      LOG.warn("<" + instanceName + ">" + "Failed to write master address " + address + " to ZooKeeper", e);
+      LOG.warn("Failed to write master address " + address + " to ZooKeeper", e);
     }
 
     return false;
@@ -673,16 +582,16 @@ public class ZooKeeperWrapper implements
   public boolean writeRSLocation(HServerInfo info) {
     ensureExists(rsZNode);
     byte[] data = Bytes.toBytes(info.getServerAddress().toString());
-    String znode = joinPath(rsZNode, info.getServerName());
+    String znode = joinPath(rsZNode, Long.toString(info.getStartCode()));
     try {
       zooKeeper.create(znode, data, Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
-      LOG.debug("<" + instanceName + ">" + "Created ZNode " + znode
+      LOG.debug("Created ZNode " + znode
           + " with data " + info.getServerAddress().toString());
       return true;
     } catch (KeeperException e) {
-      LOG.warn("<" + instanceName + ">" + "Failed to create " + znode + " znode in ZooKeeper: " + e);
+      LOG.warn("Failed to create " + znode + " znode in ZooKeeper: " + e);
     } catch (InterruptedException e) {
-      LOG.warn("<" + instanceName + ">" + "Failed to create " + znode + " znode in ZooKeeper: " + e);
+      LOG.warn("Failed to create " + znode + " znode in ZooKeeper: " + e);
     }
     return false;
   }
@@ -695,17 +604,17 @@ public class ZooKeeperWrapper implements
    */
   public boolean updateRSLocationGetWatch(HServerInfo info, Watcher watcher) {
     byte[] data = Bytes.toBytes(info.getServerAddress().toString());
-    String znode = rsZNode + ZNODE_PATH_SEPARATOR + info.getServerName();
+    String znode = rsZNode + ZNODE_PATH_SEPARATOR + info.getStartCode();
     try {
       zooKeeper.setData(znode, data, -1);
-      LOG.debug("<" + instanceName + ">" + "Updated ZNode " + znode
+      LOG.debug("Updated ZNode " + znode
           + " with data " + info.getServerAddress().toString());
       zooKeeper.getData(znode, watcher, null);
       return true;
     } catch (KeeperException e) {
-      LOG.warn("<" + instanceName + ">" + "Failed to update " + znode + " znode in ZooKeeper: " + e);
+      LOG.warn("Failed to update " + znode + " znode in ZooKeeper: " + e);
     } catch (InterruptedException e) {
-      LOG.warn("<" + instanceName + ">" + "Failed to update " + znode + " znode in ZooKeeper: " + e);
+      LOG.warn("Failed to update " + znode + " znode in ZooKeeper: " + e);
     }
 
     return false;
@@ -736,13 +645,13 @@ public class ZooKeeperWrapper implements
     try {
       List<String> nodes = zooKeeper.getChildren(rsZNode, false);
       for (String node : nodes) {
-        LOG.debug("<" + instanceName + ">" + "Deleting node: " + node);
+        LOG.debug("Deleting node: " + node);
         zooKeeper.delete(joinPath(this.rsZNode, node), -1);
       }
     } catch (KeeperException e) {
-      LOG.warn("<" + instanceName + ">" + "Failed to delete " + rsZNode + " znodes in ZooKeeper: " + e);
+      LOG.warn("Failed to delete " + rsZNode + " znodes in ZooKeeper: " + e);
     } catch (InterruptedException e) {
-      LOG.warn("<" + instanceName + ">" + "Failed to delete " + rsZNode + " znodes in ZooKeeper: " + e);
+      LOG.warn("Failed to delete " + rsZNode + " znodes in ZooKeeper: " + e);
     }
   }
 
@@ -751,9 +660,9 @@ public class ZooKeeperWrapper implements
     try {
       stat = zooKeeper.exists(path, false);
     } catch (KeeperException e) {
-      LOG.warn("<" + instanceName + ">" + "checking existence of " + path, e);
+      LOG.warn("checking existence of " + path, e);
     } catch (InterruptedException e) {
-      LOG.warn("<" + instanceName + ">" + "checking existence of " + path, e);
+      LOG.warn("checking existence of " + path, e);
     }
 
     return stat != null;
@@ -765,10 +674,9 @@ public class ZooKeeperWrapper implements
   public void close() {
     try {
       zooKeeper.close();
-      INSTANCES.remove(instanceName);
-      LOG.debug("<" + instanceName + ">" + "Closed connection with ZooKeeper; " + this.rootRegionZNode);
+      LOG.debug("Closed connection with ZooKeeper; " + this.rootRegionZNode);
     } catch (InterruptedException e) {
-      LOG.warn("<" + instanceName + ">" + "Failed to close connection with ZooKeeper");
+      LOG.warn("Failed to close connection with ZooKeeper");
     }
   }
 
@@ -777,10 +685,6 @@ public class ZooKeeperWrapper implements
         znodeName : joinPath(parentZNode, znodeName);
   }
 
-  public String getZNodePathForHBase(String znodeName) {
-    return getZNode(parentZNode, znodeName);
-  }
-
   private String joinPath(String parent, String child) {
     return parent + ZNODE_PATH_SEPARATOR + child;
   }
@@ -810,7 +714,7 @@ public class ZooKeeperWrapper implements
   public List<HServerAddress> scanAddressDirectory(String znode,
       Watcher watcher) {
     List<HServerAddress> list = new ArrayList<HServerAddress>();
-    List<String> nodes = this.listZnodes(znode);
+    List<String> nodes = this.listZnodes(znode, watcher);
     if(nodes == null) {
       return list;
     }
@@ -827,40 +731,44 @@ public class ZooKeeperWrapper implements
    * @param watcher watch to set, can be null
    * @return a list of all the znodes
    */
-  public List<String> listZnodes(String znode) {
+  public List<String> listZnodes(String znode, Watcher watcher) {
     List<String> nodes = null;
     try {
       if (checkExistenceOf(znode)) {
-        nodes = zooKeeper.getChildren(znode, this);
-        for (String node : nodes) {
-          getDataAndWatch(znode, node, this);
+        if (watcher == null) {
+          nodes = zooKeeper.getChildren(znode, false);
+        } else {
+          nodes = zooKeeper.getChildren(znode, watcher);
+          for (String node : nodes) {
+            getDataAndWatch(znode, node, watcher);
+          }
         }
+
       }
     } catch (KeeperException e) {
-      LOG.warn("<" + instanceName + ">" + "Failed to read " + znode + " znode in ZooKeeper: " + e);
+      LOG.warn("Failed to read " + znode + " znode in ZooKeeper: " + e);
     } catch (InterruptedException e) {
-      LOG.warn("<" + instanceName + ">" + "Failed to read " + znode + " znode in ZooKeeper: " + e);
+      LOG.warn("Failed to read " + znode + " znode in ZooKeeper: " + e);
     }
     return nodes;
   }
 
-  public byte[] getData(String parentZNode, String znode) {
+  public String getData(String parentZNode, String znode) {
     return getDataAndWatch(parentZNode, znode, null);
   }
 
-  public byte[] getDataAndWatch(String parentZNode,
+  public String getDataAndWatch(String parentZNode,
                                 String znode, Watcher watcher) {
-    byte[] data = null;
+    String data = null;
     try {
       String path = joinPath(parentZNode, znode);
-      // TODO: ZK-REFACTOR: remove existance check?
       if (checkExistenceOf(path)) {
-        data = zooKeeper.getData(path, watcher, null);
+        data = Bytes.toString(zooKeeper.getData(path, watcher, null));
       }
     } catch (KeeperException e) {
-      LOG.warn("<" + instanceName + ">" + "Failed to read " + znode + " znode in ZooKeeper: " + e);
+      LOG.warn("Failed to read " + znode + " znode in ZooKeeper: " + e);
     } catch (InterruptedException e) {
-      LOG.warn("<" + instanceName + ">" + "Failed to read " + znode + " znode in ZooKeeper: " + e);
+      LOG.warn("Failed to read " + znode + " znode in ZooKeeper: " + e);
     }
     return data;
   }
@@ -893,17 +801,17 @@ public class ZooKeeperWrapper implements
       boolean failOnWrite) throws InterruptedException, KeeperException {
     String path = joinPath(parentPath, child);
     if (!ensureExists(parentPath)) {
-      LOG.error("<" + instanceName + ">" + "unable to ensure parent exists: " + parentPath);
+      LOG.error("unable to ensure parent exists: " + parentPath);
     }
     byte[] data = Bytes.toBytes(strData);
     Stat stat = this.zooKeeper.exists(path, false);
     if (failOnWrite || stat == null) {
       this.zooKeeper.create(path, data,
           Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
-      LOG.debug("<" + instanceName + ">" + "Created " + path);
+      LOG.debug("Created " + path);
     } else {
       this.zooKeeper.setData(path, data, -1);
-      LOG.debug("<" + instanceName + ">" + "Updated " + path);
+      LOG.debug("Updated " + path);
     }
   }
 
@@ -913,14 +821,6 @@ public class ZooKeeperWrapper implements
   }
 
   /**
-   * Get the znode that has all the regions in transition.
-   * @return path to znode
-   */
-  public String getRegionInTransitionZNode() {
-    return this.rgnsInTransitZNode;
-  }
-
-  /**
    * Get the path of this region server's znode
    * @return path to znode
    */
@@ -928,215 +828,4 @@ public class ZooKeeperWrapper implements
     return this.rsZNode;
   }
 
-  public void deleteZNode(String zNodeName, int version) {
-    String fullyQualifiedZNodeName = getZNode(parentZNode, zNodeName);
-    try
-    {
-      zooKeeper.delete(fullyQualifiedZNodeName, version);
-    }
-    catch (InterruptedException e)
-    {
-      LOG.warn("<" + instanceName + ">" + "Failed to delete ZNode " + fullyQualifiedZNodeName + " in ZooKeeper", e);
-    }
-    catch (KeeperException e)
-    {
-      LOG.warn("<" + instanceName + ">" + "Failed to delete ZNode " + fullyQualifiedZNodeName + " in ZooKeeper", e);
-    }
-  }
-
-  public String createZNodeIfNotExists(String zNodeName) {
-    return createZNodeIfNotExists(zNodeName, null, CreateMode.PERSISTENT, true);
-  }
-
-  public void watchZNode(String zNodeName) {
-    String fullyQualifiedZNodeName = getZNode(parentZNode, zNodeName);
-
-    try {
-      zooKeeper.exists(fullyQualifiedZNodeName, this);
-      zooKeeper.getData(fullyQualifiedZNodeName, this, null);
-      zooKeeper.getChildren(fullyQualifiedZNodeName, this);
-    } catch (InterruptedException e) {
-      LOG.warn("<" + instanceName + ">" + "Failed to create ZNode " + fullyQualifiedZNodeName + " in ZooKeeper", e);
-    } catch (KeeperException e) {
-      LOG.warn("<" + instanceName + ">" + "Failed to create ZNode " + fullyQualifiedZNodeName + " in ZooKeeper", e);
-    }
-  }
-
-  public String createZNodeIfNotExists(String zNodeName, byte[] data, CreateMode createMode, boolean watch) {
-    String fullyQualifiedZNodeName = getZNode(parentZNode, zNodeName);
-
-    if (!ensureParentExists(fullyQualifiedZNodeName)) {
-      return null;
-    }
-
-    try {
-      // create the znode
-      zooKeeper.create(fullyQualifiedZNodeName, data, Ids.OPEN_ACL_UNSAFE, createMode);
-      LOG.debug("<" + instanceName + ">" + "Created ZNode " + fullyQualifiedZNodeName + " in ZooKeeper");
-      // watch the znode for deletion, data change, creation of children
-      if(watch) {
-        watchZNode(zNodeName);
-      }
-      return fullyQualifiedZNodeName;
-    } catch (InterruptedException e) {
-      LOG.warn("<" + instanceName + ">" + "Failed to create ZNode " + fullyQualifiedZNodeName + " in ZooKeeper", e);
-    } catch (KeeperException e) {
-      LOG.warn("<" + instanceName + ">" + "Failed to create ZNode " + fullyQualifiedZNodeName + " in ZooKeeper", e);
-    }
-
-    return null;
-  }
-
-  public byte[] readZNode(String znodeName, Stat stat) throws IOException {
-    byte[] data;
-    try {
-      String fullyQualifiedZNodeName = getZNode(parentZNode, znodeName);
-      data = zooKeeper.getData(fullyQualifiedZNodeName, this, stat);
-    } catch (InterruptedException e) {
-      throw new IOException(e);
-    } catch (KeeperException e) {
-      throw new IOException(e);
-    }
-    return data;
-  }
-
-  // TODO: perhaps return the version number from this write?
-  public boolean writeZNode(String znodeName, byte[] data, int version, boolean watch) throws IOException {
-      try {
-        String fullyQualifiedZNodeName = getZNode(parentZNode, znodeName);
-        zooKeeper.setData(fullyQualifiedZNodeName, data, version);
-        if(watch) {
-          zooKeeper.getData(fullyQualifiedZNodeName, this, null);
-        }
-        return true;
-      } catch (InterruptedException e) {
-        LOG.warn("<" + instanceName + ">" + "Failed to write data to ZooKeeper", e);
-        throw new IOException(e);
-      } catch (KeeperException e) {
-        LOG.warn("<" + instanceName + ">" + "Failed to write data to ZooKeeper", e);
-        throw new IOException(e);
-      }
-    }
-  
-  public void createUnassignedRegion(String regionName, byte[] data) {
-    String znode = getZNode(getRegionInTransitionZNode(), regionName);
-    if(LOG.isDebugEnabled()) {
-      // check if this node already exists - 
-      //   - it should not exist
-      //   - if it does, it should be in the CLOSED state
-      if(exists(znode, true)) {
-        Stat stat = new Stat();
-        byte[] oldData = null;
-        try {
-          oldData = readZNode(znode, stat);
-        } catch (IOException e) {
-          LOG.error("Error reading data for " + znode);
-        }
-        if(oldData == null) {
-          LOG.debug("While creating UNASSIGNED region " + regionName + " exists with no data" );          
-        }
-        else {
-          LOG.debug("While creating UNASSIGNED region " + regionName + " exists, state = " + (HBaseEventType.fromByte(oldData[0])));
-        }
-      }
-      else {
-        if(data == null) {
-          LOG.debug("Creating UNASSIGNED region " + regionName + " with no data" );          
-        }
-        else {
-          LOG.debug("Creating UNASSIGNED region " + regionName + " in state = " + (HBaseEventType.fromByte(data[0])));
-        }
-      }
-    }
-    synchronized(unassignedZNodesWatched) {
-      unassignedZNodesWatched.add(znode);
-      createZNodeIfNotExists(znode, data, CreateMode.PERSISTENT, true);
-    }
-  }
-
-  public void deleteUnassignedRegion(String regionName) {
-    String znode = getZNode(getRegionInTransitionZNode(), regionName);
-    try {
-      LOG.debug("Deleting ZNode " + znode + " in ZooKeeper as region is open...");
-      synchronized(unassignedZNodesWatched) {
-        unassignedZNodesWatched.remove(znode);
-        deleteZNode(znode);
-      }
-    } catch (KeeperException.SessionExpiredException e) {
-      LOG.error("Zookeeper session has expired", e);
-      // if the session has expired try to reconnect to ZK, then perform query
-      try {
-        // TODO: ZK-REFACTOR: should just quit on reconnect??
-        reconnectToZk();
-        synchronized(unassignedZNodesWatched) {
-          unassignedZNodesWatched.remove(znode);
-          deleteZNode(znode);
-        }
-      } catch (IOException e1) {
-        LOG.error("Error reconnecting to zookeeper", e1);
-        throw new RuntimeException("Error reconnecting to zookeeper", e1);
-      } catch (KeeperException.SessionExpiredException e1) {
-        LOG.error("Error reading after reconnecting to zookeeper", e1);
-        throw new RuntimeException("Error reading after reconnecting to zookeeper", e1);
-      } catch (KeeperException e1) {
-        LOG.error("Error reading after reconnecting to zookeeper", e1);
-      } catch (InterruptedException e1) {
-        LOG.error("Error reading after reconnecting to zookeeper", e1);
-      }
-    } catch (KeeperException e) {
-      LOG.error("Error deleting region " + regionName, e);
-    } catch (InterruptedException e) {
-      LOG.error("Error deleting region " + regionName, e);
-    }
-  }
-
-  /**
-   * Atomically adds a watch and reads data from the unwatched znodes in the 
-   * UNASSGINED region. This works because the master is the only person 
-   * deleting nodes.
-   * @param znode
-   * @return
-   */
-  public List<ZNodePathAndData> watchAndGetNewChildren(String znode) {
-    List<String> nodes = null;
-    List<ZNodePathAndData> newNodes = new ArrayList<ZNodePathAndData>();
-    try {
-      if (checkExistenceOf(znode)) {
-        synchronized(unassignedZNodesWatched) {
-          nodes = zooKeeper.getChildren(znode, this);
-          for (String node : nodes) {
-            String znodePath = joinPath(znode, node);
-            if(!unassignedZNodesWatched.contains(znodePath)) {
-              byte[] data = getDataAndWatch(znode, node, this);
-              newNodes.add(new ZNodePathAndData(znodePath, data));
-              unassignedZNodesWatched.add(znodePath);
-            }
-          }
-        }
-      }
-    } catch (KeeperException e) {
-      LOG.warn("<" + instanceName + ">" + "Failed to read " + znode + " znode in ZooKeeper: " + e);
-    } catch (InterruptedException e) {
-      LOG.warn("<" + instanceName + ">" + "Failed to read " + znode + " znode in ZooKeeper: " + e);
-    }
-    return newNodes;
-  }
-  
-  public static class ZNodePathAndData {
-    private String zNodePath;
-    private byte[] data;
-    
-    public ZNodePathAndData(String zNodePath, byte[] data) {
-      this.zNodePath = zNodePath;
-      this.data = data;
-    }
-    
-    public String getzNodePath() {
-      return zNodePath;
-    }
-    public byte[] getData() {
-      return data;
-    }
-    
-  }
 }

Modified: hbase/branches/0.89.20100621/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89.20100621/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java?rev=956748&r1=956747&r2=956748&view=diff
==============================================================================
--- hbase/branches/0.89.20100621/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java (original)
+++ hbase/branches/0.89.20100621/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java Tue Jun 22 00:21:03 2010
@@ -706,8 +706,7 @@ public class HBaseTestingUtility {
   }
 
   public void expireSession(ZooKeeperWrapper nodeZK) throws Exception{
-    ZooKeeperWrapper zkw = ZooKeeperWrapper.createInstance(conf, ZooKeeperWrapper.class.getName());
-    zkw.registerListener(EmptyWatcher.instance);
+    ZooKeeperWrapper zkw = new ZooKeeperWrapper(conf, EmptyWatcher.instance);
     String quorumServers = zkw.getQuorumServers();
     int sessionTimeout = 5 * 1000; // 5 seconds
 

Modified: hbase/branches/0.89.20100621/src/test/java/org/apache/hadoop/hbase/TestZooKeeper.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89.20100621/src/test/java/org/apache/hadoop/hbase/TestZooKeeper.java?rev=956748&r1=956747&r2=956748&view=diff
==============================================================================
--- hbase/branches/0.89.20100621/src/test/java/org/apache/hadoop/hbase/TestZooKeeper.java (original)
+++ hbase/branches/0.89.20100621/src/test/java/org/apache/hadoop/hbase/TestZooKeeper.java Tue Jun 22 00:21:03 2010
@@ -91,8 +91,7 @@ public class TestZooKeeper {
       throws IOException, InterruptedException {
     new HTable(conf, HConstants.META_TABLE_NAME);
 
-    ZooKeeperWrapper zkw = ZooKeeperWrapper.createInstance(conf, TestZooKeeper.class.getName());
-    zkw.registerListener(EmptyWatcher.instance);
+    ZooKeeperWrapper zkw = new ZooKeeperWrapper(conf, EmptyWatcher.instance);
     String quorumServers = zkw.getQuorumServers();
     int sessionTimeout = 5 * 1000; // 5 seconds
     HConnection connection = HConnectionManager.getConnection(conf);
@@ -152,7 +151,7 @@ public class TestZooKeeper {
       HTable localMeta = new HTable(conf, HConstants.META_TABLE_NAME);
       Configuration otherConf = HBaseConfiguration.create(conf);
       otherConf.set(HConstants.ZOOKEEPER_QUORUM, "127.0.0.1");
-      HTable ipMeta = new HTable(otherConf, HConstants.META_TABLE_NAME);
+      HTable ipMeta = new HTable(conf, HConstants.META_TABLE_NAME);
 
       // dummy, just to open the connection
       localMeta.exists(new Get(HConstants.LAST_ROW));
@@ -178,8 +177,7 @@ public class TestZooKeeper {
    */
   @Test
   public void testZNodeDeletes() throws Exception {
-    ZooKeeperWrapper zkw = ZooKeeperWrapper.createInstance(conf, TestZooKeeper.class.getName());
-    zkw.registerListener(EmptyWatcher.instance);
+    ZooKeeperWrapper zkw = new ZooKeeperWrapper(conf, EmptyWatcher.instance);
     zkw.ensureExists("/l1/l2/l3/l4");
     try {
       zkw.deleteZNode("/l1/l2");

Modified: hbase/branches/0.89.20100621/src/test/java/org/apache/hadoop/hbase/master/TestMaster.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89.20100621/src/test/java/org/apache/hadoop/hbase/master/TestMaster.java?rev=956748&r1=956747&r2=956748&view=diff
==============================================================================
--- hbase/branches/0.89.20100621/src/test/java/org/apache/hadoop/hbase/master/TestMaster.java (original)
+++ hbase/branches/0.89.20100621/src/test/java/org/apache/hadoop/hbase/master/TestMaster.java Tue Jun 22 00:21:03 2010
@@ -30,9 +30,6 @@ import org.apache.hadoop.hbase.HRegionIn
 import org.apache.hadoop.hbase.HServerAddress;
 import org.apache.hadoop.hbase.client.HBaseAdmin;
 import org.apache.hadoop.hbase.client.HTable;
-import org.apache.hadoop.hbase.executor.HBaseEventHandler;
-import org.apache.hadoop.hbase.executor.HBaseEventHandler.HBaseEventHandlerListener;
-import org.apache.hadoop.hbase.executor.HBaseEventHandler.HBaseEventType;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.Pair;
 
@@ -89,7 +86,7 @@ public class TestMaster {
     CountDownLatch aboutToOpen = new CountDownLatch(1);
     CountDownLatch proceed = new CountDownLatch(1);
     RegionOpenListener list = new RegionOpenListener(aboutToOpen, proceed);
-    HBaseEventHandler.registerListener(list);
+    m.getRegionServerOperationQueue().registerRegionServerOperationListener(list);
 
     LOG.info("Splitting table");
     admin.split(TABLENAME);
@@ -112,19 +109,20 @@ public class TestMaster {
     }
   }
 
-  static class RegionOpenListener implements HBaseEventHandlerListener {
+  static class RegionOpenListener implements RegionServerOperationListener {
     CountDownLatch aboutToOpen, proceed;
 
-    public RegionOpenListener(CountDownLatch aboutToOpen, CountDownLatch proceed)
+    public RegionOpenListener(
+      CountDownLatch aboutToOpen, CountDownLatch proceed)
     {
       this.aboutToOpen = aboutToOpen;
       this.proceed = proceed;
     }
 
     @Override
-    public void afterProcess(HBaseEventHandler event) {
-      if (event.getHBEvent() != HBaseEventType.RS2ZK_REGION_OPENED) {
-        return;
+    public boolean process(HServerInfo serverInfo, HMsg incomingMsg) {
+      if (!incomingMsg.isType(HMsg.Type.MSG_REPORT_OPEN)) {
+        return true;
       }
       try {
         aboutToOpen.countDown();
@@ -132,11 +130,16 @@ public class TestMaster {
       } catch (InterruptedException ie) {
         throw new RuntimeException(ie);
       }
-      return;
+      return true;
     }
 
     @Override
-    public void beforeProcess(HBaseEventHandler event) {
+    public boolean process(RegionServerOperation op) throws IOException {
+      return true;
+    }
+
+    @Override
+    public void processed(RegionServerOperation op) {
     }
   }
 



Mime
View raw message