HBASE-20567 Pass both old and new descriptors to pre/post hooks of modify operations for table and namespace.
Signed-off-by: Mike Drob <mdrob@apache.org>
This commit is contained in:
parent
2c32272dfa
commit
8c9825a030
|
@ -209,20 +209,52 @@ public interface MasterObserver {
|
|||
* table RPC call.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param tableName the name of the table
|
||||
* @param htd the TableDescriptor
|
||||
* @param newDescriptor after modify operation, table will have this descriptor
|
||||
* @deprecated Since 2.1. Will be removed in 3.0.
|
||||
*/
|
||||
@Deprecated
|
||||
default void preModifyTable(final ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
final TableName tableName, TableDescriptor newDescriptor) throws IOException {}
|
||||
|
||||
/**
|
||||
* Called prior to modifying a table's properties. Called as part of modify
|
||||
* table RPC call.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param tableName the name of the table
|
||||
* @param currentDescriptor current TableDescriptor of the table
|
||||
* @param newDescriptor after modify operation, table will have this descriptor
|
||||
*/
|
||||
default void preModifyTable(final ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
final TableName tableName, TableDescriptor htd) throws IOException {}
|
||||
final TableName tableName, TableDescriptor currentDescriptor, TableDescriptor newDescriptor)
|
||||
throws IOException {
|
||||
preModifyTable(ctx, tableName, newDescriptor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after the modifyTable operation has been requested. Called as part
|
||||
* of modify table RPC call.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param tableName the name of the table
|
||||
* @param htd the TableDescriptor
|
||||
* @param currentDescriptor current TableDescriptor of the table
|
||||
* @deprecated Since 2.1. Will be removed in 3.0.
|
||||
*/
|
||||
@Deprecated
|
||||
default void postModifyTable(final ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
final TableName tableName, TableDescriptor currentDescriptor) throws IOException {}
|
||||
|
||||
/**
|
||||
* Called after the modifyTable operation has been requested. Called as part
|
||||
* of modify table RPC call.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param tableName the name of the table
|
||||
* @param oldDescriptor descriptor of table before modify operation happened
|
||||
* @param currentDescriptor current TableDescriptor of the table
|
||||
*/
|
||||
default void postModifyTable(final ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
final TableName tableName, TableDescriptor htd) throws IOException {}
|
||||
final TableName tableName, TableDescriptor oldDescriptor, TableDescriptor currentDescriptor)
|
||||
throws IOException {
|
||||
postModifyTable(ctx, tableName, currentDescriptor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called prior to modifying a table's properties. Called as part of modify
|
||||
|
@ -230,12 +262,31 @@ public interface MasterObserver {
|
|||
*
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param tableName the name of the table
|
||||
* @param htd the TableDescriptor
|
||||
* @param newDescriptor after modify operation, table will have this descriptor
|
||||
* @deprecated Since 2.1. Will be removed in 3.0.
|
||||
*/
|
||||
@Deprecated
|
||||
default void preModifyTableAction(
|
||||
final ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
final TableName tableName,
|
||||
final TableDescriptor newDescriptor) throws IOException {}
|
||||
|
||||
/**
|
||||
* Called prior to modifying a table's properties. Called as part of modify
|
||||
* table procedure and it is async to the modify table RPC call.
|
||||
*
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param tableName the name of the table
|
||||
* @param currentDescriptor current TableDescriptor of the table
|
||||
* @param newDescriptor after modify operation, table will have this descriptor
|
||||
*/
|
||||
default void preModifyTableAction(
|
||||
final ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
final TableName tableName,
|
||||
final TableDescriptor htd) throws IOException {}
|
||||
final TableDescriptor currentDescriptor,
|
||||
final TableDescriptor newDescriptor) throws IOException {
|
||||
preModifyTableAction(ctx, tableName, newDescriptor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after to modifying a table's properties. Called as part of modify
|
||||
|
@ -243,12 +294,31 @@ public interface MasterObserver {
|
|||
*
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param tableName the name of the table
|
||||
* @param htd the TableDescriptor
|
||||
* @param currentDescriptor current TableDescriptor of the table
|
||||
* @deprecated Since 2.1. Will be removed in 3.0.
|
||||
*/
|
||||
@Deprecated
|
||||
default void postCompletedModifyTableAction(
|
||||
final ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
final TableName tableName,
|
||||
final TableDescriptor currentDescriptor) throws IOException {}
|
||||
|
||||
/**
|
||||
* Called after to modifying a table's properties. Called as part of modify
|
||||
* table procedure and it is async to the modify table RPC call.
|
||||
*
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param tableName the name of the table
|
||||
* @param oldDescriptor descriptor of table before modify operation happened
|
||||
* @param currentDescriptor current TableDescriptor of the table
|
||||
*/
|
||||
default void postCompletedModifyTableAction(
|
||||
final ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
final TableName tableName,
|
||||
final TableDescriptor htd) throws IOException {}
|
||||
final TableDescriptor oldDescriptor,
|
||||
final TableDescriptor currentDescriptor) throws IOException {
|
||||
postCompletedModifyTableAction(ctx, tableName, currentDescriptor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called prior to enabling a table. Called as part of enable table RPC call.
|
||||
|
@ -817,18 +887,46 @@ public interface MasterObserver {
|
|||
/**
|
||||
* Called prior to modifying a namespace's properties.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param ns the NamespaceDescriptor
|
||||
* @param newNsDescriptor after modify operation, namespace will have this descriptor
|
||||
* @deprecated Since 2.1. Will be removed in 3.0.
|
||||
*/
|
||||
@Deprecated
|
||||
default void preModifyNamespace(final ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
NamespaceDescriptor newNsDescriptor) throws IOException {}
|
||||
|
||||
/**
|
||||
* Called prior to modifying a namespace's properties.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param currentNsDescriptor current NamespaceDescriptor of the namespace
|
||||
* @param newNsDescriptor after modify operation, namespace will have this descriptor
|
||||
*/
|
||||
default void preModifyNamespace(final ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
NamespaceDescriptor ns) throws IOException {}
|
||||
NamespaceDescriptor currentNsDescriptor, NamespaceDescriptor newNsDescriptor)
|
||||
throws IOException {
|
||||
preModifyNamespace(ctx, newNsDescriptor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after the modifyNamespace operation has been requested.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param ns the NamespaceDescriptor
|
||||
* @param currentNsDescriptor current NamespaceDescriptor of the namespace
|
||||
* @deprecated Since 2.1. Will be removed in 3.0.
|
||||
*/
|
||||
@Deprecated
|
||||
default void postModifyNamespace(final ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
NamespaceDescriptor currentNsDescriptor) throws IOException {}
|
||||
|
||||
/**
|
||||
* Called after the modifyNamespace operation has been requested.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param oldNsDescriptor descriptor of namespace before modify operation happened
|
||||
* @param currentNsDescriptor current NamespaceDescriptor of the namespace
|
||||
*/
|
||||
default void postModifyNamespace(final ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
NamespaceDescriptor ns) throws IOException {}
|
||||
NamespaceDescriptor oldNsDescriptor, NamespaceDescriptor currentNsDescriptor)
|
||||
throws IOException {
|
||||
postModifyNamespace(ctx, currentNsDescriptor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called before a getNamespaceDescriptor request has been processed.
|
||||
|
|
|
@ -2362,16 +2362,18 @@ public class HMaster extends HRegionServer implements MasterServices {
|
|||
}
|
||||
|
||||
@Override
|
||||
public long modifyTable(final TableName tableName, final TableDescriptor descriptor,
|
||||
public long modifyTable(final TableName tableName, final TableDescriptor newDescriptor,
|
||||
final long nonceGroup, final long nonce) throws IOException {
|
||||
checkInitialized();
|
||||
sanityCheckTableDescriptor(descriptor);
|
||||
sanityCheckTableDescriptor(newDescriptor);
|
||||
|
||||
return MasterProcedureUtil.submitProcedure(
|
||||
new MasterProcedureUtil.NonceProcedureRunnable(this, nonceGroup, nonce) {
|
||||
@Override
|
||||
protected void run() throws IOException {
|
||||
getMaster().getMasterCoprocessorHost().preModifyTable(tableName, descriptor);
|
||||
TableDescriptor oldDescriptor = getMaster().getTableDescriptors().get(tableName);
|
||||
getMaster().getMasterCoprocessorHost()
|
||||
.preModifyTable(tableName, oldDescriptor, newDescriptor);
|
||||
|
||||
LOG.info(getClientIdAuditPrefix() + " modify " + tableName);
|
||||
|
||||
|
@ -2380,11 +2382,12 @@ public class HMaster extends HRegionServer implements MasterServices {
|
|||
// We need to wait for the procedure to potentially fail due to "prepare" sanity
|
||||
// checks. This will block only the beginning of the procedure. See HBASE-19953.
|
||||
ProcedurePrepareLatch latch = ProcedurePrepareLatch.createBlockingLatch();
|
||||
submitProcedure(new ModifyTableProcedure(procedureExecutor.getEnvironment(),
|
||||
descriptor, latch));
|
||||
submitProcedure(
|
||||
new ModifyTableProcedure(procedureExecutor.getEnvironment(), newDescriptor, latch));
|
||||
latch.await();
|
||||
|
||||
getMaster().getMasterCoprocessorHost().postModifyTable(tableName, descriptor);
|
||||
getMaster().getMasterCoprocessorHost()
|
||||
.postModifyTable(tableName, oldDescriptor, newDescriptor);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2997,26 +3000,28 @@ public class HMaster extends HRegionServer implements MasterServices {
|
|||
* <code>nonceGroup</code> (the source must ensure each operation gets a unique id).
|
||||
* @return procedure id
|
||||
*/
|
||||
long modifyNamespace(final NamespaceDescriptor namespaceDescriptor, final long nonceGroup,
|
||||
long modifyNamespace(final NamespaceDescriptor newNsDescriptor, final long nonceGroup,
|
||||
final long nonce) throws IOException {
|
||||
checkInitialized();
|
||||
|
||||
TableName.isLegalNamespaceName(Bytes.toBytes(namespaceDescriptor.getName()));
|
||||
TableName.isLegalNamespaceName(Bytes.toBytes(newNsDescriptor.getName()));
|
||||
|
||||
return MasterProcedureUtil.submitProcedure(new MasterProcedureUtil.NonceProcedureRunnable(this,
|
||||
nonceGroup, nonce) {
|
||||
@Override
|
||||
protected void run() throws IOException {
|
||||
getMaster().getMasterCoprocessorHost().preModifyNamespace(namespaceDescriptor);
|
||||
NamespaceDescriptor oldNsDescriptor = getNamespace(newNsDescriptor.getName());
|
||||
getMaster().getMasterCoprocessorHost().preModifyNamespace(oldNsDescriptor, newNsDescriptor);
|
||||
// We need to wait for the procedure to potentially fail due to "prepare" sanity
|
||||
// checks. This will block only the beginning of the procedure. See HBASE-19953.
|
||||
ProcedurePrepareLatch latch = ProcedurePrepareLatch.createBlockingLatch();
|
||||
LOG.info(getClientIdAuditPrefix() + " modify " + namespaceDescriptor);
|
||||
LOG.info(getClientIdAuditPrefix() + " modify " + newNsDescriptor);
|
||||
// Execute the operation synchronously - wait for the operation to complete before
|
||||
// continuing.
|
||||
setProcId(getClusterSchema().modifyNamespace(namespaceDescriptor, getNonceKey(), latch));
|
||||
setProcId(getClusterSchema().modifyNamespace(newNsDescriptor, getNonceKey(), latch));
|
||||
latch.await();
|
||||
getMaster().getMasterCoprocessorHost().postModifyNamespace(namespaceDescriptor);
|
||||
getMaster().getMasterCoprocessorHost().postModifyNamespace(oldNsDescriptor,
|
||||
newNsDescriptor);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -254,20 +254,22 @@ public class MasterCoprocessorHost
|
|||
});
|
||||
}
|
||||
|
||||
public void preModifyNamespace(final NamespaceDescriptor ns) throws IOException {
|
||||
public void preModifyNamespace(final NamespaceDescriptor currentNsDescriptor,
|
||||
final NamespaceDescriptor newNsDescriptor) throws IOException {
|
||||
execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
|
||||
@Override
|
||||
public void call(MasterObserver observer) throws IOException {
|
||||
observer.preModifyNamespace(this, ns);
|
||||
observer.preModifyNamespace(this, currentNsDescriptor, newNsDescriptor);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void postModifyNamespace(final NamespaceDescriptor ns) throws IOException {
|
||||
public void postModifyNamespace(final NamespaceDescriptor oldNsDescriptor,
|
||||
final NamespaceDescriptor currentNsDescriptor) throws IOException {
|
||||
execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
|
||||
@Override
|
||||
public void call(MasterObserver observer) throws IOException {
|
||||
observer.postModifyNamespace(this, ns);
|
||||
observer.postModifyNamespace(this, oldNsDescriptor, currentNsDescriptor);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -429,42 +431,44 @@ public class MasterCoprocessorHost
|
|||
});
|
||||
}
|
||||
|
||||
public void preModifyTable(final TableName tableName, final TableDescriptor htd)
|
||||
throws IOException {
|
||||
public void preModifyTable(final TableName tableName, final TableDescriptor currentDescriptor,
|
||||
final TableDescriptor newDescriptor) throws IOException {
|
||||
execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
|
||||
@Override
|
||||
public void call(MasterObserver observer) throws IOException {
|
||||
observer.preModifyTable(this, tableName, htd);
|
||||
observer.preModifyTable(this, tableName, currentDescriptor, newDescriptor);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void postModifyTable(final TableName tableName, final TableDescriptor htd)
|
||||
throws IOException {
|
||||
public void postModifyTable(final TableName tableName, final TableDescriptor oldDescriptor,
|
||||
final TableDescriptor currentDescriptor) throws IOException {
|
||||
execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
|
||||
@Override
|
||||
public void call(MasterObserver observer) throws IOException {
|
||||
observer.postModifyTable(this, tableName, htd);
|
||||
observer.postModifyTable(this, tableName, oldDescriptor, currentDescriptor);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void preModifyTableAction(final TableName tableName, final TableDescriptor htd,
|
||||
final User user) throws IOException {
|
||||
public void preModifyTableAction(final TableName tableName,
|
||||
final TableDescriptor currentDescriptor, final TableDescriptor newDescriptor, final User user)
|
||||
throws IOException {
|
||||
execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation(user) {
|
||||
@Override
|
||||
public void call(MasterObserver observer) throws IOException {
|
||||
observer.preModifyTableAction(this, tableName, htd);
|
||||
observer.preModifyTableAction(this, tableName, currentDescriptor, newDescriptor);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void postCompletedModifyTableAction(final TableName tableName, final TableDescriptor htd,
|
||||
final User user) throws IOException {
|
||||
public void postCompletedModifyTableAction(final TableName tableName,
|
||||
final TableDescriptor oldDescriptor, final TableDescriptor currentDescriptor, final User user)
|
||||
throws IOException {
|
||||
execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation(user) {
|
||||
@Override
|
||||
public void call(MasterObserver observer) throws IOException {
|
||||
observer.postCompletedModifyTableAction(this, tableName, htd);
|
||||
observer.postCompletedModifyTableAction(this, tableName, oldDescriptor, currentDescriptor);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -420,10 +420,12 @@ public class ModifyTableProcedure
|
|||
if (cpHost != null) {
|
||||
switch (state) {
|
||||
case MODIFY_TABLE_PRE_OPERATION:
|
||||
cpHost.preModifyTableAction(getTableName(), modifiedTableDescriptor, getUser());
|
||||
cpHost.preModifyTableAction(getTableName(), unmodifiedTableDescriptor,
|
||||
modifiedTableDescriptor, getUser());
|
||||
break;
|
||||
case MODIFY_TABLE_POST_OPERATION:
|
||||
cpHost.postCompletedModifyTableAction(getTableName(), modifiedTableDescriptor,getUser());
|
||||
cpHost.postCompletedModifyTableAction(getTableName(), unmodifiedTableDescriptor,
|
||||
modifiedTableDescriptor,getUser());
|
||||
break;
|
||||
default:
|
||||
throw new UnsupportedOperationException(this + " unhandled state=" + state);
|
||||
|
|
Loading…
Reference in New Issue