[
https://issues.apache.org/jira/browse/HBASE-12150?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14155907#comment-14155907
]
Nick Dimiduk commented on HBASE-12150:
--------------------------------------
Good plan.
> Backport replication changes from HBASE-12145
> ---------------------------------------------
>
> Key: HBASE-12150
> URL: https://issues.apache.org/jira/browse/HBASE-12150
> Project: HBase
> Issue Type: Task
> Reporter: Andrew Purtell
> Assignee: Andrew Purtell
> Fix For: 0.98.7
>
>
> HBASE-12145 makes all zk accesses synchronized in RecoverableZooKeeper in
> branch-1 +:
> {code}
> @@ -690,23 +692,23 @@ public class RecoverableZooKeeper {
> return newData;
> }
>
> - public long getSessionId() {
> - return zk == null ? null : zk.getSessionId();
> + public synchronized long getSessionId() {
> + return zk == null ? -1 : zk.getSessionId();
> }
>
> - public void close() throws InterruptedException {
> + public synchronized void close() throws InterruptedException {
> if (zk != null) zk.close();
> }
>
> - public States getState() {
> + public synchronized States getState() {
> return zk == null ? null : zk.getState();
> }
>
> - public ZooKeeper getZooKeeper() {
> + public synchronized ZooKeeper getZooKeeper() {
> return zk;
> }
>
> - public byte[] getSessionPasswd() {
> + public synchronized byte[] getSessionPasswd() {
> return zk == null ? null : zk.getSessionPasswd();
> }
> {code}
> It also makes this change:
> {code}
> @@ -391,8 +390,14 @@ public class ReplicationPeersZKImpl extends
> ReplicationStateZKBase implements Re
> if (peer == null) {
> return false;
> }
> - ((ConcurrentMap<String, ReplicationPeerZKImpl>)
> peerClusters).putIfAbsent(peerId, peer);
> - LOG.info("Added new peer cluster " +
> peer.getPeerConfig().getClusterKey());
> + ReplicationPeerZKImpl previous =
> + ((ConcurrentMap<String, ReplicationPeerZKImpl>)
> peerClusters).putIfAbsent(peerId, peer);
> + if (previous == null) {
> + LOG.info("Added new peer cluster=" +
> peer.getPeerConfig().getClusterKey());
> + } else {
> + LOG.info("Peer already present, " +
> previous.getPeerConfig().getClusterKey() +
> + ", new cluster=" + peer.getPeerConfig().getClusterKey());
> + }
> return true;
> }
> {code}
> We should keep the 0.98 code in sync with these changes because these affect
> correctness. Would like to avoid "this change works in branch-1 or master but
> breaks in some weird way in 0.98" issues.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)