use of org.apache.hadoop.hbase.replication.SyncReplicationState in project hbase by apache.
the class ReplicationPeerManager method addPeer.
public void addPeer(String peerId, ReplicationPeerConfig peerConfig, boolean enabled) throws ReplicationException {
if (peers.containsKey(peerId)) {
// this should be a retry, just return
return;
}
peerConfig = ReplicationPeerConfigUtil.updateReplicationBasePeerConfigs(conf, peerConfig);
ReplicationPeerConfig copiedPeerConfig = ReplicationPeerConfig.newBuilder(peerConfig).build();
SyncReplicationState syncReplicationState = copiedPeerConfig.isSyncReplication() ? SyncReplicationState.DOWNGRADE_ACTIVE : SyncReplicationState.NONE;
peerStorage.addPeer(peerId, copiedPeerConfig, enabled, syncReplicationState);
peers.put(peerId, new ReplicationPeerDescription(peerId, enabled, copiedPeerConfig, syncReplicationState));
}
use of org.apache.hadoop.hbase.replication.SyncReplicationState in project hbase by apache.
the class SyncReplicationPeerInfoProviderImpl method checkState.
@Override
public boolean checkState(TableName table, BiPredicate<SyncReplicationState, SyncReplicationState> checker) {
String peerId = mapping.getPeerId(table);
if (peerId == null) {
return false;
}
ReplicationPeerImpl peer = replicationPeers.getPeer(peerId);
if (peer == null) {
return false;
}
Pair<SyncReplicationState, SyncReplicationState> states = peer.getSyncReplicationStateAndNewState();
return checker.test(states.getFirst(), states.getSecond());
}
use of org.apache.hadoop.hbase.replication.SyncReplicationState in project hbase by apache.
the class SyncReplicationPeerInfoProviderImpl method getPeerIdAndRemoteWALDir.
@Override
public Optional<Pair<String, String>> getPeerIdAndRemoteWALDir(TableName table) {
if (table == null) {
return Optional.empty();
}
String peerId = mapping.getPeerId(table);
if (peerId == null) {
return Optional.empty();
}
ReplicationPeerImpl peer = replicationPeers.getPeer(peerId);
if (peer == null) {
return Optional.empty();
}
Pair<SyncReplicationState, SyncReplicationState> states = peer.getSyncReplicationStateAndNewState();
if ((states.getFirst() == SyncReplicationState.ACTIVE && states.getSecond() == SyncReplicationState.NONE) || (states.getFirst() == SyncReplicationState.DOWNGRADE_ACTIVE && states.getSecond() == SyncReplicationState.ACTIVE)) {
return Optional.of(Pair.newPair(peerId, peer.getPeerConfig().getRemoteWALDir()));
} else {
return Optional.empty();
}
}
Aggregations