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
88356029f1
commit
1b4e935cec
|
@ -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;
|
||||
|
||||
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue