Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.apache.commons.lang3.StringUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.DoNotRetryIOException;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.ReplicationPeerNotFoundException;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableName;
Expand Down Expand Up @@ -274,7 +273,7 @@ private void checkPeerConfig(ReplicationPeerConfig peerConfig) throws DoNotRetry
checkClusterKey(peerConfig.getClusterKey());
// Check if endpoint can replicate to the same cluster
if (endpoint == null || !endpoint.canReplicateToSameCluster()) {
checkSameClusterKey(peerConfig.getClusterKey());
checkSameClusterKey(peerConfig);
}
}

Expand Down Expand Up @@ -372,21 +371,22 @@ private void checkClusterKey(String clusterKey) throws DoNotRetryIOException {
}
}

private void checkSameClusterKey(String clusterKey) throws DoNotRetryIOException {
private void checkSameClusterKey(ReplicationPeerConfig peerConfig) throws DoNotRetryIOException {
String peerClusterId = "";
try {
// Create the peer cluster config for get peer cluster id
Configuration peerConf = HBaseConfiguration.createClusterConf(conf, clusterKey);
// Create the peer cluster config for getting peer cluster id, honoring per-peer CONFIG
Configuration peerConf = ReplicationUtils.getPeerClusterConfiguration(peerConfig, conf);
try (ZKWatcher zkWatcher = new ZKWatcher(peerConf, this + "check-peer-cluster-id", null)) {
peerClusterId = ZKClusterId.readClusterIdZNode(zkWatcher);
}
} catch (IOException | KeeperException e) {
throw new DoNotRetryIOException("Can't get peerClusterId for clusterKey=" + clusterKey, e);
} catch (IOException | KeeperException | ReplicationException e) {
throw new DoNotRetryIOException(
"Can't get peerClusterId for clusterKey=" + peerConfig.getClusterKey(), e);
}
// In rare case, zookeeper setting may be messed up. That leads to the incorrect
// peerClusterId value, which is the same as the source clusterId
if (clusterId.equals(peerClusterId)) {
throw new DoNotRetryIOException("Invalid cluster key: " + clusterKey
throw new DoNotRetryIOException("Invalid cluster key: " + peerConfig.getClusterKey()
+ ", should not replicate to itself for HBaseInterClusterReplicationEndpoint");
}
}
Expand Down