org.apache.hadoop.hbase.replication.regionserver
Class Replication

java.lang.Object
  extended by org.apache.hadoop.hbase.replication.regionserver.Replication
All Implemented Interfaces:
ReplicationService, ReplicationSinkService, ReplicationSourceService, WALActionsListener

@InterfaceAudience.Private
public class Replication
extends Object
implements WALActionsListener, ReplicationSourceService, ReplicationSinkService

Gateway to Replication. Used by HRegionServer.


Constructor Summary
Replication()
          Empty constructor
Replication(Server server, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path logDir, org.apache.hadoop.fs.Path oldLogDir)
          Instantiate the replication management (if rep is enabled).
 
Method Summary
static void decorateMasterConfiguration(org.apache.hadoop.conf.Configuration conf)
          This method modifies the master's configuration in order to inject replication-related features
 ReplicationSourceManager getReplicationManager()
          Get the replication sources manager
 WALActionsListener getWALActionsListener()
          Returns a WALObserver for the service.
 void initialize(Server server, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path logDir, org.apache.hadoop.fs.Path oldLogDir)
          Initializes the replication service object.
static boolean isReplication(org.apache.hadoop.conf.Configuration c)
           
 void join()
          Join with the replication threads
 void logCloseRequested()
          The WAL is about to close.
 void logRollRequested(boolean tooFewReplicas)
          A request was made that the WAL be rolled.
 void postLogArchive(org.apache.hadoop.fs.Path oldPath, org.apache.hadoop.fs.Path newPath)
          The WAL has been archived.
 void postLogRoll(org.apache.hadoop.fs.Path oldPath, org.apache.hadoop.fs.Path newPath)
          The WAL has been rolled.
 void preLogArchive(org.apache.hadoop.fs.Path oldPath, org.apache.hadoop.fs.Path newPath)
          The WAL is going to be archived.
 void preLogRoll(org.apache.hadoop.fs.Path oldPath, org.apache.hadoop.fs.Path newPath)
          The WAL is going to be rolled.
 ReplicationLoad refreshAndGetReplicationLoad()
          Refresh and Get ReplicationLoad
 void replicateLogEntries(List<AdminProtos.WALEntry> entries, CellScanner cells)
          Carry on the list of log entries down to the sink
static void scopeWALEdits(HTableDescriptor htd, HLogKey logKey, WALEdit logEdit)
          Utility method used to set the correct scopes on each log key.
 void startReplicationService()
          If replication is enabled and this cluster is a master, it starts
 void stopReplicationService()
          Stops replication service.
 void visitLogEntryBeforeWrite(HRegionInfo info, HLogKey logKey, WALEdit logEdit)
          Called before each write.
 void visitLogEntryBeforeWrite(HTableDescriptor htd, HLogKey logKey, WALEdit logEdit)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Replication

public Replication(Server server,
                   org.apache.hadoop.fs.FileSystem fs,
                   org.apache.hadoop.fs.Path logDir,
                   org.apache.hadoop.fs.Path oldLogDir)
            throws IOException
Instantiate the replication management (if rep is enabled).

Parameters:
server - Hosting server
fs - handle to the filesystem
logDir -
oldLogDir - directory where logs are archived
Throws:
IOException

Replication

public Replication()
Empty constructor

Method Detail

initialize

public void initialize(Server server,
                       org.apache.hadoop.fs.FileSystem fs,
                       org.apache.hadoop.fs.Path logDir,
                       org.apache.hadoop.fs.Path oldLogDir)
                throws IOException
Description copied from interface: ReplicationService
Initializes the replication service object.

Specified by:
initialize in interface ReplicationService
Throws:
IOException

isReplication

public static boolean isReplication(org.apache.hadoop.conf.Configuration c)
Parameters:
c - Configuration to look at
Returns:
True if replication is enabled.

getWALActionsListener

public WALActionsListener getWALActionsListener()
Description copied from interface: ReplicationSourceService
Returns a WALObserver for the service. This is needed to observe log rolls and log archival events.

Specified by:
getWALActionsListener in interface ReplicationSourceService

stopReplicationService

public void stopReplicationService()
Stops replication service.

Specified by:
stopReplicationService in interface ReplicationService

join

public void join()
Join with the replication threads


replicateLogEntries

public void replicateLogEntries(List<AdminProtos.WALEntry> entries,
                                CellScanner cells)
                         throws IOException
