|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.hadoop.hbase.regionserver.SplitTransaction
@InterfaceAudience.Private public class SplitTransaction
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 | |
---|---|
Put |
addLocation(Put p,
ServerName sn,
long openSeqNum)
|
static void |
createNodeSplitting(ZooKeeperWatcher zkw,
HRegionInfo region,
ServerName serverName,
HRegionInfo a,
HRegionInfo b)
Creates a new ephemeral node in the PENDING_SPLIT state for the specified region. |
PairOfSameType<HRegion> |
execute(Server server,
RegionServerServices services)
|
PairOfSameType<HRegion> |
execute(Server server,
RegionServerServices services,
User user)
Run the transaction. |
boolean |
prepare()
Does checks on split inputs. |
boolean |
rollback(Server server,
RegionServerServices services)
|
boolean |
rollback(Server server,
RegionServerServices services,
User user)
|
PairOfSameType<HRegion> |
stepsAfterPONR(Server server,
RegionServerServices services,
PairOfSameType<HRegion> regions)
Deprecated. |
PairOfSameType<HRegion> |
stepsAfterPONR(Server server,
RegionServerServices services,
PairOfSameType<HRegion> regions,
User user)
|
PairOfSameType<HRegion> |
stepsBeforePONR(Server server,
RegionServerServices services,
boolean testing)
|
static int |
transitionSplittingNode(ZooKeeperWatcher zkw,
HRegionInfo parent,
HRegionInfo a,
HRegionInfo b,
ServerName serverName,
int znodeVersion,
EventType beginState,
EventType endState)
Transitions an existing ephemeral node for the specified region which is currently in the begin state to be in the end state. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SplitTransaction(HRegion r, byte[] splitrow)
r
- Region to splitsplitrow
- Row to split aroundMethod Detail |
---|
public boolean prepare()
true
if the region is splittable else
false
if it is not (e.g. its already closed, etc.).public PairOfSameType<HRegion> stepsBeforePONR(Server server, RegionServerServices services, boolean testing) throws IOException
IOException
public PairOfSameType<HRegion> execute(Server server, RegionServerServices services) throws IOException
IOException
public PairOfSameType<HRegion> execute(Server server, RegionServerServices services, User user) throws IOException
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.
IOException
- If thrown, transaction failed.
Call rollback(Server, RegionServerServices)
IOException
rollback(Server, RegionServerServices)
@Deprecated public PairOfSameType<HRegion> stepsAfterPONR(Server server, RegionServerServices services, PairOfSameType<HRegion> regions) throws IOException
IOException
public PairOfSameType<HRegion> stepsAfterPONR(Server server, RegionServerServices services, PairOfSameType<HRegion> regions, User user) throws IOException
IOException
public Put addLocation(Put p, ServerName sn, long openSeqNum)
public boolean rollback(Server server, RegionServerServices services) throws IOException
IOException
public boolean rollback(Server server, RegionServerServices services, User user) throws IOException
server
- Hosting server instance (May be null when testing).services
-
IOException
- If thrown, rollback failed. Take drastic action.public static void createNodeSplitting(ZooKeeperWatcher zkw, HRegionInfo region, ServerName serverName, HRegionInfo a, HRegionInfo b) throws org.apache.zookeeper.KeeperException, IOException
Does not transition nodes from other states. If a node already exists
for this region, a KeeperException.NodeExistsException
will be thrown.
zkw
- zk referenceregion
- region to be created as offlineserverName
- server event originates from
org.apache.zookeeper.KeeperException
IOException
public static int transitionSplittingNode(ZooKeeperWatcher zkw, HRegionInfo parent, HRegionInfo a, HRegionInfo b, ServerName serverName, int znodeVersion, EventType beginState, EventType endState) throws org.apache.zookeeper.KeeperException, IOException
Does not transition nodes from other states. If for some reason the node could not be transitioned, the method returns -1. If the transition is successful, the version of the node after transition is returned.
This method can fail and return false for three different reasons:
Does not set any watches.
This method should only be used by a RegionServer when splitting a region.
zkw
- zk referenceparent
- region to be transitioned to openeda
- Daughter a of splitb
- Daughter b of splitserverName
- server event originates fromznodeVersion
- expected version of data before modificationbeginState
- the expected current state the znode should beendState
- the state to be transition to
org.apache.zookeeper.KeeperException
- if unexpected zookeeper exception
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |