You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ap...@apache.org on 2018/05/29 19:22:41 UTC
[04/14] hbase git commit: Revert "HBASE-20597 Use a lock to serialize
access to a shared reference to ZooKeeperWatcher in HBaseReplicationEndpoint"
Revert "HBASE-20597 Use a lock to serialize access to a shared reference to ZooKeeperWatcher in HBaseReplicationEndpoint"
This reverts commit 1b70763b9ee6b23a0a3c9db0474c4c6654ce7189.
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/8e79429f
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/8e79429f
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/8e79429f
Branch: refs/heads/branch-1.3
Commit: 8e79429f4c09ea9bb3c9638e83bb4ad9999dfe85
Parents: b62d12f
Author: Andrew Purtell <ap...@apache.org>
Authored: Fri May 25 10:19:29 2018 -0700
Committer: Andrew Purtell <ap...@apache.org>
Committed: Tue May 29 11:23:26 2018 -0700
----------------------------------------------------------------------
.../replication/HBaseReplicationEndpoint.java | 43 ++++++++------------
1 file changed, 16 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/8e79429f/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/HBaseReplicationEndpoint.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/HBaseReplicationEndpoint.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/HBaseReplicationEndpoint.java
index 39a3f31..6485e4a 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/HBaseReplicationEndpoint.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/HBaseReplicationEndpoint.java
@@ -43,22 +43,21 @@ import org.apache.zookeeper.KeeperException.SessionExpiredException;
* target cluster is an HBase cluster.
*/
@InterfaceAudience.Private
+@edu.umd.cs.findbugs.annotations.SuppressWarnings(value="MT_CORRECTNESS",
+ justification="Thinks zkw needs to be synchronized access but should be fine as is.")
public abstract class HBaseReplicationEndpoint extends BaseReplicationEndpoint
implements Abortable {
private static final Log LOG = LogFactory.getLog(HBaseReplicationEndpoint.class);
- private Object zkwLock = new Object();
- private ZooKeeperWatcher zkw = null;
+ private ZooKeeperWatcher zkw = null; // FindBugs: MT_CORRECTNESS
private List<ServerName> regionServers = new ArrayList<ServerName>(0);
private long lastRegionServerUpdate;
protected void disconnect() {
- synchronized (zkwLock) {
- if (zkw != null) {
- zkw.close();
- }
+ if (zkw != null) {
+ zkw.close();
}
}
@@ -103,9 +102,7 @@ public abstract class HBaseReplicationEndpoint extends BaseReplicationEndpoint
public synchronized UUID getPeerUUID() {
UUID peerUUID = null;
try {
- synchronized (zkwLock) {
- peerUUID = ZKClusterId.getUUIDForCluster(zkw);
- }
+ peerUUID = ZKClusterId.getUUIDForCluster(zkw);
} catch (KeeperException ke) {
reconnect(ke);
}
@@ -117,9 +114,7 @@ public abstract class HBaseReplicationEndpoint extends BaseReplicationEndpoint
* @return zk connection
*/
protected ZooKeeperWatcher getZkw() {
- synchronized (zkwLock) {
- return zkw;
- }
+ return zkw;
}
/**
@@ -127,14 +122,10 @@ public abstract class HBaseReplicationEndpoint extends BaseReplicationEndpoint
* @throws IOException If anything goes wrong connecting
*/
void reloadZkWatcher() throws IOException {
- synchronized (zkwLock) {
- if (zkw != null) {
- zkw.close();
- }
- zkw = new ZooKeeperWatcher(ctx.getConfiguration(),
+ if (zkw != null) zkw.close();
+ zkw = new ZooKeeperWatcher(ctx.getConfiguration(),
"connection to cluster: " + ctx.getPeerId(), this);
- zkw.registerListener(new PeerRegionServerListener(this));
- }
+ getZkw().registerListener(new PeerRegionServerListener(this));
}
@Override
@@ -172,15 +163,13 @@ public abstract class HBaseReplicationEndpoint extends BaseReplicationEndpoint
* for this peer cluster
* @return list of addresses
*/
- public List<ServerName> getRegionServers() {
+ // Synchronize peer cluster connection attempts to avoid races and rate
+ // limit connections when multiple replication sources try to connect to
+ // the peer cluster. If the peer cluster is down we can get out of control
+ // over time.
+ public synchronized List<ServerName> getRegionServers() {
try {
- // Synchronize peer cluster connection attempts to avoid races and rate
- // limit connections when multiple replication sources try to connect to
- // the peer cluster. If the peer cluster is down we can get out of control
- // over time.
- synchronized (zkwLock) {
- setRegionServers(fetchSlavesAddresses(zkw));
- }
+ setRegionServers(fetchSlavesAddresses(this.getZkw()));
} catch (KeeperException ke) {
if (LOG.isDebugEnabled()) {
LOG.debug("Fetch slaves addresses failed", ke);