Skip to content

Commit 73c26a6

Browse files
authored
HBASE-29684 Replication peer config is not honored in few cases (#7413)
Signed-off-by: Andrew Purtell <[email protected]> Signed-off-by: Viraj Jasani <[email protected]>
1 parent 7b58903 commit 73c26a6

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

hbase-server/src/main/java/org/apache/hadoop/hbase/master/replication/ReplicationPeerManager.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import org.apache.commons.lang3.StringUtils;
3232
import org.apache.hadoop.conf.Configuration;
3333
import org.apache.hadoop.hbase.DoNotRetryIOException;
34-
import org.apache.hadoop.hbase.HBaseConfiguration;
3534
import org.apache.hadoop.hbase.ReplicationPeerNotFoundException;
3635
import org.apache.hadoop.hbase.ServerName;
3736
import org.apache.hadoop.hbase.TableName;
@@ -274,7 +273,7 @@ private void checkPeerConfig(ReplicationPeerConfig peerConfig) throws DoNotRetry
274273
checkClusterKey(peerConfig.getClusterKey());
275274
// Check if endpoint can replicate to the same cluster
276275
if (endpoint == null || !endpoint.canReplicateToSameCluster()) {
277-
checkSameClusterKey(peerConfig.getClusterKey());
276+
checkSameClusterKey(peerConfig);
278277
}
279278
}
280279

@@ -372,21 +371,22 @@ private void checkClusterKey(String clusterKey) throws DoNotRetryIOException {
372371
}
373372
}
374373

375-
private void checkSameClusterKey(String clusterKey) throws DoNotRetryIOException {
374+
private void checkSameClusterKey(ReplicationPeerConfig peerConfig) throws DoNotRetryIOException {
376375
String peerClusterId = "";
377376
try {
378-
// Create the peer cluster config for get peer cluster id
379-
Configuration peerConf = HBaseConfiguration.createClusterConf(conf, clusterKey);
377+
// Create the peer cluster config for getting peer cluster id, honoring per-peer CONFIG
378+
Configuration peerConf = ReplicationUtils.getPeerClusterConfiguration(peerConfig, conf);
380379
try (ZKWatcher zkWatcher = new ZKWatcher(peerConf, this + "check-peer-cluster-id", null)) {
381380
peerClusterId = ZKClusterId.readClusterIdZNode(zkWatcher);
382381
}
383-
} catch (IOException | KeeperException e) {
384-
throw new DoNotRetryIOException("Can't get peerClusterId for clusterKey=" + clusterKey, e);
382+
} catch (IOException | KeeperException | ReplicationException e) {
383+
throw new DoNotRetryIOException(
384+
"Can't get peerClusterId for clusterKey=" + peerConfig.getClusterKey(), e);
385385
}
386386
// In rare case, zookeeper setting may be messed up. That leads to the incorrect
387387
// peerClusterId value, which is the same as the source clusterId
388388
if (clusterId.equals(peerClusterId)) {
389-
throw new DoNotRetryIOException("Invalid cluster key: " + clusterKey
389+
throw new DoNotRetryIOException("Invalid cluster key: " + peerConfig.getClusterKey()
390390
+ ", should not replicate to itself for HBaseInterClusterReplicationEndpoint");
391391
}
392392
}

0 commit comments

Comments
 (0)