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.
This commit is contained in:
parent
adbe844ea5
commit
6230d21506
|
@ -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;
|
|
||||||
}
|
|
|
@ -17,8 +17,8 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.hadoop.hbase.master;
|
package org.apache.hadoop.hbase.master;
|
||||||
|
|
||||||
import org.apache.hadoop.hbase.Service;
|
|
||||||
import org.apache.hadoop.hbase.classification.InterfaceAudience;
|
import org.apache.hadoop.hbase.classification.InterfaceAudience;
|
||||||
|
import org.apache.hadoop.hbase.shaded.com.google.common.util.concurrent.Service;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mixes in ClusterSchema and Service
|
* Mixes in ClusterSchema and Service
|
||||||
|
|
|
@ -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.master.procedure.ModifyNamespaceProcedure;
|
||||||
import org.apache.hadoop.hbase.procedure2.Procedure;
|
import org.apache.hadoop.hbase.procedure2.Procedure;
|
||||||
import org.apache.hadoop.hbase.procedure2.ProcedureExecutor;
|
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;
|
import org.apache.hadoop.hbase.util.NonceKey;
|
||||||
|
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
class ClusterSchemaServiceImpl implements ClusterSchemaService {
|
class ClusterSchemaServiceImpl extends AbstractService implements ClusterSchemaService {
|
||||||
private boolean running = false;
|
|
||||||
private final TableNamespaceManager tableNamespaceManager;
|
private final TableNamespaceManager tableNamespaceManager;
|
||||||
private final MasterServices masterServices;
|
private final MasterServices masterServices;
|
||||||
private final static List<NamespaceDescriptor> EMPTY_NAMESPACE_LIST =
|
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.
|
// 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 {
|
private synchronized void checkIsRunning() throws ServiceNotRunningException {
|
||||||
if (!isRunning()) throw new ServiceNotRunningException();
|
if (!isRunning()) throw new ServiceNotRunningException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void startAndWait() throws IOException {
|
public synchronized void doStart() {
|
||||||
if (isRunning()) throw new IllegalStateException("Already running; cannot double-start.");
|
try {
|
||||||
// Set to running FIRST because tableNamespaceManager start uses this class to do namespace ops
|
notifyStarted();
|
||||||
this.running = true;
|
|
||||||
this.tableNamespaceManager.start();
|
this.tableNamespaceManager.start();
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
notifyFailed(ioe);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void stopAndWait() throws IOException {
|
protected void doStop() {
|
||||||
checkIsRunning();
|
// This is no stop for the table manager.
|
||||||
// You can't stop tableNamespaceManager.
|
notifyStopped();
|
||||||
this.running = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -39,6 +39,7 @@ import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
@ -305,6 +306,10 @@ public class HMaster extends HRegionServer implements MasterServices {
|
||||||
|
|
||||||
private ClusterSchemaService clusterSchemaService;
|
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
|
// Metrics for the HMaster
|
||||||
final MetricsMaster metricsMaster;
|
final MetricsMaster metricsMaster;
|
||||||
// file system manager for the master FS operations
|
// file system manager for the master FS operations
|
||||||
|
@ -539,6 +544,13 @@ public class HMaster extends HRegionServer implements MasterServices {
|
||||||
super.run();
|
super.run();
|
||||||
} finally {
|
} finally {
|
||||||
// If on way out, then we are no longer active master.
|
// 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;
|
this.activeMaster = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1014,8 +1026,14 @@ public class HMaster extends HRegionServer implements MasterServices {
|
||||||
|
|
||||||
void initClusterSchemaService() throws IOException, InterruptedException {
|
void initClusterSchemaService() throws IOException, InterruptedException {
|
||||||
this.clusterSchemaService = new ClusterSchemaServiceImpl(this);
|
this.clusterSchemaService = new ClusterSchemaServiceImpl(this);
|
||||||
this.clusterSchemaService.startAndWait();
|
this.clusterSchemaService.startAsync();
|
||||||
if (!this.clusterSchemaService.isRunning()) throw new HBaseIOException("Failed start");
|
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 {
|
void initQuotaManager() throws IOException {
|
||||||
|
|
Loading…
Reference in New Issue