Carry on the list of log entries down to the sink

Specified by:
replicateLogEntries in interface ReplicationSinkService
Parameters:
entries - list of entries to replicate
cells - The data -- the cells -- that entries describes (the entries do not contain the Cells we are replicating; they are passed here on the side in this CellScanner).
Throws:
IOException

startReplicationService

public void startReplicationService()
                             throws IOException
If replication is enabled and this cluster is a master, it starts

Specified by:
startReplicationService in interface ReplicationService
Throws:
IOException

getReplicationManager

public ReplicationSourceManager getReplicationManager()
Get the replication sources manager

Returns:
the manager if replication is enabled, else returns false

visitLogEntryBeforeWrite

public void visitLogEntryBeforeWrite(HRegionInfo info,
                                     HLogKey logKey,
                                     WALEdit logEdit)
Description copied from interface: WALActionsListener
Called before each write.

Specified by:
visitLogEntryBeforeWrite in interface WALActionsListener

visitLogEntryBeforeWrite

public void visitLogEntryBeforeWrite(HTableDescriptor htd,
                                     HLogKey logKey,
                                     WALEdit logEdit)
Specified by:
visitLogEntryBeforeWrite in interface WALActionsListener

scopeWALEdits

public static void scopeWALEdits(HTableDescriptor htd,
                                 HLogKey logKey,
                                 WALEdit logEdit)
Utility method used to set the correct scopes on each log key. Doesn't set a scope on keys from compaction WAL edits and if the scope is local.

Parameters:
htd - Descriptor used to find the scope to use
logKey - Key that may get scoped according to its edits
logEdit - Edits used to lookup the scopes

preLogRoll

public void preLogRoll(org.apache.hadoop.fs.Path oldPath,
                       org.apache.hadoop.fs.Path newPath)
                throws IOException
Description copied from interface: WALActionsListener
The WAL is going to be rolled. The oldPath can be null if this is the first log file from the regionserver.

Specified by:
preLogRoll in interface WALActionsListener
Parameters:
oldPath - the path to the old hlog
newPath - the path to the new hlog
Throws:
IOException

postLogRoll

public void postLogRoll(org.apache.hadoop.fs.Path oldPath,
                        org.apache.hadoop.fs.Path newPath)
                 throws IOException
Description copied from interface: WALActionsListener
The WAL has been rolled. The oldPath can be null if this is the first log file from the regionserver.

Specified by:
postLogRoll in interface WALActionsListener
Parameters:
oldPath - the path to the old hlog
newPath - the path to the new hlog
Throws:
IOException

preLogArchive

public void preLogArchive(org.apache.hadoop.fs.Path oldPath,
                          org.apache.hadoop.fs.Path newPath)
                   throws IOException
Description copied from interface: WALActionsListener
The WAL is going to be archived.

Specified by:
preLogArchive in interface WALActionsListener
Parameters:
oldPath - the path to the old hlog
newPath - the path to the new hlog
Throws:
IOException

postLogArchive

public void postLogArchive(org.apache.hadoop.fs.Path oldPath,
                           org.apache.hadoop.fs.Path newPath)
                    throws IOException
Description copied from interface: WALActionsListener
The WAL has been archived.

Specified by:
postLogArchive in interface WALActionsListener
Parameters:
oldPath - the path to the old hlog
newPath - the path to the new hlog
Throws:
IOException

decorateMasterConfiguration

public static void decorateMasterConfiguration(org.apache.hadoop.conf.Configuration conf)
This method modifies the master's configuration in order to inject replication-related features

Parameters:
conf -

logRollRequested

public void logRollRequested(boolean tooFewReplicas)
Description copied from interface: WALActionsListener
A request was made that the WAL be rolled.

Specified by:
logRollRequested in interface WALActionsListener
Parameters:
tooFewReplicas - roll requested because of too few replicas if true

logCloseRequested

public void logCloseRequested()
Description copied from interface: WALActionsListener
The WAL is about to close.

Specified by:
logCloseRequested in interface WALActionsListener

refreshAndGetReplicationLoad

public ReplicationLoad refreshAndGetReplicationLoad()
Description copied from interface: ReplicationService
Refresh and Get ReplicationLoad

Specified by:
refreshAndGetReplicationLoad in interface ReplicationService


Copyright © 2015 The Apache Software Foundation. All rights reserved.