Skip to content

Commit

Permalink
HBASE-26587 Introduce a new Admin API to change SFT implementation (#…
Browse files Browse the repository at this point in the history
…4030) (#4080)

Signed-off-by: Wellington Ramos Chevreuil <[email protected]>
Reviewed-by: Josh Elser <[email protected]>
  • Loading branch information
Apache9 authored Jan 30, 2022
1 parent 76eb1b0 commit dffeb8e
Show file tree
Hide file tree
Showing 30 changed files with 1,716 additions and 276 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
import org.apache.yetus.audience.InterfaceAudience;

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

/**
* The administrative API for HBase. Obtain an instance from {@link Connection#getAdmin()} and
Expand Down Expand Up @@ -806,6 +805,31 @@ default void modifyColumnFamily(TableName tableName, ColumnFamilyDescriptor colu
Future<Void> 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<Void> modifyColumnFamilyStoreFileTrackerAsync(TableName tableName, byte[] family,
String dstSFT) throws IOException;

/**
* Uses {@link #unassign(byte[], boolean)} to unassign the region. For expert-admins.
*
Expand Down Expand Up @@ -1633,6 +1657,28 @@ default Future<Void> modifyTableAsync(TableName tableName, TableDescriptor td)
*/
Future<Void> 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<Void> modifyTableStoreFileTrackerAsync(TableName tableName, String dstSFT)
throws IOException;

/**
* Shuts down the HBase cluster.
* <p/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,13 @@ CompletableFuture<Void> createTable(TableDescriptor desc, byte[] startKey, byte[
*/
CompletableFuture<Void> modifyTable(TableDescriptor desc);

/**
* Change the store file tracker of the given table.
* @param tableName the table you want to change
* @param dstSFT the destination store file tracker
*/
CompletableFuture<Void> modifyTableStoreFileTracker(TableName tableName, String dstSFT);

/**
* Deletes a table.
* @param tableName name of table to delete
Expand Down Expand Up @@ -259,6 +266,15 @@ CompletableFuture<Void> addColumnFamily(TableName tableName,
CompletableFuture<Void> modifyColumnFamily(TableName tableName,
ColumnFamilyDescriptor columnFamily);

/**
* 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
*/
CompletableFuture<Void> modifyColumnFamilyStoreFileTracker(TableName tableName, byte[] family,
String dstSFT);

/**
* Create a new namespace.
* @param descriptor descriptor which describes the new namespace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ public CompletableFuture<Void> modifyTable(TableDescriptor desc) {
return wrap(rawAdmin.modifyTable(desc));
}

@Override
public CompletableFuture<Void> modifyTableStoreFileTracker(TableName tableName, String dstSFT) {
return wrap(rawAdmin.modifyTableStoreFileTracker(tableName, dstSFT));
}

@Override
public CompletableFuture<Void> deleteTable(TableName tableName) {
return wrap(rawAdmin.deleteTable(tableName));
Expand Down Expand Up @@ -199,6 +204,12 @@ public CompletableFuture<Void> modifyColumnFamily(TableName tableName,
return wrap(rawAdmin.modifyColumnFamily(tableName, columnFamily));
}

@Override
public CompletableFuture<Void> modifyColumnFamilyStoreFileTracker(TableName tableName,
byte[] family, String dstSFT) {
return wrap(rawAdmin.modifyColumnFamilyStoreFileTracker(tableName, family, dstSFT));
}

@Override
public CompletableFuture<Void> createNamespace(NamespaceDescriptor descriptor) {
return wrap(rawAdmin.createNamespace(descriptor));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsRpcThrottleEnabledResponse;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ListDecommissionedRegionServersRequest;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ListDecommissionedRegionServersResponse;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ModifyColumnStoreFileTrackerRequest;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ModifyColumnStoreFileTrackerResponse;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ModifyTableStoreFileTrackerRequest;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ModifyTableStoreFileTrackerResponse;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.NormalizeRequest;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.NormalizeResponse;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.RecommissionRegionServerRequest;
Expand Down Expand Up @@ -1948,6 +1952,20 @@ public HBaseProtos.LogEntry getLogEntries(RpcController controller,
HBaseProtos.LogRequest request) throws ServiceException {
return stub.getLogEntries(controller, request);
}

@Override
public ModifyTableStoreFileTrackerResponse modifyTableStoreFileTracker(
RpcController controller, ModifyTableStoreFileTrackerRequest request)
throws ServiceException {
return stub.modifyTableStoreFileTracker(controller, request);
}

@Override
public ModifyColumnStoreFileTrackerResponse modifyColumnStoreFileTracker(
RpcController controller, ModifyColumnStoreFileTrackerRequest request)
throws ServiceException {
return stub.modifyColumnStoreFileTracker(controller, request);
}
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,14 @@
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.MergeTableRegionsResponse;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ModifyColumnRequest;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ModifyColumnResponse;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ModifyColumnStoreFileTrackerRequest;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ModifyColumnStoreFileTrackerResponse;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ModifyNamespaceRequest;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ModifyNamespaceResponse;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ModifyTableRequest;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ModifyTableResponse;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ModifyTableStoreFileTrackerRequest;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ModifyTableStoreFileTrackerResponse;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.MoveRegionRequest;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.RestoreSnapshotRequest;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.RestoreSnapshotResponse;
Expand Down Expand Up @@ -368,19 +372,54 @@ public TableDescriptor getDescriptor(TableName tableName)
public Future<Void> modifyTableAsync(TableDescriptor td) throws IOException {
ModifyTableResponse response = executeCallable(
new MasterCallable<ModifyTableResponse>(getConnection(), getRpcControllerFactory()) {
Long nonceGroup = ng.getNonceGroup();
Long nonce = ng.newNonce();
long nonceGroup = ng.getNonceGroup();
long nonce = ng.newNonce();

@Override
protected ModifyTableResponse rpcCall() throws Exception {
setPriority(td.getTableName());
ModifyTableRequest request = RequestConverter.buildModifyTableRequest(
td.getTableName(), td, nonceGroup, nonce);
ModifyTableRequest request =
RequestConverter.buildModifyTableRequest(td.getTableName(), td, nonceGroup, nonce);
return master.modifyTable(getRpcController(), request);
}
});
return new ModifyTableFuture(this, td.getTableName(), response);
}


@Override
public Future<Void> modifyTableStoreFileTrackerAsync(TableName tableName, String dstSFT)
throws IOException {
ModifyTableStoreFileTrackerResponse response =
executeCallable(new MasterCallable<ModifyTableStoreFileTrackerResponse>(getConnection(),
getRpcControllerFactory()) {
long nonceGroup = ng.getNonceGroup();
long nonce = ng.newNonce();

@Override
protected ModifyTableStoreFileTrackerResponse rpcCall() throws Exception {
setPriority(tableName);
ModifyTableStoreFileTrackerRequest request = RequestConverter
.buildModifyTableStoreFileTrackerRequest(tableName, dstSFT, nonceGroup, nonce);
return master.modifyTableStoreFileTracker(getRpcController(), request);
}
});
return new ModifyTablerStoreFileTrackerFuture(this, tableName, response);
}

private static class ModifyTablerStoreFileTrackerFuture extends ModifyTableFuture {
public ModifyTablerStoreFileTrackerFuture(HBaseAdmin admin, TableName tableName,
ModifyTableStoreFileTrackerResponse response) {
super(admin, tableName,
(response != null && response.hasProcId()) ? response.getProcId() : null);
}

@Override
public String getOperationType() {
return "MODIFY_TABLE_STORE_FILE_TRACKER";
}
}

@Override
public List<TableDescriptor> listTableDescriptorsByNamespace(byte[] name) throws IOException {
return executeCallable(new MasterCallable<List<TableDescriptor>>(getConnection(),
Expand Down Expand Up @@ -1077,21 +1116,20 @@ public String getOperationType() {

@Override
public Future<Void> modifyColumnFamilyAsync(final TableName tableName,
final ColumnFamilyDescriptor columnFamily) throws IOException {
ModifyColumnResponse response =
executeCallable(new MasterCallable<ModifyColumnResponse>(getConnection(),
getRpcControllerFactory()) {
Long nonceGroup = ng.getNonceGroup();
Long nonce = ng.newNonce();
@Override
protected ModifyColumnResponse rpcCall() throws Exception {
setPriority(tableName);
ModifyColumnRequest req =
RequestConverter.buildModifyColumnRequest(tableName, columnFamily,
nonceGroup, nonce);
return master.modifyColumn(getRpcController(), req);
}
});
final ColumnFamilyDescriptor columnFamily) throws IOException {
ModifyColumnResponse response = executeCallable(
new MasterCallable<ModifyColumnResponse>(getConnection(), getRpcControllerFactory()) {
long nonceGroup = ng.getNonceGroup();
long nonce = ng.newNonce();

@Override
protected ModifyColumnResponse rpcCall() throws Exception {
setPriority(tableName);
ModifyColumnRequest req =
RequestConverter.buildModifyColumnRequest(tableName, columnFamily, nonceGroup, nonce);
return master.modifyColumn(getRpcController(), req);
}
});
return new ModifyColumnFamilyFuture(this, tableName, response);
}

Expand All @@ -1108,6 +1146,39 @@ public String getOperationType() {
}
}

@Override
public Future<Void> modifyColumnFamilyStoreFileTrackerAsync(TableName tableName, byte[] family,
String dstSFT) throws IOException {
ModifyColumnStoreFileTrackerResponse response =
executeCallable(new MasterCallable<ModifyColumnStoreFileTrackerResponse>(getConnection(),
getRpcControllerFactory()) {
long nonceGroup = ng.getNonceGroup();
long nonce = ng.newNonce();

@Override
protected ModifyColumnStoreFileTrackerResponse rpcCall() throws Exception {
setPriority(tableName);
ModifyColumnStoreFileTrackerRequest req = RequestConverter
.buildModifyColumnStoreFileTrackerRequest(tableName, family, dstSFT, nonceGroup, nonce);
return master.modifyColumnStoreFileTracker(getRpcController(), req);
}
});
return new ModifyColumnFamilyStoreFileTrackerFuture(this, tableName, response);
}

private static class ModifyColumnFamilyStoreFileTrackerFuture extends ModifyTableFuture {
public ModifyColumnFamilyStoreFileTrackerFuture(HBaseAdmin admin, TableName tableName,
final ModifyColumnStoreFileTrackerResponse response) {
super(admin, tableName,
(response != null && response.hasProcId()) ? response.getProcId() : null);
}

@Override
public String getOperationType() {
return "MODIFY_COLUMN_FAMILY_STORE_FILE_TRACKER";
}
}

@Deprecated
@Override
public void closeRegion(final String regionName, final String unused) throws IOException {
Expand Down
Loading

0 comments on commit dffeb8e

Please sign in to comment.