org.apache.hadoop.hbase.regionserver
Class SplitTransaction

java.lang.Object
  extended by org.apache.hadoop.hbase.regionserver.SplitTransaction

public class SplitTransaction
extends Object

Executes region split as a "transaction". Call prepare() to setup the transaction, execute(Server, RegionServerServices) to run the transaction and rollback(Server, RegionServerServices) to cleanup if execute fails.

Here is an example of how you would use this class:

  SplitTransaction st = new SplitTransaction(this.conf, parent, midKey)
  if (!st.prepare()) return;
  try {
    st.execute(server, services);
  } catch (IOException ioe) {
    try {
      st.rollback(server, services);
      return;
    } catch (RuntimeException e) {
      myAbortable.abort("Failed split, abort");
    }
  }
 

This class is not thread safe. Caller needs ensure split is run by one thread only.


Constructor Summary
SplitTransaction(HRegion r, byte[] splitrow)
          Constructor
 
Method Summary
 PairOfSameType<HRegion> execute(Server server, RegionServerServices services)
          Run the transaction.
 boolean prepare()
          Does checks on split inputs.
 boolean rollback(Server server, RegionServerServices services)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SplitTransaction

public SplitTransaction(HRegion r,
                        byte[] splitrow)
Constructor

Parameters:
r - Region to split
splitrow - Row to split around
Method Detail

prepare

public boolean prepare()
Does checks on split inputs.

Returns:
true if the region is splittable else false if it is not (e.g. its already closed, etc.).

execute

public PairOfSameType<HRegion> execute(Server server,
                                       RegionServerServices services)
                                throws IOException
Run the transaction.

Parameters:
server - Hosting server instance. Can be null when testing (won't try and update in zk if a null server)
services - Used to online/offline regions.
Returns:
Regions created
Throws:
IOException - If thrown, transaction failed. Call rollback(Server, RegionServerServices)
IOException
See Also:
rollback(Server, RegionServerServices)

rollback

public boolean rollback(Server server,
                        RegionServerServices services)
                 throws IOException
Parameters:
server - Hosting server instance (May be null when testing).
services -
Returns:
True if we successfully rolled back, false if we got to the point of no return and so now need to abort the server to minimize damage.
Throws:
IOException - If thrown, rollback failed. Take drastic action.


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