From 3080fb6f029adf41d8829381321d328d1f9bbf9c Mon Sep 17 00:00:00 2001 From: Zhihong Yu Date: Wed, 31 Aug 2011 17:50:33 +0000 Subject: [PATCH] HBASE-4283 HBaseAdmin never recovers from restarted cluster (Lars Hofhansl) git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1163719 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 1 + .../java/org/apache/hadoop/hbase/client/HBaseAdmin.java | 3 +++ src/main/java/org/apache/hadoop/hbase/util/PoolMap.java | 9 ++++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index 4384c060c77..c497a1e10a1 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -229,6 +229,7 @@ Release 0.91.0 - Unreleased HBASE-4303 HRegionInfo.toString has bad quoting (todd) HBASE-4307 race condition in CacheTestUtils (Li Pi) HBASE-4310 SlabCache metrics bugfix (Li Pi) + HBASE-4283 HBaseAdmin never recovers from restarted cluster (Lars Hofhansl) IMPROVEMENTS HBASE-3290 Max Compaction Size (Nicolas Spiegelberg via Stack) diff --git a/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java b/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java index 2ca678fd71e..88d72a02a1e 100644 --- a/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java +++ b/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java @@ -104,6 +104,9 @@ public class HBaseAdmin implements Abortable, Closeable { try { this.connection.getMaster(); break; + } catch (MasterNotRunningException mnre) { + HConnectionManager.deleteStaleConnection(this.connection); + this.connection = HConnectionManager.getConnection(this.conf); } catch (UndeclaredThrowableException ute) { HConnectionManager.deleteStaleConnection(this.connection); this.connection = HConnectionManager.getConnection(this.conf); diff --git a/src/main/java/org/apache/hadoop/hbase/util/PoolMap.java b/src/main/java/org/apache/hadoop/hbase/util/PoolMap.java index e3e11f831e5..1956e6b8ae5 100644 --- a/src/main/java/org/apache/hadoop/hbase/util/PoolMap.java +++ b/src/main/java/org/apache/hadoop/hbase/util/PoolMap.java @@ -93,7 +93,14 @@ public class PoolMap implements Map { public boolean remove(K key, V value) { Pool pool = pools.get(key); - return pool != null ? pool.remove(value) : false; + boolean res = false; + if (pool != null) { + res = pool.remove(value); + if (res && pool.size() == 0) { + pools.remove(key); + } + } + return res; } @Override