org.apache.hadoop.hbase.executor
Class RegionTransitionData

java.lang.Object
  extended by org.apache.hadoop.hbase.executor.RegionTransitionData
All Implemented Interfaces:
org.apache.hadoop.io.Writable

public class RegionTransitionData
extends Object
implements org.apache.hadoop.io.Writable

Data serialized into ZooKeeper for region transitions.


Constructor Summary
RegionTransitionData()
          Writable constructor.
RegionTransitionData(EventHandler.EventType eventType, byte[] regionName)
          Construct data for a new region transition event with the specified event type and region name.
RegionTransitionData(EventHandler.EventType eventType, byte[] regionName, String serverName)
          Construct data for a new region transition event with the specified event type, region name, and server name.
 
Method Summary
static RegionTransitionData fromBytes(byte[] bytes)
          Get an instance from bytes.
 byte[] getBytes()
          Get the bytes for this instance.
 EventHandler.EventType getEventType()
          Gets the type of region transition event.
 byte[] getRegionName()
          Gets the name of the region being transitioned.
 String getServerName()
          Gets the server the event originated from.
 long getStamp()
          Gets the timestamp when this event was created.
 void readFields(DataInput in)
           
 String toString()
           
 void write(DataOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RegionTransitionData

public RegionTransitionData()
Writable constructor. Do not use directly.


RegionTransitionData

public RegionTransitionData(EventHandler.EventType eventType,
                            byte[] regionName)
Construct data for a new region transition event with the specified event type and region name.

Used when the server name is not known (the master is setting it). This happens during cluster startup or during failure scenarios. When processing a failed regionserver, the master assigns the regions from that server to other servers though the region was never 'closed'. During master failover, the new master may have regions stuck in transition without a destination so may have to set regions offline and generate a new assignment.

Since only the master uses this constructor, the type should always be EventHandler.EventType.M_ZK_REGION_OFFLINE.

Parameters:
eventType - type of event
regionName - name of region as per HRegionInfo#getRegionName()

RegionTransitionData

public RegionTransitionData(EventHandler.EventType eventType,
                            byte[] regionName,
                            String serverName)
Construct data for a new region transition event with the specified event type, region name, and server name.

Used when the server name is known (a regionserver is setting it).

Valid types for this constructor are EventHandler.EventType.RS_ZK_REGION_CLOSING, EventHandler.EventType.RS_ZK_REGION_CLOSED, EventHandler.EventType.RS_ZK_REGION_OPENING, and EventHandler.EventType.RS_ZK_REGION_OPENED.

Parameters:
eventType - type of event
regionName - name of region as per HRegionInfo#getRegionName()
serverName - name of server setting data
Method Detail

getEventType

public EventHandler.EventType getEventType()
Gets the type of region transition event.

One of:

Returns:
type of region transition event

getRegionName

public byte[] getRegionName()
Gets the name of the region being transitioned.

Region name is required so this never returns null.

Returns:
region name, the result of a call to HRegionInfo#getRegionName()

getServerName

public String getServerName()
Gets the server the event originated from. If null, this event originated from the master.

Returns:
server name of originating regionserver, or null if from master

getStamp

public long getStamp()
Gets the timestamp when this event was created.

Returns:
stamp event was created

readFields

public void readFields(DataInput in)
                throws IOException
Specified by:
readFields in interface org.apache.hadoop.io.Writable
Throws:
IOException

write

public void write(DataOutput out)
           throws IOException
Specified by:
write in interface org.apache.hadoop.io.Writable
Throws:
IOException

getBytes

public byte[] getBytes()
Get the bytes for this instance. Throws a RuntimeException if there is an error deserializing this instance because it represents a code bug.

Returns:
binary representation of this instance

fromBytes

public static RegionTransitionData fromBytes(byte[] bytes)
Get an instance from bytes. Throws a RuntimeException if there is an error serializing this instance from bytes because it represents a code bug.

Parameters:
bytes - binary representation of this instance
Returns:
instance of this class

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2011 The Apache Software Foundation. All Rights Reserved.