HBASE-18736 Cleanup the HTD/HCD for Admin
This commit is contained in:
parent
a1efda29e9
commit
0e01544838
|
@ -21,12 +21,11 @@ package org.apache.hbase.archetypes.exemplars.client;
|
|||
import java.io.IOException;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.NavigableMap;
|
||||
import org.apache.hadoop.hbase.HColumnDescriptor;
|
||||
import org.apache.hadoop.hbase.HTableDescriptor;
|
||||
import org.apache.hadoop.hbase.NamespaceDescriptor;
|
||||
import org.apache.hadoop.hbase.NamespaceNotFoundException;
|
||||
import org.apache.hadoop.hbase.TableName;
|
||||
import org.apache.hadoop.hbase.client.Admin;
|
||||
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder;
|
||||
import org.apache.hadoop.hbase.client.Connection;
|
||||
import org.apache.hadoop.hbase.client.ConnectionFactory;
|
||||
import org.apache.hadoop.hbase.client.Delete;
|
||||
|
@ -34,6 +33,8 @@ import org.apache.hadoop.hbase.client.Get;
|
|||
import org.apache.hadoop.hbase.client.Put;
|
||||
import org.apache.hadoop.hbase.client.Result;
|
||||
import org.apache.hadoop.hbase.client.Table;
|
||||
import org.apache.hadoop.hbase.client.TableDescriptor;
|
||||
import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
|
||||
import org.apache.hadoop.hbase.util.Bytes;
|
||||
|
||||
/**
|
||||
|
@ -110,9 +111,10 @@ public final class HelloHBase {
|
|||
System.out.println("Creating Table [" + MY_TABLE_NAME.getNameAsString()
|
||||
+ "], with one Column Family ["
|
||||
+ Bytes.toString(MY_COLUMN_FAMILY_NAME) + "].");
|
||||
|
||||
admin.createTable(new HTableDescriptor(MY_TABLE_NAME)
|
||||
.addFamily(new HColumnDescriptor(MY_COLUMN_FAMILY_NAME)));
|
||||
TableDescriptor desc = TableDescriptorBuilder.newBuilder(MY_TABLE_NAME)
|
||||
.addColumnFamily(ColumnFamilyDescriptorBuilder.of(MY_COLUMN_FAMILY_NAME))
|
||||
.build();
|
||||
admin.createTable(desc);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ import org.apache.hadoop.conf.Configuration;
|
|||
import org.apache.hadoop.hbase.Abortable;
|
||||
import org.apache.hadoop.hbase.ClusterStatus;
|
||||
import org.apache.hadoop.hbase.ClusterStatus.Options;
|
||||
import org.apache.hadoop.hbase.HColumnDescriptor;
|
||||
import org.apache.hadoop.hbase.HRegionInfo;
|
||||
import org.apache.hadoop.hbase.HTableDescriptor;
|
||||
import org.apache.hadoop.hbase.NamespaceDescriptor;
|
||||
|
@ -282,23 +281,6 @@ public interface Admin extends Abortable, Closeable {
|
|||
TableDescriptor listTableDescriptor(final 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 org.apache.hadoop.hbase.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
|
||||
* @deprecated since 2.0 version and will be removed in 3.0 version.
|
||||
* use {@link #createTable(TableDescriptor)}
|
||||
*/
|
||||
@Deprecated
|
||||
default void createTable(HTableDescriptor desc) throws IOException {
|
||||
createTable((TableDescriptor) desc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new table. Synchronous operation.
|
||||
*
|
||||
|
@ -311,31 +293,6 @@ public interface Admin extends Abortable, Closeable {
|
|||
*/
|
||||
void createTable(TableDescriptor desc) throws IOException;
|
||||
|
||||
/**
|
||||
* 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 org.apache.hadoop.hbase.MasterNotRunningException if master is not running
|
||||
* @throws org.apache.hadoop.hbase.TableExistsException if table already exists (If concurrent
|
||||
* threads, the table may have been created between test-for-existence and attempt-at-creation).
|
||||
* @throws IOException
|
||||
* @deprecated since 2.0 version and will be removed in 3.0 version.
|
||||
* use {@link #createTable(TableDescriptor, byte[], byte[], int)}
|
||||
*/
|
||||
@Deprecated
|
||||
default void createTable(HTableDescriptor desc, byte[] startKey, byte[] endKey, int numRegions)
|
||||
throws IOException {
|
||||
createTable((TableDescriptor) desc, startKey, endKey, numRegions);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
@ -356,27 +313,6 @@ public interface Admin extends Abortable, Closeable {
|
|||
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 org.apache.hadoop.hbase.TableExistsException if table already exists (If concurrent
|
||||
* threads, the table may have been created between test-for-existence and attempt-at-creation).
|
||||
* @throws IOException
|
||||
* @deprecated since 2.0 version and will be removed in 3.0 version.
|
||||
* use {@link #createTable(TableDescriptor, byte[][])}
|
||||
*/
|
||||
@Deprecated
|
||||
default void createTable(final HTableDescriptor desc, byte[][] splitKeys) throws IOException {
|
||||
createTable((TableDescriptor) desc, splitKeys);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
@ -393,29 +329,6 @@ public interface Admin extends Abortable, Closeable {
|
|||
*/
|
||||
void createTable(final TableDescriptor desc, byte[][] splitKeys) 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.
|
||||
* @deprecated since 2.0 version and will be removed in 3.0 version.
|
||||
* use {@link #createTableAsync(TableDescriptor, byte[][])}
|
||||
*/
|
||||
@Deprecated
|
||||
default Future<Void> createTableAsync(final HTableDescriptor desc, final byte[][] splitKeys)
|
||||
throws IOException {
|
||||
return createTableAsync((TableDescriptor) desc, splitKeys);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
|
@ -718,8 +631,10 @@ public interface Admin extends Abortable, Closeable {
|
|||
* Use {@link #addColumnFamily(TableName, ColumnFamilyDescriptor)}.
|
||||
*/
|
||||
@Deprecated
|
||||
void addColumn(final TableName tableName, final HColumnDescriptor columnFamily)
|
||||
throws IOException;
|
||||
default void addColumn(final TableName tableName, final ColumnFamilyDescriptor columnFamily)
|
||||
throws IOException {
|
||||
addColumnFamily(tableName, columnFamily);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a column family to an existing table.
|
||||
|
@ -798,8 +713,10 @@ public interface Admin extends Abortable, Closeable {
|
|||
* Use {@link #modifyColumnFamily(TableName, ColumnFamilyDescriptor)}.
|
||||
*/
|
||||
@Deprecated
|
||||
void modifyColumn(final TableName tableName, final HColumnDescriptor columnFamily)
|
||||
throws IOException;
|
||||
default void modifyColumn(final TableName tableName, final ColumnFamilyDescriptor columnFamily)
|
||||
throws IOException {
|
||||
modifyColumnFamily(tableName, columnFamily);
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify an existing column family on a table.
|
||||
|
@ -1231,13 +1148,13 @@ public interface Admin extends Abortable, Closeable {
|
|||
* Modify an existing table, more IRB friendly version.
|
||||
*
|
||||
* @param tableName name of table.
|
||||
* @param htd modified description of the 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
|
||||
void modifyTable(final TableName tableName, final HTableDescriptor htd)
|
||||
void modifyTable(final TableName tableName, final TableDescriptor td)
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
|
@ -1257,7 +1174,7 @@ public interface Admin extends Abortable, Closeable {
|
|||
* operation to complete.
|
||||
*
|
||||
* @param tableName name of table.
|
||||
* @param htd modified description of the 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
|
||||
|
@ -1265,7 +1182,7 @@ public interface Admin extends Abortable, Closeable {
|
|||
* use {@link #modifyTableAsync(TableDescriptor)}
|
||||
*/
|
||||
@Deprecated
|
||||
Future<Void> modifyTableAsync(final TableName tableName, final HTableDescriptor htd)
|
||||
Future<Void> modifyTableAsync(final TableName tableName, final TableDescriptor td)
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
|
|
|
@ -994,18 +994,6 @@ public class HBaseAdmin implements Admin {
|
|||
return getAlterStatus(TableName.valueOf(tableName));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @deprecated Since 2.0. Will be removed in 3.0. Use
|
||||
* {@link #addColumnFamily(TableName, ColumnFamilyDescriptor)} instead.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public void addColumn(final TableName tableName, final HColumnDescriptor columnFamily)
|
||||
throws IOException {
|
||||
addColumnFamily(tableName, columnFamily);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addColumnFamily(final TableName tableName, final ColumnFamilyDescriptor columnFamily)
|
||||
throws IOException {
|
||||
|
@ -1092,18 +1080,6 @@ public class HBaseAdmin implements Admin {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @deprecated As of 2.0. Will be removed in 3.0. Use
|
||||
* {@link #modifyColumnFamily(TableName, ColumnFamilyDescriptor)} instead.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public void modifyColumn(final TableName tableName, final HColumnDescriptor columnFamily)
|
||||
throws IOException {
|
||||
modifyColumnFamily(tableName, columnFamily);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyColumnFamily(final TableName tableName,
|
||||
final ColumnFamilyDescriptor columnFamily) throws IOException {
|
||||
|
@ -1872,29 +1848,19 @@ public class HBaseAdmin implements Admin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void modifyTable(final TableName tableName, final HTableDescriptor htd)
|
||||
public void modifyTable(final TableName tableName, final TableDescriptor td)
|
||||
throws IOException {
|
||||
get(modifyTableAsync(tableName, htd), syncWaitTimeout, TimeUnit.MILLISECONDS);
|
||||
get(modifyTableAsync(tableName, td), syncWaitTimeout, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Future<Void> modifyTableAsync(final TableName tableName, final HTableDescriptor htd)
|
||||
public Future<Void> modifyTableAsync(final TableName tableName, final TableDescriptor td)
|
||||
throws IOException {
|
||||
if (!tableName.equals(htd.getTableName())) {
|
||||
if (!tableName.equals(td.getTableName())) {
|
||||
throw new IllegalArgumentException("the specified table name '" + tableName +
|
||||
"' doesn't match with the HTD one: " + htd.getTableName());
|
||||
"' doesn't match with the HTD one: " + td.getTableName());
|
||||
}
|
||||
ModifyTableResponse response = executeCallable(
|
||||
new MasterCallable<ModifyTableResponse>(getConnection(), getRpcControllerFactory()) {
|
||||
@Override
|
||||
protected ModifyTableResponse rpcCall() throws Exception {
|
||||
setPriority(tableName);
|
||||
ModifyTableRequest request = RequestConverter.buildModifyTableRequest(
|
||||
tableName, htd, ng.getNonceGroup(), ng.newNonce());
|
||||
return master.modifyTable(getRpcController(), request);
|
||||
}
|
||||
});
|
||||
return new ModifyTableFuture(this, tableName, response);
|
||||
return modifyTableAsync(td);
|
||||
}
|
||||
|
||||
private static class ModifyTableFuture extends TableFuture<Void> {
|
||||
|
|
|
@ -243,12 +243,8 @@ public class HTable implements Table {
|
|||
|
||||
@Override
|
||||
public TableDescriptor getDescriptor() throws IOException {
|
||||
HTableDescriptor htd = HBaseAdmin.getHTableDescriptor(tableName, connection, rpcCallerFactory,
|
||||
return HBaseAdmin.getTableDescriptor(tableName, connection, rpcCallerFactory,
|
||||
rpcControllerFactory, operationTimeout, readRpcTimeout);
|
||||
if (htd != null) {
|
||||
return new ImmutableHTableDescriptor(htd);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -438,7 +438,7 @@ public final class SnapshotInfo extends AbstractHBaseTool {
|
|||
}
|
||||
|
||||
/**
|
||||
* Dump the {@link org.apache.hadoop.hbase.HTableDescriptor}
|
||||
* Dump the {@link org.apache.hadoop.hbase.client.TableDescriptor}
|
||||
*/
|
||||
private void printSchema() {
|
||||
System.out.println("Table Descriptor");
|
||||
|
|
Loading…
Reference in New Issue