@InterfaceAudience.Private public class RegionMergeTransactionImpl extends Object implements RegionMergeTransaction
Modifier and Type | Class and Description |
---|---|
static class |
RegionMergeTransactionImpl.JournalEntryImpl |
RegionMergeTransaction.JournalEntry, RegionMergeTransaction.RegionMergeTransactionPhase, RegionMergeTransaction.TransactionListener
Modifier and Type | Field and Description |
---|---|
private static IOException |
closedByOtherException |
private RegionMergeTransaction.RegionMergeTransactionPhase |
currentPhase |
private boolean |
forcible |
private List<RegionMergeTransaction.JournalEntry> |
journal |
private ArrayList<RegionMergeTransaction.TransactionListener> |
listeners |
private static org.apache.commons.logging.Log |
LOG |
private long |
masterSystemTime |
private HRegionInfo |
mergedRegionInfo |
private org.apache.hadoop.fs.Path |
mergesdir |
private HRegion |
region_a |
private HRegion |
region_b |
private RegionMergeCoordination.RegionMergeDetails |
rmd |
private RegionServerCoprocessorHost |
rsCoprocessorHost |
private RegionServerServices |
rsServices |
private Server |
server |
private boolean |
useCoordinationForAssignment |
Constructor and Description |
---|
RegionMergeTransactionImpl(Region a,
Region b,
boolean forcible)
Constructor
|
RegionMergeTransactionImpl(Region a,
Region b,
boolean forcible,
long masterSystemTime)
Constructor
|
Modifier and Type | Method and Description |
---|---|
private static Put |
addEmptyLocation(Put p,
int replicaId) |
Put |
addLocation(Put p,
ServerName sn,
long openSeqNum) |
private Map<byte[],List<StoreFile>> |
closeAndOfflineRegion(RegionServerServices services,
HRegion region,
boolean isRegionA,
boolean testing)
Close the merging region and offline it in regionserver
|
(package private) HRegion |
createMergedRegion(Server server,
RegionServerServices services,
User user)
Prepare the merged region and region files.
|
(package private) HRegion |
createMergedRegionFromMerges(HRegion a,
HRegion b,
HRegionInfo mergedRegion)
Create a merged region from the merges directory under region a.
|
HRegion |
execute(Server server,
RegionServerServices services)
Run the transaction.
|
HRegion |
execute(Server server,
RegionServerServices services,
User user)
Run the transaction.
|
List<RegionMergeTransaction.JournalEntry> |
getJournal()
Get the journal for the transaction.
|
HRegionInfo |
getMergedRegionInfo() |
static HRegionInfo |
getMergedRegionInfo(HRegionInfo a,
HRegionInfo b)
Get merged region info through the specified two regions
|
(package private) org.apache.hadoop.fs.Path |
getMergesDir() |
RegionServerServices |
getRegionServerServices()
Get the RegonServerServices of the server running the transaction or rollback
|
Server |
getServer()
Get the Server running the transaction or rollback
|
(package private) boolean |
hasMergeQualifierInMeta(RegionServerServices services,
byte[] regionName)
Checks if the given region has merge qualifier in hbase:meta
|
private void |
mergeRegionsAndPutMetaEntries(HConnection hConnection,
HRegionInfo mergedRegion,
HRegionInfo regionA,
HRegionInfo regionB,
ServerName serverName,
List<Mutation> metaEntries,
int regionReplication) |
private void |
mergeStoreFiles(Map<byte[],List<StoreFile>> hstoreFilesOfRegionA,
Map<byte[],List<StoreFile>> hstoreFilesOfRegionB)
Create reference file(s) of merging regions under the region_a merges dir
|
(package private) void |
openMergedRegion(Server server,
RegionServerServices services,
HRegion merged)
Perform time consuming opening of the merged region.
|
boolean |
prepare(RegionServerServices services)
Does checks on merge inputs.
|
void |
prepareMutationsForMerge(HRegionInfo mergedRegion,
HRegionInfo regionA,
HRegionInfo regionB,
ServerName serverName,
List<Mutation> mutations,
int regionReplication) |
RegionMergeTransaction |
registerTransactionListener(RegionMergeTransaction.TransactionListener listener)
Register a listener for transaction preparation, execution, and possibly
rollback phases.
|
boolean |
rollback(Server server,
RegionServerServices services)
Roll back a failed transaction
|
boolean |
rollback(Server server,
RegionServerServices services,
User user)
Roll back a failed transaction
|
void |
stepsAfterPONR(Server server,
RegionServerServices services,
HRegion mergedRegion)
Deprecated.
|
void |
stepsAfterPONR(Server server,
RegionServerServices services,
HRegion mergedRegion,
User user) |
HRegion |
stepsBeforePONR(Server server,
RegionServerServices services,
boolean testing) |
private void |
transition(RegionMergeTransaction.RegionMergeTransactionPhase nextPhase) |
private void |
transition(RegionMergeTransaction.RegionMergeTransactionPhase nextPhase,
boolean isRollback) |
private boolean |
useCoordination(Server server) |
private static final org.apache.commons.logging.Log LOG
private HRegionInfo mergedRegionInfo
private final HRegion region_a
private final HRegion region_b
private final org.apache.hadoop.fs.Path mergesdir
private final boolean forcible
private boolean useCoordinationForAssignment
private final long masterSystemTime
private RegionMergeTransaction.RegionMergeTransactionPhase currentPhase
private Server server
private RegionServerServices rsServices
private final List<RegionMergeTransaction.JournalEntry> journal
private final ArrayList<RegionMergeTransaction.TransactionListener> listeners
private static IOException closedByOtherException
private RegionServerCoprocessorHost rsCoprocessorHost
private RegionMergeCoordination.RegionMergeDetails rmd
public RegionMergeTransactionImpl(Region a, Region b, boolean forcible)
a
- region a to mergeb
- region b to mergeforcible
- if false, we will only merge adjacent regionsprivate void transition(RegionMergeTransaction.RegionMergeTransactionPhase nextPhase) throws IOException
IOException
private void transition(RegionMergeTransaction.RegionMergeTransactionPhase nextPhase, boolean isRollback) throws IOException
IOException
public boolean prepare(RegionServerServices services) throws IOException
prepare
in interface RegionMergeTransaction
services
- true
if the regions are mergeable else
false
if they are not (e.g. its already closed, etc.).IOException
public HRegion execute(Server server, RegionServerServices services) throws IOException
execute
in interface RegionMergeTransaction
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 execute(Server server, RegionServerServices services, User user) throws IOException
RegionMergeTransaction
execute
in interface RegionMergeTransaction
server
- Hosting server instance. Can be null when testingservices
- Used to online/offline regions.IOException
- If thrown, transaction failed. Call
RegionMergeTransaction.rollback(Server, RegionServerServices)
RegionMergeTransaction.rollback(Server, RegionServerServices, User)
@Deprecated public void stepsAfterPONR(Server server, RegionServerServices services, HRegion mergedRegion) throws IOException
IOException
public void stepsAfterPONR(Server server, RegionServerServices services, HRegion mergedRegion, User user) throws IOException
IOException
HRegion createMergedRegion(Server server, RegionServerServices services, User user) 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)
private void mergeRegionsAndPutMetaEntries(HConnection hConnection, HRegionInfo mergedRegion, HRegionInfo regionA, HRegionInfo regionB, ServerName serverName, List<Mutation> metaEntries, int regionReplication) throws IOException
IOException
public void prepareMutationsForMerge(HRegionInfo mergedRegion, HRegionInfo regionA, HRegionInfo regionB, ServerName serverName, List<Mutation> mutations, int regionReplication) throws IOException
IOException
public Put addLocation(Put p, ServerName sn, long openSeqNum)
public HRegion stepsBeforePONR(Server server, RegionServerServices services, boolean testing) throws IOException
IOException
HRegion createMergedRegionFromMerges(HRegion a, HRegion b, HRegionInfo mergedRegion) throws IOException
a
- hri of region ab
- hri of region bmergedRegion
- hri of merged regionIOException
private Map<byte[],List<StoreFile>> closeAndOfflineRegion(RegionServerServices services, HRegion region, boolean isRegionA, boolean testing) throws IOException
services
- region
- isRegionA
- true if it is merging region a, false if it is region btesting
- true if it is testingIOException
public static HRegionInfo getMergedRegionInfo(HRegionInfo a, HRegionInfo b)
a
- merging region Ab
- merging region Bvoid openMergedRegion(Server server, RegionServerServices services, HRegion merged) throws IOException
server
- Hosting server instance. Can be null when testingservices
- Used to online/offline regions.merged
- the merged regionIOException
- If thrown, transaction failed. Call
rollback(Server, RegionServerServices)
private void mergeStoreFiles(Map<byte[],List<StoreFile>> hstoreFilesOfRegionA, Map<byte[],List<StoreFile>> hstoreFilesOfRegionB) throws IOException
hstoreFilesOfRegionA
- hstoreFilesOfRegionB
- IOException
public boolean rollback(Server server, RegionServerServices services) throws IOException
RegionMergeTransaction
rollback
in interface RegionMergeTransaction
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.public boolean rollback(Server server, RegionServerServices services, User user) throws IOException
RegionMergeTransaction
rollback
in interface RegionMergeTransaction
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.public HRegionInfo getMergedRegionInfo()
getMergedRegionInfo
in interface RegionMergeTransaction
org.apache.hadoop.fs.Path getMergesDir()
private boolean useCoordination(Server server)
boolean hasMergeQualifierInMeta(RegionServerServices services, byte[] regionName) throws IOException
services
- regionName
- name of specified regionIOException
public List<RegionMergeTransaction.JournalEntry> getJournal()
RegionMergeTransaction
Journal entries are an opaque type represented as JournalEntry. They can also provide useful debugging information via their toString method.
getJournal
in interface RegionMergeTransaction
public RegionMergeTransaction registerTransactionListener(RegionMergeTransaction.TransactionListener listener)
RegionMergeTransaction
A listener can abort a transaction by throwing an exception.
registerTransactionListener
in interface RegionMergeTransaction
listener
- the listenerpublic Server getServer()
RegionMergeTransaction
getServer
in interface RegionMergeTransaction
public RegionServerServices getRegionServerServices()
RegionMergeTransaction
getRegionServerServices
in interface RegionMergeTransaction
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.