@InterfaceAudience.Private public class RegionMergeTransaction extends Object
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 class:
RegionMergeTransaction mt = new RegionMergeTransaction(this.conf, parent, midKey) if (!mt.prepare(services)) return; try { mt.execute(server, services); } catch (IOException ioe) { try { mt.rollback(server, services); return; } catch (RuntimeException e) { myAbortable.abort("Failed merge, abort"); } }
This class is not thread safe. Caller needs ensure merge is run by one thread only.
Constructor and Description |
---|
RegionMergeTransaction(HRegion a,
HRegion b,
boolean forcible)
Constructor
|
Modifier and Type | Method and Description |
---|---|
Put |
addLocation(Put p,
ServerName sn,
long openSeqNum) |
HRegion |
execute(Server server,
RegionServerServices services)
Run the transaction.
|
static HRegionInfo |
getMergedRegionInfo(HRegionInfo a,
HRegionInfo b)
Get merged region info through the specified two regions
|
boolean |
prepare(RegionServerServices services)
Does checks on merge inputs.
|
void |
prepareMutationsForMerge(HRegionInfo mergedRegion,
HRegionInfo regionA,
HRegionInfo regionB,
ServerName serverName,
List<Mutation> mutations) |
boolean |
rollback(Server server,
RegionServerServices services) |
HRegion |
stepsAfterPONR(Server server,
RegionServerServices services,
HRegion mergedRegion) |
HRegion |
stepsBeforePONR(Server server,
RegionServerServices services,
boolean testing) |
public boolean prepare(RegionServerServices services)
services
- true
if the regions are mergeable else
false
if they are not (e.g. its already closed, etc.).public HRegion 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)
public HRegion stepsAfterPONR(Server server, RegionServerServices services, HRegion mergedRegion) throws IOException
IOException
public void prepareMutationsForMerge(HRegionInfo mergedRegion, HRegionInfo regionA, HRegionInfo regionB, ServerName serverName, List<Mutation> mutations) throws IOException
IOException
public Put addLocation(Put p, ServerName sn, long openSeqNum)
public HRegion stepsBeforePONR(Server server, RegionServerServices services, boolean testing) throws IOException
IOException
public static HRegionInfo getMergedRegionInfo(HRegionInfo a, HRegionInfo b)
a
- merging region Ab
- merging region Bpublic 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.Copyright © 2015 The Apache Software Foundation. All Rights Reserved.