@InterfaceAudience.LimitedPrivate(value="Coprocesssor") @InterfaceStability.Evolving public interface SplitTransaction
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 interface:
SplitTransactionFactory factory = new SplitTransactionFactory(conf); SplitTransaction st = factory.create(parent, midKey) .registerTransactionListener(new TransactionListener() { public void transition(SplitTransaction transaction, SplitTransactionPhase from, SplitTransactionPhase to) throws IOException { // ... } public void rollback(SplitTransaction transaction, SplitTransactionPhase from, SplitTransactionPhase to) { // ... } }); if (!st.prepare()) return; try { st.execute(server, services); } catch (IOException e) { try { st.rollback(server, services); return; } catch (RuntimeException e) { // abort the server } }
A split transaction is not thread safe. Callers must ensure a split is run by one thread only.
Modifier and Type | Interface and Description |
---|---|
static interface |
SplitTransaction.JournalEntry
Split transaction journal entry
|
static class |
SplitTransaction.SplitTransactionPhase
Each enum is a step in the split transaction.
|
static interface |
SplitTransaction.TransactionListener
Split transaction listener
|
Modifier and Type | Method and Description |
---|---|
PairOfSameType<Region> |
execute(Server server,
RegionServerServices services)
Deprecated.
use #execute(Server, RegionServerServices, User)
|
PairOfSameType<Region> |
execute(Server server,
RegionServerServices services,
User user)
Run the transaction.
|
List<SplitTransaction.JournalEntry> |
getJournal()
Get the journal for the transaction.
|
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()
Check split inputs and prepare the transaction.
|
SplitTransaction |
registerTransactionListener(SplitTransaction.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() throws IOException
true
if the region is splittable else
false
if it is not (e.g. its already closed, etc.).IOException
@Deprecated PairOfSameType<Region> execute(Server server, RegionServerServices services) throws IOException
server
- Hosting server instance. Can be null when testing.services
- Used to online/offline regions.IOException
- If thrown, transaction failed.
Call rollback(Server, RegionServerServices)
IOException
rollback(Server, RegionServerServices)
PairOfSameType<Region> execute(Server server, RegionServerServices services, User user) throws IOException
server
- Hosting server instance. Can be null when testing.services
- Used to online/offline regions.user
- IOException
- If thrown, transaction failed.
Call rollback(Server, RegionServerServices)
IOException
rollback(Server, RegionServerServices)
@Deprecated boolean rollback(Server server, RegionServerServices services) throws IOException
server
- Hosting server instance (May be null when testing).services
- 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
- user
- IOException
- If thrown, rollback failed. Take drastic action.SplitTransaction registerTransactionListener(SplitTransaction.TransactionListener listener)
A listener can abort a transaction by throwing an exception.
listener
- the listenerList<SplitTransaction.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()
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.