Search in sources :

Example 6 with SyncReplicationState

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));
}
Also used : ReplicationPeerConfig(org.apache.hadoop.hbase.replication.ReplicationPeerConfig) SyncReplicationState(org.apache.hadoop.hbase.replication.SyncReplicationState) ReplicationPeerDescription(org.apache.hadoop.hbase.replication.ReplicationPeerDescription)

Example 7 with 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());
}
Also used : ReplicationPeerImpl(org.apache.hadoop.hbase.replication.ReplicationPeerImpl) SyncReplicationState(org.apache.hadoop.hbase.replication.SyncReplicationState)

Example 8 with SyncReplicationState

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();
    }
}
Also used : ReplicationPeerImpl(org.apache.hadoop.hbase.replication.ReplicationPeerImpl) SyncReplicationState(org.apache.hadoop.hbase.replication.SyncReplicationState)

Aggregations

SyncReplicationState (org.apache.hadoop.hbase.replication.SyncReplicationState)8 ReplicationPeerImpl (org.apache.hadoop.hbase.replication.ReplicationPeerImpl)5 ReplicationPeerDescription (org.apache.hadoop.hbase.replication.ReplicationPeerDescription)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 Path (org.apache.hadoop.fs.Path)2 ReplicationException (org.apache.hadoop.hbase.replication.ReplicationException)2 ReplicationPeerConfig (org.apache.hadoop.hbase.replication.ReplicationPeerConfig)2 IOException (java.io.IOException)1 InterruptedIOException (java.io.InterruptedIOException)1 HashMap (java.util.HashMap)1 NavigableSet (java.util.NavigableSet)1 SortedSet (java.util.SortedSet)1 Lock (java.util.concurrent.locks.Lock)1 FSDataInputStream (org.apache.hadoop.fs.FSDataInputStream)1 FSDataOutputStream (org.apache.hadoop.fs.FSDataOutputStream)1 FileSystem (org.apache.hadoop.fs.FileSystem)1 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)1 LogRoller (org.apache.hadoop.hbase.regionserver.LogRoller)1 PeerState (org.apache.hadoop.hbase.replication.ReplicationPeer.PeerState)1 ReplicationPeerStorage (org.apache.hadoop.hbase.replication.ReplicationPeerStorage)1