@InterfaceAudience.LimitedPrivate(value="Coprocesssor") @InterfaceStability.Evolving public interface RegionMergeTransaction
prepare(RegionServerServices)
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 interface:
RegionMergeTransactionFactory factory = new RegionMergeTransactionFactory(conf); RegionMergeTransaction mt = factory.create(parent, midKey) .registerTransactionListener(new TransactionListener() { public void transition(RegionMergeTransaction transaction, RegionMergeTransactionPhase from, RegionMergeTransactionPhase to) throws IOException { // ... } public void rollback(RegionMergeTransaction transaction, RegionMergeTransactionPhase from, RegionMergeTransactionPhase to) { // ... } }); if (!mt.prepare()) return; try { mt.execute(server, services); } catch (IOException ioe) { try { mt.rollback(server, services); return; } catch (RuntimeException e) { // abort the server } }
A merge transaction is not thread safe. Callers must ensure a split is run by one thread only.
Modifier and Type | Interface and Description |
---|---|
static interface |
RegionMergeTransaction.JournalEntry
Split transaction journal entry
|
static class |
RegionMergeTransaction.RegionMergeTransactionPhase
Each enum is a step in the merge transaction.
|
static interface |
RegionMergeTransaction.TransactionListener
Split transaction listener
|
Modifier and Type | Method and Description |
---|---|
Region |
execute(Server server,
RegionServerServices services)
Deprecated.
use #execute(Server, RegionServerServices, User)
|
Region |
execute(Server server,
RegionServerServices services,
User user)
Run the transaction.
|
List<RegionMergeTransaction.JournalEntry> |
getJournal()
Get the journal for the transaction.
|
HRegionInfo |
getMergedRegionInfo() |
RegionServerServices |
getRegionServerServices()
Get the RegonServerServices of the server running the transaction or rollback
|
Server |
getServer()
Get the Server running the transaction or rollback
|
boolean |
prepare(RegionServerServices services)
Check merge inputs and prepare the transaction.
|
RegionMergeTransaction |
registerTransactionListener(RegionMergeTransaction.TransactionListener listener)
Register a listener for transaction preparation, execution, and possibly
rollback phases.
|
boolean |
rollback(Server server,
RegionServerServices services)
Deprecated.
use #rollback(Server, RegionServerServices, User)
|
boolean |
rollback(Server server,
RegionServerServices services,
User user)
Roll back a failed transaction
|
boolean prepare(RegionServerServices services) throws IOException
services
- true
if the regions are mergeable else
false
if they are not (e.g. its already closed, etc.).IOException
@Deprecated Region execute(Server server, RegionServerServices services) throws IOException
server
- Hosting server instance. Can be null when testingservices
- Used to online/offline regions.IOException
- If thrown, transaction failed. Call
rollback(Server, RegionServerServices)
IOException
rollback(Server, RegionServerServices)
Region execute(Server server, RegionServerServices services, User user) throws IOException
server
- Hosting server instance. Can be null when testingservices
- Used to online/offline regions.user
- IOException
- If thrown, transaction failed. Call
rollback(Server, RegionServerServices)
IOException
rollback(Server, RegionServerServices, User)
@Deprecated boolean rollback(Server server, RegionServerServices services) throws IOException
server
- Hosting server instance (May be null when testing).services
- Services of regionserver, used to online regions.IOException
- If thrown, rollback failed. Take drastic action.boolean rollback(Server server, RegionServerServices services, User user) throws IOException
server
- Hosting server instance (May be null when testing).services
- Services of regionserver, used to online regions.user
- IOException
- If thrown, rollback failed. Take drastic action.RegionMergeTransaction registerTransactionListener(RegionMergeTransaction.TransactionListener listener)
A listener can abort a transaction by throwing an exception.
listener
- the listenerHRegionInfo getMergedRegionInfo()
List<RegionMergeTransaction.JournalEntry> getJournal()
Journal entries are an opaque type represented as JournalEntry. They can also provide useful debugging information via their toString method.
Server getServer()
RegionServerServices getRegionServerServices()