From b66a478e73b59e0335de89038475409d916ea164 Mon Sep 17 00:00:00 2001 From: Guanghao Zhang Date: Thu, 25 May 2017 09:51:40 +0800 Subject: [PATCH] HBASE-18111 Replication stuck when cluster connection is closed Conflicts: hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/HBaseInterClusterReplicationEndpoint.java Signed-off-by: Andrew Purtell --- .../HBaseInterClusterReplicationEndpoint.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/HBaseInterClusterReplicationEndpoint.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/HBaseInterClusterReplicationEndpoint.java index 85bd11ab4c3..cf85ffd7b11 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/HBaseInterClusterReplicationEndpoint.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/HBaseInterClusterReplicationEndpoint.java @@ -225,6 +225,18 @@ public class HBaseInterClusterReplicationEndpoint extends HBaseReplicationEndpoi return entryLists; } + private void reconnectToPeerCluster() { + HConnection connection = null; + try { + connection = HConnectionManager.createConnection(this.conf); + } catch (IOException ioe) { + LOG.warn("Failed to create connection for peer cluster", ioe); + } + if (connection != null) { + this.conn = connection; + } + } + /** * Do the shipping logic */ @@ -256,6 +268,9 @@ public class HBaseInterClusterReplicationEndpoint extends HBaseReplicationEndpoi } continue; } + if (this.conn == null || this.conn.isClosed()) { + reconnectToPeerCluster(); + } try { int futures = 0; for (int i=0; i