You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2012/05/02 18:26:38 UTC

svn commit: r1333099 [1/5] - in /hbase/trunk/src: main/java/org/apache/hadoop/hbase/ main/java/org/apache/hadoop/hbase/executor/ main/java/org/apache/hadoop/hbase/master/ main/java/org/apache/hadoop/hbase/protobuf/ main/java/org/apache/hadoop/hbase/pro...

Author: stack
Date: Wed May  2 16:26:36 2012
New Revision: 1333099

URL: http://svn.apache.org/viewvc?rev=1333099&view=rev
Log:
HBASE-5869 Move SplitLogManager splitlog taskstate and AssignmentManager RegionTransitionData znode datas to pb

Added:
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/DeserializationException.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/HBaseException.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/RegionTransition.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/SplitLogCounters.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/SplitLogTask.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/zookeeper/EmptyWatcher.java
Removed:
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/EmptyWatcher.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/executor/RegionTransitionData.java
Modified:
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/ServerName.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/executor/EventHandler.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/executor/ExecutorService.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/ActiveMasterManager.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/SplitLogManager.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/protobuf/generated/ZooKeeperProtos.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/SplitLogWorker.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLogSplitter.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/zookeeper/MasterAddressTracker.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/zookeeper/RootRegionTracker.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKAssign.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKSplitLog.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java
    hbase/trunk/src/main/protobuf/ZooKeeper.proto
    hbase/trunk/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
    hbase/trunk/src/test/java/org/apache/hadoop/hbase/TestSerialization.java
    hbase/trunk/src/test/java/org/apache/hadoop/hbase/TestZooKeeper.java
    hbase/trunk/src/test/java/org/apache/hadoop/hbase/catalog/TestMetaReaderEditor.java
    hbase/trunk/src/test/java/org/apache/hadoop/hbase/coprocessor/TestWALObserver.java
    hbase/trunk/src/test/java/org/apache/hadoop/hbase/master/Mocking.java
    hbase/trunk/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManager.java
    hbase/trunk/src/test/java/org/apache/hadoop/hbase/master/TestDistributedLogSplitting.java
    hbase/trunk/src/test/java/org/apache/hadoop/hbase/master/TestMasterFailover.java
    hbase/trunk/src/test/java/org/apache/hadoop/hbase/master/TestMasterNoCluster.java
    hbase/trunk/src/test/java/org/apache/hadoop/hbase/master/TestSplitLogManager.java
    hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitLogWorker.java
    hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java
    hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/handler/TestCloseRegionHandler.java
    hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/handler/TestOpenRegionHandler.java
    hbase/trunk/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java

Added: hbase/trunk/src/main/java/org/apache/hadoop/hbase/DeserializationException.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/DeserializationException.java?rev=1333099&view=auto
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/DeserializationException.java (added)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/DeserializationException.java Wed May  2 16:26:36 2012
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hbase;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+
+/**
+ * Failed deserialization.
+ */
+@InterfaceAudience.Private
+@SuppressWarnings("serial")
+public class DeserializationException extends HBaseException {
+  public DeserializationException() {
+    super();
+  }
+
+  public DeserializationException(final String message) {
+    super(message);
+  }
+
+  public DeserializationException(final String message, final Throwable t) {
+    super(message, t);
+  }
+
+  public DeserializationException(final Throwable t) {
+    super(t);
+  }
+}
\ No newline at end of file

Added: hbase/trunk/src/main/java/org/apache/hadoop/hbase/HBaseException.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/HBaseException.java?rev=1333099&view=auto
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/HBaseException.java (added)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/HBaseException.java Wed May  2 16:26:36 2012
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hbase;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+
+/**
+ * Base checked exception in HBase.
+ * @see https://issues.apache.org/jira/browse/HBASE-5796
+ */
+@SuppressWarnings("serial")
+@InterfaceAudience.Private
+public class HBaseException extends Exception {
+  public HBaseException() {
+    super();
+  }
+
+  public HBaseException(final String message) {
+    super(message);
+  }
+
+  public HBaseException(final String message, final Throwable t) {
+    super(message, t);
+  }
+
+  public HBaseException(final Throwable t) {
+    super(t);
+  }
+}
\ No newline at end of file

Added: hbase/trunk/src/main/java/org/apache/hadoop/hbase/RegionTransition.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/RegionTransition.java?rev=1333099&view=auto
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/RegionTransition.java (added)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/RegionTransition.java Wed May  2 16:26:36 2012
@@ -0,0 +1,141 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hbase;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.hbase.executor.EventHandler;
+import org.apache.hadoop.hbase.executor.EventHandler.EventType;
+import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
+import org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos;
+import org.apache.hadoop.hbase.util.Bytes;
+
+import com.google.protobuf.ByteString;
+import com.google.protobuf.InvalidProtocolBufferException;
+
+/**
+ * Current state of a region in transition.  Holds state of a region as it moves through the
+ * steps that take it from offline to open, etc.  Used by regionserver, master, and zk packages.
+ * Encapsulates protobuf serialization/deserialization so we don't leak generated pb outside this
+ * class.  Create an instance using {@link #createRegionTransition(EventType, byte[], ServerName)}.
+ * <p>Immutable
+ */
+@InterfaceAudience.Private
+public class RegionTransition {
+  private final ZooKeeperProtos.RegionTransition rt;
+
+  /**
+   * Shutdown constructor
+   */
+  private RegionTransition() {
+    this(null);
+  }
+
+  private RegionTransition(final ZooKeeperProtos.RegionTransition rt) {
+    this.rt = rt;
+  }
+
+  public EventHandler.EventType getEventType() {
+    return EventHandler.EventType.get(this.rt.getEventTypeCode());
+  }
+
+  public ServerName getServerName() {
+    return ProtobufUtil.toServerName(this.rt.getOriginServerName());
+  }
+
+  public long getCreateTime() {
+    return this.rt.getCreateTime();
+  }
+
+  /**
+   * @return Full region name
+   */
+  public byte [] getRegionName() {
+    return this.rt.getRegionName().toByteArray();
+  }
+
+  public byte [] getPayload() {
+    return this.rt.getPayload().toByteArray();
+  }
+
+  @Override
+  public String toString() {
+    byte [] payload = getPayload();
+    return "region=" + Bytes.toStringBinary(getRegionName()) + ", state=" + getEventType() +
+      ", servername=" + getServerName() + ", createTime=" + this.getCreateTime() +
+      ", payload.length=" + (payload == null? 0: payload.length);
+  }
+
+  /**
+   * @param type
+   * @param regionName
+   * @param sn
+   * @return a serialized pb {@link RegionTransition}
+   * @see #parseRegionTransition(byte[])
+   */
+  public static RegionTransition createRegionTransition(final EventType type,
+      final byte [] regionName, final ServerName sn) {
+    return createRegionTransition(type, regionName, sn, null);
+  }
+
+  /**
+   * @param type
+   * @param regionName
+   * @param sn
+   * @param payload May be null
+   * @return a serialized pb {@link RegionTransition}
+   * @see #parseRegionTransition(byte[])
+   */
+  public static RegionTransition createRegionTransition(final EventType type,
+      final byte [] regionName, final ServerName sn, final byte [] payload) {
+    org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.ServerName pbsn =
+      org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.ServerName.newBuilder().
+        setHostName(sn.getHostname()).setPort(sn.getPort()).setStartCode(sn.getStartcode()).build();
+    ZooKeeperProtos.RegionTransition.Builder builder = ZooKeeperProtos.RegionTransition.newBuilder().
+      setEventTypeCode(type.getCode()).setRegionName(ByteString.copyFrom(regionName)).
+        setOriginServerName(pbsn);
+    builder.setCreateTime(System.currentTimeMillis());
+    if (payload != null) builder.setPayload(ByteString.copyFrom(payload));
+    return new RegionTransition(builder.build());
+  }
+
+  /**
+   * @param data Serialized date to parse.
+   * @return A RegionTransition instance made of the passed <code>data</code>
+   * @throws DeserializationException 
+   * @see #toByteArray()
+   */
+  public static RegionTransition parseFrom(final byte [] data) throws DeserializationException {
+    ProtobufUtil.expectPBMagicPrefix(data);
+    try {
+      int prefixLen = ProtobufUtil.lengthOfPBMagic();
+      ZooKeeperProtos.RegionTransition rt = ZooKeeperProtos.RegionTransition.newBuilder().
+        mergeFrom(data, prefixLen, data.length - prefixLen).build();
+      return new RegionTransition(rt);
+    } catch (InvalidProtocolBufferException e) {
+      throw new DeserializationException(e);
+    }
+  }
+
+  /**
+   * @return This instance serialized into a byte array
+   * @see #parseFrom(byte[])
+   */
+  public byte [] toByteArray() {
+    return ProtobufUtil.prependPBMagic(this.rt.toByteArray());
+  }
+}
\ No newline at end of file

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/ServerName.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/ServerName.java?rev=1333099&r1=1333098&r2=1333099&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/ServerName.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/ServerName.java Wed May  2 16:26:36 2012
@@ -24,9 +24,13 @@ import java.util.regex.Pattern;
 
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.classification.InterfaceStability;
+import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
+import org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.RootRegionServer;
 import org.apache.hadoop.hbase.util.Addressing;
 import org.apache.hadoop.hbase.util.Bytes;
 
