All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.hadoop.hbase.client.Admin Maven / Gradle / Ivy

There is a newer version: 3.0.0-beta-1
Show newest version
/*
 * 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.client;

import static org.apache.hadoop.hbase.util.FutureUtils.get;

import java.io.Closeable;
import java.io.IOException;
import java.util.Collection;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Abortable;
import org.apache.hadoop.hbase.CacheEvictionStats;
import org.apache.hadoop.hbase.ClusterMetrics;
import org.apache.hadoop.hbase.ClusterMetrics.Option;
import org.apache.hadoop.hbase.ClusterStatus;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.NamespaceDescriptor;
import org.apache.hadoop.hbase.NamespaceNotFoundException;
import org.apache.hadoop.hbase.RegionMetrics;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableExistsException;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.TableNotFoundException;
import org.apache.hadoop.hbase.client.replication.ReplicationPeerConfigUtil;
import org.apache.hadoop.hbase.client.replication.TableCFs;
import org.apache.hadoop.hbase.client.security.SecurityCapability;
import org.apache.hadoop.hbase.ipc.CoprocessorRpcChannel;
import org.apache.hadoop.hbase.quotas.QuotaFilter;
import org.apache.hadoop.hbase.quotas.QuotaRetriever;
import org.apache.hadoop.hbase.quotas.QuotaSettings;
import org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshotView;
import org.apache.hadoop.hbase.regionserver.wal.FailedLogCloseException;
import org.apache.hadoop.hbase.replication.ReplicationException;
import org.apache.hadoop.hbase.replication.ReplicationPeerConfig;
import org.apache.hadoop.hbase.replication.ReplicationPeerDescription;
import org.apache.hadoop.hbase.security.access.GetUserPermissionsRequest;
import org.apache.hadoop.hbase.security.access.Permission;
import org.apache.hadoop.hbase.security.access.UserPermission;
import org.apache.hadoop.hbase.snapshot.HBaseSnapshotException;
import org.apache.hadoop.hbase.snapshot.RestoreSnapshotException;
import org.apache.hadoop.hbase.snapshot.SnapshotCreationException;
import org.apache.hadoop.hbase.snapshot.UnknownSnapshotException;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.Pair;
import org.apache.yetus.audience.InterfaceAudience;

import org.apache.hbase.thirdparty.com.google.common.collect.ImmutableList;

/**
 * The administrative API for HBase. Obtain an instance from {@link Connection#getAdmin()} and call
 * {@link #close()} when done.
 * 

* Admin can be used to create, drop, list, enable and disable and otherwise modify tables, as well * as perform other administrative operations. * @see ConnectionFactory * @see Connection * @see Table * @since 0.99.0 */ @InterfaceAudience.Public public interface Admin extends Abortable, Closeable { /** * Return the operation timeout for a rpc call. * @see #getSyncWaitTimeout() */ int getOperationTimeout(); /** * Return the blocking wait time for an asynchronous operation. Can be configured by * {@code hbase.client.sync.wait.timeout.msec}. *

* For several operations, such as createTable, deleteTable, etc, the rpc call will finish right * after we schedule a procedure at master side, so the timeout will not be controlled by the * above {@link #getOperationTimeout()}. And timeout value here tells you how much time we will * wait until the procedure at master side is finished. *

* In general, you can consider that the implementation for XXXX method is just a * XXXXAsync().get(getSyncWaitTimeout(), TimeUnit.MILLISECONDS). * @see #getOperationTimeout() */ int getSyncWaitTimeout(); @Override void abort(String why, Throwable e); @Override boolean isAborted(); /** Returns Connection used by this object. */ Connection getConnection(); /** * Check if a table exists. * @param tableName Table to check. * @return true if table exists already. * @throws IOException if a remote or network exception occurs */ boolean tableExists(TableName tableName) throws IOException; /** * List all the userspace tables. * @return an array of read-only HTableDescriptors * @throws IOException if a remote or network exception occurs * @deprecated since 2.0 version and will be removed in 3.0 version. Use * {@link #listTableDescriptors()}. * @see #listTableDescriptors() */ @Deprecated HTableDescriptor[] listTables() throws IOException; /** * List all the userspace tables. * @return a list of TableDescriptors * @throws IOException if a remote or network exception occurs */ List listTableDescriptors() throws IOException; /** * List all the userspace tables that match the given pattern. * @param pattern The compiled regular expression to match against * @return an array of read-only HTableDescriptors * @throws IOException if a remote or network exception occurs * @see #listTables() * @deprecated since 2.0 version and will be removed in 3.0 version. Use * {@link #listTableDescriptors(java.util.regex.Pattern)}. * @see #listTableDescriptors(Pattern) */ @Deprecated HTableDescriptor[] listTables(Pattern pattern) throws IOException; /** * List all the userspace tables that match the given pattern. * @param pattern The compiled regular expression to match against * @return a list of TableDescriptors * @throws IOException if a remote or network exception occurs * @see #listTables() */ default List listTableDescriptors(Pattern pattern) throws IOException { return listTableDescriptors(pattern, false); } /** * List all the userspace tables matching the given regular expression. * @param regex The regular expression to match against * @return a list of read-only HTableDescriptors * @throws IOException if a remote or network exception occurs * @see #listTableDescriptors(Pattern) * @deprecated since 2.0 version and will be removed in 3.0 version. Use * {@link #listTableDescriptors(Pattern)} instead. */ @Deprecated HTableDescriptor[] listTables(String regex) throws IOException; /** * List all the tables matching the given pattern. * @param pattern The compiled regular expression to match against * @param includeSysTables false to match only against userspace tables * @return an array of read-only HTableDescriptors * @throws IOException if a remote or network exception occurs * @see #listTables() * @deprecated since 2.0 version and will be removed in 3.0 version. Use * {@link #listTableDescriptors(java.util.regex.Pattern, boolean)}. * @see #listTableDescriptors(java.util.regex.Pattern, boolean) */ @Deprecated HTableDescriptor[] listTables(Pattern pattern, boolean includeSysTables) throws IOException; /** * List all the tables matching the given pattern. * @param pattern The compiled regular expression to match against * @param includeSysTables false to match only against userspace tables * @return a list of TableDescriptors * @throws IOException if a remote or network exception occurs * @see #listTables() */ List listTableDescriptors(Pattern pattern, boolean includeSysTables) throws IOException; /** * List all the tables matching the given pattern. * @param regex The regular expression to match against * @param includeSysTables false to match only against userspace tables * @return an array of read-only HTableDescriptors * @throws IOException if a remote or network exception occurs * @see #listTables(java.util.regex.Pattern, boolean) * @deprecated since 2.0 version and will be removed in 3.0 version. Use * {@link #listTableDescriptors(Pattern, boolean)}. */ @Deprecated HTableDescriptor[] listTables(String regex, boolean includeSysTables) throws IOException; /** * List all of the names of userspace tables. * @return TableName[] table names * @throws IOException if a remote or network exception occurs */ TableName[] listTableNames() throws IOException; /** * List all of the names of userspace tables. * @param pattern The regular expression to match against * @return array of table names * @throws IOException if a remote or network exception occurs */ default TableName[] listTableNames(Pattern pattern) throws IOException { return listTableNames(pattern, false); } /** * List all of the names of userspace tables. * @param regex The regular expression to match against * @return TableName[] table names * @throws IOException if a remote or network exception occurs * @deprecated since 2.0 version and will be removed in 3.0 version. Use * {@link #listTableNames(Pattern)} instead. */ @Deprecated TableName[] listTableNames(String regex) throws IOException; /** * List all of the names of userspace tables. * @param pattern The regular expression to match against * @param includeSysTables false to match only against userspace tables * @return TableName[] table names * @throws IOException if a remote or network exception occurs */ TableName[] listTableNames(Pattern pattern, boolean includeSysTables) throws IOException; /** * List all of the names of userspace tables. * @param regex The regular expression to match against * @param includeSysTables false to match only against userspace tables * @return TableName[] table names * @throws IOException if a remote or network exception occurs * @deprecated since 2.0 version and will be removed in 3.0 version. Use * {@link #listTableNames(Pattern, boolean)} instead. */ @Deprecated TableName[] listTableNames(String regex, boolean includeSysTables) throws IOException; /** * Get a table descriptor. * @param tableName as a {@link TableName} * @return the read-only tableDescriptor * @throws TableNotFoundException if the table was not found * @throws IOException if a remote or network exception occurs * @deprecated since 2.0 version and will be removed in 3.0 version. Use * {@link #getDescriptor(TableName)}. */ @Deprecated HTableDescriptor getTableDescriptor(TableName tableName) throws TableNotFoundException, IOException; /** * Get a table descriptor. * @param tableName as a {@link TableName} * @return the tableDescriptor * @throws TableNotFoundException if the table was not found * @throws IOException if a remote or network exception occurs */ TableDescriptor getDescriptor(TableName tableName) throws TableNotFoundException, IOException; /** * Creates a new table. Synchronous operation. * @param desc table descriptor for table * @throws IllegalArgumentException if the table name is reserved * @throws org.apache.hadoop.hbase.MasterNotRunningException if master is not running * @throws TableExistsException if table already exists (If * concurrent threads, the table may * have been created between * test-for-existence and * attempt-at-creation). * @throws IOException if a remote or network exception * occurs */ default void createTable(TableDescriptor desc) throws IOException { get(createTableAsync(desc), getSyncWaitTimeout(), TimeUnit.MILLISECONDS); } /** * Creates a new table with the specified number of regions. The start key specified will become * the end key of the first region of the table, and the end key specified will become the start * key of the last region of the table (the first region has a null start key and the last region * has a null end key). BigInteger math will be used to divide the key range specified into enough * segments to make the required number of total regions. Synchronous operation. * @param desc table descriptor for table * @param startKey beginning of key range * @param endKey end of key range * @param numRegions the total number of regions to create * @throws IllegalArgumentException if the table name is reserved * @throws IOException if a remote or network exception * occurs * @throws org.apache.hadoop.hbase.MasterNotRunningException if master is not running * @throws TableExistsException if table already exists (If * concurrent threads, the table may * have been created between * test-for-existence and * attempt-at-creation). */ void createTable(TableDescriptor desc, byte[] startKey, byte[] endKey, int numRegions) throws IOException; /** * Creates a new table with an initial set of empty regions defined by the specified split keys. * The total number of regions created will be the number of split keys plus one. Synchronous * operation. Note : Avoid passing empty split key. * @param desc table descriptor for table * @param splitKeys array of split keys for the initial regions of the table * @throws IllegalArgumentException if the table name is reserved, if the * split keys are repeated and if the * split key has empty byte array. * @throws org.apache.hadoop.hbase.MasterNotRunningException if master is not running * @throws TableExistsException if table already exists (If * concurrent threads, the table may * have been created between * test-for-existence and * attempt-at-creation). * @throws IOException if a remote or network exception * occurs */ default void createTable(TableDescriptor desc, byte[][] splitKeys) throws IOException { get(createTableAsync(desc, splitKeys), getSyncWaitTimeout(), TimeUnit.MILLISECONDS); } /** * Creates a new table but does not block and wait for it to come online. You can use * Future.get(long, TimeUnit) to wait on the operation to complete. It may throw * ExecutionException if there was an error while executing the operation or TimeoutException in * case the wait timeout was not long enough to allow the operation to complete. *

* Throws IllegalArgumentException Bad table name, if the split keys are repeated and if the split * key has empty byte array. * @param desc table descriptor for table * @throws IOException if a remote or network exception occurs * @return the result of the async creation. You can use Future.get(long, TimeUnit) to wait on the * operation to complete. */ Future createTableAsync(TableDescriptor desc) throws IOException; /** * Creates a new table but does not block and wait for it to come online. You can use * Future.get(long, TimeUnit) to wait on the operation to complete. It may throw * ExecutionException if there was an error while executing the operation or TimeoutException in * case the wait timeout was not long enough to allow the operation to complete. *

* Throws IllegalArgumentException Bad table name, if the split keys are repeated and if the split * key has empty byte array. * @param desc table descriptor for table * @param splitKeys keys to check if the table has been created with all split keys * @throws IOException if a remote or network exception occurs * @return the result of the async creation. You can use Future.get(long, TimeUnit) to wait on the * operation to complete. */ Future createTableAsync(TableDescriptor desc, byte[][] splitKeys) throws IOException; /** * Deletes a table. Synchronous operation. * @param tableName name of table to delete * @throws IOException if a remote or network exception occurs */ default void deleteTable(TableName tableName) throws IOException { get(deleteTableAsync(tableName), getSyncWaitTimeout(), TimeUnit.MILLISECONDS); } /** * Deletes the table but does not block and wait for it to be completely removed. You can use * Future.get(long, TimeUnit) to wait on the operation to complete. It may throw * ExecutionException if there was an error while executing the operation or TimeoutException in * case the wait timeout was not long enough to allow the operation to complete. * @param tableName name of table to delete * @throws IOException if a remote or network exception occurs * @return the result of the async delete. You can use Future.get(long, TimeUnit) to wait on the * operation to complete. */ Future deleteTableAsync(TableName tableName) throws IOException; /** * Deletes tables matching the passed in pattern and wait on completion. Warning: Use this method * carefully, there is no prompting and the effect is immediate. Consider using * {@link #listTableDescriptors(Pattern)} and * {@link #deleteTable(org.apache.hadoop.hbase.TableName)} * @param regex The regular expression to match table names against * @return Table descriptors for tables that couldn't be deleted. The return htds are read-only * @throws IOException if a remote or network exception occurs * @see #deleteTables(java.util.regex.Pattern) * @see #deleteTable(org.apache.hadoop.hbase.TableName) * @deprecated since 2.0 version and will be removed in 3.0 version This is just a trivial helper * method without any magic. Consider using {@link #listTableDescriptors(Pattern)} and * {@link #deleteTable(TableName)} */ @Deprecated HTableDescriptor[] deleteTables(String regex) throws IOException; /** * Delete tables matching the passed in pattern and wait on completion. Warning: Use this method * carefully, there is no prompting and the effect is immediate. Consider using * {@link #listTableDescriptors(java.util.regex.Pattern)} and * {@link #deleteTable(org.apache.hadoop.hbase.TableName)} * @param pattern The pattern to match table names against * @return Table descriptors for tables that couldn't be deleted The return htds are read-only * @throws IOException if a remote or network exception occurs * @deprecated since 2.0 version and will be removed in 3.0 version This is just a trivial helper * method without any magic. Consider using * {@link #listTableDescriptors(java.util.regex.Pattern)} and * {@link #deleteTable(TableName)} */ @Deprecated HTableDescriptor[] deleteTables(Pattern pattern) throws IOException; /** * Truncate a table. Synchronous operation. * @param tableName name of table to truncate * @param preserveSplits true if the splits should be preserved * @throws IOException if a remote or network exception occurs */ default void truncateTable(TableName tableName, boolean preserveSplits) throws IOException { get(truncateTableAsync(tableName, preserveSplits), getSyncWaitTimeout(), TimeUnit.MILLISECONDS); } /** * Truncate the table but does not block and wait for it to be completely enabled. You can use * Future.get(long, TimeUnit) to wait on the operation to complete. It may throw * ExecutionException if there was an error while executing the operation or TimeoutException in * case the wait timeout was not long enough to allow the operation to complete. * @param tableName name of table to delete * @param preserveSplits true if the splits should be preserved * @throws IOException if a remote or network exception occurs * @return the result of the async truncate. You can use Future.get(long, TimeUnit) to wait on the * operation to complete. */ Future truncateTableAsync(TableName tableName, boolean preserveSplits) throws IOException; /** * Enable a table. May timeout. Use {@link #enableTableAsync(org.apache.hadoop.hbase.TableName)} * and {@link #isTableEnabled(org.apache.hadoop.hbase.TableName)} instead. The table has to be in * disabled state for it to be enabled. * @param tableName name of the table * @throws IOException if a remote or network exception occurs There could be couple types of * IOException TableNotFoundException means the table doesn't exist. * TableNotDisabledException means the table isn't in disabled state. * @see #isTableEnabled(org.apache.hadoop.hbase.TableName) * @see #disableTable(org.apache.hadoop.hbase.TableName) * @see #enableTableAsync(org.apache.hadoop.hbase.TableName) */ default void enableTable(TableName tableName) throws IOException { get(enableTableAsync(tableName), getSyncWaitTimeout(), TimeUnit.MILLISECONDS); } /** * Enable the table but does not block and wait for it to be completely enabled. You can use * Future.get(long, TimeUnit) to wait on the operation to complete. It may throw * ExecutionException if there was an error while executing the operation or TimeoutException in * case the wait timeout was not long enough to allow the operation to complete. * @param tableName name of table to delete * @throws IOException if a remote or network exception occurs * @return the result of the async enable. You can use Future.get(long, TimeUnit) to wait on the * operation to complete. */ Future enableTableAsync(TableName tableName) throws IOException; /** * Enable tables matching the passed in pattern and wait on completion. Warning: Use this method * carefully, there is no prompting and the effect is immediate. Consider using * {@link #listTableDescriptors(Pattern)} and * {@link #enableTable(org.apache.hadoop.hbase.TableName)} * @param regex The regular expression to match table names against * @throws IOException if a remote or network exception occurs * @return Table descriptors for tables that couldn't be enabled. The return HTDs are read-only. * @see #enableTables(java.util.regex.Pattern) * @see #enableTable(org.apache.hadoop.hbase.TableName) * @deprecated since 2.0 version and will be removed in 3.0 version This is just a trivial helper * method without any magic. Consider using {@link #listTableDescriptors(Pattern)} and * {@link #enableTable(org.apache.hadoop.hbase.TableName)} */ @Deprecated HTableDescriptor[] enableTables(String regex) throws IOException; /** * Enable tables matching the passed in pattern and wait on completion. Warning: Use this method * carefully, there is no prompting and the effect is immediate. Consider using * {@link #listTableDescriptors(java.util.regex.Pattern)} and * {@link #enableTable(org.apache.hadoop.hbase.TableName)} * @param pattern The pattern to match table names against * @throws IOException if a remote or network exception occurs * @return Table descriptors for tables that couldn't be enabled. The return HTDs are read-only. * @deprecated since 2.0 version and will be removed in 3.0 version This is just a trivial helper * method without any magic. Consider using * {@link #listTableDescriptors(java.util.regex.Pattern)} and * {@link #enableTable(org.apache.hadoop.hbase.TableName)} */ @Deprecated HTableDescriptor[] enableTables(Pattern pattern) throws IOException; /** * Disable the table but does not block and wait for it to be completely disabled. You can use * Future.get(long, TimeUnit) to wait on the operation to complete. It may throw * ExecutionException if there was an error while executing the operation or TimeoutException in * case the wait timeout was not long enough to allow the operation to complete. * @param tableName name of table to delete * @throws IOException if a remote or network exception occurs * @return the result of the async disable. You can use Future.get(long, TimeUnit) to wait on the * operation to complete. */ Future disableTableAsync(TableName tableName) throws IOException; /** * Disable table and wait on completion. May timeout eventually. Use * {@link #disableTableAsync(org.apache.hadoop.hbase.TableName)} and * {@link #isTableDisabled(org.apache.hadoop.hbase.TableName)} instead. The table has to be in * enabled state for it to be disabled. * @throws IOException There could be couple types of IOException TableNotFoundException means the * table doesn't exist. TableNotEnabledException means the table isn't in * enabled state. */ default void disableTable(TableName tableName) throws IOException { get(disableTableAsync(tableName), getSyncWaitTimeout(), TimeUnit.MILLISECONDS); } /** * Disable tables matching the passed in pattern and wait on completion. Warning: Use this method * carefully, there is no prompting and the effect is immediate. Consider using * {@link #listTableDescriptors(Pattern)} and * {@link #disableTable(org.apache.hadoop.hbase.TableName)} * @param regex The regular expression to match table names against * @return Table descriptors for tables that couldn't be disabled The return htds are read-only * @throws IOException if a remote or network exception occurs * @see #disableTables(java.util.regex.Pattern) * @see #disableTable(org.apache.hadoop.hbase.TableName) * @deprecated since 2.0 version and will be removed in 3.0 version This is just a trivial helper * method without any magic. Consider using {@link #listTableDescriptors(Pattern)} and * {@link #disableTable(org.apache.hadoop.hbase.TableName)} */ @Deprecated HTableDescriptor[] disableTables(String regex) throws IOException; /** * Disable tables matching the passed in pattern and wait on completion. Warning: Use this method * carefully, there is no prompting and the effect is immediate. Consider using * {@link #listTableDescriptors(java.util.regex.Pattern)} and * {@link #disableTable(org.apache.hadoop.hbase.TableName)} * @param pattern The pattern to match table names against * @return Table descriptors for tables that couldn't be disabled The return htds are read-only * @throws IOException if a remote or network exception occurs * @deprecated since 2.0 version and will be removed in 3.0 version This is just a trivial helper * method without any magic. Consider using * {@link #listTableDescriptors(java.util.regex.Pattern)} and * {@link #disableTable(org.apache.hadoop.hbase.TableName)} */ @Deprecated HTableDescriptor[] disableTables(Pattern pattern) throws IOException; /** * Check if a table is enabled. * @param tableName name of table to check * @return true if table is on-line * @throws IOException if a remote or network exception occurs */ boolean isTableEnabled(TableName tableName) throws IOException; /** * Check if a table is disabled. * @param tableName name of table to check * @return true if table is off-line * @throws IOException if a remote or network exception occurs */ boolean isTableDisabled(TableName tableName) throws IOException; /** * Check if a table is available. * @param tableName name of table to check * @return true if all regions of the table are available * @throws IOException if a remote or network exception occurs */ boolean isTableAvailable(TableName tableName) throws IOException; /** * Use this api to check if the table has been created with the specified number of splitkeys * which was used while creating the given table. Note : If this api is used after a table's * region gets splitted, the api may return false. * @param tableName name of table to check * @param splitKeys keys to check if the table has been created with all split keys * @throws IOException if a remote or network excpetion occurs * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use {@link #isTableAvailable(TableName)} */ @Deprecated boolean isTableAvailable(TableName tableName, byte[][] splitKeys) throws IOException; /** * Get the status of an alter (a.k.a modify) command - indicates how * many regions have received the updated schema Asynchronous operation. * @param tableName TableName instance * @return Pair indicating the number of regions updated Pair.getFirst() is the regions that are * yet to be updated Pair.getSecond() is the total number of regions of the table * @throws IOException if a remote or network exception occurs * @deprecated Since 2.0.0. Will be removed in 3.0.0. No longer needed now you get a Future on an * operation. */ @Deprecated Pair getAlterStatus(TableName tableName) throws IOException; /** * Get the status of alter (a.k.a modify) command - indicates how many * regions have received the updated schema Asynchronous operation. * @param tableName name of the table to get the status of * @return Pair indicating the number of regions updated Pair.getFirst() is the regions that are * yet to be updated Pair.getSecond() is the total number of regions of the table * @throws IOException if a remote or network exception occurs * @deprecated Since 2.0.0. Will be removed in 3.0.0. No longer needed now you get a Future on an * operation. */ @Deprecated Pair getAlterStatus(byte[] tableName) throws IOException; /** * Add a column family to an existing table. Synchronous operation. Use * {@link #addColumnFamilyAsync(TableName, ColumnFamilyDescriptor)} instead because it returns a * {@link Future} from which you can learn whether success or failure. * @param tableName name of the table to add column family to * @param columnFamily column family descriptor of column family to be added * @throws IOException if a remote or network exception occurs * @deprecated As of release 2.0.0. This will be removed in HBase 3.0.0. Use * {@link #addColumnFamily(TableName, ColumnFamilyDescriptor)}. */ @Deprecated default void addColumn(TableName tableName, ColumnFamilyDescriptor columnFamily) throws IOException { addColumnFamily(tableName, columnFamily); } /** * Add a column family to an existing table. Synchronous operation. Use * {@link #addColumnFamilyAsync(TableName, ColumnFamilyDescriptor)} instead because it returns a * {@link Future} from which you can learn whether success or failure. * @param tableName name of the table to add column family to * @param columnFamily column family descriptor of column family to be added * @throws IOException if a remote or network exception occurs */ default void addColumnFamily(TableName tableName, ColumnFamilyDescriptor columnFamily) throws IOException { get(addColumnFamilyAsync(tableName, columnFamily), getSyncWaitTimeout(), TimeUnit.MILLISECONDS); } /** * Add a column family to an existing table. Asynchronous operation. You can use Future.get(long, * TimeUnit) to wait on the operation to complete. It may throw ExecutionException if there was an * error while executing the operation or TimeoutException in case the wait timeout was not long * enough to allow the operation to complete. * @param tableName name of the table to add column family to * @param columnFamily column family descriptor of column family to be added * @throws IOException if a remote or network exception occurs * @return the result of the async add column family. You can use Future.get(long, TimeUnit) to * wait on the operation to complete. */ Future addColumnFamilyAsync(TableName tableName, ColumnFamilyDescriptor columnFamily) throws IOException; /** * Delete a column family from a table. Synchronous operation. Use * {@link #deleteColumnFamily(TableName, byte[])} instead because it returns a {@link Future} from * which you can learn whether success or failure. * @param tableName name of table * @param columnFamily name of column family to be deleted * @throws IOException if a remote or network exception occurs * @deprecated As of release 2.0.0. This will be removed in HBase 3.0.0. Use * {@link #deleteColumnFamily(TableName, byte[])}}. */ @Deprecated void deleteColumn(TableName tableName, byte[] columnFamily) throws IOException; /** * Delete a column family from a table. Synchronous operation. Use * {@link #deleteColumnFamily(TableName, byte[])} instead because it returns a {@link Future} from * which you can learn whether success or failure. * @param tableName name of table * @param columnFamily name of column family to be deleted * @throws IOException if a remote or network exception occurs */ default void deleteColumnFamily(TableName tableName, byte[] columnFamily) throws IOException { get(deleteColumnFamilyAsync(tableName, columnFamily), getSyncWaitTimeout(), TimeUnit.MILLISECONDS); } /** * Delete a column family from a table. Asynchronous operation. You can use Future.get(long, * TimeUnit) to wait on the operation to complete. It may throw ExecutionException if there was an * error while executing the operation or TimeoutException in case the wait timeout was not long * enough to allow the operation to complete. * @param tableName name of table * @param columnFamily name of column family to be deleted * @throws IOException if a remote or network exception occurs * @return the result of the async delete column family. You can use Future.get(long, TimeUnit) to * wait on the operation to complete. */ Future deleteColumnFamilyAsync(TableName tableName, byte[] columnFamily) throws IOException; /** * Modify an existing column family on a table. Synchronous operation. Use * {@link #modifyColumnFamilyAsync(TableName, ColumnFamilyDescriptor)} instead because it returns * a {@link Future} from which you can learn whether success or failure. * @param tableName name of table * @param columnFamily new column family descriptor to use * @throws IOException if a remote or network exception occurs * @deprecated As of release 2.0.0. This will be removed in HBase 3.0.0. Use * {@link #modifyColumnFamily(TableName, ColumnFamilyDescriptor)}. */ @Deprecated default void modifyColumn(TableName tableName, ColumnFamilyDescriptor columnFamily) throws IOException { modifyColumnFamily(tableName, columnFamily); } /** * Modify an existing column family on a table. Synchronous operation. Use * {@link #modifyColumnFamilyAsync(TableName, ColumnFamilyDescriptor)} instead because it returns * a {@link Future} from which you can learn whether success or failure. * @param tableName name of table * @param columnFamily new column family descriptor to use * @throws IOException if a remote or network exception occurs */ default void modifyColumnFamily(TableName tableName, ColumnFamilyDescriptor columnFamily) throws IOException { get(modifyColumnFamilyAsync(tableName, columnFamily), getSyncWaitTimeout(), TimeUnit.MILLISECONDS); } /** * Modify an existing column family on a table. Asynchronous operation. You can use * Future.get(long, TimeUnit) to wait on the operation to complete. It may throw * ExecutionException if there was an error while executing the operation or TimeoutException in * case the wait timeout was not long enough to allow the operation to complete. * @param tableName name of table * @param columnFamily new column family descriptor to use * @throws IOException if a remote or network exception occurs * @return the result of the async modify column family. You can use Future.get(long, TimeUnit) to * wait on the operation to complete. */ Future modifyColumnFamilyAsync(TableName tableName, ColumnFamilyDescriptor columnFamily) throws IOException; /** * Change the store file tracker of the given table's given family. * @param tableName the table you want to change * @param family the family you want to change * @param dstSFT the destination store file tracker * @throws IOException if a remote or network exception occurs */ default void modifyColumnFamilyStoreFileTracker(TableName tableName, byte[] family, String dstSFT) throws IOException { get(modifyColumnFamilyStoreFileTrackerAsync(tableName, family, dstSFT), getSyncWaitTimeout(), TimeUnit.MILLISECONDS); } /** * Change the store file tracker of the given table's given family. * @param tableName the table you want to change * @param family the family you want to change * @param dstSFT the destination store file tracker * @return the result of the async modify. You can use Future.get(long, TimeUnit) to wait on the * operation to complete * @throws IOException if a remote or network exception occurs */ Future modifyColumnFamilyStoreFileTrackerAsync(TableName tableName, byte[] family, String dstSFT) throws IOException; /** * Uses {@link #unassign(byte[], boolean)} to unassign the region. For expert-admins. * @param regionname region name to close * @param serverName Deprecated. Not used. * @throws IOException if a remote or network exception occurs * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0. Use * {@link #unassign(byte[], boolean)}. */ @Deprecated void closeRegion(String regionname, String serverName) throws IOException; /** * Uses {@link #unassign(byte[], boolean)} to unassign the region. For expert-admins. * @param regionname region name to close * @param serverName Deprecated. Not used. * @throws IOException if a remote or network exception occurs * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0. Use * {@link #unassign(byte[], boolean)}. */ @Deprecated void closeRegion(byte[] regionname, String serverName) throws IOException; /** * Uses {@link #unassign(byte[], boolean)} to unassign the region. For expert-admins. * @param encodedRegionName The encoded region name; i.e. the hash that makes up the region name * suffix: e.g. if regionname is * TestTable,0094429456,1289497600452.527db22f95c8a9e0116f0cc13c680396., * then the encoded region name is: * 527db22f95c8a9e0116f0cc13c680396. * @param serverName Deprecated. Not used. * @return Deprecated. Returns true always. * @throws IOException if a remote or network exception occurs * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0. Use * {@link #unassign(byte[], boolean)}. */ @Deprecated boolean closeRegionWithEncodedRegionName(String encodedRegionName, String serverName) throws IOException; /** * Used {@link #unassign(byte[], boolean)} to unassign the region. For expert-admins. * @param sn Deprecated. Not used. * @throws IOException if a remote or network exception occurs * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0 * (HBASE-18231). Use * {@link #unassign(byte[], boolean)}. */ @Deprecated void closeRegion(final ServerName sn, final HRegionInfo hri) throws IOException; /** * Get all the online regions on a region server. * @throws IOException if a remote or network exception occurs * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0 * (HBASE-17980). Use * {@link #getRegions(ServerName sn)}. */ @Deprecated List getOnlineRegions(ServerName sn) throws IOException; /** * Get all the online regions on a region server. * @return List of {@link RegionInfo} * @throws IOException if a remote or network exception occurs */ List getRegions(ServerName serverName) throws IOException; /** * Flush a table. Synchronous operation. * @param tableName table to flush * @throws IOException if a remote or network exception occurs */ void flush(TableName tableName) throws IOException; /** * Flush the specified column family stores on all regions of the passed table. This runs as a * synchronous operation. * @param tableName table to flush * @param columnFamily column family within a table * @throws IOException if a remote or network exception occurs */ void flush(TableName tableName, byte[] columnFamily) throws IOException; /** * Flush an individual region. Synchronous operation. * @param regionName region to flush * @throws IOException if a remote or network exception occurs */ void flushRegion(byte[] regionName) throws IOException; /** * Flush a column family within a region. Synchronous operation. * @param regionName region to flush * @param columnFamily column family within a region * @throws IOException if a remote or network exception occurs */ void flushRegion(byte[] regionName, byte[] columnFamily) throws IOException; /** * Flush all regions on the region server. Synchronous operation. * @param serverName the region server name to flush * @throws IOException if a remote or network exception occurs */ void flushRegionServer(ServerName serverName) throws IOException; /** * Compact a table. Asynchronous operation in that this method requests that a Compaction run and * then it returns. It does not wait on the completion of Compaction (it can take a while). * @param tableName table to compact * @throws IOException if a remote or network exception occurs */ void compact(TableName tableName) throws IOException; /** * Compact an individual region. Asynchronous operation in that this method requests that a * Compaction run and then it returns. It does not wait on the completion of Compaction (it can * take a while). * @param regionName region to compact * @throws IOException if a remote or network exception occurs */ void compactRegion(byte[] regionName) throws IOException; /** * Compact a column family within a table. Asynchronous operation in that this method requests * that a Compaction run and then it returns. It does not wait on the completion of Compaction (it * can take a while). * @param tableName table to compact * @param columnFamily column family within a table * @throws IOException if a remote or network exception occurs */ void compact(TableName tableName, byte[] columnFamily) throws IOException; /** * Compact a column family within a region. Asynchronous operation in that this method requests * that a Compaction run and then it returns. It does not wait on the completion of Compaction (it * can take a while). * @param regionName region to compact * @param columnFamily column family within a region * @throws IOException if a remote or network exception occurs */ void compactRegion(byte[] regionName, byte[] columnFamily) throws IOException; /** * Compact a table. Asynchronous operation in that this method requests that a Compaction run and * then it returns. It does not wait on the completion of Compaction (it can take a while). * @param tableName table to compact * @param compactType {@link org.apache.hadoop.hbase.client.CompactType} * @throws IOException if a remote or network exception occurs */ void compact(TableName tableName, CompactType compactType) throws IOException, InterruptedException; /** * Compact a column family within a table. Asynchronous operation in that this method requests * that a Compaction run and then it returns. It does not wait on the completion of Compaction (it * can take a while). * @param tableName table to compact * @param columnFamily column family within a table * @param compactType {@link org.apache.hadoop.hbase.client.CompactType} * @throws IOException if not a mob column family or if a remote or network exception occurs */ void compact(TableName tableName, byte[] columnFamily, CompactType compactType) throws IOException, InterruptedException; /** * Major compact a table. Asynchronous operation in that this method requests that a Compaction * run and then it returns. It does not wait on the completion of Compaction (it can take a * while). * @param tableName table to major compact * @throws IOException if a remote or network exception occurs */ void majorCompact(TableName tableName) throws IOException; /** * Major compact a table or an individual region. Asynchronous operation in that this method * requests that a Compaction run and then it returns. It does not wait on the completion of * Compaction (it can take a while). * @param regionName region to major compact * @throws IOException if a remote or network exception occurs */ void majorCompactRegion(byte[] regionName) throws IOException; /** * Major compact a column family within a table. Asynchronous operation in that this method * requests that a Compaction run and then it returns. It does not wait on the completion of * Compaction (it can take a while). * @param tableName table to major compact * @param columnFamily column family within a table * @throws IOException if a remote or network exception occurs */ void majorCompact(TableName tableName, byte[] columnFamily) throws IOException; /** * Major compact a column family within region. Asynchronous operation in that this method * requests that a Compaction run and then it returns. It does not wait on the completion of * Compaction (it can take a while). * @param regionName egion to major compact * @param columnFamily column family within a region * @throws IOException if a remote or network exception occurs */ void majorCompactRegion(byte[] regionName, byte[] columnFamily) throws IOException; /** * Major compact a table. Asynchronous operation in that this method requests that a Compaction * run and then it returns. It does not wait on the completion of Compaction (it can take a * while). * @param tableName table to compact * @param compactType {@link org.apache.hadoop.hbase.client.CompactType} * @throws IOException if a remote or network exception occurs */ void majorCompact(TableName tableName, CompactType compactType) throws IOException, InterruptedException; /** * Major compact a column family within a table. Asynchronous operation in that this method * requests that a Compaction run and then it returns. It does not wait on the completion of * Compaction (it can take a while). * @param tableName table to compact * @param columnFamily column family within a table * @param compactType {@link org.apache.hadoop.hbase.client.CompactType} * @throws IOException if not a mob column family or if a remote or network exception occurs */ void majorCompact(TableName tableName, byte[] columnFamily, CompactType compactType) throws IOException, InterruptedException; /** * Compact all regions on the region server. Asynchronous operation in that this method requests * that a Compaction run and then it returns. It does not wait on the completion of Compaction (it * can take a while). * @param sn the region server name * @param major if it's major compaction * @throws IOException if a remote or network exception occurs * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0. Use * {@link #compactRegionServer(ServerName)} or * {@link #majorCompactRegionServer(ServerName)}. */ @Deprecated default void compactRegionServer(ServerName sn, boolean major) throws IOException, InterruptedException { if (major) { majorCompactRegionServer(sn); } else { compactRegionServer(sn); } } /** * Turn the compaction on or off. Disabling compactions will also interrupt any currently ongoing * compactions. This state is ephemeral. The setting will be lost on restart. Compaction can also * be enabled/disabled by modifying configuration hbase.regionserver.compaction.enabled in * hbase-site.xml. * @param switchState Set to true to enable, false to disable. * @param serverNamesList list of region servers. * @return Previous compaction states for region servers */ Map compactionSwitch(boolean switchState, List serverNamesList) throws IOException; /** * Compact all regions on the region server. Asynchronous operation in that this method requests * that a Compaction run and then it returns. It does not wait on the completion of Compaction (it * can take a while). * @param serverName the region server name * @throws IOException if a remote or network exception occurs */ void compactRegionServer(ServerName serverName) throws IOException; /** * Major compact all regions on the region server. Asynchronous operation in that this method * requests that a Compaction run and then it returns. It does not wait on the completion of * Compaction (it can take a while). * @param serverName the region server name * @throws IOException if a remote or network exception occurs */ void majorCompactRegionServer(ServerName serverName) throws IOException; /** * Move the region encodedRegionName to a random server. * @param encodedRegionName The encoded region name; i.e. the hash that makes up the region name * suffix: e.g. if regionname is * TestTable,0094429456,1289497600452.527db22f95c8a9e0116f0cc13c680396., * then the encoded region name is: * 527db22f95c8a9e0116f0cc13c680396. * @throws IOException if we can't find a region named encodedRegionName */ void move(byte[] encodedRegionName) throws IOException; /** * Move the region rencodedRegionName to destServerName. * @param encodedRegionName The encoded region name; i.e. the hash that makes up the region name * suffix: e.g. if regionname is * TestTable,0094429456,1289497600452.527db22f95c8a9e0116f0cc13c680396., * then the encoded region name is: * 527db22f95c8a9e0116f0cc13c680396. * @param destServerName The servername of the destination regionserver. If passed the empty * byte array we'll assign to a random server. A server name is made of * host, port and startcode. Here is an example: * host187.example.com,60020,1289493121758 * @throws IOException if we can't find a region named encodedRegionName * @deprecated since 2.2.0 and will be removed in 4.0.0. Use {@link #move(byte[], ServerName)} * instead. And if you want to move the region to a random server, please use * {@link #move(byte[])}. * @see HBASE-22108 */ @Deprecated default void move(byte[] encodedRegionName, byte[] destServerName) throws IOException { if (destServerName == null || destServerName.length == 0) { move(encodedRegionName); } else { move(encodedRegionName, ServerName.valueOf(Bytes.toString(destServerName))); } } /** * Move the region rencodedRegionName to destServerName. * @param encodedRegionName The encoded region name; i.e. the hash that makes up the region name * suffix: e.g. if regionname is * TestTable,0094429456,1289497600452.527db22f95c8a9e0116f0cc13c680396., * then the encoded region name is: * 527db22f95c8a9e0116f0cc13c680396. * @param destServerName The servername of the destination regionserver. A server name is made * of host, port and startcode. Here is an example: * host187.example.com,60020,1289493121758 * @throws IOException if we can't find a region named encodedRegionName */ void move(byte[] encodedRegionName, ServerName destServerName) throws IOException; /** * Assign a Region. * @param regionName Region name to assign. * @throws IOException if a remote or network exception occurs */ void assign(byte[] regionName) throws IOException; /** * Unassign a Region. * @param regionName Region name to assign. * @throws IOException if a remote or network exception occurs */ void unassign(byte[] regionName) throws IOException; /** * Unassign a region from current hosting regionserver. Region will then be assigned to a * regionserver chosen at random. Region could be reassigned back to the same server. Use * {@link #move(byte[], ServerName)} if you want to control the region movement. * @param regionName Region to unassign. Will clear any existing RegionPlan if one found. * @param force If true, force unassign (Will remove region from * regions-in-transition too if present. If results in double assignment use * hbck -fix to resolve. To be used by experts). * @throws IOException if a remote or network exception occurs * @deprecated since 2.4.0 and will be removed in 4.0.0. Use {@link #unassign(byte[])} instead. * @see HBASE-24875 */ @Deprecated default void unassign(byte[] regionName, boolean force) throws IOException { unassign(regionName); } /** * Offline specified region from master's in-memory state. It will not attempt to reassign the * region as in unassign. This API can be used when a region not served by any region server and * still online as per Master's in memory state. If this API is incorrectly used on active region * then master will loose track of that region. This is a special method that should be used by * experts or hbck. * @param regionName Region to offline. * @throws IOException if a remote or network exception occurs */ void offline(byte[] regionName) throws IOException; /** * Turn the load balancer on or off. * @param synchronous If true, it waits until current balance() call, if outstanding, * to return. * @return Previous balancer value * @throws IOException if a remote or network exception occurs * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use * {@link #balancerSwitch(boolean, boolean)} instead. */ @Deprecated default boolean setBalancerRunning(boolean on, boolean synchronous) throws IOException { return balancerSwitch(on, synchronous); } /** * Turn the load balancer on or off. * @param onOrOff Set to true to enable, false to disable. * @param synchronous If true, it waits until current balance() call, if outstanding, * to return. * @return Previous balancer value * @throws IOException if a remote or network exception occurs */ boolean balancerSwitch(boolean onOrOff, boolean synchronous) throws IOException; /** * Invoke the balancer. Will run the balancer and if regions to move, it will go ahead and do the * reassignments. Can NOT run for various reasons. Check logs. * @return true if balancer ran, false otherwise. * @throws IOException if a remote or network exception occurs * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use {@link #balance()} instead. */ @Deprecated default boolean balancer() throws IOException { return balance(); } /** * Invoke the balancer. Will run the balancer and if regions to move, it will go ahead and do the * reassignments. Can NOT run for various reasons. Check logs. * @return true if balancer ran, false otherwise. * @throws IOException if a remote or network exception occurs */ default boolean balance() throws IOException { return balance(BalanceRequest.defaultInstance()).isBalancerRan(); } /** * Invoke the balancer with the given balance request. The BalanceRequest defines how the balancer * will run. See {@link BalanceRequest} for more details. * @param request defines how the balancer should run * @return {@link BalanceResponse} with details about the results of the invocation. * @throws IOException if a remote or network exception occurs */ BalanceResponse balance(BalanceRequest request) throws IOException; /** * Invoke the balancer. Will run the balancer and if regions to move, it will go ahead and do the * reassignments. If there is region in transition, force parameter of true would still run * balancer. Can *not* run for other reasons. Check logs. * @param force whether we should force balance even if there is region in transition * @return true if balancer ran, false otherwise. * @throws IOException if a remote or network exception occurs * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use {@link #balance(BalanceRequest)} * instead. */ @Deprecated default boolean balancer(boolean force) throws IOException { return balance(force); } /** * Invoke the balancer. Will run the balancer and if regions to move, it will go ahead and do the * reassignments. If there is region in transition, force parameter of true would still run * balancer. Can *not* run for other reasons. Check logs. * @param force whether we should force balance even if there is region in transition * @return true if balancer ran, false otherwise. * @throws IOException if a remote or network exception occurs * @deprecated Since 2.5.0. Will be removed in 4.0.0. Use {@link #balance(BalanceRequest)} * instead. */ @Deprecated default boolean balance(boolean force) throws IOException { return balance(BalanceRequest.newBuilder().setIgnoreRegionsInTransition(force).build()) .isBalancerRan(); } /** * Query the current state of the balancer. * @return true if the balancer is enabled, false otherwise. * @throws IOException if a remote or network exception occurs */ boolean isBalancerEnabled() throws IOException; /** * Clear all the blocks corresponding to this table from BlockCache. For expert-admins. Calling * this API will drop all the cached blocks specific to a table from BlockCache. This can * significantly impact the query performance as the subsequent queries will have to retrieve the * blocks from underlying filesystem. * @param tableName table to clear block cache * @return CacheEvictionStats related to the eviction * @throws IOException if a remote or network exception occurs */ CacheEvictionStats clearBlockCache(final TableName tableName) throws IOException; /** * Invoke region normalizer. Can NOT run for various reasons. Check logs. This is a non-blocking * invocation to region normalizer. If return value is true, it means the request was submitted * successfully. We need to check logs for the details of which regions were split/merged. * @return {@code true} if region normalizer ran, {@code false} otherwise. * @throws IOException if a remote or network exception occurs */ default boolean normalize() throws IOException { return normalize(new NormalizeTableFilterParams.Builder().build()); } /** * Invoke region normalizer. Can NOT run for various reasons. Check logs. This is a non-blocking * invocation to region normalizer. If return value is true, it means the request was submitted * successfully. We need to check logs for the details of which regions were split/merged. * @param ntfp limit to tables matching the specified filter. * @return {@code true} if region normalizer ran, {@code false} otherwise. * @throws IOException if a remote or network exception occurs */ boolean normalize(NormalizeTableFilterParams ntfp) throws IOException; /** * Query the current state of the region normalizer. * @return true if region normalizer is enabled, false otherwise. * @throws IOException if a remote or network exception occurs */ boolean isNormalizerEnabled() throws IOException; /** * Turn region normalizer on or off. * @return Previous normalizer value * @throws IOException if a remote or network exception occurs * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use {@link #normalizerSwitch(boolean)}} * instead. */ @Deprecated default boolean setNormalizerRunning(boolean on) throws IOException { return normalizerSwitch(on); } /** * Turn region normalizer on or off. * @return Previous normalizer value * @throws IOException if a remote or network exception occurs */ boolean normalizerSwitch(boolean on) throws IOException; /** * Enable/Disable the catalog janitor. * @param enable if true enables the catalog janitor * @return the previous state * @throws IOException if a remote or network exception occurs * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use {@link #catalogJanitorSwitch(boolean)}} * instead. */ @Deprecated default boolean enableCatalogJanitor(boolean enable) throws IOException { return catalogJanitorSwitch(enable); } /** * Enable/Disable the catalog janitor/ * @param onOrOff if true enables the catalog janitor * @return the previous state * @throws IOException if a remote or network exception occurs */ boolean catalogJanitorSwitch(boolean onOrOff) throws IOException; /** * Ask for a scan of the catalog table. * @return the number of entries cleaned. Returns -1 if previous run is in progress. * @throws IOException if a remote or network exception occurs * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use {@link #runCatalogJanitor()}} instead. */ @Deprecated default int runCatalogScan() throws IOException { return runCatalogJanitor(); } /** * Ask for a scan of the catalog table. * @return the number of entries cleaned * @throws IOException if a remote or network exception occurs */ int runCatalogJanitor() throws IOException; /** * Query on the catalog janitor state (Enabled/Disabled?). * @throws IOException if a remote or network exception occurs */ boolean isCatalogJanitorEnabled() throws IOException; /** * Enable/Disable the cleaner chore. * @param on if true enables the cleaner chore * @return the previous state * @throws IOException if a remote or network exception occurs * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use {@link #cleanerChoreSwitch(boolean)}} * instead. */ @Deprecated default boolean setCleanerChoreRunning(boolean on) throws IOException { return cleanerChoreSwitch(on); } /** * Enable/Disable the cleaner chore. * @param onOrOff if true enables the cleaner chore * @return the previous state * @throws IOException if a remote or network exception occurs */ boolean cleanerChoreSwitch(boolean onOrOff) throws IOException; /** * Ask for cleaner chore to run. * @return true if cleaner chore ran, false otherwise * @throws IOException if a remote or network exception occurs */ boolean runCleanerChore() throws IOException; /** * Query on the cleaner chore state (Enabled/Disabled?). * @throws IOException if a remote or network exception occurs */ boolean isCleanerChoreEnabled() throws IOException; /** * Merge two regions. Asynchronous operation. * @param nameOfRegionA encoded or full name of region a * @param nameOfRegionB encoded or full name of region b * @param forcible true if do a compulsory merge, otherwise we will only merge * two adjacent regions * @throws IOException if a remote or network exception occurs * @deprecated Since 2.0. Will be removed in 3.0. Use * {@link #mergeRegionsAsync(byte[], byte[], boolean)} instead. */ @Deprecated void mergeRegions(byte[] nameOfRegionA, byte[] nameOfRegionB, boolean forcible) throws IOException; /** * Merge two regions. Asynchronous operation. * @param nameOfRegionA encoded or full name of region a * @param nameOfRegionB encoded or full name of region b * @param forcible true if do a compulsory merge, otherwise we will only merge * two adjacent regions * @throws IOException if a remote or network exception occurs * @deprecated since 2.3.0 and will be removed in 4.0.0. Multi-region merge feature is now * supported. Use {@link #mergeRegionsAsync(byte[][], boolean)} instead. */ @Deprecated default Future mergeRegionsAsync(byte[] nameOfRegionA, byte[] nameOfRegionB, boolean forcible) throws IOException { byte[][] nameofRegionsToMerge = new byte[2][]; nameofRegionsToMerge[0] = nameOfRegionA; nameofRegionsToMerge[1] = nameOfRegionB; return mergeRegionsAsync(nameofRegionsToMerge, forcible); } /** * Merge multiple regions (>=2). Asynchronous operation. * @param nameofRegionsToMerge encoded or full name of daughter regions * @param forcible true if do a compulsory merge, otherwise we will only * merge adjacent regions * @throws IOException if a remote or network exception occurs */ Future mergeRegionsAsync(byte[][] nameofRegionsToMerge, boolean forcible) throws IOException; /** * Split a table. The method will execute split action for each region in table. Asynchronous * operation. * @param tableName table to split * @throws IOException if a remote or network exception occurs */ void split(TableName tableName) throws IOException; /** * Split an individual region. Asynchronous operation. * @param regionName region to split * @throws IOException if a remote or network exception occurs * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0. Use * {@link #splitRegionAsync(byte[], byte[])}. */ @Deprecated void splitRegion(byte[] regionName) throws IOException; /** * Split a table. Asynchronous operation. * @param tableName table to split * @param splitPoint the explicit position to split on * @throws IOException if a remote or network exception occurs */ void split(TableName tableName, byte[] splitPoint) throws IOException; /** * Split an individual region. Asynchronous operation. * @param regionName region to split * @param splitPoint the explicit position to split on * @throws IOException if a remote or network exception occurs * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0. Use * {@link #splitRegionAsync(byte[], byte[])}. */ @Deprecated void splitRegion(byte[] regionName, byte[] splitPoint) throws IOException; /** * Split an individual region. Asynchronous operation. * @param regionName region to split * @throws IOException if a remote or network exception occurs */ Future splitRegionAsync(byte[] regionName) throws IOException; /** * Split an individual region. Asynchronous operation. * @param regionName region to split * @param splitPoint the explicit position to split on * @throws IOException if a remote or network exception occurs */ Future splitRegionAsync(byte[] regionName, byte[] splitPoint) throws IOException; /** * Modify an existing table, more IRB friendly version. * @param tableName name of table. * @param td modified description of the table * @throws IOException if a remote or network exception occurs * @deprecated since 2.0 version and will be removed in 3.0 version. use * {@link #modifyTable(TableDescriptor)} */ @Deprecated default void modifyTable(TableName tableName, TableDescriptor td) throws IOException { if (!tableName.equals(td.getTableName())) { throw new IllegalArgumentException("the specified table name '" + tableName + "' doesn't match with the HTD one: " + td.getTableName()); } modifyTable(td); } /** * Modify an existing table, more IRB friendly version. * @param td modified description of the table * @throws IOException if a remote or network exception occurs */ default void modifyTable(TableDescriptor td) throws IOException { get(modifyTableAsync(td), getSyncWaitTimeout(), TimeUnit.MILLISECONDS); } /** * Modify an existing table, more IRB friendly version. Asynchronous operation. This means that it * may be a while before your schema change is updated across all of the table. You can use * Future.get(long, TimeUnit) to wait on the operation to complete. It may throw * ExecutionException if there was an error while executing the operation or TimeoutException in * case the wait timeout was not long enough to allow the operation to complete. * @param tableName name of table. * @param td modified description of the table * @throws IOException if a remote or network exception occurs * @return the result of the async modify. You can use Future.get(long, TimeUnit) to wait on the * operation to complete * @deprecated since 2.0 version and will be removed in 3.0 version. use * {@link #modifyTableAsync(TableDescriptor)} */ @Deprecated default Future modifyTableAsync(TableName tableName, TableDescriptor td) throws IOException { if (!tableName.equals(td.getTableName())) { throw new IllegalArgumentException("the specified table name '" + tableName + "' doesn't match with the HTD one: " + td.getTableName()); } return modifyTableAsync(td); } /** * Modify an existing table, more IRB (ruby) friendly version. Asynchronous operation. This means * that it may be a while before your schema change is updated across all of the table. You can * use Future.get(long, TimeUnit) to wait on the operation to complete. It may throw * ExecutionException if there was an error while executing the operation or TimeoutException in * case the wait timeout was not long enough to allow the operation to complete. * @param td description of the table * @throws IOException if a remote or network exception occurs * @return the result of the async modify. You can use Future.get(long, TimeUnit) to wait on the * operation to complete */ Future modifyTableAsync(TableDescriptor td) throws IOException; /** * Change the store file tracker of the given table. * @param tableName the table you want to change * @param dstSFT the destination store file tracker * @throws IOException if a remote or network exception occurs */ default void modifyTableStoreFileTracker(TableName tableName, String dstSFT) throws IOException { get(modifyTableStoreFileTrackerAsync(tableName, dstSFT), getSyncWaitTimeout(), TimeUnit.MILLISECONDS); } /** * Change the store file tracker of the given table. * @param tableName the table you want to change * @param dstSFT the destination store file tracker * @return the result of the async modify. You can use Future.get(long, TimeUnit) to wait on the * operation to complete * @throws IOException if a remote or network exception occurs */ Future modifyTableStoreFileTrackerAsync(TableName tableName, String dstSFT) throws IOException; /** * Shuts down the HBase cluster. *

* Notice that, a success shutdown call may ends with an error since the remote server has already * been shutdown. * @throws IOException if a remote or network exception occurs */ void shutdown() throws IOException; /** * Shuts down the current HBase master only. Does not shutdown the cluster. *

* Notice that, a success stopMaster call may ends with an error since the remote server has * already been shutdown. * @throws IOException if a remote or network exception occurs * @see #shutdown() */ void stopMaster() throws IOException; /** * Check whether Master is in maintenance mode. * @throws IOException if a remote or network exception occurs */ boolean isMasterInMaintenanceMode() throws IOException; /** * Stop the designated regionserver. * @param hostnamePort Hostname and port delimited by a : as in * example.org:1234 * @throws IOException if a remote or network exception occurs */ void stopRegionServer(String hostnamePort) throws IOException; /** * Get whole cluster status, containing status about: * *

   * hbase version
   * cluster id
   * primary/backup master(s)
   * master's coprocessors
   * live/dead regionservers
   * balancer
   * regions in transition
   * 
* * @return cluster status * @throws IOException if a remote or network exception occurs * @deprecated since 2.0 version and will be removed in 3.0 version. use * {@link #getClusterMetrics()} */ @Deprecated default ClusterStatus getClusterStatus() throws IOException { return new ClusterStatus(getClusterMetrics()); } /** * Get whole cluster metrics, containing status about: * *
   * hbase version
   * cluster id
   * primary/backup master(s)
   * master's coprocessors
   * live/dead regionservers
   * balancer
   * regions in transition
   * 
* * @return cluster metrics * @throws IOException if a remote or network exception occurs */ default ClusterMetrics getClusterMetrics() throws IOException { return getClusterMetrics(EnumSet.allOf(ClusterMetrics.Option.class)); } /** * Get cluster status with a set of {@link Option} to get desired status. * @return cluster status * @throws IOException if a remote or network exception occurs */ ClusterMetrics getClusterMetrics(EnumSet

* You can use Future.get(long, TimeUnit) to wait on the operation to complete. It may throw * ExecutionException if there was an error while executing the operation or TimeoutException in * case the wait timeout was not long enough to allow the operation to complete. * @param peerId a short name that identifies the peer * @param peerConfig new config for the replication peer * @return the result of the async operation * @throws IOException IOException if a remote or network exception occurs */ Future updateReplicationPeerConfigAsync(String peerId, ReplicationPeerConfig peerConfig) throws IOException; /** * Append the replicable table column family config from the specified peer. * @param id a short that identifies the cluster * @param tableCfs A map from tableName to column family names * @throws ReplicationException if tableCfs has conflict with existing config * @throws IOException if a remote or network exception occurs */ default void appendReplicationPeerTableCFs(String id, Map> tableCfs) throws ReplicationException, IOException { if (tableCfs == null) { throw new ReplicationException("tableCfs is null"); } ReplicationPeerConfig peerConfig = getReplicationPeerConfig(id); ReplicationPeerConfig newPeerConfig = ReplicationPeerConfigUtil.appendTableCFsToReplicationPeerConfig(tableCfs, peerConfig); updateReplicationPeerConfig(id, newPeerConfig); } /** * Remove some table-cfs from config of the specified peer. * @param id a short name that identifies the cluster * @param tableCfs A map from tableName to column family names * @throws ReplicationException if tableCfs has conflict with existing config * @throws IOException if a remote or network exception occurs */ default void removeReplicationPeerTableCFs(String id, Map> tableCfs) throws ReplicationException, IOException { if (tableCfs == null) { throw new ReplicationException("tableCfs is null"); } ReplicationPeerConfig peerConfig = getReplicationPeerConfig(id); ReplicationPeerConfig newPeerConfig = ReplicationPeerConfigUtil.removeTableCFsFromReplicationPeerConfig(tableCfs, peerConfig, id); updateReplicationPeerConfig(id, newPeerConfig); } /** * Return a list of replication peers. * @return a list of replication peers description * @throws IOException if a remote or network exception occurs */ List listReplicationPeers() throws IOException; /** * Return a list of replication peers. * @param pattern The compiled regular expression to match peer id * @return a list of replication peers description * @throws IOException if a remote or network exception occurs */ List listReplicationPeers(Pattern pattern) throws IOException; /** * Mark region server(s) as decommissioned to prevent additional regions from getting assigned to * them. Optionally unload the regions on the servers. If there are multiple servers to be * decommissioned, decommissioning them at the same time can prevent wasteful region movements. * Region unloading is asynchronous. * @param servers The list of servers to decommission. * @param offload True to offload the regions from the decommissioned servers * @throws IOException if a remote or network exception occurs */ void decommissionRegionServers(List servers, boolean offload) throws IOException; /** * List region servers marked as decommissioned, which can not be assigned regions. * @return List of decommissioned region servers. * @throws IOException if a remote or network exception occurs */ List listDecommissionedRegionServers() throws IOException; /** * Remove decommission marker from a region server to allow regions assignments. Load regions onto * the server if a list of regions is given. Region loading is asynchronous. * @param server The server to recommission. * @param encodedRegionNames Regions to load onto the server. * @throws IOException if a remote or network exception occurs */ void recommissionRegionServer(ServerName server, List encodedRegionNames) throws IOException; /** * Find all table and column families that are replicated from this cluster * @return the replicated table-cfs list of this cluster. * @throws IOException if a remote or network exception occurs */ List listReplicatedTableCFs() throws IOException; /** * Enable a table's replication switch. * @param tableName name of the table * @throws IOException if a remote or network exception occurs */ void enableTableReplication(TableName tableName) throws IOException; /** * Disable a table's replication switch. * @param tableName name of the table * @throws IOException if a remote or network exception occurs */ void disableTableReplication(TableName tableName) throws IOException; /** * Clear compacting queues on a regionserver. * @param serverName the region server name * @param queues the set of queue name * @throws IOException if a remote or network exception occurs */ void clearCompactionQueues(ServerName serverName, Set queues) throws IOException, InterruptedException; /** * List dead region servers. * @return List of dead region servers. * @throws IOException if a remote or network exception occurs */ default List listDeadServers() throws IOException { return getClusterMetrics(EnumSet.of(Option.DEAD_SERVERS)).getDeadServerNames(); } /** * List unknown region servers. * @return List of unknown region servers. */ default List listUnknownServers() throws IOException { return getClusterMetrics(EnumSet.of(Option.UNKNOWN_SERVERS)).getUnknownServerNames(); } /** * Clear dead region servers from master. * @param servers list of dead region servers. * @throws IOException if a remote or network exception occurs * @return List of servers that are not cleared */ List clearDeadServers(List servers) throws IOException; /** * Create a new table by cloning the existent table schema. * @param tableName name of the table to be cloned * @param newTableName name of the new table where the table will be created * @param preserveSplits True if the splits should be preserved * @throws IOException if a remote or network exception occurs */ void cloneTableSchema(TableName tableName, TableName newTableName, boolean preserveSplits) throws IOException; /** * Switch the rpc throttle enable state. * @param enable Set to true to enable, false to disable. * @return Previous rpc throttle enabled value * @throws IOException if a remote or network exception occurs */ boolean switchRpcThrottle(boolean enable) throws IOException; /** * Get if the rpc throttle is enabled. * @return True if rpc throttle is enabled * @throws IOException if a remote or network exception occurs */ boolean isRpcThrottleEnabled() throws IOException; /** * Switch the exceed throttle quota. If enabled, user/table/namespace throttle quota can be * exceeded if region server has availble quota. * @param enable Set to true to enable, false to disable. * @return Previous exceed throttle enabled value * @throws IOException if a remote or network exception occurs */ boolean exceedThrottleQuotaSwitch(final boolean enable) throws IOException; /** * Fetches the table sizes on the filesystem as tracked by the HBase Master. * @throws IOException if a remote or network exception occurs */ Map getSpaceQuotaTableSizes() throws IOException; /** * Fetches the observed {@link SpaceQuotaSnapshotView}s observed by a RegionServer. * @throws IOException if a remote or network exception occurs */ Map getRegionServerSpaceQuotaSnapshots(ServerName serverName) throws IOException; /** * Returns the Master's view of a quota on the given {@code namespace} or null if the Master has * no quota information on that namespace. * @throws IOException if a remote or network exception occurs */ SpaceQuotaSnapshotView getCurrentSpaceQuotaSnapshot(String namespace) throws IOException; /** * Returns the Master's view of a quota on the given {@code tableName} or null if the Master has * no quota information on that table. * @throws IOException if a remote or network exception occurs */ SpaceQuotaSnapshotView getCurrentSpaceQuotaSnapshot(TableName tableName) throws IOException; /** * Grants user specific permissions * @param userPermission user name and the specific permission * @param mergeExistingPermissions If set to false, later granted permissions will override * previous granted permissions. otherwise, it'll merge with * previous granted permissions. * @throws IOException if a remote or network exception occurs */ void grant(UserPermission userPermission, boolean mergeExistingPermissions) throws IOException; /** * Revokes user specific permissions * @param userPermission user name and the specific permission * @throws IOException if a remote or network exception occurs */ void revoke(UserPermission userPermission) throws IOException; /** * Get the global/namespace/table permissions for user * @param getUserPermissionsRequest A request contains which user, global, namespace or table * permissions needed * @return The user and permission list * @throws IOException if a remote or network exception occurs */ List getUserPermissions(GetUserPermissionsRequest getUserPermissionsRequest) throws IOException; /** * Check if the user has specific permissions * @param userName the user name * @param permissions the specific permission list * @return True if user has the specific permissions * @throws IOException if a remote or network exception occurs */ List hasUserPermissions(String userName, List permissions) throws IOException; /** * Check if call user has specific permissions * @param permissions the specific permission list * @return True if user has the specific permissions * @throws IOException if a remote or network exception occurs */ default List hasUserPermissions(List permissions) throws IOException { return hasUserPermissions(null, permissions); } /** * Turn on or off the auto snapshot cleanup based on TTL. * @param on Set to true to enable, false to disable. * @param synchronous If true, it waits until current snapshot cleanup is completed, * if outstanding. * @return Previous auto snapshot cleanup value * @throws IOException if a remote or network exception occurs */ boolean snapshotCleanupSwitch(final boolean on, final boolean synchronous) throws IOException; /** * Query the current state of the auto snapshot cleanup based on TTL. * @return true if the auto snapshot cleanup is enabled, false * otherwise. * @throws IOException if a remote or network exception occurs */ boolean isSnapshotCleanupEnabled() throws IOException; /** * Retrieves online slow/large RPC logs from the provided list of RegionServers * @param serverNames Server names to get slowlog responses from * @param logQueryFilter filter to be used if provided (determines slow / large RPC logs) * @return online slowlog response list * @throws IOException if a remote or network exception occurs * @deprecated since 2.4.0 and will be removed in 4.0.0. Use * {@link #getLogEntries(Set, String, ServerType, int, Map)} instead. */ @Deprecated default List getSlowLogResponses(final Set serverNames, final LogQueryFilter logQueryFilter) throws IOException { String logType; if (LogQueryFilter.Type.LARGE_LOG.equals(logQueryFilter.getType())) { logType = "LARGE_LOG"; } else { logType = "SLOW_LOG"; } Map filterParams = new HashMap<>(); filterParams.put("regionName", logQueryFilter.getRegionName()); filterParams.put("clientAddress", logQueryFilter.getClientAddress()); filterParams.put("tableName", logQueryFilter.getTableName()); filterParams.put("userName", logQueryFilter.getUserName()); filterParams.put("filterByOperator", logQueryFilter.getFilterByOperator().toString()); List logEntries = getLogEntries(serverNames, logType, ServerType.REGION_SERVER, logQueryFilter.getLimit(), filterParams); return logEntries.stream().map(logEntry -> (OnlineLogRecord) logEntry) .collect(Collectors.toList()); } /** * Clears online slow/large RPC logs from the provided list of RegionServers * @param serverNames Set of Server names to clean slowlog responses from * @return List of booleans representing if online slowlog response buffer is cleaned from each * RegionServer * @throws IOException if a remote or network exception occurs */ List clearSlowLogResponses(final Set serverNames) throws IOException; /** * Retrieve recent online records from HMaster / RegionServers. Examples include slow/large RPC * logs, balancer decisions by master. * @param serverNames servers to retrieve records from, useful in case of records maintained by * RegionServer as we can select specific server. In case of * servertype=MASTER, logs will only come from the currently active master. * @param logType string representing type of log records * @param serverType enum for server type: HMaster or RegionServer * @param limit put a limit to list of records that server should send in response * @param filterParams additional filter params * @return Log entries representing online records from servers * @throws IOException if a remote or network exception occurs */ List getLogEntries(Set serverNames, String logType, ServerType serverType, int limit, Map filterParams) throws IOException; /** * Flush master local region */ void flushMasterStore() throws IOException; }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy