From 817dc5644c4c3b2f9a422e250d2d2378d42a3a84 Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Fri, 27 Oct 2017 09:39:06 -0700 Subject: [PATCH] HBASE-19110 Add default for Server#isStopping & #getFileSystem --- .../java/org/apache/hadoop/hbase/Server.java | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/Server.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/Server.java index f436dcc1a9c..a6b39f3f7a7 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/Server.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/Server.java @@ -26,6 +26,8 @@ import org.apache.hadoop.hbase.zookeeper.MetaTableLocator; import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher; import org.apache.yetus.audience.InterfaceAudience; +import java.io.IOException; + /** * Defines a curated set of shared functions implemented by HBase servers (Masters * and RegionServers). For use internally only. Be judicious adding API. Changes cause ripples @@ -83,15 +85,29 @@ public interface Server extends Abortable, Stoppable { ChoreService getChoreService(); /** - * @return Return the FileSystem object used. + * @return Return the FileSystem object used (can return null!). */ // TODO: On Master, return Master's. On RegionServer, return RegionServers. The FileSystems // may differ. TODO. - FileSystem getFileSystem(); + default FileSystem getFileSystem() { + // This default is pretty dodgy! + Configuration c = getConfiguration(); + FileSystem fs = null; + try { + if (c != null) { + fs = FileSystem.get(c); + } + } catch (IOException e) { + // If an exception, just return null + } + return fs; + }; /** * @return True is the server is Stopping */ // Note: This method is not part of the Stoppable Interface. - boolean isStopping(); + default boolean isStopping() { + return false; + } }