+import com.google.protobuf.InvalidProtocolBufferException;
+
 /**
  * Instance of an HBase ServerName.
  * A server name is used uniquely identifying a server instance and is made
@@ -296,4 +300,47 @@ public class ServerName implements Compa
     return SERVERNAME_PATTERN.matcher(str).matches()? new ServerName(str):
       new ServerName(str, NON_STARTCODE);
   }
-}
+
+  /**
+   * Get a ServerName from the passed in data bytes.
+   * @param data Data with a serialize server name in it; can handle the old style
+   * servername where servername was host and port.  Works too with data that
+   * begins w/ the pb 'PBUF' magic and that is then followed by a protobuf that
+   * has a serialized {@link ServerName} in it.
+   * @return Returns null if <code>data</code> is null else converts passed data
+   * to a ServerName instance.
+   * @throws DeserializationException 
+   */
+  public static ServerName parseFrom(final byte [] data) throws DeserializationException {
+    if (data == null || data.length <= 0) return null;
+    if (ProtobufUtil.isPBMagicPrefix(data)) {
+      int prefixLen = ProtobufUtil.lengthOfPBMagic();
+      try {
+        RootRegionServer rss =
+          RootRegionServer.newBuilder().mergeFrom(data, prefixLen, data.length - prefixLen).build();
+        org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.ServerName sn = rss.getServer();
+        return new ServerName(sn.getHostName(), sn.getPort(), sn.getStartCode());
+      } catch (InvalidProtocolBufferException e) {
+        // A failed parse of the znode is pretty catastrophic. Rather than loop
+        // retrying hoping the bad bytes will changes, and rather than change
+        // the signature on this method to add an IOE which will send ripples all
+        // over the code base, throw a RuntimeException.  This should "never" happen.
+        // Fail fast if it does.
+        throw new DeserializationException(e);
+      }
+    }
+    // The str returned could be old style -- pre hbase-1502 -- which was
+    // hostname and port seperated by a colon rather than hostname, port and
+    // startcode delimited by a ','.
+    String str = Bytes.toString(data);
+    int index = str.indexOf(ServerName.SERVERNAME_SEPARATOR);
+    if (index != -1) {
+      // Presume its ServerName serialized with versioned bytes.
+      return ServerName.parseVersionedServerName(data);
+    }
+    // Presume it a hostname:port format.
+    String hostname = Addressing.parseHostname(str);
+    int port = Addressing.parsePort(str);
+    return new ServerName(hostname, port, -1L);
+  }
+}
\ No newline at end of file

Added: hbase/trunk/src/main/java/org/apache/hadoop/hbase/SplitLogCounters.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/SplitLogCounters.java?rev=1333099&view=auto
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/SplitLogCounters.java (added)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/SplitLogCounters.java Wed May  2 16:26:36 2012
@@ -0,0 +1,102 @@
+package org.apache.hadoop.hbase;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import java.lang.reflect.Field;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+
+/**
+ * Counters kept by the distributed WAL split log process.
+ * Used by master and regionserver packages.
+ */
+@InterfaceAudience.Private
+public class SplitLogCounters {
+  //SplitLogManager counters
+  public static AtomicLong tot_mgr_log_split_batch_start = new AtomicLong(0);
+  public static AtomicLong tot_mgr_log_split_batch_success =
+    new AtomicLong(0);
+  public static AtomicLong tot_mgr_log_split_batch_err = new AtomicLong(0);
+  public static AtomicLong tot_mgr_new_unexpected_hlogs = new AtomicLong(0);
+  public static AtomicLong tot_mgr_log_split_start = new AtomicLong(0);
+  public static AtomicLong tot_mgr_log_split_success = new AtomicLong(0);
+  public static AtomicLong tot_mgr_log_split_err = new AtomicLong(0);
+  public static AtomicLong tot_mgr_node_create_queued = new AtomicLong(0);
+  public static AtomicLong tot_mgr_node_create_result = new AtomicLong(0);
+  public static AtomicLong tot_mgr_node_already_exists = new AtomicLong(0);
+  public static AtomicLong tot_mgr_node_create_err = new AtomicLong(0);
+  public static AtomicLong tot_mgr_node_create_retry = new AtomicLong(0);
+  public static AtomicLong tot_mgr_get_data_queued = new AtomicLong(0);
+  public static AtomicLong tot_mgr_get_data_result = new AtomicLong(0);
+  public static AtomicLong tot_mgr_get_data_nonode = new AtomicLong(0);
+  public static AtomicLong tot_mgr_get_data_err = new AtomicLong(0);
+  public static AtomicLong tot_mgr_get_data_retry = new AtomicLong(0);
+  public static AtomicLong tot_mgr_node_delete_queued = new AtomicLong(0);
+  public static AtomicLong tot_mgr_node_delete_result = new AtomicLong(0);
+  public static AtomicLong tot_mgr_node_delete_err = new AtomicLong(0);
+  public static AtomicLong tot_mgr_resubmit = new AtomicLong(0);
+  public static AtomicLong tot_mgr_resubmit_failed = new AtomicLong(0);
+  public static AtomicLong tot_mgr_null_data = new AtomicLong(0);
+  public static AtomicLong tot_mgr_orphan_task_acquired = new AtomicLong(0);
+  public static AtomicLong tot_mgr_wait_for_zk_delete = new AtomicLong(0);
+  public static AtomicLong tot_mgr_unacquired_orphan_done = new AtomicLong(0);
+  public static AtomicLong tot_mgr_resubmit_threshold_reached =
+    new AtomicLong(0);
+  public static AtomicLong tot_mgr_missing_state_in_delete =
+    new AtomicLong(0);
+  public static AtomicLong tot_mgr_heartbeat = new AtomicLong(0);
+  public static AtomicLong tot_mgr_rescan = new AtomicLong(0);
+  public static AtomicLong tot_mgr_rescan_deleted = new AtomicLong(0);
+  public static AtomicLong tot_mgr_task_deleted = new AtomicLong(0);
+  public static AtomicLong tot_mgr_resubmit_unassigned = new AtomicLong(0);
+  public static AtomicLong tot_mgr_relist_logdir = new AtomicLong(0);
+  public static AtomicLong tot_mgr_resubmit_dead_server_task =
+    new AtomicLong(0);
+
+  // SplitLogWorker counters
+  public static AtomicLong tot_wkr_failed_to_grab_task_no_data =
+    new AtomicLong(0);
+  public static AtomicLong tot_wkr_failed_to_grab_task_exception =
+    new AtomicLong(0);
+  public static AtomicLong tot_wkr_failed_to_grab_task_owned =
+    new AtomicLong(0);
+  public static AtomicLong tot_wkr_failed_to_grab_task_lost_race =
+    new AtomicLong(0);
+  public static AtomicLong tot_wkr_task_acquired = new AtomicLong(0);
+  public static AtomicLong tot_wkr_task_resigned = new AtomicLong(0);
+  public static AtomicLong tot_wkr_task_done = new AtomicLong(0);
+  public static AtomicLong tot_wkr_task_err = new AtomicLong(0);
+  public static AtomicLong tot_wkr_task_heartbeat = new AtomicLong(0);
+  public static AtomicLong tot_wkr_task_acquired_rescan = new AtomicLong(0);
+  public static AtomicLong tot_wkr_get_data_queued = new AtomicLong(0);
+  public static AtomicLong tot_wkr_get_data_result = new AtomicLong(0);
+  public static AtomicLong tot_wkr_get_data_retry = new AtomicLong(0);
+  public static AtomicLong tot_wkr_preempt_task = new AtomicLong(0);
+  public static AtomicLong tot_wkr_task_heartbeat_failed = new AtomicLong(0);
+  public static AtomicLong tot_wkr_final_transistion_failed =
+    new AtomicLong(0);
+
+  public static void resetCounters() throws Exception {
+    Class<?> cl = (new SplitLogCounters()).getClass();
+    Field[] flds = cl.getDeclaredFields();
+    for (Field fld : flds) {
+      ((AtomicLong)fld.get(null)).set(0);
+    }
+  }
+}
\ No newline at end of file

