@InterfaceAudience.Private public class TableReplicationQueueStorage extends Object implements ReplicationQueueStorage
Modifier and Type | Field and Description |
---|---|
private Connection |
conn |
static byte[] |
HFILE_REF_FAMILY |
static byte[] |
LAST_SEQUENCE_ID_FAMILY |
static byte[] |
QUEUE_FAMILY |
private TableName |
tableName |
Constructor and Description |
---|
TableReplicationQueueStorage(Connection conn,
TableName tableName) |
Modifier and Type | Method and Description |
---|---|
void |
addHFileRefs(String peerId,
List<Pair<org.apache.hadoop.fs.Path,org.apache.hadoop.fs.Path>> pairs)
Add new hfile references to the queue.
|
private void |
addLastSeqIdsPut(org.apache.hadoop.hbase.shaded.protobuf.generated.MultiRowMutationProtos.MutateRowsRequest.Builder builder,
String peerId,
Map<String,Long> lastSeqIds,
AsyncTable<?> table) |
void |
batchUpdateHFileRefs(String peerId,
List<String> hfileRefs)
Add the given hfile refs to the given peer.
|
void |
batchUpdateLastSequenceIds(List<ZKReplicationQueueStorageForMigration.ZkLastPushedSeqId> lastPushedSeqIds)
Update last pushed sequence id for the given regions and peers.
|
void |
batchUpdateQueues(ServerName serverName,
List<ReplicationQueueData> datas)
Update the replication queue datas for a given region server.
|
Map<String,ReplicationGroupOffset> |
claimQueue(ReplicationQueueId queueId,
ServerName targetServerName)
Change ownership for the queue identified by queueId and belongs to a dead region server.
|
Set<String> |
getAllHFileRefs()
Load all hfile references in all replication queues.
|
List<String> |
getAllPeersFromHFileRefsQueue()
Get list of all peers from hfile reference queue.
|
long |
getLastSequenceId(String encodedRegionName,
String peerId)
Read the max sequence id of the specific region for a given peer.
|
Map<String,ReplicationGroupOffset> |
getOffsets(ReplicationQueueId queueId)
Get the current offset of all the WAL groups for a queue
|
private Map<String,ReplicationGroupOffset> |
getOffsets0(Table table,
ReplicationQueueId queueId) |
List<String> |
getReplicableHFiles(String peerId)
Get a list of all hfile references in the given peer.
|
boolean |
hasData()
Whether the replication queue table exists.
|
List<ReplicationQueueId> |
listAllQueueIds(ServerName serverName)
Get a list of all queues for the specific region server.
|
List<ReplicationQueueId> |
listAllQueueIds(String peerId)
Get a list of all queues for the specific peer.
|
List<ReplicationQueueId> |
listAllQueueIds(String peerId,
ServerName serverName)
Get a list of all queues for the specific region server and the specific peer
|
private void |
listAllQueueIds(Table table,
Scan scan,
List<ReplicationQueueId> queueIds) |
private void |
listAllQueueIds(Table table,
String peerId,
ServerName serverName,
List<ReplicationQueueId> queueIds) |
List<ReplicationQueueData> |
listAllQueues()
Get a list of all queues and the offsets.
|
List<ServerName> |
listAllReplicators()
Get a list of all region servers that have outstanding replication queues.
|
private org.apache.hbase.thirdparty.com.google.common.collect.ImmutableMap<String,ReplicationGroupOffset> |
parseOffsets(Result result) |
void |
removeAllQueues(String peerId)
Remove all the replication queues for the given peer.
|
void |
removeHFileRefs(String peerId,
List<String> files)
Remove hfile references from the queue.
|
void |
removeLastSequenceIds(String peerId)
Remove all the max sequence id record for the given peer.
|
void |
removeLastSequenceIds(String peerId,
List<String> encodedRegionNames)
Remove the max sequence id record for the given peer and regions.
|
void |
removeLastSequenceIdsAndHFileRefsBefore(long ts)
Remove all the last sequence ids and hfile references data which are written before the given
timestamp.
|
void |
removePeerFromHFileRefs(String peerId)
Remove a peer from hfile reference queue.
|
void |
removeQueue(ReplicationQueueId queueId)
Remove a replication queue
|
private <T extends Collection<String>> |
scanHFiles(Scan scan,
Supplier<T> creator) |
void |
setLastSequenceIds(String peerId,
Map<String,Long> lastSeqIds)
Set the max sequence id of a bunch of regions for a given peer.
|
void |
setOffset(ReplicationQueueId queueId,
String walGroup,
ReplicationGroupOffset offset,
Map<String,Long> lastSeqIds)
Set the current offset for a specific WAL group in a given queue.
|
public static final byte[] QUEUE_FAMILY
public static final byte[] LAST_SEQUENCE_ID_FAMILY
public static final byte[] HFILE_REF_FAMILY
private final Connection conn
public TableReplicationQueueStorage(Connection conn, TableName tableName)
private void addLastSeqIdsPut(org.apache.hadoop.hbase.shaded.protobuf.generated.MultiRowMutationProtos.MutateRowsRequest.Builder builder, String peerId, Map<String,Long> lastSeqIds, AsyncTable<?> table) throws IOException
IOException
public void setOffset(ReplicationQueueId queueId, String walGroup, ReplicationGroupOffset offset, Map<String,Long> lastSeqIds) throws ReplicationException
ReplicationQueueStorage
setOffset
in interface ReplicationQueueStorage
queueId
- the id of the queuewalGroup
- the group of the WAL, can be empty if multi wal is not enabledoffset
- the current offset of replication progresslastSeqIds
- map with {encodedRegionName, sequenceId} pairs for serial replication.ReplicationException
private org.apache.hbase.thirdparty.com.google.common.collect.ImmutableMap<String,ReplicationGroupOffset> parseOffsets(Result result)
private Map<String,ReplicationGroupOffset> getOffsets0(Table table, ReplicationQueueId queueId) throws IOException
IOException
public Map<String,ReplicationGroupOffset> getOffsets(ReplicationQueueId queueId) throws ReplicationException
ReplicationQueueStorage
getOffsets
in interface ReplicationQueueStorage
queueId
- the id of the queueReplicationException
private void listAllQueueIds(Table table, Scan scan, List<ReplicationQueueId> queueIds) throws IOException
IOException
private void listAllQueueIds(Table table, String peerId, ServerName serverName, List<ReplicationQueueId> queueIds) throws IOException
IOException
public List<ReplicationQueueId> listAllQueueIds(String peerId) throws ReplicationException
ReplicationQueueStorage
listAllQueueIds
in interface ReplicationQueueStorage
peerId
- the id of the peerReplicationException
public List<ReplicationQueueId> listAllQueueIds(ServerName serverName) throws ReplicationException
ReplicationQueueStorage
listAllQueueIds
in interface ReplicationQueueStorage
serverName
- the server name of the region server that owns the set of queuesReplicationException
public List<ReplicationQueueId> listAllQueueIds(String peerId, ServerName serverName) throws ReplicationException
ReplicationQueueStorage
listAllQueueIds
in interface ReplicationQueueStorage
peerId
- the id of the peerserverName
- the server name of the region server that owns the set of queuesReplicationException
public List<ReplicationQueueData> listAllQueues() throws ReplicationException
ReplicationQueueStorage
listAllQueues
in interface ReplicationQueueStorage
ReplicationException
public List<ServerName> listAllReplicators() throws ReplicationException
ReplicationQueueStorage
listAllReplicators
in interface ReplicationQueueStorage
ReplicationException
public Map<String,ReplicationGroupOffset> claimQueue(ReplicationQueueId queueId, ServerName targetServerName) throws ReplicationException
ReplicationQueueStorage
claimQueue
in interface ReplicationQueueStorage
queueId
- the id of the queuetargetServerName
- the name of the target region serverReplicationException
public void removeQueue(ReplicationQueueId queueId) throws ReplicationException
ReplicationQueueStorage
removeQueue
in interface ReplicationQueueStorage
queueId
- the id of the queue to removeReplicationException
public void removeAllQueues(String peerId) throws ReplicationException
ReplicationQueueStorage
removeAllQueues
in interface ReplicationQueueStorage
peerId
- the id of the peerReplicationException
public long getLastSequenceId(String encodedRegionName, String peerId) throws ReplicationException
ReplicationQueueStorage
getLastSequenceId
in interface ReplicationQueueStorage
encodedRegionName
- the encoded region namepeerId
- peer idReplicationException
public void setLastSequenceIds(String peerId, Map<String,Long> lastSeqIds) throws ReplicationException
ReplicationQueueStorage
setLastSequenceIds
in interface ReplicationQueueStorage
peerId
- peer idlastSeqIds
- map with {encodedRegionName, sequenceId} pairs for serial replication.ReplicationException
public void removeLastSequenceIds(String peerId) throws ReplicationException
ReplicationQueueStorage
removeLastSequenceIds
in interface ReplicationQueueStorage
peerId
- peer idReplicationException
public void removeLastSequenceIds(String peerId, List<String> encodedRegionNames) throws ReplicationException
ReplicationQueueStorage
removeLastSequenceIds
in interface ReplicationQueueStorage
peerId
- peer idencodedRegionNames
- the encoded region namesReplicationException
public void removePeerFromHFileRefs(String peerId) throws ReplicationException
ReplicationQueueStorage
removePeerFromHFileRefs
in interface ReplicationQueueStorage
peerId
- peer cluster id to be removedReplicationException
public void addHFileRefs(String peerId, List<Pair<org.apache.hadoop.fs.Path,org.apache.hadoop.fs.Path>> pairs) throws ReplicationException
ReplicationQueueStorage
addHFileRefs
in interface ReplicationQueueStorage
peerId
- peer cluster id to which the hfiles need to be replicatedpairs
- list of pairs of { HFile location in staging dir, HFile path in region dir which
will be added in the queue }ReplicationException
- if fails to add a hfile referencepublic void removeHFileRefs(String peerId, List<String> files) throws ReplicationException
ReplicationQueueStorage
removeHFileRefs
in interface ReplicationQueueStorage
peerId
- peer cluster id from which this hfile references needs to be removedfiles
- list of hfile references to be removedReplicationException
public List<String> getAllPeersFromHFileRefsQueue() throws ReplicationException
ReplicationQueueStorage
getAllPeersFromHFileRefsQueue
in interface ReplicationQueueStorage
ReplicationException
private <T extends Collection<String>> T scanHFiles(Scan scan, Supplier<T> creator) throws IOException
IOException
public List<String> getReplicableHFiles(String peerId) throws ReplicationException
ReplicationQueueStorage
getReplicableHFiles
in interface ReplicationQueueStorage
peerId
- a String that identifies the peerReplicationException
public Set<String> getAllHFileRefs() throws ReplicationException
ReplicationQueueStorage
getAllHFileRefs
in interface ReplicationQueueStorage
ReplicationException
public boolean hasData() throws ReplicationException
ReplicationQueueStorage
hasData
in interface ReplicationQueueStorage
ReplicationException
public void batchUpdateQueues(ServerName serverName, List<ReplicationQueueData> datas) throws ReplicationException
ReplicationQueueStorage
batchUpdateQueues
in interface ReplicationQueueStorage
ReplicationException
public void batchUpdateLastSequenceIds(List<ZKReplicationQueueStorageForMigration.ZkLastPushedSeqId> lastPushedSeqIds) throws ReplicationException
ReplicationQueueStorage
batchUpdateLastSequenceIds
in interface ReplicationQueueStorage
ReplicationException
public void batchUpdateHFileRefs(String peerId, List<String> hfileRefs) throws ReplicationException
ReplicationQueueStorage
batchUpdateHFileRefs
in interface ReplicationQueueStorage
ReplicationException
public void removeLastSequenceIdsAndHFileRefsBefore(long ts) throws ReplicationException
ReplicationQueueStorage
removeLastSequenceIdsAndHFileRefsBefore
in interface ReplicationQueueStorage
ReplicationException
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.