Search in sources :

Example 16 with ReplicationPeerDescription

use of org.apache.hadoop.hbase.replication.ReplicationPeerDescription in project hbase by apache.

the class ReplicationPeerManager method preTransitPeerSyncReplicationState.

/**
 * @return the old desciption of the peer
 */
ReplicationPeerDescription preTransitPeerSyncReplicationState(String peerId, SyncReplicationState state) throws DoNotRetryIOException {
    ReplicationPeerDescription desc = checkPeerExists(peerId);
    SyncReplicationState fromState = desc.getSyncReplicationState();
    EnumSet<SyncReplicationState> allowedToStates = allowedTransition.get(fromState);
    if (allowedToStates == null || !allowedToStates.contains(state)) {
        throw new DoNotRetryIOException("Can not transit current cluster state from " + fromState + " to " + state + " for peer id=" + peerId);
    }
    return desc;
}
Also used : DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) SyncReplicationState(org.apache.hadoop.hbase.replication.SyncReplicationState) ReplicationPeerDescription(org.apache.hadoop.hbase.replication.ReplicationPeerDescription)

Example 17 with ReplicationPeerDescription

use of org.apache.hadoop.hbase.replication.ReplicationPeerDescription in project hbase by apache.

the class ReplicationPeerManager method create.

public static ReplicationPeerManager create(ZKWatcher zk, Configuration conf, String clusterId) throws ReplicationException {
    ReplicationPeerStorage peerStorage = ReplicationStorageFactory.getReplicationPeerStorage(zk, conf);
    ConcurrentMap<String, ReplicationPeerDescription> peers = new ConcurrentHashMap<>();
    for (String peerId : peerStorage.listPeerIds()) {
        ReplicationPeerConfig peerConfig = peerStorage.getPeerConfig(peerId);
        if (ReplicationUtils.LEGACY_REGION_REPLICATION_ENDPOINT_NAME.equals(peerConfig.getReplicationEndpointImpl())) {
            // we do not use this endpoint for region replication any more, see HBASE-26233
            LOG.info("Legacy region replication peer found, removing: {}", peerConfig);
            peerStorage.removePeer(peerId);
            continue;
        }
        peerConfig = ReplicationPeerConfigUtil.updateReplicationBasePeerConfigs(conf, peerConfig);
        peerStorage.updatePeerConfig(peerId, peerConfig);
        boolean enabled = peerStorage.isPeerEnabled(peerId);
        SyncReplicationState state = peerStorage.getPeerSyncReplicationState(peerId);
        peers.put(peerId, new ReplicationPeerDescription(peerId, enabled, peerConfig, state));
    }
    return new ReplicationPeerManager(peerStorage, ReplicationStorageFactory.getReplicationQueueStorage(zk, conf), peers, conf, clusterId);
}
Also used : ReplicationPeerConfig(org.apache.hadoop.hbase.replication.ReplicationPeerConfig) SyncReplicationState(org.apache.hadoop.hbase.replication.SyncReplicationState) ReplicationPeerDescription(org.apache.hadoop.hbase.replication.ReplicationPeerDescription) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ReplicationPeerStorage(org.apache.hadoop.hbase.replication.ReplicationPeerStorage)

Example 18 with ReplicationPeerDescription

use of org.apache.hadoop.hbase.replication.ReplicationPeerDescription 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 19 with ReplicationPeerDescription

use of org.apache.hadoop.hbase.replication.ReplicationPeerDescription in project hbase by apache.

the class TransitPeerSyncReplicationStateProcedure method preTransit.

protected void preTransit(MasterProcedureEnv env) throws IOException {
    MasterCoprocessorHost cpHost = env.getMasterCoprocessorHost();
    if (cpHost != null) {
        cpHost.preTransitReplicationPeerSyncReplicationState(peerId, toState);
    }
    ReplicationPeerDescription desc = env.getReplicationPeerManager().preTransitPeerSyncReplicationState(peerId, toState);
    if (toState == SyncReplicationState.ACTIVE) {
        Path remoteWALDirForPeer = ReplicationUtils.getPeerRemoteWALDir(desc.getPeerConfig().getRemoteWALDir(), peerId);
        // check whether the remote wal directory is present
        if (!remoteWALDirForPeer.getFileSystem(env.getMasterConfiguration()).exists(remoteWALDirForPeer)) {
            throw new DoNotRetryIOException("The remote WAL directory " + remoteWALDirForPeer + " does not exist");
        }
    }
    fromState = desc.getSyncReplicationState();
    enabled = desc.isEnabled();
    serial = desc.getPeerConfig().isSerial();
}
Also used : Path(org.apache.hadoop.fs.Path) MasterCoprocessorHost(org.apache.hadoop.hbase.master.MasterCoprocessorHost) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) ReplicationPeerDescription(org.apache.hadoop.hbase.replication.ReplicationPeerDescription)

Example 20 with ReplicationPeerDescription

use of org.apache.hadoop.hbase.replication.ReplicationPeerDescription in project hbase by apache.

the class HMaster method listReplicationPeers.

@Override
public List<ReplicationPeerDescription> listReplicationPeers(String regex) throws ReplicationException, IOException {
    if (cpHost != null) {
        cpHost.preListReplicationPeers(regex);
    }
    LOG.debug("{} list replication peers, regex={}", getClientIdAuditPrefix(), regex);
    Pattern pattern = regex == null ? null : Pattern.compile(regex);
    List<ReplicationPeerDescription> peers = this.replicationPeerManager.listPeers(pattern);
    if (cpHost != null) {
        cpHost.postListReplicationPeers(regex);
    }
    return peers;
}
Also used : Pattern(java.util.regex.Pattern) ReplicationPeerDescription(org.apache.hadoop.hbase.replication.ReplicationPeerDescription)

Aggregations

ReplicationPeerDescription (org.apache.hadoop.hbase.replication.ReplicationPeerDescription)23 ReplicationPeerConfig (org.apache.hadoop.hbase.replication.ReplicationPeerConfig)13 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Map (java.util.Map)4 Set (java.util.Set)4 Configuration (org.apache.hadoop.conf.Configuration)4 Collections (java.util.Collections)3 HashMap (java.util.HashMap)3 Collectors (java.util.stream.Collectors)3 Path (org.apache.hadoop.fs.Path)3 HBaseConfiguration (org.apache.hadoop.hbase.HBaseConfiguration)3 ServerName (org.apache.hadoop.hbase.ServerName)3 SyncReplicationState (org.apache.hadoop.hbase.replication.SyncReplicationState)3 ZKUtil (org.apache.hadoop.hbase.zookeeper.ZKUtil)3 ZKWatcher (org.apache.hadoop.hbase.zookeeper.ZKWatcher)3 InterfaceAudience (org.apache.yetus.audience.InterfaceAudience)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3