Added: hbase/trunk/src/main/java/org/apache/hadoop/hbase/SplitLogTask.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/SplitLogTask.java?rev=1333099&view=auto
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/SplitLogTask.java (added)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/SplitLogTask.java Wed May  2 16:26:36 2012
@@ -0,0 +1,172 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hbase;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
+import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos;
+import org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos;
+import org.apache.hadoop.hbase.util.Bytes;
+
+import com.google.protobuf.InvalidProtocolBufferException;
+
+/**
+ * State of a WAL log split during distributed splitting.  State is kept up in zookeeper.
+ * Encapsulates protobuf serialization/deserialization so we don't leak generated pb outside of
+ * this class.  Used by regionserver and master packages.
+ * <p>Immutable
+ */
+@InterfaceAudience.Private
+public class SplitLogTask {
+  private final ServerName originServer;
+  private final ZooKeeperProtos.SplitLogTask.State state;
+
+  public static class Unassigned extends SplitLogTask {
+    public Unassigned(final ServerName originServer) {
+      super(originServer, ZooKeeperProtos.SplitLogTask.State.UNASSIGNED);
+    }
+  }
+
+  public static class Owned extends SplitLogTask {
+    public Owned(final ServerName originServer) {
+      super(originServer, ZooKeeperProtos.SplitLogTask.State.OWNED);
+    }
+  }
+
+  public static class Resigned extends SplitLogTask {
+    public Resigned(final ServerName originServer) {
+      super(originServer, ZooKeeperProtos.SplitLogTask.State.RESIGNED);
+    }
+  }
+
+  public static class Done extends SplitLogTask {
+    public Done(final ServerName originServer) {
+      super(originServer, ZooKeeperProtos.SplitLogTask.State.DONE);
+    }
+  }
+
+  public static class Err extends SplitLogTask {
+    public Err(final ServerName originServer) {
+      super(originServer, ZooKeeperProtos.SplitLogTask.State.ERR);
+    }
+  }
+
+  SplitLogTask(final ZooKeeperProtos.SplitLogTask slt) {
+    this(ProtobufUtil.toServerName(slt.getServerName()), slt.getState());
+  }
+
+  SplitLogTask(final ServerName originServer, final ZooKeeperProtos.SplitLogTask.State state) {
+    this.originServer = originServer;
+    this.state = state;
+  }
+
+  public ServerName getServerName() {
+    return this.originServer;
+  }
+
+  public boolean isUnassigned(final ServerName sn) {
+    return this.originServer.equals(sn) && isUnassigned();
+  }
+
+  public boolean isUnassigned() {
+    return this.state == ZooKeeperProtos.SplitLogTask.State.UNASSIGNED;
+  }
+
+  public boolean isOwned(final ServerName sn) {
+    return this.originServer.equals(sn) && isOwned();
+  }
+
+  public boolean isOwned() {
+    return this.state == ZooKeeperProtos.SplitLogTask.State.OWNED;
+  }
+
+  public boolean isResigned(final ServerName sn) {
+    return this.originServer.equals(sn) && isResigned();
+  }
+
+  public boolean isResigned() {
+    return this.state == ZooKeeperProtos.SplitLogTask.State.RESIGNED;
+  }
+
+  public boolean isDone(final ServerName sn) {
+    return this.originServer.equals(sn) && isDone();
+  }
+
+  public boolean isDone() {
+    return this.state == ZooKeeperProtos.SplitLogTask.State.DONE;
+  }
+
+  public boolean isErr(final ServerName sn) {
+    return this.originServer.equals(sn) && isErr();
+  }
+
+  public boolean isErr() {
+    return this.state == ZooKeeperProtos.SplitLogTask.State.ERR;
+  }
+
+  @Override
+  public String toString() {
+    return this.state.toString() + " " + this.originServer.toString();
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    if (!(obj instanceof SplitLogTask)) return false;
+    SplitLogTask other = (SplitLogTask)obj;
+    return other.state.equals(this.state) && other.originServer.equals(this.originServer);
+  }
+
+  @Override
+  public int hashCode() {
+    int hash = 7;
+    hash = 31 * hash + this.state.hashCode();
+    return 31 * hash + this.originServer.hashCode();
+  }
+
+  /**
+   * @param data Serialized date to parse.
+   * @return An SplitLogTaskState instance made of the passed <code>data</code>
+   * @throws DeserializationException 
+   * @see #toByteArray()
+   */
+  public static SplitLogTask parseFrom(final byte [] data) throws DeserializationException {
+    ProtobufUtil.expectPBMagicPrefix(data);
+    try {
+      int prefixLen = ProtobufUtil.lengthOfPBMagic();
+      ZooKeeperProtos.SplitLogTask slt = ZooKeeperProtos.SplitLogTask.newBuilder().
+        mergeFrom(data, prefixLen, data.length - prefixLen).build();
+      return new SplitLogTask(slt);
+    } catch (InvalidProtocolBufferException e) {
+      throw new DeserializationException(Bytes.toStringBinary(data, 0, 64), e);
+    }
+  }
+
+  /**
+   * @return This instance serialized into a byte array
+   * @see #parseFrom(byte[])
+   */
+  public byte [] toByteArray() {
+    // First create a pb ServerName.  Then create a ByteString w/ the TaskState
+    // bytes in it.  Finally create a SplitLogTaskState passing in the two
+    // pbs just created.
+    HBaseProtos.ServerName snpb = ProtobufUtil.toServerName(this.originServer);
+    ZooKeeperProtos.SplitLogTask slts =
+      ZooKeeperProtos.SplitLogTask.newBuilder().setServerName(snpb).setState(this.state).build();
+    return ProtobufUtil.prependPBMagic(slts.toByteArray());
+  }
+}
\ No newline at end of file

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/executor/EventHandler.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/executor/EventHandler.java?rev=1333099&r1=1333098&r2=1333099&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/executor/EventHandler.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/executor/EventHandler.java Wed May  2 16:26:36 2012
@@ -105,7 +105,7 @@ public abstract class EventHandler imple
   public enum EventType {
     // Messages originating from RS (NOTE: there is NO direct communication from
     // RS to Master). These are a result of RS updates into ZK.
-    //RS_ZK_REGION_CLOSING    (1),   // It is replaced by M_ZK_REGION_CLOSING(HBASE-4739)
+    // RS_ZK_REGION_CLOSING    (1),   // It is replaced by M_ZK_REGION_CLOSING(HBASE-4739)
     RS_ZK_REGION_CLOSED       (2),   // RS has finished closing a region
     RS_ZK_REGION_OPENING      (3),   // RS is in process of opening a region
     RS_ZK_REGION_OPENED       (4),   // RS has finished opening a region
@@ -140,10 +140,27 @@ public abstract class EventHandler imple
     M_SERVER_SHUTDOWN         (70),  // Master is processing shutdown of a RS
     M_META_SERVER_SHUTDOWN    (72);  // Master is processing shutdown of RS hosting a meta region (-ROOT- or .META.).
 
+    private final int code;
+
     /**
      * Constructor
      */
-    EventType(int value) {}
+    EventType(final int code) {
+      this.code = code;
+    }
+
+    public int getCode() {
+      return this.code;
+    }
+
+    public static EventType get(final int code) {
+      // Is this going to be slow?  Its used rare but still...
+      for (EventType et: EventType.values()) {
+        if (et.getCode() == code) return et;
+      }
+      throw new IllegalArgumentException("Unknown code " + code);
+    }
+
     public boolean isOnlineSchemaChangeSupported() {
       return (
         this.equals(EventType.C_M_ADD_FAMILY) ||

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/executor/ExecutorService.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/executor/ExecutorService.java?rev=1333099&r1=1333098&r2=1333099&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/executor/ExecutorService.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/executor/ExecutorService.java Wed May  2 16:26:36 2012
@@ -20,7 +20,6 @@
 package org.apache.hadoop.hbase.executor;
 
 import java.io.IOException;
-import java.io.PrintWriter;
 import java.io.Writer;
 import java.lang.management.ThreadInfo;
 import java.util.List;
@@ -30,8 +29,6 @@ import java.util.concurrent.BlockingQueu
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.RejectedExecutionHandler;
-import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicLong;
@@ -40,7 +37,6 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.hbase.executor.EventHandler.EventHandlerListener;
-import org.apache.hadoop.hbase.executor.EventHandler.EventType;
 import org.apache.hadoop.hbase.monitoring.ThreadMonitoring;
 
 import com.google.common.collect.Lists;

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/ActiveMasterManager.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/ActiveMasterManager.java?rev=1333099&r1=1333098&r2=1333099&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/ActiveMasterManager.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/ActiveMasterManager.java Wed May  2 16:26:36 2012
@@ -25,6 +25,7 @@ import java.util.concurrent.atomic.Atomi
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.hbase.DeserializationException;
 import org.apache.hadoop.hbase.Server;
 import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.monitoring.MonitoredTask;
@@ -138,7 +139,8 @@ class ActiveMasterManager extends ZooKee
       // Try to become the active master, watch if there is another master.
       // Write out our ServerName as versioned bytes.
       try {
-        String backupZNode = ZKUtil.joinZNode(this.watcher.backupMasterAddressesZNode, this.sn.toString());
+        String backupZNode =
+            ZKUtil.joinZNode(this.watcher.backupMasterAddressesZNode, this.sn.toString());
         if (MasterAddressTracker.setMasterAddress(this.watcher, this.watcher.getMasterAddressZNode(), this.sn)) {
           // If we were a backup master before, delete our ZNode from the backup
           // master directory since we are the active now
@@ -174,7 +176,14 @@ class ActiveMasterManager extends ZooKee
           msg = ("A master was detected, but went down before its address " +
             "could be read.  Attempting to become the next active master");
         } else {
-          ServerName currentMaster = ZKUtil.znodeContentToServerName(bytes);
+          ServerName currentMaster;
+          try {
+            currentMaster = ServerName.parseFrom(bytes);
+          } catch (DeserializationException e) {
+            LOG.warn("Failed parse", e);
+            // Hopefully next time around we won't fail the parse.  Dangerous.
+            continue;
+          }
           if (ServerName.isSameHostnameAndPort(currentMaster, this.sn)) {
             msg = ("Current master has this master's address, " +
               currentMaster + "; master was restarted? Deleting node.");

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java?rev=1333099&r1=1333098&r2=1333099&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java Wed May  2 16:26:36 2012
@@ -48,10 +48,12 @@ import org.apache.commons.logging.LogFac
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.Chore;
+import org.apache.hadoop.hbase.DeserializationException;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.HServerLoad;
 import org.apache.hadoop.hbase.NotServingRegionException;
+import org.apache.hadoop.hbase.RegionTransition;
 import org.apache.hadoop.hbase.Server;
 import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.Stoppable;
@@ -62,7 +64,6 @@ import org.apache.hadoop.hbase.client.Re
 import org.apache.hadoop.hbase.executor.EventHandler;
 import org.apache.hadoop.hbase.executor.EventHandler.EventType;
 import org.apache.hadoop.hbase.executor.ExecutorService;
-import org.apache.hadoop.hbase.executor.RegionTransitionData;
 import org.apache.hadoop.hbase.ipc.ServerNotRunningYetException;
 import org.apache.hadoop.hbase.master.AssignmentManager.RegionState.State;
 import org.apache.hadoop.hbase.master.handler.ClosedRegionHandler;
@@ -489,29 +490,34 @@ public class AssignmentManager extends Z
    * @throws IOException
    */
   boolean processRegionInTransition(final String encodedRegionName,
-      final HRegionInfo regionInfo,
-      final Map<ServerName,List<Pair<HRegionInfo,Result>>> deadServers)
+      final HRegionInfo regionInfo, final Map<ServerName,List<Pair<HRegionInfo,Result>>> deadServers)
   throws KeeperException, IOException {
     Stat stat = new Stat();
-    RegionTransitionData data = ZKAssign.getDataAndWatch(watcher,
-        encodedRegionName, stat);
+    byte [] data = ZKAssign.getDataAndWatch(watcher, encodedRegionName, stat);
     if (data == null) return false;
+    RegionTransition rt;
+    try {
+      rt = RegionTransition.parseFrom(data);
+    } catch (DeserializationException e) {
+      LOG.warn("Failed parse znode data", e);
+      return false;
+    }
     HRegionInfo hri = regionInfo;
     if (hri == null) {
-      if ((hri = getHRegionInfo(data)) == null) return false; 
+      if ((hri = getHRegionInfo(rt.getRegionName())) == null) return false; 
     }
-    processRegionsInTransition(data, hri, deadServers, stat.getVersion());
+    processRegionsInTransition(rt, hri, deadServers, stat.getVersion());
     return true;
   }
 
-  void processRegionsInTransition(final RegionTransitionData data,
-      final HRegionInfo regionInfo,
-      final Map<ServerName, List<Pair<HRegionInfo, Result>>> deadServers,
-      int expectedVersion)
+  void processRegionsInTransition(final RegionTransition rt, final HRegionInfo regionInfo,
+      final Map<ServerName, List<Pair<HRegionInfo, Result>>> deadServers, int expectedVersion)
   throws KeeperException {
+    EventType et = rt.getEventType();
+    // Get ServerName.  Could be null.
+    ServerName sn = rt.getServerName();
     String encodedRegionName = regionInfo.getEncodedName();
-    LOG.info("Processing region " + regionInfo.getRegionNameAsString() +
-      " in state " + data.getEventType());
+    LOG.info("Processing region " + regionInfo.getRegionNameAsString() + " in state " + et);
     synchronized (regionsInTransition) {
       RegionState regionState = regionsInTransition.get(encodedRegionName);
       if (regionState != null ||
@@ -519,21 +525,19 @@ public class AssignmentManager extends Z
         // Just return
         return;
       }
-      switch (data.getEventType()) {
+      switch (et) {
       case M_ZK_REGION_CLOSING:
         // If zk node of the region was updated by a live server skip this
         // region and just add it into RIT.
-        if (isOnDeadServer(regionInfo, deadServers) &&
-            (data.getOrigin() == null || !serverManager.isServerOnline(data.getOrigin()))) {
+        if (isOnDeadServer(regionInfo, deadServers) && (sn == null || !isServerOnline(sn))) {
           // If was on dead server, its closed now. Force to OFFLINE and this
           // will get it reassigned if appropriate
-          forceOffline(regionInfo, data);
+          forceOffline(regionInfo, rt);
         } else {
           // Just insert region into RIT.
           // If this never updates the timeout will trigger new assignment
-          regionsInTransition.put(encodedRegionName, new RegionState(
-            regionInfo, RegionState.State.CLOSING,
-            data.getStamp(), data.getOrigin()));
+          regionsInTransition.put(encodedRegionName,
+            getRegionState(regionInfo, RegionState.State.CLOSING, rt));
         }
         failoverProcessedRegions.put(encodedRegionName, regionInfo);
         break;
@@ -541,27 +545,23 @@ public class AssignmentManager extends Z
       case RS_ZK_REGION_CLOSED:
       case RS_ZK_REGION_FAILED_OPEN:
         // Region is closed, insert into RIT and handle it
-        addToRITandCallClose(regionInfo, RegionState.State.CLOSED, data);
+        addToRITandCallClose(regionInfo, RegionState.State.CLOSED, rt);
         failoverProcessedRegions.put(encodedRegionName, regionInfo);
         break;
 
       case M_ZK_REGION_OFFLINE:
         // If zk node of the region was updated by a live server skip this
         // region and just add it into RIT.
-        if (isOnDeadServer(regionInfo, deadServers) &&
-            (data.getOrigin() == null ||
-              !serverManager.isServerOnline(data.getOrigin()))) {
+        if (isOnDeadServer(regionInfo, deadServers) && (sn == null || !isServerOnline(sn))) {
           // Region is offline, insert into RIT and handle it like a closed
-          addToRITandCallClose(regionInfo, RegionState.State.OFFLINE, data);
-        } else if (data.getOrigin() != null &&
-            !serverManager.isServerOnline(data.getOrigin())) {
+          addToRITandCallClose(regionInfo, RegionState.State.OFFLINE, rt);
+        } else if (sn != null && !isServerOnline(sn)) {
           // to handle cases where offline node is created but sendRegionOpen
           // RPC is not yet sent
-          addToRITandCallClose(regionInfo, RegionState.State.OFFLINE, data);
+          addToRITandCallClose(regionInfo, RegionState.State.OFFLINE, rt);
         } else {
-          regionsInTransition.put(encodedRegionName, new RegionState(
-              regionInfo, RegionState.State.PENDING_OPEN, data.getStamp(), data
-                  .getOrigin()));
+          regionsInTransition.put(encodedRegionName,
+            getRegionState(regionInfo, RegionState.State.PENDING_OPEN, rt));
         }
         failoverProcessedRegions.put(encodedRegionName, regionInfo);
         break;
@@ -573,9 +573,8 @@ public class AssignmentManager extends Z
         // Just insert region into RIT
         // If this never updates the timeout will trigger new assignment
         if (regionInfo.isMetaTable()) {
-          regionsInTransition.put(encodedRegionName, new RegionState(
-              regionInfo, RegionState.State.OPENING, data.getStamp(), data
-                  .getOrigin()));
+          regionsInTransition.put(encodedRegionName,
+            getRegionState(regionInfo, RegionState.State.OPENING, rt));
           // If ROOT or .META. table is waiting for timeout monitor to assign
           // it may take lot of time when the assignment.timeout.period is
           // the default value which may be very long.  We will not be able
@@ -584,17 +583,15 @@ public class AssignmentManager extends Z
           processOpeningState(regionInfo);
           break;
         }
-        regionsInTransition.put(encodedRegionName, new RegionState(regionInfo,
-            RegionState.State.OPENING, data.getStamp(), data.getOrigin()));
+        regionsInTransition.put(encodedRegionName,
+          getRegionState(regionInfo, RegionState.State.OPENING, rt));
         failoverProcessedRegions.put(encodedRegionName, regionInfo);
         break;
 
       case RS_ZK_REGION_OPENED:
         // Region is opened, insert into RIT and handle it
-        regionsInTransition.put(encodedRegionName, new RegionState(
-            regionInfo, RegionState.State.OPEN,
-            data.getStamp(), data.getOrigin()));
-        ServerName sn = data.getOrigin() == null? null: data.getOrigin();
+        regionsInTransition.put(encodedRegionName,
+          getRegionState(regionInfo, RegionState.State.OPEN, rt));
         // sn could be null if this server is no longer online.  If
         // that is the case, just let this RIT timeout; it'll be assigned
         // to new server then.
@@ -605,10 +602,9 @@ public class AssignmentManager extends Z
         } else if (!serverManager.isServerOnline(sn)
             && (isOnDeadServer(regionInfo, deadServers)
                 || regionInfo.isMetaRegion() || regionInfo.isRootRegion())) {
-          forceOffline(regionInfo, data);
+          forceOffline(regionInfo, rt);
         } else {
-          new OpenedRegionHandler(master, this, regionInfo, sn, expectedVersion)
-              .process();
+          new OpenedRegionHandler(master, this, regionInfo, sn, expectedVersion).process();
         }
         failoverProcessedRegions.put(encodedRegionName, regionInfo);
         break;
@@ -623,19 +619,18 @@ public class AssignmentManager extends Z
   /**
    * Put the region <code>hri</code> into an offline state up in zk.
    * @param hri
-   * @param oldData
+   * @param oldRt
    * @throws KeeperException
    */
-  private void forceOffline(final HRegionInfo hri,
-      final RegionTransitionData oldData)
+  private void forceOffline(final HRegionInfo hri, final RegionTransition oldRt)
   throws KeeperException {
     // If was on dead server, its closed now.  Force to OFFLINE and then
     // handle it like a close; this will get it reassigned if appropriate
-    LOG.debug("RIT " + hri.getEncodedName() + " in state=" +
-      oldData.getEventType() + " was on deadserver; forcing offline");
+    LOG.debug("RIT " + hri.getEncodedName() + " in state=" + oldRt.getEventType() +
+      " was on deadserver; forcing offline");
     ZKAssign.createOrForceNodeOffline(this.watcher, hri,
       this.master.getServerName());
-    addToRITandCallClose(hri, RegionState.State.OFFLINE, oldData);
+    addToRITandCallClose(hri, RegionState.State.OFFLINE, oldRt);
   }
 
   /**
@@ -646,13 +641,23 @@ public class AssignmentManager extends Z
    * @param oldData
    */
   private void addToRITandCallClose(final HRegionInfo hri,
-      final RegionState.State state, final RegionTransitionData oldData) {
-    this.regionsInTransition.put(hri.getEncodedName(),
-      new RegionState(hri, state, oldData.getStamp(), oldData.getOrigin()));
+      final RegionState.State state, final RegionTransition oldData) {
+    this.regionsInTransition.put(hri.getEncodedName(), getRegionState(hri, state, oldData));
     new ClosedRegionHandler(this.master, this, hri).process();
   }
 
   /**
+   * @param hri
+   * @param state
+   * @param rt
+   * @return A new {@link RegionState} instance made of the passed arguments
+   */
+  RegionState getRegionState(final HRegionInfo hri, final RegionState.State state,
+      final RegionTransition rt) {
+    return new RegionState(hri, state, rt.getCreateTime(), rt.getServerName());
+  }
+
+  /**
    * When a region is closed, it should be removed from the regionsToReopen
    * @param hri HRegionInfo of the region which was closed
    */
@@ -689,41 +694,46 @@ public class AssignmentManager extends Z
    * <p>
    * This deals with skipped transitions (we got a CLOSED but didn't see CLOSING
    * yet).
-   * @param data
+   * @param rt
    * @param expectedVersion
    */
-  private void handleRegion(final RegionTransitionData data, int expectedVersion) {
+  private void handleRegion(final RegionTransition rt, int expectedVersion) {
     synchronized(regionsInTransition) {
       HRegionInfo hri = null;
-      if (data == null || data.getOrigin() == null) {
-        LOG.warn("Unexpected NULL input " + data);
+      if (rt == null) {
+        LOG.warn("Unexpected NULL input " + rt);
+        return;
+      }
+      final ServerName sn = rt.getServerName();
+      if (sn == null) {
+        LOG.warn("Null servername: " + rt);
         return;
       }
-      ServerName sn = data.getOrigin();
       // Check if this is a special HBCK transition
       if (sn.equals(HConstants.HBCK_CODE_SERVERNAME)) {
-        handleHBCK(data);
+        handleHBCK(rt);
         return;
       }
-      String encodedName = HRegionInfo.encodeRegionName(data.getRegionName());
+      final long createTime = rt.getCreateTime();
+      final byte [] regionName = rt.getRegionName();
+      String encodedName = HRegionInfo.encodeRegionName(regionName);
       String prettyPrintedRegionName = HRegionInfo.prettyPrint(encodedName);
       // Verify this is a known server
       if (!serverManager.isServerOnline(sn) &&
           !this.master.getServerName().equals(sn)
-          && !ignoreStatesRSOffline.contains(data.getEventType())) {
+          && !ignoreStatesRSOffline.contains(rt.getEventType())) {
         LOG.warn("Attempted to handle region transition for server but " +
           "server is not online: " + prettyPrintedRegionName);
         return;
       }
       // Printing if the event was created a long time ago helps debugging
-      boolean lateEvent = data.getStamp() <
-          (System.currentTimeMillis() - 15000);
-      LOG.debug("Handling transition=" + data.getEventType() +
-        ", server=" + data.getOrigin() + ", region=" +
+      boolean lateEvent = createTime < (System.currentTimeMillis() - 15000);
+      LOG.debug("Handling transition=" + rt.getEventType() +
+        ", server=" + sn + ", region=" +
           (prettyPrintedRegionName == null? "null": prettyPrintedRegionName)  +
           (lateEvent? ", which is more than 15 seconds late" : ""));
       RegionState regionState = regionsInTransition.get(encodedName);
-      switch (data.getEventType()) {
+      switch (rt.getEventType()) {
         case M_ZK_REGION_OFFLINE:
           // Nothing to do.
           break;
@@ -751,7 +761,7 @@ public class AssignmentManager extends Z
                 " but region was not first in SPLITTING state; continuing");
           }
           // Check it has daughters.
-          byte [] payload = data.getPayload();
+          byte [] payload = rt.getPayload();
           List<HRegionInfo> daughters = null;
           try {
             daughters = Writables.getHRegionInfos(payload, 0, payload.length);
@@ -772,10 +782,9 @@ public class AssignmentManager extends Z
           break;
 
         case M_ZK_REGION_CLOSING:
-          hri = checkIfInFailover(regionState, encodedName, data);
+          hri = checkIfInFailover(regionState, encodedName, regionName);
           if (hri != null) {
-            regionState = new RegionState(hri, RegionState.State.CLOSING, data
-               .getStamp(), data.getOrigin());
+            regionState = new RegionState(hri, RegionState.State.CLOSING, createTime, sn);
             regionsInTransition.put(encodedName, regionState);
             failoverProcessedRegions.put(encodedName, hri);
             break;
@@ -785,21 +794,19 @@ public class AssignmentManager extends Z
           if (regionState == null ||
               (!regionState.isPendingClose() && !regionState.isClosing())) {
             LOG.warn("Received CLOSING for region " + prettyPrintedRegionName +
-              " from server " + data.getOrigin() + " but region was in " +
+              " from server " + sn + " but region was in " +
               " the state " + regionState + " and not " +
               "in expected PENDING_CLOSE or CLOSING states");
             return;
           }
           // Transition to CLOSING (or update stamp if already CLOSING)
-          regionState.update(RegionState.State.CLOSING,
-              data.getStamp(), data.getOrigin());
+          regionState.update(RegionState.State.CLOSING, createTime, sn);
           break;
 
         case RS_ZK_REGION_CLOSED:
-          hri = checkIfInFailover(regionState, encodedName, data);
+          hri = checkIfInFailover(regionState, encodedName, regionName);
           if (hri != null) {
-            regionState = new RegionState(hri, RegionState.State.CLOSED, data
-                .getStamp(), data.getOrigin());
+            regionState = new RegionState(hri, RegionState.State.CLOSED, createTime, sn);
             regionsInTransition.put(encodedName, regionState);
             removeClosedRegion(regionState.getRegion());
             new ClosedRegionHandler(master, this, regionState.getRegion())
@@ -811,7 +818,7 @@ public class AssignmentManager extends Z
           if (regionState == null ||
               (!regionState.isPendingClose() && !regionState.isClosing())) {
             LOG.warn("Received CLOSED for region " + prettyPrintedRegionName +
-                " from server " + data.getOrigin() + " but region was in " +
+                " from server " + sn + " but region was in " +
                 " the state " + regionState + " and not " +
                 "in expected PENDING_CLOSE or CLOSING states");
             return;
@@ -819,18 +826,16 @@ public class AssignmentManager extends Z
           // Handle CLOSED by assigning elsewhere or stopping if a disable
           // If we got here all is good.  Need to update RegionState -- else
           // what follows will fail because not in expected state.
-          regionState.update(RegionState.State.CLOSED,
-              data.getStamp(), data.getOrigin());
+          regionState.update(RegionState.State.CLOSED, createTime, sn);
           removeClosedRegion(regionState.getRegion());
           this.executorService.submit(new ClosedRegionHandler(master,
             this, regionState.getRegion()));
           break;
           
         case RS_ZK_REGION_FAILED_OPEN:
-          hri = checkIfInFailover(regionState, encodedName, data);
+          hri = checkIfInFailover(regionState, encodedName, regionName);
           if (hri != null) {
-            regionState = new RegionState(hri, RegionState.State.CLOSED, data
-                .getStamp(), data.getOrigin());
+            regionState = new RegionState(hri, RegionState.State.CLOSED, createTime, sn);
             regionsInTransition.put(encodedName, regionState);
             new ClosedRegionHandler(master, this, regionState.getRegion())
               .process();
@@ -840,22 +845,20 @@ public class AssignmentManager extends Z
           if (regionState == null ||
               (!regionState.isPendingOpen() && !regionState.isOpening())) {
             LOG.warn("Received FAILED_OPEN for region " + prettyPrintedRegionName +
-                " from server " + data.getOrigin() + " but region was in " +
+                " from server " + sn + " but region was in " +
                 " the state " + regionState + " and not in PENDING_OPEN or OPENING");
             return;
           }
           // Handle this the same as if it were opened and then closed.
-          regionState.update(RegionState.State.CLOSED,
-              data.getStamp(), data.getOrigin());
+          regionState.update(RegionState.State.CLOSED, createTime, sn);
           this.executorService.submit(new ClosedRegionHandler(master,
             this, regionState.getRegion()));
           break;
 
         case RS_ZK_REGION_OPENING:
-          hri = checkIfInFailover(regionState, encodedName, data);       
+          hri = checkIfInFailover(regionState, encodedName, regionName);
           if (hri != null) {
-            regionState = new RegionState(hri, RegionState.State.OPENING, data
-                .getStamp(), data.getOrigin());
+            regionState = new RegionState(hri, RegionState.State.OPENING, createTime, sn);
             regionsInTransition.put(encodedName, regionState);
             failoverProcessedRegions.put(encodedName, hri);
             break;
@@ -866,24 +869,21 @@ public class AssignmentManager extends Z
               (!regionState.isPendingOpen() && !regionState.isOpening())) {
             LOG.warn("Received OPENING for region " +
                 prettyPrintedRegionName +
-                " from server " + data.getOrigin() + " but region was in " +
+                " from server " + sn + " but region was in " +
                 " the state " + regionState + " and not " +
                 "in expected PENDING_OPEN or OPENING states");
             return;
           }
           // Transition to OPENING (or update stamp if already OPENING)
-          regionState.update(RegionState.State.OPENING,
-              data.getStamp(), data.getOrigin());
+          regionState.update(RegionState.State.OPENING, createTime, sn);
           break;
 
         case RS_ZK_REGION_OPENED:
-          hri = checkIfInFailover(regionState, encodedName, data);
+          hri = checkIfInFailover(regionState, encodedName, regionName);
           if (hri != null) {
-            regionState = new RegionState(hri, RegionState.State.OPEN, data
-                .getStamp(), data.getOrigin());
+            regionState = new RegionState(hri, RegionState.State.OPEN, createTime, sn);
             regionsInTransition.put(encodedName, regionState);
-            new OpenedRegionHandler(master, this, regionState.getRegion(), data
-              .getOrigin(), expectedVersion).process();
+            new OpenedRegionHandler(master, this, regionState.getRegion(), sn, expectedVersion).process();
             failoverProcessedRegions.put(encodedName, hri);
             break;
           }
@@ -892,17 +892,15 @@ public class AssignmentManager extends Z
               (!regionState.isPendingOpen() && !regionState.isOpening())) {
             LOG.warn("Received OPENED for region " +
                 prettyPrintedRegionName +
-                " from server " + data.getOrigin() + " but region was in " +
+                " from server " + sn + " but region was in " +
                 " the state " + regionState + " and not " +
                 "in expected PENDING_OPEN or OPENING states");
             return;
           }
           // Handle OPENED by removing from transition and deleted zk node
-          regionState.update(RegionState.State.OPEN,
-              data.getStamp(), data.getOrigin());
+          regionState.update(RegionState.State.OPEN, createTime, sn);
           this.executorService.submit(
-            new OpenedRegionHandler(master, this, regionState.getRegion(),
-              data.getOrigin(), expectedVersion));
+            new OpenedRegionHandler(master, this, regionState.getRegion(), sn, expectedVersion));
           break;
           
         default:
@@ -920,12 +918,12 @@ public class AssignmentManager extends Z
    * @return hri
    */
   private HRegionInfo checkIfInFailover(RegionState regionState,
-      String encodedName, RegionTransitionData data) {
+      String encodedName, final byte [] regionName) {
     if (regionState == null && this.failover &&
         (failoverProcessedRegions.containsKey(encodedName) == false ||
           failoverProcessedRegions.get(encodedName) == null)) {
       HRegionInfo hri = this.failoverProcessedRegions.get(encodedName);
-      if (hri == null) hri = getHRegionInfo(data);
+      if (hri == null) hri = getHRegionInfo(regionName);
       return hri;
     }
     return null;
@@ -933,18 +931,18 @@ public class AssignmentManager extends Z
   
   /**
    * Gets the HRegionInfo from the META table
-   * @param  data
+   * @param  regionName
    * @return HRegionInfo hri for the region 
    */
-  private HRegionInfo getHRegionInfo(RegionTransitionData data) {
+  private HRegionInfo getHRegionInfo(final byte [] regionName) {
     Pair<HRegionInfo, ServerName> p = null;
     try {
-      p = MetaReader.getRegion(catalogTracker, data.getRegionName());
+      p = MetaReader.getRegion(catalogTracker, regionName);
       if (p == null) return null;
       return p.getFirst();
     } catch (IOException e) {
-      master.abort("Aborting because error occoured while reading "
-          + Bytes.toStringBinary(data.getRegionName()) + " from .META.", e);
+      master.abort("Aborting because error occoured while reading " +
+        Bytes.toStringBinary(regionName) + " from .META.", e);
       return null;
     }
   }
@@ -1042,22 +1040,22 @@ public class AssignmentManager extends Z
    * Handle a ZK unassigned node transition triggered by HBCK repair tool.
    * <p>
    * This is handled in a separate code path because it breaks the normal rules.
-   * @param data
+   * @param rt
    */
-  private void handleHBCK(RegionTransitionData data) {
-    String encodedName = HRegionInfo.encodeRegionName(data.getRegionName());
-    LOG.info("Handling HBCK triggered transition=" + data.getEventType() +
-      ", server=" + data.getOrigin() + ", region=" +
+  private void handleHBCK(RegionTransition rt) {
+    String encodedName = HRegionInfo.encodeRegionName(rt.getRegionName());
+    LOG.info("Handling HBCK triggered transition=" + rt.getEventType() +
+      ", server=" + rt.getServerName() + ", region=" +
       HRegionInfo.prettyPrint(encodedName));
     RegionState regionState = regionsInTransition.get(encodedName);
-    switch (data.getEventType()) {
+    switch (rt.getEventType()) {
       case M_ZK_REGION_OFFLINE:
         HRegionInfo regionInfo = null;
         if (regionState != null) {
           regionInfo = regionState.getRegion();
         } else {
           try {
-            byte[] name = data.getRegionName();
+            byte [] name = rt.getRegionName();
             Pair<HRegionInfo, ServerName> p = MetaReader.getRegion(catalogTracker, name);
             regionInfo = p.getFirst();
           } catch (IOException e) {
@@ -1072,8 +1070,7 @@ public class AssignmentManager extends Z
         break;
 
       default:
-        LOG.warn("Received unexpected region state from HBCK (" +
-            data.getEventType() + ")");
+        LOG.warn("Received unexpected region state from HBCK: " + rt.toString());
         break;
     }
   }
@@ -1094,18 +1091,7 @@ public class AssignmentManager extends Z
    */
   @Override
   public void nodeCreated(String path) {
-    if(path.startsWith(watcher.assignmentZNode)) {
-      try {
-        Stat stat = new Stat();
-        RegionTransitionData data = ZKAssign.getDataAndWatch(watcher, path, stat);
-        if (data == null) {
-          return;
-        }
-        handleRegion(data, stat.getVersion());
-      } catch (KeeperException e) {
-        master.abort("Unexpected ZK exception reading unassigned node data", e);
-      }
-    }
+    handleAssignmentEvent(path);
   }
 
   /**
@@ -1122,17 +1108,21 @@ public class AssignmentManager extends Z
    */
   @Override
   public void nodeDataChanged(String path) {
-    if(path.startsWith(watcher.assignmentZNode)) {
-      try {
-        Stat stat = new Stat();
-        RegionTransitionData data = ZKAssign.getDataAndWatch(watcher, path, stat);
-        if (data == null) {
-          return;
-        }
-        handleRegion(data, stat.getVersion());
-      } catch (KeeperException e) {
-        master.abort("Unexpected ZK exception reading unassigned node data", e);
-      }
+    handleAssignmentEvent(path);
+  }
+
+  private void handleAssignmentEvent(final String path) {
+    if (!path.startsWith(watcher.assignmentZNode)) return;
+    try {
+      Stat stat = new Stat();
+      byte [] data = ZKAssign.getDataAndWatch(watcher, path, stat);
+      if (data == null) return;
+      RegionTransition rt = RegionTransition.parseFrom(data);
+      handleRegion(rt, stat.getVersion());
+    } catch (KeeperException e) {
+      master.abort("Unexpected ZK exception reading unassigned node data", e);
+    } catch (DeserializationException e) {
+      master.abort("Unexpected exception deserializing node data", e);
     }
   }
 
@@ -1983,7 +1973,8 @@ public class AssignmentManager extends Z
                 + "can't be created.");
             return;
           }
-        } catch (KeeperException e) {
+        } catch (KeeperException ee) {
+          Exception e = ee; 
           if (e instanceof NodeExistsException) {
             // Handle race between master initiated close and regionserver
             // orchestrated splitting. See if existing node is in a
@@ -2004,6 +1995,8 @@ public class AssignmentManager extends Z
               return;
             } catch (KeeperException ke) {
               LOG.error("Unexpected zk state", ke);
+            } catch (DeserializationException de) {
+              LOG.error("Failed parse", de);
             }
           }
           // If we get here, don't understand whats going on -- abort.
@@ -2125,14 +2118,17 @@ public class AssignmentManager extends Z
    * @param path
    * @return True if znode is in SPLIT or SPLITTING state.
    * @throws KeeperException Can happen if the znode went away in meantime.
+   * @throws DeserializationException 
    */
-  private boolean isSplitOrSplitting(final String path) throws KeeperException {
+  private boolean isSplitOrSplitting(final String path)
+  throws KeeperException, DeserializationException {
     boolean result = false;
     // This may fail if the SPLIT or SPLITTING znode gets cleaned up before we
     // can get data from it.
-    RegionTransitionData data = ZKAssign.getData(master.getZooKeeper(), path);
-    EventType evt = data.getEventType();
-    switch (evt) {
+    byte [] data = ZKAssign.getData(master.getZooKeeper(), path);
+    if (data == null) return false;
+    RegionTransition rt = RegionTransition.parseFrom(data);
+    switch (rt.getEventType()) {
     case RS_ZK_REGION_SPLIT:
     case RS_ZK_REGION_SPLITTING:
       result = true;
@@ -2659,53 +2655,67 @@ public class AssignmentManager extends Z
    * @throws KeeperException
    */
   private void processDeadServersAndRecoverLostRegions(
-      Map<ServerName, List<Pair<HRegionInfo, Result>>> deadServers,
-      List<String> nodes) throws IOException, KeeperException {
-    if (null != deadServers) {
-      for (Map.Entry<ServerName, List<Pair<HRegionInfo, Result>>> deadServer : 
-        deadServers.entrySet()) {
-        List<Pair<HRegionInfo, Result>> regions = deadServer.getValue();
-        for (Pair<HRegionInfo, Result> region : regions) {
-          HRegionInfo regionInfo = region.getFirst();
-          Result result = region.getSecond();
-          // If region was in transition (was in zk) force it offline for
-          // reassign
-          try {
-            RegionTransitionData data = ZKAssign.getData(watcher,
-                regionInfo.getEncodedName());
+      Map<ServerName, List<Pair<HRegionInfo, Result>>> deadServers, List<String> nodes)
+  throws IOException, KeeperException {
+    processDeadServers(deadServers, nodes);
+    if (!nodes.isEmpty()) {
+      for (String encodedRegionName : nodes) {
+        processRegionInTransition(encodedRegionName, null, deadServers);
+      }
+    }
+  }
+
+  private void processDeadServers(Map<ServerName, List<Pair<HRegionInfo, Result>>> deadServers,
+      final List<String> nodes)
+  throws KeeperException, IOException {
+    if (deadServers == null) return;
+    for (Map.Entry<ServerName, List<Pair<HRegionInfo, Result>>> deadServer: deadServers.entrySet()) {
+      List<Pair<HRegionInfo, Result>> regions = deadServer.getValue();
+      for (Pair<HRegionInfo, Result> region : regions) {
+        HRegionInfo regionInfo = region.getFirst();
+        Result result = region.getSecond();
+        try {
+          // If region was in transition (was in zk) force it offline for reassign.  Check if node
+          // up in zk at all first.
+          if (ZKUtil.checkExists(this.watcher,
+              ZKAssign.getPath(this.watcher, regionInfo.getEncodedName())) != -1) {
+            byte [] data = ZKAssign.getData(watcher, regionInfo.getEncodedName());
+            if (data == null) {
+              LOG.warn("No data in znode for " + regionInfo.getEncodedName());
+              continue;
+            }
+            RegionTransition rt;
+            try {
+              rt = RegionTransition.parseFrom(data);
+            } catch (DeserializationException e) {
+              LOG.warn("Failed parse of znode data for " + regionInfo.getEncodedName(), e);
+              continue;
+            }
 
             // If zk node of this region has been updated by a live server,
             // we consider that this region is being handled.
-            // So we should skip it and process it in
-            // processRegionsInTransition.
-            if (data != null && data.getOrigin() != null && 
-                serverManager.isServerOnline(data.getOrigin())) {
-              LOG.info("The region " + regionInfo.getEncodedName()
-                  + "is being handled on " + data.getOrigin());
+            // So we should skip it and process it in processRegionsInTransition.
+            ServerName sn = rt.getServerName();
+            if (isServerOnline(sn)) {
+              LOG.info("The region " + regionInfo.getEncodedName() + "is being handled on " + sn);
               continue;
             }
-            // Process with existing RS shutdown code
-            boolean assign = ServerShutdownHandler.processDeadRegion(
-                regionInfo, result, this, this.catalogTracker);
-            if (assign) {
-              ZKAssign.createOrForceNodeOffline(watcher, regionInfo,
-                  master.getServerName());
-              if (!nodes.contains(regionInfo.getEncodedName())) {
-                nodes.add(regionInfo.getEncodedName());
-              }
+          }
+          // Process with existing RS shutdown code
+          boolean assign = ServerShutdownHandler.processDeadRegion(
+              regionInfo, result, this, this.catalogTracker);
+          if (assign) {
+            ZKAssign.createOrForceNodeOffline(watcher, regionInfo,
+                master.getServerName());
+            if (!nodes.contains(regionInfo.getEncodedName())) {
+              nodes.add(regionInfo.getEncodedName());
             }
-          } catch (KeeperException.NoNodeException nne) {
-            // This is fine
           }
+        } catch (KeeperException.NoNodeException nne) {
+          // This is fine
         }
       }
     }
-
-    if (!nodes.isEmpty()) {
-      for (String encodedRegionName : nodes) {
-        processRegionInTransition(encodedRegionName, null, deadServers);
-      }
-    }
   }
 
   /*
@@ -2967,27 +2977,28 @@ public class AssignmentManager extends Z
     try {
       String node = ZKAssign.getNodeName(watcher, regionInfo.getEncodedName());
       Stat stat = new Stat();
-      RegionTransitionData dataInZNode = ZKAssign.getDataNoWatch(watcher, node,
-          stat);
-      if (dataInZNode == null) {
+      byte [] data = ZKAssign.getDataNoWatch(watcher, node, stat);
+      if (data == null) {
         LOG.warn("Data is null, node " + node + " no longer exists");
         return;
       }
-      if (dataInZNode.getEventType() == EventType.RS_ZK_REGION_OPENED) {
+      RegionTransition rt = RegionTransition.parseFrom(data);
+      EventType et = rt.getEventType();
+      if (et == EventType.RS_ZK_REGION_OPENED) {
         LOG.debug("Region has transitioned to OPENED, allowing "
             + "watched event handlers to process");
         return;
-      } else if (dataInZNode.getEventType() != EventType.RS_ZK_REGION_OPENING &&
-          dataInZNode.getEventType() != EventType.RS_ZK_REGION_FAILED_OPEN ) {
-        LOG.warn("While timing out a region in state OPENING, "
-            + "found ZK node in unexpected state: "
-            + dataInZNode.getEventType());
+      } else if (et != EventType.RS_ZK_REGION_OPENING && et != EventType.RS_ZK_REGION_FAILED_OPEN ) {
+        LOG.warn("While timing out a region, found ZK node in unexpected state: " + et);
         return;
       }
       invokeAssign(regionInfo);
     } catch (KeeperException ke) {
       LOG.error("Unexpected ZK exception timing out CLOSING region", ke);
       return;
+    } catch (DeserializationException e) {
+      LOG.error("Unexpected exception parsing CLOSING region", e);
+      return;
     }
     return;
   }
@@ -3019,16 +3030,18 @@ public class AssignmentManager extends Z
    * @return whether the serverName currently hosts the region
    */
   public boolean isCarryingRegion(ServerName serverName, HRegionInfo hri) {
-    RegionTransitionData data = null;
+    RegionTransition rt = null;
     try {
-      data = ZKAssign.getData(master.getZooKeeper(), hri.getEncodedName());
+      byte [] data = ZKAssign.getData(master.getZooKeeper(), hri.getEncodedName());
+      // This call can legitimately come by null
+      rt = data == null? null: RegionTransition.parseFrom(data);
     } catch (KeeperException e) {
-      master.abort("Unexpected ZK exception reading unassigned node for region="
-        + hri.getEncodedName(), e);
+      master.abort("Exception reading unassigned node for region=" + hri.getEncodedName(), e);
+    } catch (DeserializationException e) {
+      master.abort("Exception parsing unassigned node for region=" + hri.getEncodedName(), e);
     }
 
-    ServerName addressFromZK = (data != null && data.getOrigin() != null) ?
-      data.getOrigin() : null;
+    ServerName addressFromZK = rt != null? rt.getServerName():  null;
     if (addressFromZK != null) {
       // if we get something from ZK, we will use the data
       boolean matchZK = (addressFromZK != null &&
@@ -3048,6 +3061,7 @@ public class AssignmentManager extends Z
 
     return matchAM;
   }
+
   /**
    * Process shutdown server removing any assignments.
    * @param sn Server that went down.
@@ -3391,7 +3405,7 @@ public class AssignmentManager extends Z
    * @return True if online.
    */
   public boolean isServerOnline(ServerName serverName) {
-    return this.serverManager.isServerOnline(serverName);
+    return serverName != null && this.serverManager.isServerOnline(serverName);
   }
   /**
    * Shutdown the threadpool executor service

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/HMaster.java?rev=1333099&r1=1333098&r2=1333099&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/HMaster.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/HMaster.java Wed May  2 16:26:36 2012
@@ -49,6 +49,7 @@ import org.apache.hadoop.conf.Configurat
 import org.apache.hadoop.hbase.Abortable;
 import org.apache.hadoop.hbase.Chore;
 import org.apache.hadoop.hbase.ClusterStatus;
+import org.apache.hadoop.hbase.DeserializationException;
 import org.apache.hadoop.hbase.HColumnDescriptor;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HRegionInfo;
@@ -1427,7 +1428,7 @@ Server {
     List<String> backupMasterStrings;
     try {
       backupMasterStrings = ZKUtil.listChildrenNoWatch(this.zooKeeper,
-                              this.zooKeeper.backupMasterAddressesZNode);
+        this.zooKeeper.backupMasterAddressesZNode);
     } catch (KeeperException e) {
       LOG.warn(this.zooKeeper.prefix("Unable to list backup servers"), e);
       backupMasterStrings = new ArrayList<String>(0);
@@ -1436,9 +1437,17 @@ Server {
                                           backupMasterStrings.size());
     for (String s: backupMasterStrings) {
       try {
-        byte[] bytes = ZKUtil.getData(this.zooKeeper, ZKUtil.joinZNode(this.zooKeeper.backupMasterAddressesZNode, s));
+        byte [] bytes =
+            ZKUtil.getData(this.zooKeeper, ZKUtil.joinZNode(this.zooKeeper.backupMasterAddressesZNode, s));
         if (bytes != null) {
-          backupMasters.add(ZKUtil.znodeContentToServerName(bytes));
+          ServerName sn;
+          try {
+            sn = ServerName.parseFrom(bytes);
+          } catch (DeserializationException e) {
+            LOG.warn("Failed parse, skipping registering backup server", e);
+            continue;
+          }
+          backupMasters.add(sn);
         }
       } catch (KeeperException e) {
         LOG.warn(this.zooKeeper.prefix("Unable to get information about " +

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java?rev=1333099&r1=1333098&r2=1333099&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java Wed May  2 16:26:36 2012
@@ -104,7 +104,7 @@ public class MasterFileSystem {
       conf.getBoolean(HConstants.DISTRIBUTED_LOG_SPLITTING_KEY, true);
     if (this.distributedLogSplitting) {
       this.splitLogManager = new SplitLogManager(master.getZooKeeper(),
-          master.getConfiguration(), master, master.getServerName().toString());
+          master.getConfiguration(), master, master.getServerName());
       this.splitLogManager.finishInitialization();
     } else {
       this.splitLogManager = null;
@@ -250,11 +250,10 @@ public class MasterFileSystem {
   public void splitLog(final List<ServerName> serverNames) throws IOException {
     long splitTime = 0, splitLogSize = 0;
     List<Path> logDirs = new ArrayList<Path>();
-    for(ServerName serverName: serverNames){
-      Path logDir = new Path(this.rootdir,
-        HLog.getHLogDirectoryName(serverName.toString()));
+    for (ServerName serverName: serverNames) {
+      Path logDir = new Path(this.rootdir, HLog.getHLogDirectoryName(serverName.toString()));
       Path splitDir = logDir.suffix(HLog.SPLITTING_EXT);
-      // rename the directory so a rogue RS doesn't create more HLogs
+      // Rename the directory so a rogue RS doesn't create more HLogs
       if (fs.exists(logDir)) {
         if (!this.fs.rename(logDir, splitDir)) {
           throw new IOException("Failed fs.rename for log split: " + logDir);
@@ -272,7 +271,7 @@ public class MasterFileSystem {
       LOG.info("No logs to split");
       return;
     }
-      
+
     if (distributedLogSplitting) {
       splitLogManager.handleDeadWorkers(serverNames);
       splitTime = EnvironmentEdgeManager.currentTimeMillis();