|
31 | 31 | import org.apache.commons.lang3.StringUtils; |
32 | 32 | import org.apache.hadoop.conf.Configuration; |
33 | 33 | import org.apache.hadoop.hbase.DoNotRetryIOException; |
34 | | -import org.apache.hadoop.hbase.HBaseConfiguration; |
35 | 34 | import org.apache.hadoop.hbase.ReplicationPeerNotFoundException; |
36 | 35 | import org.apache.hadoop.hbase.ServerName; |
37 | 36 | import org.apache.hadoop.hbase.TableName; |
@@ -274,7 +273,7 @@ private void checkPeerConfig(ReplicationPeerConfig peerConfig) throws DoNotRetry |
274 | 273 | checkClusterKey(peerConfig.getClusterKey()); |
275 | 274 | // Check if endpoint can replicate to the same cluster |
276 | 275 | if (endpoint == null || !endpoint.canReplicateToSameCluster()) { |
277 | | - checkSameClusterKey(peerConfig.getClusterKey()); |
| 276 | + checkSameClusterKey(peerConfig); |
278 | 277 | } |
279 | 278 | } |
280 | 279 |
|
@@ -372,21 +371,22 @@ private void checkClusterKey(String clusterKey) throws DoNotRetryIOException { |
372 | 371 | } |
373 | 372 | } |
374 | 373 |
|
375 | | - private void checkSameClusterKey(String clusterKey) throws DoNotRetryIOException { |
| 374 | + private void checkSameClusterKey(ReplicationPeerConfig peerConfig) throws DoNotRetryIOException { |
376 | 375 | String peerClusterId = ""; |
377 | 376 | 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); |
380 | 379 | try (ZKWatcher zkWatcher = new ZKWatcher(peerConf, this + "check-peer-cluster-id", null)) { |
381 | 380 | peerClusterId = ZKClusterId.readClusterIdZNode(zkWatcher); |
382 | 381 | } |
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); |
385 | 385 | } |
386 | 386 | // In rare case, zookeeper setting may be messed up. That leads to the incorrect |
387 | 387 | // peerClusterId value, which is the same as the source clusterId |
388 | 388 | if (clusterId.equals(peerClusterId)) { |
389 | | - throw new DoNotRetryIOException("Invalid cluster key: " + clusterKey |
| 389 | + throw new DoNotRetryIOException("Invalid cluster key: " + peerConfig.getClusterKey() |
390 | 390 | + ", should not replicate to itself for HBaseInterClusterReplicationEndpoint"); |
391 | 391 | } |
392 | 392 | } |
|
0 commit comments