From 41bfe09a492f867a705627c47235fc714f4862fa Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Sun, 22 Nov 2009 23:36:00 +0000 Subject: [PATCH] HBASE-1999 When HTable goes away, close zk session in shutdown hook or something... git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@883189 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 2 ++ .../hadoop/hbase/client/HConnectionManager.java | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index ec17d0fd146..7fce53e44e3 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -114,6 +114,8 @@ Release 0.21.0 - Unreleased HBASE-1979 MurmurHash does not yield the same results as the reference C++ implementation when size % 4 >= 2 (Olivier Gillet via Andrew Purtell) + HBASE-1999 When HTable goes away, close zk session in shutdown hook or + something... IMPROVEMENTS HBASE-1760 Cleanup TODOs in HTable diff --git a/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java b/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java index 0d4c482c5a2..626c071f848 100644 --- a/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java +++ b/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java @@ -67,7 +67,17 @@ import org.apache.zookeeper.Watcher.Event.KeeperState; public class HConnectionManager implements HConstants { private static final Delete [] DELETE_ARRAY_TYPE = new Delete[0]; private static final Put [] PUT_ARRAY_TYPE = new Put[0]; - + + // Register a shutdown hook, one that cleans up RPC and closes zk sessions. + static { + Runtime.getRuntime().addShutdownHook(new Thread("HCM.shutdownHook") { + @Override + public void run() { + HConnectionManager.deleteAllConnections(true); + } + }); + } + /* * Not instantiable. */