hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject hbase git commit: HBASE-18658 Purge hokey hbase Service implementation; use (internal) Guava Service instead
Date Thu, 24 Aug 2017 16:24:50 GMT
Repository: hbase
Updated Branches:
  refs/heads/master 88356029f -> 1b4e935ce


HBASE-18658 Purge hokey hbase Service implementation; use (internal) Guava Service instead

Removes hbase Service. Moves the single user, ClusterSchemaServiceImpl
to use relocated internal Guava Service instead.


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/1b4e935c
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/1b4e935c
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/1b4e935c

Branch: refs/heads/master
Commit: 1b4e935cec47cf03c18e11b789177a6484661abd
Parents: 8835602
Author: Michael Stack <stack@apache.org>
Authored: Tue Aug 22 15:27:17 2017 -0700
Committer: Michael Stack <stack@apache.org>
Committed: Thu Aug 24 09:19:36 2017 -0700

----------------------------------------------------------------------
 .../java/org/apache/hadoop/hbase/Service.java   | 50 --------------------
 .../hbase/master/ClusterSchemaService.java      |  2 +-
 .../hbase/master/ClusterSchemaServiceImpl.java  | 27 +++++------
 .../org/apache/hadoop/hbase/master/HMaster.java | 22 ++++++++-
 4 files changed, 33 insertions(+), 68 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/1b4e935c/hbase-common/src/main/java/org/apache/hadoop/hbase/Service.java
----------------------------------------------------------------------
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/Service.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/Service.java
deleted file mode 100644
index 97d93cc..0000000
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/Service.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.hadoop.hbase;
-
-import java.io.IOException;
-
-import org.apache.hadoop.hbase.classification.InterfaceAudience;
-
-/**
- * Simple Service.
- */
-// This is a WIP. We have Services throughout hbase. Either have all implement what is here
or
-// just remove this as an experiment that did not work out.
-// TODO: Move on to guava Service after we update our guava version; later guava has nicer
-// Service implmentation.
-// TODO: Move all Services on to this one Interface.
-@InterfaceAudience.Private
-public interface Service {
-  /**
-   * Initiates service startup (if necessary), returning once the service has finished starting.
-   * @throws IOException Throws exception if already running and if we fail to start successfully.
-   */
-  void startAndWait() throws IOException;
-
-  /**
-   * @return True if this Service is running.
-   */
-  boolean isRunning();
-
-  /**
-   * Initiates service shutdown (if necessary), returning once the service has finished stopping.
-   * @throws IOException Throws exception if not running of if we fail to stop successfully.
-   */
-  void stopAndWait() throws IOException;
-}

http://git-wip-us.apache.org/repos/asf/hbase/blob/1b4e935c/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ClusterSchemaService.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ClusterSchemaService.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ClusterSchemaService.java
index 43353ba..9cfbe8c 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ClusterSchemaService.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ClusterSchemaService.java
@@ -17,8 +17,8 @@
  */
 package org.apache.hadoop.hbase.master;
 
-import org.apache.hadoop.hbase.Service;
 import org.apache.hadoop.hbase.classification.InterfaceAudience;
+import org.apache.hadoop.hbase.shaded.com.google.common.util.concurrent.Service;
 
 /**
  * Mixes in ClusterSchema and Service

http://git-wip-us.apache.org/repos/asf/hbase/blob/1b4e935c/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ClusterSchemaServiceImpl.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ClusterSchemaServiceImpl.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ClusterSchemaServiceImpl.java
index bf3ae7e..69d41ba 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ClusterSchemaServiceImpl.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ClusterSchemaServiceImpl.java
@@ -33,11 +33,11 @@ import org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv;
 import org.apache.hadoop.hbase.master.procedure.ModifyNamespaceProcedure;
 import org.apache.hadoop.hbase.procedure2.Procedure;
 import org.apache.hadoop.hbase.procedure2.ProcedureExecutor;
+import org.apache.hadoop.hbase.shaded.com.google.common.util.concurrent.AbstractService;
 import org.apache.hadoop.hbase.util.NonceKey;
 
 @InterfaceAudience.Private
-class ClusterSchemaServiceImpl implements ClusterSchemaService {
-  private boolean running = false;
+class ClusterSchemaServiceImpl extends AbstractService implements ClusterSchemaService {
   private final TableNamespaceManager tableNamespaceManager;
   private final MasterServices masterServices;
   private final static List<NamespaceDescriptor> EMPTY_NAMESPACE_LIST =
@@ -50,28 +50,25 @@ class ClusterSchemaServiceImpl implements ClusterSchemaService {
 
   // All below are synchronized so consistent view on whether running or not.
 
-  @Override
-  public synchronized boolean isRunning() {
-    return this.running;
-  }
 
   private synchronized void checkIsRunning() throws ServiceNotRunningException {
     if (!isRunning()) throw new ServiceNotRunningException();
   }
 
   @Override
-  public synchronized void startAndWait() throws IOException {
-    if (isRunning()) throw new IllegalStateException("Already running; cannot double-start.");
-    // Set to running FIRST because tableNamespaceManager start uses this class to do namespace
ops
-    this.running = true;
-    this.tableNamespaceManager.start();
+  public synchronized void doStart() {
+    try {
+      notifyStarted();
+      this.tableNamespaceManager.start();
+    } catch (IOException ioe) {
+      notifyFailed(ioe);
+    }
   }
 
   @Override
-  public synchronized void stopAndWait() throws IOException {
-    checkIsRunning();
-    // You can't stop tableNamespaceManager.
-    this.running = false;
+  protected void doStop() {
+    // This is no stop for the table manager.
+    notifyStopped();
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/hbase/blob/1b4e935c/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
index 93624de..0912e06 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
@@ -39,6 +39,7 @@ import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.function.Function;
@@ -305,6 +306,10 @@ public class HMaster extends HRegionServer implements MasterServices
{
 
   private ClusterSchemaService clusterSchemaService;
 
+  public static final String HBASE_MASTER_WAIT_ON_SERVICE_IN_SECONDS =
+    "hbase.master.wait.on.service.seconds";
+  public static final int DEFAULT_HBASE_MASTER_WAIT_ON_SERVICE_IN_SECONDS = 5 * 60;
+
   // Metrics for the HMaster
   final MetricsMaster metricsMaster;
   // file system manager for the master FS operations
@@ -539,6 +544,13 @@ public class HMaster extends HRegionServer implements MasterServices
{
       super.run();
     } finally {
       // If on way out, then we are no longer active master.
+      this.clusterSchemaService.stopAsync();
+      try {
+        this.clusterSchemaService.awaitTerminated(getConfiguration().getInt(HBASE_MASTER_WAIT_ON_SERVICE_IN_SECONDS,
+          DEFAULT_HBASE_MASTER_WAIT_ON_SERVICE_IN_SECONDS), TimeUnit.SECONDS);
+      } catch (TimeoutException te) {
+        LOG.warn("Failed shutdown of clusterSchemaService", te);
+      }
       this.activeMaster = false;
     }
   }
@@ -1014,8 +1026,14 @@ public class HMaster extends HRegionServer implements MasterServices
{
 
   void initClusterSchemaService() throws IOException, InterruptedException {
     this.clusterSchemaService = new ClusterSchemaServiceImpl(this);
-    this.clusterSchemaService.startAndWait();
-    if (!this.clusterSchemaService.isRunning()) throw new HBaseIOException("Failed start");
+    this.clusterSchemaService.startAsync();
+    try {
+      this.clusterSchemaService.awaitRunning(getConfiguration().getInt(
+        HBASE_MASTER_WAIT_ON_SERVICE_IN_SECONDS,
+        DEFAULT_HBASE_MASTER_WAIT_ON_SERVICE_IN_SECONDS), TimeUnit.SECONDS);
+    } catch (TimeoutException toe) {
+      throw new IOException("Timedout starting ClusterSchemaService", toe);
+    }
   }
 
   void initQuotaManager() throws IOException {


Mime
View raw message