HBASE-21762 Move some methods in ClusterConnection to Connection
Signed-off-by: Peter Somogyi <psomogyi@apache.org>
This commit is contained in:
parent
7b867a9d1d
commit
4f3b95b318
|
@ -107,9 +107,12 @@ public interface ClusterConnection extends Connection {
|
|||
final byte [] row) throws IOException;
|
||||
|
||||
/**
|
||||
* Allows flushing the region cache.
|
||||
* @deprecated {@link #clearRegionLocationCache()} instead.
|
||||
*/
|
||||
void clearRegionCache();
|
||||
@Deprecated
|
||||
default void clearRegionCache() {
|
||||
clearRegionLocationCache();
|
||||
}
|
||||
|
||||
void cacheLocation(final TableName tableName, final RegionLocations location);
|
||||
|
||||
|
@ -326,36 +329,4 @@ public interface ClusterConnection extends Connection {
|
|||
* @throws IOException if a remote or network exception occurs
|
||||
*/
|
||||
int getCurrentNrHRS() throws IOException;
|
||||
|
||||
/**
|
||||
* Retrieve an Hbck implementation to fix an HBase cluster.
|
||||
* The returned Hbck is not guaranteed to be thread-safe. A new instance should be created by
|
||||
* each thread. This is a lightweight operation. Pooling or caching of the returned Hbck instance
|
||||
* is not recommended.
|
||||
* <br>
|
||||
* The caller is responsible for calling {@link Hbck#close()} on the returned Hbck instance.
|
||||
*<br>
|
||||
* This will be used mostly by hbck tool.
|
||||
*
|
||||
* @return an Hbck instance for active master. Active master is fetched from the zookeeper.
|
||||
*/
|
||||
Hbck getHbck() throws IOException;
|
||||
|
||||
/**
|
||||
* Retrieve an Hbck implementation to fix an HBase cluster.
|
||||
* The returned Hbck is not guaranteed to be thread-safe. A new instance should be created by
|
||||
* each thread. This is a lightweight operation. Pooling or caching of the returned Hbck instance
|
||||
* is not recommended.
|
||||
* <br>
|
||||
* The caller is responsible for calling {@link Hbck#close()} on the returned Hbck instance.
|
||||
*<br>
|
||||
* This will be used mostly by hbck tool. This may only be used to by pass getting
|
||||
* registered master from ZK. In situations where ZK is not available or active master is not
|
||||
* registered with ZK and user can get master address by other means, master can be explicitly
|
||||
* specified.
|
||||
*
|
||||
* @param masterServer explicit {@link ServerName} for master server
|
||||
* @return an Hbck instance for a specified master server
|
||||
*/
|
||||
Hbck getHbck(ServerName masterServer) throws IOException;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
/*
|
||||
*
|
||||
/**
|
||||
* 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
|
||||
|
@ -21,9 +20,10 @@ package org.apache.hadoop.hbase.client;
|
|||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hbase.Abortable;
|
||||
import org.apache.hadoop.hbase.HBaseInterfaceAudience;
|
||||
import org.apache.hadoop.hbase.ServerName;
|
||||
import org.apache.hadoop.hbase.TableName;
|
||||
import org.apache.yetus.audience.InterfaceAudience;
|
||||
|
||||
|
@ -154,6 +154,16 @@ public interface Connection extends Abortable, Closeable {
|
|||
*/
|
||||
RegionLocator getRegionLocator(TableName tableName) throws IOException;
|
||||
|
||||
/**
|
||||
* Clear all the entries in the region location cache, for all the tables.
|
||||
* <p/>
|
||||
* If you only want to clear the cache for a specific table, use
|
||||
* {@link RegionLocator#clearRegionLocationCache()}.
|
||||
* <p/>
|
||||
* This may cause performance issue so use it with caution.
|
||||
*/
|
||||
void clearRegionLocationCache();
|
||||
|
||||
/**
|
||||
* Retrieve an Admin implementation to administer an HBase cluster.
|
||||
* The returned Admin is not guaranteed to be thread-safe. A new instance should be created for
|
||||
|
@ -182,4 +192,42 @@ public interface Connection extends Abortable, Closeable {
|
|||
* @param pool the thread pool to use for requests like batch and scan
|
||||
*/
|
||||
TableBuilder getTableBuilder(TableName tableName, ExecutorService pool);
|
||||
|
||||
/**
|
||||
* Retrieve an Hbck implementation to fix an HBase cluster.
|
||||
* The returned Hbck is not guaranteed to be thread-safe. A new instance should be created by
|
||||
* each thread. This is a lightweight operation. Pooling or caching of the returned Hbck instance
|
||||
* is not recommended.
|
||||
* <br>
|
||||
* The caller is responsible for calling {@link Hbck#close()} on the returned Hbck instance.
|
||||
*<br>
|
||||
* This will be used mostly by hbck tool.
|
||||
*
|
||||
* @return an Hbck instance for active master. Active master is fetched from the zookeeper.
|
||||
*/
|
||||
@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.HBCK)
|
||||
default Hbck getHbck() throws IOException {
|
||||
throw new UnsupportedOperationException("Not implemented");
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve an Hbck implementation to fix an HBase cluster.
|
||||
* The returned Hbck is not guaranteed to be thread-safe. A new instance should be created by
|
||||
* each thread. This is a lightweight operation. Pooling or caching of the returned Hbck instance
|
||||
* is not recommended.
|
||||
* <br>
|
||||
* The caller is responsible for calling {@link Hbck#close()} on the returned Hbck instance.
|
||||
*<br>
|
||||
* This will be used mostly by hbck tool. This may only be used to by pass getting
|
||||
* registered master from ZK. In situations where ZK is not available or active master is not
|
||||
* registered with ZK and user can get master address by other means, master can be explicitly
|
||||
* specified.
|
||||
*
|
||||
* @param masterServer explicit {@link ServerName} for master server
|
||||
* @return an Hbck instance for a specified master server
|
||||
*/
|
||||
@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.HBCK)
|
||||
default Hbck getHbck(ServerName masterServer) throws IOException {
|
||||
throw new UnsupportedOperationException("Not implemented");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,6 +89,7 @@ import org.apache.hbase.thirdparty.com.google.common.base.Throwables;
|
|||
import org.apache.hbase.thirdparty.com.google.protobuf.BlockingRpcChannel;
|
||||
import org.apache.hbase.thirdparty.com.google.protobuf.RpcController;
|
||||
import org.apache.hbase.thirdparty.com.google.protobuf.ServiceException;
|
||||
|
||||
import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;
|
||||
import org.apache.hadoop.hbase.shaded.protobuf.RequestConverter;
|
||||
import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos;
|
||||
|
@ -993,7 +994,7 @@ class ConnectionImplementation implements ClusterConnection, Closeable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void clearRegionCache() {
|
||||
public void clearRegionLocationCache() {
|
||||
metaCache.clearCache();
|
||||
}
|
||||
|
||||
|
|
|
@ -236,5 +236,9 @@ public class TestMultiTableInputFormatBase {
|
|||
public TableBuilder getTableBuilder(TableName tableName, ExecutorService pool) {
|
||||
return Mockito.mock(TableBuilder.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearRegionLocationCache() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -286,5 +286,9 @@ public class TestTableInputFormatBase {
|
|||
public TableBuilder getTableBuilder(TableName tableName, ExecutorService pool) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearRegionLocationCache() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,12 +19,12 @@ package org.apache.hadoop.hbase;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hbase.client.Admin;
|
||||
import org.apache.hadoop.hbase.client.BufferedMutator;
|
||||
import org.apache.hadoop.hbase.client.BufferedMutatorParams;
|
||||
import org.apache.hadoop.hbase.client.Connection;
|
||||
import org.apache.hadoop.hbase.client.Hbck;
|
||||
import org.apache.hadoop.hbase.client.RegionLocator;
|
||||
import org.apache.hadoop.hbase.client.TableBuilder;
|
||||
import org.apache.yetus.audience.InterfaceAudience;
|
||||
|
@ -90,4 +90,19 @@ public class SharedConnection implements Connection {
|
|||
public TableBuilder getTableBuilder(TableName tableName, ExecutorService pool) {
|
||||
return this.conn.getTableBuilder(tableName, pool);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearRegionLocationCache() {
|
||||
conn.clearRegionLocationCache();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Hbck getHbck() throws IOException {
|
||||
return conn.getHbck();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Hbck getHbck(ServerName masterServer) throws IOException {
|
||||
return conn.getHbck(masterServer);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,7 +64,6 @@ import org.apache.hadoop.hbase.Waiter.ExplainingPredicate;
|
|||
import org.apache.hadoop.hbase.Waiter.Predicate;
|
||||
import org.apache.hadoop.hbase.client.Admin;
|
||||
import org.apache.hadoop.hbase.client.BufferedMutator;
|
||||
import org.apache.hadoop.hbase.client.ClusterConnection;
|
||||
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor;
|
||||
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder;
|
||||
import org.apache.hadoop.hbase.client.Connection;
|
||||
|
@ -3072,7 +3071,7 @@ public class HBaseTestingUtility extends HBaseZKTestingUtility {
|
|||
* Returns an {@link Hbck} instance. Needs be closed when done.
|
||||
*/
|
||||
public Hbck getHbck() throws IOException {
|
||||
return ((ClusterConnection) getConnection()).getHbck();
|
||||
return getConnection().getHbck();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -546,6 +546,10 @@ public class TestWALEntrySinkFilter {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearRegionLocationCache() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -319,4 +319,9 @@ public class ThriftConnection implements Connection {
|
|||
public RegionLocator getRegionLocator(TableName tableName) throws IOException {
|
||||
throw new NotImplementedException("batchCoprocessorService not supported in ThriftTable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearRegionLocationCache() {
|
||||
throw new NotImplementedException("clearRegionLocationCache not supported in ThriftTable");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue