HBASE-5584 Coprocessor hooks can be called in the respective handlers (Ram)
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1334560 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9c8d4067ce
commit
4774650cc1
|
@ -44,6 +44,18 @@ public class BaseMasterObserver implements MasterObserver {
|
|||
HTableDescriptor desc, HRegionInfo[] regions) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preCreateTableHandler(
|
||||
final ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
HTableDescriptor desc, HRegionInfo[] regions) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postCreateTableHandler(
|
||||
final ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
HTableDescriptor desc, HRegionInfo[] regions) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preDeleteTable(ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
byte[] tableName) throws IOException {
|
||||
|
@ -54,11 +66,35 @@ public class BaseMasterObserver implements MasterObserver {
|
|||
byte[] tableName) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preDeleteTableHandler(
|
||||
final ObserverContext<MasterCoprocessorEnvironment> ctx, byte[] tableName)
|
||||
throws IOException{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postDeleteTableHandler(
|
||||
final ObserverContext<MasterCoprocessorEnvironment> ctx, byte[] tableName)
|
||||
throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preModifyTable(ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
byte[] tableName, HTableDescriptor htd) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postModifyTableHandler(
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx, byte[] tableName,
|
||||
HTableDescriptor htd) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preModifyTableHandler(
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx, byte[] tableName,
|
||||
HTableDescriptor htd) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postModifyTable(ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
byte[] tableName, HTableDescriptor htd) throws IOException {
|
||||
|
@ -74,6 +110,18 @@ public class BaseMasterObserver implements MasterObserver {
|
|||
byte[] tableName, HColumnDescriptor column) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preAddColumnHandler(
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx, byte[] tableName,
|
||||
HColumnDescriptor column) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postAddColumnHandler(
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx, byte[] tableName,
|
||||
HColumnDescriptor column) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preModifyColumn(ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
byte[] tableName, HColumnDescriptor descriptor) throws IOException {
|
||||
|
@ -84,6 +132,18 @@ public class BaseMasterObserver implements MasterObserver {
|
|||
byte[] tableName, HColumnDescriptor descriptor) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preModifyColumnHandler(
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx, byte[] tableName,
|
||||
HColumnDescriptor descriptor) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postModifyColumnHandler(
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx, byte[] tableName,
|
||||
HColumnDescriptor descriptor) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preDeleteColumn(ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
byte[] tableName, byte[] c) throws IOException {
|
||||
|
@ -94,6 +154,19 @@ public class BaseMasterObserver implements MasterObserver {
|
|||
byte[] tableName, byte[] c) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preDeleteColumnHandler(
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx, byte[] tableName,
|
||||
byte[] c) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postDeleteColumnHandler(
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx, byte[] tableName,
|
||||
byte[] c) throws IOException {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void preEnableTable(ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
byte[] tableName) throws IOException {
|
||||
|
@ -104,6 +177,18 @@ public class BaseMasterObserver implements MasterObserver {
|
|||
byte[] tableName) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preEnableTableHandler(
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx, byte[] tableName)
|
||||
throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postEnableTableHandler(
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx, byte[] tableName)
|
||||
throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preDisableTable(ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
byte[] tableName) throws IOException {
|
||||
|
@ -114,11 +199,23 @@ public class BaseMasterObserver implements MasterObserver {
|
|||
byte[] tableName) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preDisableTableHandler(
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx, byte[] tableName)
|
||||
throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postDisableTableHandler(
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx, byte[] tableName)
|
||||
throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preAssign(ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
HRegionInfo regionInfo) throws IOException {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void postAssign(ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
HRegionInfo regionInfo) throws IOException {
|
||||
|
|
|
@ -36,7 +36,8 @@ public interface MasterObserver extends Coprocessor {
|
|||
|
||||
/**
|
||||
* Called before a new table is created by
|
||||
* {@link org.apache.hadoop.hbase.master.HMaster}.
|
||||
* {@link org.apache.hadoop.hbase.master.HMaster}. Called as part of create
|
||||
* table RPC call.
|
||||
* It can't bypass the default action, e.g., ctx.bypass() won't have effect.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param desc the HTableDescriptor for the table
|
||||
|
@ -47,7 +48,8 @@ public interface MasterObserver extends Coprocessor {
|
|||
HTableDescriptor desc, HRegionInfo[] regions) throws IOException;
|
||||
|
||||
/**
|
||||
* Called after the createTable operation has been requested.
|
||||
* Called after the createTable operation has been requested. Called as part
|
||||
* of create table RPC call.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param desc the HTableDescriptor for the table
|
||||
* @param regions the initial regions created for the table
|
||||
|
@ -55,10 +57,34 @@ public interface MasterObserver extends Coprocessor {
|
|||
*/
|
||||
void postCreateTable(final ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
HTableDescriptor desc, HRegionInfo[] regions) throws IOException;
|
||||
/**
|
||||
* Called before a new table is created by
|
||||
* {@link org.apache.hadoop.hbase.master.HMaster}. Called as part of create
|
||||
* table handler and it is async to the create RPC call.
|
||||
* It can't bypass the default action, e.g., ctx.bypass() won't have effect.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param desc the HTableDescriptor for the table
|
||||
* @param regions the initial regions created for the table
|
||||
* @throws IOException
|
||||
*/
|
||||
void preCreateTableHandler(final ObserverContext<MasterCoprocessorEnvironment>
|
||||
ctx, HTableDescriptor desc, HRegionInfo[] regions) throws IOException;
|
||||
|
||||
/**
|
||||
* Called after the createTable operation has been requested. Called as part
|
||||
* of create table RPC call. Called as part of create table handler and
|
||||
* it is async to the create RPC call.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param desc the HTableDescriptor for the table
|
||||
* @param regions the initial regions created for the table
|
||||
* @throws IOException
|
||||
*/
|
||||
void postCreateTableHandler(final ObserverContext<MasterCoprocessorEnvironment>
|
||||
ctx, HTableDescriptor desc, HRegionInfo[] regions) throws IOException;
|
||||
|
||||
/**
|
||||
* Called before {@link org.apache.hadoop.hbase.master.HMaster} deletes a
|
||||
* table
|
||||
* table. Called as part of delete table RPC call.
|
||||
* It can't bypass the default action, e.g., ctx.bypass() won't have effect.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param tableName the name of the table
|
||||
|
@ -67,7 +93,8 @@ public interface MasterObserver extends Coprocessor {
|
|||
byte[] tableName) throws IOException;
|
||||
|
||||
/**
|
||||
* Called after the deleteTable operation has been requested.
|
||||
* Called after the deleteTable operation has been requested. Called as part
|
||||
* of delete table RPC call.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param tableName the name of the table
|
||||
*/
|
||||
|
@ -75,7 +102,32 @@ public interface MasterObserver extends Coprocessor {
|
|||
byte[] tableName) throws IOException;
|
||||
|
||||
/**
|
||||
* Called prior to modifying a table's properties.
|
||||
* Called before {@link org.apache.hadoop.hbase.master.HMaster} deletes a
|
||||
* table. Called as part of delete table handler and
|
||||
* it is async to the delete RPC call.
|
||||
* It can't bypass the default action, e.g., ctx.bypass() won't have effect.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param tableName the name of the table
|
||||
*/
|
||||
void preDeleteTableHandler(
|
||||
final ObserverContext<MasterCoprocessorEnvironment> ctx, byte[] tableName)
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
* Called after {@link org.apache.hadoop.hbase.master.HMaster} deletes a
|
||||
* table. Called as part of delete table handler and it is async to the
|
||||
* delete RPC call.
|
||||
* It can't bypass the default action, e.g., ctx.bypass() won't have effect.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param tableName the name of the table
|
||||
*/
|
||||
void postDeleteTableHandler(
|
||||
final ObserverContext<MasterCoprocessorEnvironment> ctx, byte[] tableName)
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
* Called prior to modifying a table's properties. Called as part of modify
|
||||
* table RPC call.
|
||||
* It can't bypass the default action, e.g., ctx.bypass() won't have effect.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param tableName the name of the table
|
||||
|
@ -85,7 +137,8 @@ public interface MasterObserver extends Coprocessor {
|
|||
final byte[] tableName, HTableDescriptor htd) throws IOException;
|
||||
|
||||
/**
|
||||
* Called after the modifyTable operation has been requested.
|
||||
* 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 HTableDescriptor
|
||||
|
@ -94,7 +147,32 @@ public interface MasterObserver extends Coprocessor {
|
|||
final byte[] tableName, HTableDescriptor htd) throws IOException;
|
||||
|
||||
/**
|
||||
* Called prior to adding a new column family to the table.
|
||||
* Called prior to modifying a table's properties. Called as part of modify
|
||||
* table handler and it is async to the modify table RPC call.
|
||||
* It can't bypass the default action, e.g., ctx.bypass() won't have effect.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param tableName the name of the table
|
||||
* @param htd the HTableDescriptor
|
||||
*/
|
||||
void preModifyTableHandler(
|
||||
final ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
final byte[] tableName, HTableDescriptor htd) throws IOException;
|
||||
|
||||
/**
|
||||
* Called after to modifying a table's properties. Called as part of modify
|
||||
* table handler and it is async to the modify table RPC call.
|
||||
* It can't bypass the default action, e.g., ctx.bypass() won't have effect.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param tableName the name of the table
|
||||
* @param htd the HTableDescriptor
|
||||
*/
|
||||
void postModifyTableHandler(
|
||||
final ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
final byte[] tableName, HTableDescriptor htd) throws IOException;
|
||||
|
||||
/**
|
||||
* Called prior to adding a new column family to the table. Called as part of
|
||||
* add column RPC call.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param tableName the name of the table
|
||||
* @param column the HColumnDescriptor
|
||||
|
@ -103,7 +181,8 @@ public interface MasterObserver extends Coprocessor {
|
|||
byte[] tableName, HColumnDescriptor column) throws IOException;
|
||||
|
||||
/**
|
||||
* Called after the new column family has been created.
|
||||
* Called after the new column family has been created. Called as part of
|
||||
* add column RPC call.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param tableName the name of the table
|
||||
* @param column the HColumnDescriptor
|
||||
|
@ -112,7 +191,30 @@ public interface MasterObserver extends Coprocessor {
|
|||
byte[] tableName, HColumnDescriptor column) throws IOException;
|
||||
|
||||
/**
|
||||
* Called prior to modifying a column family's attributes.
|
||||
* Called prior to adding a new column family to the table. Called as part of
|
||||
* add column handler.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param tableName the name of the table
|
||||
* @param column the HColumnDescriptor
|
||||
*/
|
||||
void preAddColumnHandler(
|
||||
final ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
byte[] tableName, HColumnDescriptor column) throws IOException;
|
||||
|
||||
/**
|
||||
* Called after the new column family has been created. Called as part of
|
||||
* add column handler.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param tableName the name of the table
|
||||
* @param column the HColumnDescriptor
|
||||
*/
|
||||
void postAddColumnHandler(
|
||||
final ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
byte[] tableName, HColumnDescriptor column) throws IOException;
|
||||
|
||||
/**
|
||||
* Called prior to modifying a column family's attributes. Called as part of
|
||||
* modify column RPC call.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param tableName the name of the table
|
||||
* @param descriptor the HColumnDescriptor
|
||||
|
@ -121,7 +223,8 @@ public interface MasterObserver extends Coprocessor {
|
|||
byte [] tableName, HColumnDescriptor descriptor) throws IOException;
|
||||
|
||||
/**
|
||||
* Called after the column family has been updated.
|
||||
* Called after the column family has been updated. Called as part of modify
|
||||
* column RPC call.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param tableName the name of the table
|
||||
* @param descriptor the HColumnDescriptor
|
||||
|
@ -130,7 +233,31 @@ public interface MasterObserver extends Coprocessor {
|
|||
byte[] tableName, HColumnDescriptor descriptor) throws IOException;
|
||||
|
||||
/**
|
||||
* Called prior to deleting the entire column family.
|
||||
* Called prior to modifying a column family's attributes. Called as part of
|
||||
* modify column handler.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param tableName the name of the table
|
||||
* @param descriptor the HColumnDescriptor
|
||||
*/
|
||||
void preModifyColumnHandler(
|
||||
final ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
byte[] tableName, HColumnDescriptor descriptor) throws IOException;
|
||||
|
||||
/**
|
||||
* Called after the column family has been updated. Called as part of modify
|
||||
* column handler.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param tableName the name of the table
|
||||
* @param descriptor the HColumnDescriptor
|
||||
*/
|
||||
void postModifyColumnHandler(
|
||||
final ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
byte[] tableName, HColumnDescriptor descriptor) throws IOException;
|
||||
|
||||
|
||||
/**
|
||||
* Called prior to deleting the entire column family. Called as part of
|
||||
* delete column RPC call.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param tableName the name of the table
|
||||
* @param c the column
|
||||
|
@ -139,7 +266,8 @@ public interface MasterObserver extends Coprocessor {
|
|||
final byte [] tableName, final byte[] c) throws IOException;
|
||||
|
||||
/**
|
||||
* Called after the column family has been deleted.
|
||||
* Called after the column family has been deleted. Called as part of delete
|
||||
* column RPC call.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param tableName the name of the table
|
||||
* @param c the column
|
||||
|
@ -148,7 +276,29 @@ public interface MasterObserver extends Coprocessor {
|
|||
final byte [] tableName, final byte[] c) throws IOException;
|
||||
|
||||
/**
|
||||
* Called prior to enabling a table.
|
||||
* Called prior to deleting the entire column family. Called as part of
|
||||
* delete column handler.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param tableName the name of the table
|
||||
* @param c the column
|
||||
*/
|
||||
void preDeleteColumnHandler(
|
||||
final ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
final byte[] tableName, final byte[] c) throws IOException;
|
||||
|
||||
/**
|
||||
* Called after the column family has been deleted. Called as part of
|
||||
* delete column handler.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param tableName the name of the table
|
||||
* @param c the column
|
||||
*/
|
||||
void postDeleteColumnHandler(
|
||||
final ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
final byte[] tableName, final byte[] c) throws IOException;
|
||||
|
||||
/**
|
||||
* Called prior to enabling a table. Called as part of enable table RPC call.
|
||||
* It can't bypass the default action, e.g., ctx.bypass() won't have effect.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param tableName the name of the table
|
||||
|
@ -157,7 +307,8 @@ public interface MasterObserver extends Coprocessor {
|
|||
final byte[] tableName) throws IOException;
|
||||
|
||||
/**
|
||||
* Called after the enableTable operation has been requested.
|
||||
* Called after the enableTable operation has been requested. Called as part
|
||||
* of enable table RPC call.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param tableName the name of the table
|
||||
*/
|
||||
|
@ -165,7 +316,29 @@ public interface MasterObserver extends Coprocessor {
|
|||
final byte[] tableName) throws IOException;
|
||||
|
||||
/**
|
||||
* Called prior to disabling a table.
|
||||
* Called prior to enabling a table. Called as part of enable table handler
|
||||
* and it is async to the enable table RPC call.
|
||||
* It can't bypass the default action, e.g., ctx.bypass() won't have effect.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param tableName the name of the table
|
||||
*/
|
||||
void preEnableTableHandler(
|
||||
final ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
final byte[] tableName) throws IOException;
|
||||
|
||||
/**
|
||||
* Called after the enableTable operation has been requested. Called as part
|
||||
* of enable table handler and it is async to the enable table RPC call.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param tableName the name of the table
|
||||
*/
|
||||
void postEnableTableHandler(
|
||||
final ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
final byte[] tableName) throws IOException;
|
||||
|
||||
/**
|
||||
* Called prior to disabling a table. Called as part of disable table RPC
|
||||
* call.
|
||||
* It can't bypass the default action, e.g., ctx.bypass() won't have effect.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param tableName the name of the table
|
||||
|
@ -174,13 +347,35 @@ public interface MasterObserver extends Coprocessor {
|
|||
final byte[] tableName) throws IOException;
|
||||
|
||||
/**
|
||||
* Called after the disableTable operation has been requested.
|
||||
* Called after the disableTable operation has been requested. Called as part
|
||||
* of disable table RPC call.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param tableName the name of the table
|
||||
*/
|
||||
void postDisableTable(final ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
final byte[] tableName) throws IOException;
|
||||
|
||||
/**
|
||||
* Called prior to disabling a table. Called as part of disable table handler
|
||||
* and it is asyn to the disable table RPC call.
|
||||
* It can't bypass the default action, e.g., ctx.bypass() won't have effect.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param tableName the name of the table
|
||||
*/
|
||||
void preDisableTableHandler(
|
||||
final ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
final byte[] tableName) throws IOException;
|
||||
|
||||
/**
|
||||
* Called after the disableTable operation has been requested. Called as part
|
||||
* of disable table handler and it is asyn to the disable table RPC call.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param tableName the name of the table
|
||||
*/
|
||||
void postDisableTableHandler(
|
||||
final ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
final byte[] tableName) throws IOException;
|
||||
|
||||
/**
|
||||
* Called prior to moving a given region from one region server to another.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
|
@ -212,7 +407,7 @@ public interface MasterObserver extends Coprocessor {
|
|||
*/
|
||||
void preAssign(final ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
final HRegionInfo regionInfo) throws IOException;
|
||||
|
||||
|
||||
/**
|
||||
* Called after the region assignment has been requested.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
|
@ -220,7 +415,7 @@ public interface MasterObserver extends Coprocessor {
|
|||
*/
|
||||
void postAssign(final ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
final HRegionInfo regionInfo) throws IOException;
|
||||
|
||||
|
||||
/**
|
||||
* Called prior to unassigning a given region.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
|
|
|
@ -81,7 +81,7 @@ public class MasterCoprocessorHost
|
|||
}
|
||||
|
||||
/* Implementation of hooks for invoking MasterObservers */
|
||||
void preCreateTable(HTableDescriptor htd, HRegionInfo[] regions)
|
||||
public void preCreateTable(HTableDescriptor htd, HRegionInfo[] regions)
|
||||
throws IOException {
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx = null;
|
||||
for (MasterEnvironment env: coprocessors) {
|
||||
|
@ -99,7 +99,7 @@ public class MasterCoprocessorHost
|
|||
}
|
||||
}
|
||||
|
||||
void postCreateTable(HTableDescriptor htd, HRegionInfo[] regions)
|
||||
public void postCreateTable(HTableDescriptor htd, HRegionInfo[] regions)
|
||||
throws IOException {
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx = null;
|
||||
for (MasterEnvironment env: coprocessors) {
|
||||
|
@ -117,7 +117,44 @@ public class MasterCoprocessorHost
|
|||
}
|
||||
}
|
||||
|
||||
void preDeleteTable(byte[] tableName) throws IOException {
|
||||
public void preCreateTableHandler(HTableDescriptor htd, HRegionInfo[] regions)
|
||||
throws IOException {
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx = null;
|
||||
for (MasterEnvironment env : coprocessors) {
|
||||
if (env.getInstance() instanceof MasterObserver) {
|
||||
ctx = ObserverContext.createAndPrepare(env, ctx);
|
||||
try {
|
||||
((MasterObserver) env.getInstance()).preCreateTableHandler(ctx, htd,
|
||||
regions);
|
||||
} catch (Throwable e) {
|
||||
handleCoprocessorThrowable(env, e);
|
||||
}
|
||||
if (ctx.shouldComplete()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void postCreateTableHandler(HTableDescriptor htd, HRegionInfo[] regions)
|
||||
throws IOException {
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx = null;
|
||||
for (MasterEnvironment env : coprocessors) {
|
||||
if (env.getInstance() instanceof MasterObserver) {
|
||||
ctx = ObserverContext.createAndPrepare(env, ctx);
|
||||
try {
|
||||
((MasterObserver) env.getInstance()).postCreateTableHandler(ctx, htd,
|
||||
regions);
|
||||
} catch (Throwable e) {
|
||||
handleCoprocessorThrowable(env, e);
|
||||
}
|
||||
if (ctx.shouldComplete()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void preDeleteTable(byte[] tableName) throws IOException {
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx = null;
|
||||
for (MasterEnvironment env: coprocessors) {
|
||||
if (env.getInstance() instanceof MasterObserver) {
|
||||
|
@ -134,7 +171,7 @@ public class MasterCoprocessorHost
|
|||
}
|
||||
}
|
||||
|
||||
void postDeleteTable(byte[] tableName) throws IOException {
|
||||
public void postDeleteTable(byte[] tableName) throws IOException {
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx = null;
|
||||
for (MasterEnvironment env: coprocessors) {
|
||||
if (env.getInstance() instanceof MasterObserver) {
|
||||
|
@ -151,7 +188,42 @@ public class MasterCoprocessorHost
|
|||
}
|
||||
}
|
||||
|
||||
void preModifyTable(final byte[] tableName, HTableDescriptor htd)
|
||||
public void preDeleteTableHandler(byte[] tableName) throws IOException {
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx = null;
|
||||
for (MasterEnvironment env : coprocessors) {
|
||||
if (env.getInstance() instanceof MasterObserver) {
|
||||
ctx = ObserverContext.createAndPrepare(env, ctx);
|
||||
try {
|
||||
((MasterObserver) env.getInstance()).preDeleteTableHandler(ctx,
|
||||
tableName);
|
||||
} catch (Throwable e) {
|
||||
handleCoprocessorThrowable(env, e);
|
||||
}
|
||||
if (ctx.shouldComplete()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void postDeleteTableHandler(byte[] tableName) throws IOException {
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx = null;
|
||||
for (MasterEnvironment env : coprocessors) {
|
||||
if (env.getInstance() instanceof MasterObserver) {
|
||||
ctx = ObserverContext.createAndPrepare(env, ctx);
|
||||
try {
|
||||
((MasterObserver) env.getInstance()).postDeleteTableHandler(ctx,
|
||||
tableName);
|
||||
} catch (Throwable e) {
|
||||
handleCoprocessorThrowable(env, e);
|
||||
}
|
||||
if (ctx.shouldComplete()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void preModifyTable(final byte[] tableName, HTableDescriptor htd)
|
||||
throws IOException {
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx = null;
|
||||
for (MasterEnvironment env: coprocessors) {
|
||||
|
@ -170,7 +242,7 @@ public class MasterCoprocessorHost
|
|||
}
|
||||
}
|
||||
|
||||
void postModifyTable(final byte[] tableName, HTableDescriptor htd)
|
||||
public void postModifyTable(final byte[] tableName, HTableDescriptor htd)
|
||||
throws IOException {
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx = null;
|
||||
for (MasterEnvironment env: coprocessors) {
|
||||
|
@ -189,7 +261,45 @@ public class MasterCoprocessorHost
|
|||
}
|
||||
}
|
||||
|
||||
boolean preAddColumn(byte [] tableName, HColumnDescriptor column)
|
||||
public void preModifyTableHandler(final byte[] tableName, HTableDescriptor htd)
|
||||
throws IOException {
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx = null;
|
||||
for (MasterEnvironment env : coprocessors) {
|
||||
if (env.getInstance() instanceof MasterObserver) {
|
||||
ctx = ObserverContext.createAndPrepare(env, ctx);
|
||||
try {
|
||||
((MasterObserver) env.getInstance()).preModifyTableHandler(ctx,
|
||||
tableName, htd);
|
||||
} catch (Throwable e) {
|
||||
handleCoprocessorThrowable(env, e);
|
||||
}
|
||||
if (ctx.shouldComplete()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void postModifyTableHandler(final byte[] tableName,
|
||||
HTableDescriptor htd) throws IOException {
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx = null;
|
||||
for (MasterEnvironment env : coprocessors) {
|
||||
if (env.getInstance() instanceof MasterObserver) {
|
||||
ctx = ObserverContext.createAndPrepare(env, ctx);
|
||||
try {
|
||||
((MasterObserver) env.getInstance()).postModifyTableHandler(ctx,
|
||||
tableName, htd);
|
||||
} catch (Throwable e) {
|
||||
handleCoprocessorThrowable(env, e);
|
||||
}
|
||||
if (ctx.shouldComplete()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean preAddColumn(byte [] tableName, HColumnDescriptor column)
|
||||
throws IOException {
|
||||
boolean bypass = false;
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx = null;
|
||||
|
@ -210,7 +320,7 @@ public class MasterCoprocessorHost
|
|||
return bypass;
|
||||
}
|
||||
|
||||
void postAddColumn(byte [] tableName, HColumnDescriptor column)
|
||||
public void postAddColumn(byte [] tableName, HColumnDescriptor column)
|
||||
throws IOException {
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx = null;
|
||||
for (MasterEnvironment env: coprocessors) {
|
||||
|
@ -229,7 +339,48 @@ public class MasterCoprocessorHost
|
|||
}
|
||||
}
|
||||
|
||||
boolean preModifyColumn(byte [] tableName, HColumnDescriptor descriptor)
|
||||
public boolean preAddColumnHandler(byte[] tableName, HColumnDescriptor column)
|
||||
throws IOException {
|
||||
boolean bypass = false;
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx = null;
|
||||
for (MasterEnvironment env : coprocessors) {
|
||||
if (env.getInstance() instanceof MasterObserver) {
|
||||
ctx = ObserverContext.createAndPrepare(env, ctx);
|
||||
try {
|
||||
((MasterObserver) env.getInstance()).preAddColumnHandler(ctx,
|
||||
tableName, column);
|
||||
} catch (Throwable e) {
|
||||
handleCoprocessorThrowable(env, e);
|
||||
}
|
||||
bypass |= ctx.shouldBypass();
|
||||
if (ctx.shouldComplete()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return bypass;
|
||||
}
|
||||
|
||||
public void postAddColumnHandler(byte[] tableName, HColumnDescriptor column)
|
||||
throws IOException {
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx = null;
|
||||
for (MasterEnvironment env : coprocessors) {
|
||||
if (env.getInstance() instanceof MasterObserver) {
|
||||
ctx = ObserverContext.createAndPrepare(env, ctx);
|
||||
try {
|
||||
((MasterObserver) env.getInstance()).postAddColumnHandler(ctx,
|
||||
tableName, column);
|
||||
} catch (Throwable e) {
|
||||
handleCoprocessorThrowable(env, e);
|
||||
}
|
||||
if (ctx.shouldComplete()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean preModifyColumn(byte [] tableName, HColumnDescriptor descriptor)
|
||||
throws IOException {
|
||||
boolean bypass = false;
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx = null;
|
||||
|
@ -251,7 +402,7 @@ public class MasterCoprocessorHost
|
|||
return bypass;
|
||||
}
|
||||
|
||||
void postModifyColumn(byte [] tableName, HColumnDescriptor descriptor)
|
||||
public void postModifyColumn(byte [] tableName, HColumnDescriptor descriptor)
|
||||
throws IOException {
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx = null;
|
||||
for (MasterEnvironment env: coprocessors) {
|
||||
|
@ -270,6 +421,47 @@ public class MasterCoprocessorHost
|
|||
}
|
||||
}
|
||||
|
||||
public boolean preModifyColumnHandler(byte[] tableName,
|
||||
HColumnDescriptor descriptor) throws IOException {
|
||||
boolean bypass = false;
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx = null;
|
||||
for (MasterEnvironment env : coprocessors) {
|
||||
if (env.getInstance() instanceof MasterObserver) {
|
||||
ctx = ObserverContext.createAndPrepare(env, ctx);
|
||||
try {
|
||||
((MasterObserver) env.getInstance()).preModifyColumnHandler(ctx,
|
||||
tableName, descriptor);
|
||||
} catch (Throwable e) {
|
||||
handleCoprocessorThrowable(env, e);
|
||||
}
|
||||
bypass |= ctx.shouldBypass();
|
||||
if (ctx.shouldComplete()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return bypass;
|
||||
}
|
||||
|
||||
public void postModifyColumnHandler(byte[] tableName,
|
||||
HColumnDescriptor descriptor) throws IOException {
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx = null;
|
||||
for (MasterEnvironment env : coprocessors) {
|
||||
if (env.getInstance() instanceof MasterObserver) {
|
||||
ctx = ObserverContext.createAndPrepare(env, ctx);
|
||||
try {
|
||||
((MasterObserver) env.getInstance()).postModifyColumnHandler(ctx,
|
||||
tableName, descriptor);
|
||||
} catch (Throwable e) {
|
||||
handleCoprocessorThrowable(env, e);
|
||||
}
|
||||
if (ctx.shouldComplete()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean preDeleteColumn(final byte [] tableName, final byte [] c)
|
||||
throws IOException {
|
||||
boolean bypass = false;
|
||||
|
@ -291,7 +483,7 @@ public class MasterCoprocessorHost
|
|||
return bypass;
|
||||
}
|
||||
|
||||
void postDeleteColumn(final byte [] tableName, final byte [] c)
|
||||
public void postDeleteColumn(final byte [] tableName, final byte [] c)
|
||||
throws IOException {
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx = null;
|
||||
for (MasterEnvironment env: coprocessors) {
|
||||
|
@ -310,7 +502,48 @@ public class MasterCoprocessorHost
|
|||
}
|
||||
}
|
||||
|
||||
void preEnableTable(final byte [] tableName) throws IOException {
|
||||
public boolean preDeleteColumnHandler(final byte[] tableName, final byte[] c)
|
||||
throws IOException {
|
||||
boolean bypass = false;
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx = null;
|
||||
for (MasterEnvironment env : coprocessors) {
|
||||
if (env.getInstance() instanceof MasterObserver) {
|
||||
ctx = ObserverContext.createAndPrepare(env, ctx);
|
||||
try {
|
||||
((MasterObserver) env.getInstance()).preDeleteColumnHandler(ctx,
|
||||
tableName, c);
|
||||
} catch (Throwable e) {
|
||||
handleCoprocessorThrowable(env, e);
|
||||
}
|
||||
bypass |= ctx.shouldBypass();
|
||||
if (ctx.shouldComplete()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return bypass;
|
||||
}
|
||||
|
||||
public void postDeleteColumnHandler(final byte[] tableName, final byte[] c)
|
||||
throws IOException {
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx = null;
|
||||
for (MasterEnvironment env : coprocessors) {
|
||||
if (env.getInstance() instanceof MasterObserver) {
|
||||
ctx = ObserverContext.createAndPrepare(env, ctx);
|
||||
try {
|
||||
((MasterObserver) env.getInstance()).postDeleteColumnHandler(ctx,
|
||||
tableName, c);
|
||||
} catch (Throwable e) {
|
||||
handleCoprocessorThrowable(env, e);
|
||||
}
|
||||
if (ctx.shouldComplete()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void preEnableTable(final byte [] tableName) throws IOException {
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx = null;
|
||||
for (MasterEnvironment env: coprocessors) {
|
||||
if (env.getInstance() instanceof MasterObserver) {
|
||||
|
@ -327,7 +560,7 @@ public class MasterCoprocessorHost
|
|||
}
|
||||
}
|
||||
|
||||
void postEnableTable(final byte [] tableName) throws IOException {
|
||||
public void postEnableTable(final byte [] tableName) throws IOException {
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx = null;
|
||||
for (MasterEnvironment env: coprocessors) {
|
||||
if (env.getInstance() instanceof MasterObserver) {
|
||||
|
@ -344,7 +577,43 @@ public class MasterCoprocessorHost
|
|||
}
|
||||
}
|
||||
|
||||
void preDisableTable(final byte [] tableName) throws IOException {
|
||||
public void preEnableTableHandler(final byte[] tableName) throws IOException {
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx = null;
|
||||
for (MasterEnvironment env : coprocessors) {
|
||||
if (env.getInstance() instanceof MasterObserver) {
|
||||
ctx = ObserverContext.createAndPrepare(env, ctx);
|
||||
try {
|
||||
((MasterObserver) env.getInstance()).preEnableTableHandler(ctx,
|
||||
tableName);
|
||||
} catch (Throwable e) {
|
||||
handleCoprocessorThrowable(env, e);
|
||||
}
|
||||
if (ctx.shouldComplete()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void postEnableTableHandler(final byte[] tableName) throws IOException {
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx = null;
|
||||
for (MasterEnvironment env : coprocessors) {
|
||||
if (env.getInstance() instanceof MasterObserver) {
|
||||
ctx = ObserverContext.createAndPrepare(env, ctx);
|
||||
try {
|
||||
((MasterObserver) env.getInstance()).postEnableTableHandler(ctx,
|
||||
tableName);
|
||||
} catch (Throwable e) {
|
||||
handleCoprocessorThrowable(env, e);
|
||||
}
|
||||
if (ctx.shouldComplete()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void preDisableTable(final byte [] tableName) throws IOException {
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx = null;
|
||||
for (MasterEnvironment env: coprocessors) {
|
||||
if (env.getInstance() instanceof MasterObserver) {
|
||||
|
@ -361,7 +630,7 @@ public class MasterCoprocessorHost
|
|||
}
|
||||
}
|
||||
|
||||
void postDisableTable(final byte [] tableName) throws IOException {
|
||||
public void postDisableTable(final byte [] tableName) throws IOException {
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx = null;
|
||||
for (MasterEnvironment env: coprocessors) {
|
||||
if (env.getInstance() instanceof MasterObserver) {
|
||||
|
@ -378,8 +647,45 @@ public class MasterCoprocessorHost
|
|||
}
|
||||
}
|
||||
|
||||
boolean preMove(final HRegionInfo region, final ServerName srcServer, final ServerName destServer)
|
||||
public void preDisableTableHandler(final byte[] tableName) throws IOException {
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx = null;
|
||||
for (MasterEnvironment env : coprocessors) {
|
||||
if (env.getInstance() instanceof MasterObserver) {
|
||||
ctx = ObserverContext.createAndPrepare(env, ctx);
|
||||
try {
|
||||
((MasterObserver) env.getInstance()).preDisableTableHandler(ctx,
|
||||
tableName);
|
||||
} catch (Throwable e) {
|
||||
handleCoprocessorThrowable(env, e);
|
||||
}
|
||||
if (ctx.shouldComplete()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void postDisableTableHandler(final byte[] tableName)
|
||||
throws IOException {
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx = null;
|
||||
for (MasterEnvironment env : coprocessors) {
|
||||
if (env.getInstance() instanceof MasterObserver) {
|
||||
ctx = ObserverContext.createAndPrepare(env, ctx);
|
||||
try {
|
||||
((MasterObserver) env.getInstance()).postDisableTableHandler(ctx,
|
||||
tableName);
|
||||
} catch (Throwable e) {
|
||||
handleCoprocessorThrowable(env, e);
|
||||
}
|
||||
if (ctx.shouldComplete()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean preMove(final HRegionInfo region, final ServerName srcServer,
|
||||
final ServerName destServer) throws IOException {
|
||||
boolean bypass = false;
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx = null;
|
||||
for (MasterEnvironment env: coprocessors) {
|
||||
|
@ -400,8 +706,8 @@ public class MasterCoprocessorHost
|
|||
return bypass;
|
||||
}
|
||||
|
||||
void postMove(final HRegionInfo region, final ServerName srcServer, final ServerName destServer)
|
||||
throws IOException {
|
||||
public void postMove(final HRegionInfo region, final ServerName srcServer,
|
||||
final ServerName destServer) throws IOException {
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx = null;
|
||||
for (MasterEnvironment env: coprocessors) {
|
||||
if (env.getInstance() instanceof MasterObserver) {
|
||||
|
|
|
@ -39,6 +39,8 @@ import org.apache.hadoop.hbase.catalog.MetaEditor;
|
|||
import org.apache.hadoop.hbase.catalog.MetaReader;
|
||||
import org.apache.hadoop.hbase.executor.EventHandler;
|
||||
import org.apache.hadoop.hbase.master.AssignmentManager;
|
||||
import org.apache.hadoop.hbase.master.HMaster;
|
||||
import org.apache.hadoop.hbase.master.MasterCoprocessorHost;
|
||||
import org.apache.hadoop.hbase.master.MasterFileSystem;
|
||||
import org.apache.hadoop.hbase.master.ServerManager;
|
||||
import org.apache.hadoop.hbase.regionserver.HRegion;
|
||||
|
@ -125,7 +127,15 @@ public class CreateTableHandler extends EventHandler {
|
|||
String tableName = this.hTableDescriptor.getNameAsString();
|
||||
try {
|
||||
LOG.info("Attemping to create the table " + tableName);
|
||||
MasterCoprocessorHost cpHost = ((HMaster) this.server)
|
||||
.getCoprocessorHost();
|
||||
if (cpHost != null) {
|
||||
cpHost.preCreateTableHandler(this.hTableDescriptor, this.newRegions);
|
||||
}
|
||||
handleCreateTable();
|
||||
if (cpHost != null) {
|
||||
cpHost.postCreateTableHandler(this.hTableDescriptor, this.newRegions);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
LOG.error("Error trying to create the table " + tableName, e);
|
||||
} catch (KeeperException e) {
|
||||
|
@ -191,4 +201,4 @@ public class CreateTableHandler extends EventHandler {
|
|||
" enabled because of a ZooKeeper issue", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,8 @@ import org.apache.hadoop.hbase.HRegionInfo;
|
|||
import org.apache.hadoop.hbase.Server;
|
||||
import org.apache.hadoop.hbase.catalog.MetaEditor;
|
||||
import org.apache.hadoop.hbase.master.AssignmentManager;
|
||||
import org.apache.hadoop.hbase.master.HMaster;
|
||||
import org.apache.hadoop.hbase.master.MasterCoprocessorHost;
|
||||
import org.apache.hadoop.hbase.master.MasterServices;
|
||||
import org.apache.hadoop.hbase.util.Bytes;
|
||||
import org.apache.hadoop.hbase.util.Threads;
|
||||
|
@ -49,6 +51,11 @@ public class DeleteTableHandler extends TableEventHandler {
|
|||
@Override
|
||||
protected void handleTableOperation(List<HRegionInfo> regions)
|
||||
throws IOException, KeeperException {
|
||||
MasterCoprocessorHost cpHost = ((HMaster) this.server)
|
||||
.getCoprocessorHost();
|
||||
if (cpHost != null) {
|
||||
cpHost.preDeleteTableHandler(this.tableName);
|
||||
}
|
||||
AssignmentManager am = this.masterServices.getAssignmentManager();
|
||||
long waitTime = server.getConfiguration().
|
||||
getLong("hbase.master.wait.on.region", 5 * 60 * 1000);
|
||||
|
@ -80,8 +87,11 @@ public class DeleteTableHandler extends TableEventHandler {
|
|||
// If entry for this table in zk, and up in AssignmentManager, remove it.
|
||||
|
||||
am.getZKTable().setDeletedTable(Bytes.toString(tableName));
|
||||
if (cpHost != null) {
|
||||
cpHost.postDeleteTableHandler(this.tableName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String name = "UnknownServerName";
|
||||
|
|
|
@ -35,6 +35,8 @@ import org.apache.hadoop.hbase.catalog.MetaReader;
|
|||
import org.apache.hadoop.hbase.executor.EventHandler;
|
||||
import org.apache.hadoop.hbase.master.AssignmentManager;
|
||||
import org.apache.hadoop.hbase.master.BulkAssigner;
|
||||
import org.apache.hadoop.hbase.master.HMaster;
|
||||
import org.apache.hadoop.hbase.master.MasterCoprocessorHost;
|
||||
import org.apache.hadoop.hbase.util.Bytes;
|
||||
import org.apache.zookeeper.KeeperException;
|
||||
|
||||
|
@ -97,7 +99,15 @@ public class DisableTableHandler extends EventHandler {
|
|||
public void process() {
|
||||
try {
|
||||
LOG.info("Attemping to disable table " + this.tableNameStr);
|
||||
MasterCoprocessorHost cpHost = ((HMaster) this.server)
|
||||
.getCoprocessorHost();
|
||||
if (cpHost != null) {
|
||||
cpHost.preDisableTableHandler(this.tableName);
|
||||
}
|
||||
handleDisableTable();
|
||||
if (cpHost != null) {
|
||||
cpHost.postDisableTableHandler(this.tableName);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
LOG.error("Error trying to disable table " + this.tableNameStr, e);
|
||||
} catch (KeeperException e) {
|
||||
|
|
|
@ -35,6 +35,8 @@ import org.apache.hadoop.hbase.catalog.MetaReader;
|
|||
import org.apache.hadoop.hbase.executor.EventHandler;
|
||||
import org.apache.hadoop.hbase.master.AssignmentManager;
|
||||
import org.apache.hadoop.hbase.master.BulkAssigner;
|
||||
import org.apache.hadoop.hbase.master.HMaster;
|
||||
import org.apache.hadoop.hbase.master.MasterCoprocessorHost;
|
||||
import org.apache.hadoop.hbase.util.Bytes;
|
||||
import org.apache.zookeeper.KeeperException;
|
||||
|
||||
|
@ -96,7 +98,15 @@ public class EnableTableHandler extends EventHandler {
|
|||
public void process() {
|
||||
try {
|
||||
LOG.info("Attemping to enable the table " + this.tableNameStr);
|
||||
MasterCoprocessorHost cpHost = ((HMaster) this.server)
|
||||
.getCoprocessorHost();
|
||||
if (cpHost != null) {
|
||||
cpHost.preEnableTableHandler(this.tableName);
|
||||
}
|
||||
handleEnableTable();
|
||||
if (cpHost != null) {
|
||||
cpHost.postEnableTableHandler(this.tableName);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
LOG.error("Error trying to enable the table " + this.tableNameStr, e);
|
||||
} catch (KeeperException e) {
|
||||
|
|
|
@ -26,6 +26,8 @@ import org.apache.hadoop.classification.InterfaceAudience;
|
|||
import org.apache.hadoop.hbase.HRegionInfo;
|
||||
import org.apache.hadoop.hbase.HTableDescriptor;
|
||||
import org.apache.hadoop.hbase.Server;
|
||||
import org.apache.hadoop.hbase.master.HMaster;
|
||||
import org.apache.hadoop.hbase.master.MasterCoprocessorHost;
|
||||
import org.apache.hadoop.hbase.master.MasterServices;
|
||||
|
||||
@InterfaceAudience.Private
|
||||
|
@ -46,8 +48,16 @@ public class ModifyTableHandler extends TableEventHandler {
|
|||
@Override
|
||||
protected void handleTableOperation(List<HRegionInfo> hris)
|
||||
throws IOException {
|
||||
MasterCoprocessorHost cpHost = ((HMaster) this.server)
|
||||
.getCoprocessorHost();
|
||||
if (cpHost != null) {
|
||||
cpHost.preModifyTableHandler(this.tableName, this.htd);
|
||||
}
|
||||
// Update descriptor
|
||||
this.masterServices.getTableDescriptors().add(this.htd);
|
||||
if (cpHost != null) {
|
||||
cpHost.postModifyTableHandler(this.tableName, this.htd);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -28,6 +28,8 @@ import org.apache.hadoop.hbase.HRegionInfo;
|
|||
import org.apache.hadoop.hbase.HTableDescriptor;
|
||||
import org.apache.hadoop.hbase.InvalidFamilyOperationException;
|
||||
import org.apache.hadoop.hbase.Server;
|
||||
import org.apache.hadoop.hbase.master.HMaster;
|
||||
import org.apache.hadoop.hbase.master.MasterCoprocessorHost;
|
||||
import org.apache.hadoop.hbase.master.MasterServices;
|
||||
|
||||
/**
|
||||
|
@ -52,11 +54,19 @@ public class TableAddFamilyHandler extends TableEventHandler {
|
|||
@Override
|
||||
protected void handleTableOperation(List<HRegionInfo> hris)
|
||||
throws IOException {
|
||||
MasterCoprocessorHost cpHost = ((HMaster) this.server)
|
||||
.getCoprocessorHost();
|
||||
if(cpHost != null){
|
||||
cpHost.preAddColumnHandler(this.tableName, this.familyDesc);
|
||||
}
|
||||
// Update table descriptor in HDFS
|
||||
HTableDescriptor htd = this.masterServices.getMasterFileSystem()
|
||||
.addColumn(tableName, familyDesc);
|
||||
// Update in-memory descriptor cache
|
||||
this.masterServices.getTableDescriptors().add(htd);
|
||||
if(cpHost != null){
|
||||
cpHost.postAddColumnHandler(this.tableName, this.familyDesc);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
|
|
|
@ -26,6 +26,8 @@ import org.apache.hadoop.classification.InterfaceAudience;
|
|||
import org.apache.hadoop.hbase.HRegionInfo;
|
||||
import org.apache.hadoop.hbase.HTableDescriptor;
|
||||
import org.apache.hadoop.hbase.Server;
|
||||
import org.apache.hadoop.hbase.master.HMaster;
|
||||
import org.apache.hadoop.hbase.master.MasterCoprocessorHost;
|
||||
import org.apache.hadoop.hbase.master.MasterServices;
|
||||
import org.apache.hadoop.hbase.util.Bytes;
|
||||
|
||||
|
@ -46,11 +48,19 @@ public class TableDeleteFamilyHandler extends TableEventHandler {
|
|||
|
||||
@Override
|
||||
protected void handleTableOperation(List<HRegionInfo> hris) throws IOException {
|
||||
MasterCoprocessorHost cpHost = ((HMaster) this.server)
|
||||
.getCoprocessorHost();
|
||||
if (cpHost != null) {
|
||||
cpHost.preDeleteColumnHandler(this.tableName, this.familyName);
|
||||
}
|
||||
// Update table descriptor in HDFS
|
||||
HTableDescriptor htd =
|
||||
this.masterServices.getMasterFileSystem().deleteColumn(tableName, familyName);
|
||||
// Update in-memory descriptor cache
|
||||
this.masterServices.getTableDescriptors().add(htd);
|
||||
if (cpHost != null) {
|
||||
cpHost.postDeleteColumnHandler(this.tableName, this.familyName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -28,6 +28,8 @@ import org.apache.hadoop.hbase.HRegionInfo;
|
|||
import org.apache.hadoop.hbase.HTableDescriptor;
|
||||
import org.apache.hadoop.hbase.InvalidFamilyOperationException;
|
||||
import org.apache.hadoop.hbase.Server;
|
||||
import org.apache.hadoop.hbase.master.HMaster;
|
||||
import org.apache.hadoop.hbase.master.MasterCoprocessorHost;
|
||||
import org.apache.hadoop.hbase.master.MasterServices;
|
||||
import org.apache.hadoop.hbase.util.Bytes;
|
||||
|
||||
|
@ -49,11 +51,19 @@ public class TableModifyFamilyHandler extends TableEventHandler {
|
|||
|
||||
@Override
|
||||
protected void handleTableOperation(List<HRegionInfo> regions) throws IOException {
|
||||
MasterCoprocessorHost cpHost = ((HMaster) this.server)
|
||||
.getCoprocessorHost();
|
||||
if (cpHost != null) {
|
||||
cpHost.preModifyColumnHandler(this.tableName, this.familyDesc);
|
||||
}
|
||||
// Update table descriptor in HDFS
|
||||
HTableDescriptor htd =
|
||||
this.masterServices.getMasterFileSystem().modifyColumn(tableName, familyDesc);
|
||||
// Update in-memory descriptor cache
|
||||
this.masterServices.getTableDescriptors().add(htd);
|
||||
if (cpHost != null) {
|
||||
cpHost.postModifyColumnHandler(this.tableName, this.familyDesc);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -30,6 +30,7 @@ import java.util.Collection;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.NavigableMap;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
@ -56,6 +57,8 @@ import org.junit.experimental.categories.Category;
|
|||
public class TestMasterObserver {
|
||||
private static final Log LOG = LogFactory.getLog(TestMasterObserver.class);
|
||||
|
||||
public static CountDownLatch countDown = new CountDownLatch(1);
|
||||
|
||||
public static class CPMasterObserver implements MasterObserver {
|
||||
|
||||
private boolean bypass = false;
|
||||
|
@ -90,6 +93,23 @@ public class TestMasterObserver {
|
|||
private boolean postStartMasterCalled;
|
||||
private boolean startCalled;
|
||||
private boolean stopCalled;
|
||||
private boolean preCreateTableHandlerCalled;
|
||||
private boolean postCreateTableHandlerCalled;
|
||||
private boolean preDeleteTableHandlerCalled;
|
||||
private boolean postDeleteTableHandlerCalled;
|
||||
private boolean preAddColumnHandlerCalled;
|
||||
private boolean postAddColumnHandlerCalled;
|
||||
private boolean preModifyColumnHandlerCalled;
|
||||
private boolean postModifyColumnHandlerCalled;
|
||||
private boolean preDeleteColumnHandlerCalled;
|
||||
private boolean postDeleteColumnHandlerCalled;
|
||||
private boolean preEnableTableHandlerCalled;
|
||||
private boolean postEnableTableHandlerCalled;
|
||||
private boolean preDisableTableHandlerCalled;
|
||||
private boolean postDisableTableHandlerCalled;
|
||||
private boolean preModifyTableHandlerCalled;
|
||||
private boolean postModifyTableHandlerCalled;
|
||||
|
||||
|
||||
public void enableBypass(boolean bypass) {
|
||||
this.bypass = bypass;
|
||||
|
@ -122,6 +142,22 @@ public class TestMasterObserver {
|
|||
postBalanceCalled = false;
|
||||
preBalanceSwitchCalled = false;
|
||||
postBalanceSwitchCalled = false;
|
||||
preCreateTableHandlerCalled = false;
|
||||
postCreateTableHandlerCalled = false;
|
||||
preDeleteTableHandlerCalled = false;
|
||||
postDeleteTableHandlerCalled = false;
|
||||
preModifyTableHandlerCalled = false;
|
||||
postModifyTableHandlerCalled = false;
|
||||
preAddColumnHandlerCalled = false;
|
||||
postAddColumnHandlerCalled = false;
|
||||
preModifyColumnHandlerCalled = false;
|
||||
postModifyColumnHandlerCalled = false;
|
||||
preDeleteColumnHandlerCalled = false;
|
||||
postDeleteColumnHandlerCalled = false;
|
||||
preEnableTableHandlerCalled = false;
|
||||
postEnableTableHandlerCalled = false;
|
||||
preDisableTableHandlerCalled = false;
|
||||
postDisableTableHandlerCalled = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -175,6 +211,8 @@ public class TestMasterObserver {
|
|||
byte[] tableName, HTableDescriptor htd) throws IOException {
|
||||
if (bypass) {
|
||||
env.bypass();
|
||||
}else{
|
||||
env.shouldBypass();
|
||||
}
|
||||
preModifyTableCalled = true;
|
||||
}
|
||||
|
@ -198,7 +236,10 @@ public class TestMasterObserver {
|
|||
byte[] tableName, HColumnDescriptor column) throws IOException {
|
||||
if (bypass) {
|
||||
env.bypass();
|
||||
}else{
|
||||
env.shouldBypass();
|
||||
}
|
||||
|
||||
preAddColumnCalled = true;
|
||||
}
|
||||
|
||||
|
@ -332,7 +373,7 @@ public class TestMasterObserver {
|
|||
public boolean preMoveCalledOnly() {
|
||||
return preMoveCalled && !postMoveCalled;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void preAssign(ObserverContext<MasterCoprocessorEnvironment> env,
|
||||
final HRegionInfo regionInfo) throws IOException {
|
||||
|
@ -347,7 +388,7 @@ public class TestMasterObserver {
|
|||
final HRegionInfo regionInfo) throws IOException {
|
||||
postAssignCalled = true;
|
||||
}
|
||||
|
||||
|
||||
public boolean wasAssignCalled() {
|
||||
return preAssignCalled && postAssignCalled;
|
||||
}
|
||||
|
@ -461,12 +502,214 @@ public class TestMasterObserver {
|
|||
public boolean wasStarted() { return startCalled; }
|
||||
|
||||
public boolean wasStopped() { return stopCalled; }
|
||||
|
||||
@Override
|
||||
public void preCreateTableHandler(
|
||||
ObserverContext<MasterCoprocessorEnvironment> env,
|
||||
HTableDescriptor desc, HRegionInfo[] regions) throws IOException {
|
||||
if (bypass) {
|
||||
env.bypass();
|
||||
}
|
||||
preCreateTableHandlerCalled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postCreateTableHandler(
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
HTableDescriptor desc, HRegionInfo[] regions) throws IOException {
|
||||
postCreateTableHandlerCalled = true;
|
||||
countDown.countDown();
|
||||
}
|
||||
|
||||
public boolean wasPreCreateTableHandlerCalled(){
|
||||
return preCreateTableHandlerCalled;
|
||||
}
|
||||
public boolean wasCreateTableHandlerCalled() {
|
||||
return preCreateTableHandlerCalled && postCreateTableHandlerCalled;
|
||||
}
|
||||
|
||||
public boolean wasCreateTableHandlerCalledOnly() {
|
||||
return preCreateTableHandlerCalled && !postCreateTableHandlerCalled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preDeleteTableHandler(
|
||||
ObserverContext<MasterCoprocessorEnvironment> env, byte[] tableName)
|
||||
throws IOException {
|
||||
if (bypass) {
|
||||
env.bypass();
|
||||
}
|
||||
preDeleteTableHandlerCalled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postDeleteTableHandler(
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx, byte[] tableName)
|
||||
throws IOException {
|
||||
postDeleteTableHandlerCalled = true;
|
||||
}
|
||||
|
||||
public boolean wasDeleteTableHandlerCalled() {
|
||||
return preDeleteTableHandlerCalled && postDeleteTableHandlerCalled;
|
||||
}
|
||||
|
||||
public boolean wasDeleteTableHandlerCalledOnly() {
|
||||
return preDeleteTableHandlerCalled && !postDeleteTableHandlerCalled;
|
||||
}
|
||||
@Override
|
||||
public void preModifyTableHandler(
|
||||
ObserverContext<MasterCoprocessorEnvironment> env, byte[] tableName,
|
||||
HTableDescriptor htd) throws IOException {
|
||||
if (bypass) {
|
||||
env.bypass();
|
||||
}
|
||||
preModifyTableHandlerCalled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postModifyTableHandler(
|
||||
ObserverContext<MasterCoprocessorEnvironment> env, byte[] tableName,
|
||||
HTableDescriptor htd) throws IOException {
|
||||
postModifyTableHandlerCalled = true;
|
||||
}
|
||||
|
||||
public boolean wasModifyTableHandlerCalled() {
|
||||
return preModifyColumnHandlerCalled && postModifyColumnHandlerCalled;
|
||||
}
|
||||
|
||||
public boolean wasModifyTableHandlerCalledOnly() {
|
||||
return preModifyColumnHandlerCalled && !postModifyColumnHandlerCalled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preAddColumnHandler(
|
||||
ObserverContext<MasterCoprocessorEnvironment> env, byte[] tableName,
|
||||
HColumnDescriptor column) throws IOException {
|
||||
if (bypass) {
|
||||
env.bypass();
|
||||
}
|
||||
preAddColumnHandlerCalled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postAddColumnHandler(
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx, byte[] tableName,
|
||||
HColumnDescriptor column) throws IOException {
|
||||
postAddColumnHandlerCalled = true;
|
||||
}
|
||||
public boolean wasAddColumnHandlerCalled() {
|
||||
return preAddColumnHandlerCalled && postAddColumnHandlerCalled;
|
||||
}
|
||||
|
||||
public boolean preAddColumnHandlerCalledOnly() {
|
||||
return preAddColumnHandlerCalled && !postAddColumnHandlerCalled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preModifyColumnHandler(
|
||||
ObserverContext<MasterCoprocessorEnvironment> env, byte[] tableName,
|
||||
HColumnDescriptor descriptor) throws IOException {
|
||||
if (bypass) {
|
||||
env.bypass();
|
||||
}
|
||||
preModifyColumnHandlerCalled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postModifyColumnHandler(
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx, byte[] tableName,
|
||||
HColumnDescriptor descriptor) throws IOException {
|
||||
postModifyColumnHandlerCalled = true;
|
||||
}
|
||||
|
||||
public boolean wasModifyColumnHandlerCalled() {
|
||||
return preModifyColumnHandlerCalled && postModifyColumnHandlerCalled;
|
||||
}
|
||||
|
||||
public boolean preModifyColumnHandlerCalledOnly() {
|
||||
return preModifyColumnHandlerCalled && !postModifyColumnHandlerCalled;
|
||||
}
|
||||
@Override
|
||||
public void preDeleteColumnHandler(
|
||||
ObserverContext<MasterCoprocessorEnvironment> env, byte[] tableName,
|
||||
byte[] c) throws IOException {
|
||||
if (bypass) {
|
||||
env.bypass();
|
||||
}
|
||||
preDeleteColumnHandlerCalled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postDeleteColumnHandler(
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx, byte[] tableName,
|
||||
byte[] c) throws IOException {
|
||||
postDeleteColumnHandlerCalled = true;
|
||||
}
|
||||
|
||||
public boolean wasDeleteColumnHandlerCalled() {
|
||||
return preDeleteColumnHandlerCalled && postDeleteColumnHandlerCalled;
|
||||
}
|
||||
|
||||
public boolean preDeleteColumnHandlerCalledOnly() {
|
||||
return preDeleteColumnHandlerCalled && !postDeleteColumnHandlerCalled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preEnableTableHandler(
|
||||
ObserverContext<MasterCoprocessorEnvironment> env, byte[] tableName)
|
||||
throws IOException {
|
||||
if (bypass) {
|
||||
env.bypass();
|
||||
}
|
||||
preEnableTableHandlerCalled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postEnableTableHandler(
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx, byte[] tableName)
|
||||
throws IOException {
|
||||
postEnableTableHandlerCalled = true;
|
||||
}
|
||||
|
||||
public boolean wasEnableTableHandlerCalled() {
|
||||
return preEnableTableHandlerCalled && postEnableTableHandlerCalled;
|
||||
}
|
||||
|
||||
public boolean preEnableTableHandlerCalledOnly() {
|
||||
return preEnableTableHandlerCalled && !postEnableTableHandlerCalled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preDisableTableHandler(
|
||||
ObserverContext<MasterCoprocessorEnvironment> env, byte[] tableName)
|
||||
throws IOException {
|
||||
if (bypass) {
|
||||
env.bypass();
|
||||
}
|
||||
preDisableTableHandlerCalled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postDisableTableHandler(
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx, byte[] tableName)
|
||||
throws IOException {
|
||||
postDisableTableHandlerCalled = true;
|
||||
}
|
||||
|
||||
public boolean wasDisableTableHandlerCalled() {
|
||||
return preDisableTableHandlerCalled && postDisableTableHandlerCalled;
|
||||
}
|
||||
|
||||
public boolean preDisableTableHandlerCalledOnly() {
|
||||
return preDisableTableHandlerCalled && !postDisableTableHandlerCalled;
|
||||
}
|
||||
}
|
||||
|
||||
private static HBaseTestingUtility UTIL = new HBaseTestingUtility();
|
||||
private static byte[] TEST_TABLE = Bytes.toBytes("observed_table");
|
||||
private static byte[] TEST_FAMILY = Bytes.toBytes("fam1");
|
||||
private static byte[] TEST_FAMILY2 = Bytes.toBytes("fam2");
|
||||
private static byte[] TEST_FAMILY3 = Bytes.toBytes("fam3");
|
||||
|
||||
@BeforeClass
|
||||
public static void setupBeforeClass() throws Exception {
|
||||
|
@ -520,12 +763,20 @@ public class TestMasterObserver {
|
|||
admin.createTable(htd);
|
||||
// preCreateTable can't bypass default action.
|
||||
assertTrue("Test table should be created", cp.wasCreateTableCalled());
|
||||
countDown.await();
|
||||
assertTrue("Table pre create handler called.", cp
|
||||
.wasPreCreateTableHandlerCalled());
|
||||
assertTrue("Table create handler should be called.",
|
||||
cp.wasCreateTableHandlerCalled());
|
||||
|
||||
countDown = new CountDownLatch(1);
|
||||
admin.disableTable(TEST_TABLE);
|
||||
assertTrue(admin.isTableDisabled(TEST_TABLE));
|
||||
// preDisableTable can't bypass default action.
|
||||
assertTrue("Coprocessor should have been called on table disable",
|
||||
cp.wasDisableTableCalled());
|
||||
assertTrue("Disable table handler should be called.",
|
||||
cp.wasDisableTableHandlerCalled());
|
||||
|
||||
// enable
|
||||
assertFalse(cp.wasEnableTableCalled());
|
||||
|
@ -534,6 +785,8 @@ public class TestMasterObserver {
|
|||
// preEnableTable can't bypass default action.
|
||||
assertTrue("Coprocessor should have been called on table enable",
|
||||
cp.wasEnableTableCalled());
|
||||
assertTrue("Enable table handler should be called.",
|
||||
cp.wasEnableTableHandlerCalled());
|
||||
|
||||
admin.disableTable(TEST_TABLE);
|
||||
assertTrue(admin.isTableDisabled(TEST_TABLE));
|
||||
|
@ -563,8 +816,9 @@ public class TestMasterObserver {
|
|||
admin.tableExists(TEST_TABLE));
|
||||
// preDeleteTable can't bypass default action.
|
||||
assertTrue("Coprocessor should have been called on table delete",
|
||||
cp.wasDeleteTableCalled());
|
||||
|
||||
cp.wasDeleteTableCalled());
|
||||
assertTrue("Delete table handler should be called.",
|
||||
cp.wasDeleteTableHandlerCalled());
|
||||
|
||||
// turn off bypass, run the tests again
|
||||
cp.enableBypass(false);
|
||||
|
@ -572,25 +826,33 @@ public class TestMasterObserver {
|
|||
|
||||
admin.createTable(htd);
|
||||
assertTrue("Test table should be created", cp.wasCreateTableCalled());
|
||||
countDown.await();
|
||||
assertTrue("Table pre create handler called.", cp
|
||||
.wasPreCreateTableHandlerCalled());
|
||||
assertTrue("Table create handler should be called.",
|
||||
cp.wasCreateTableHandlerCalled());
|
||||
|
||||
// disable
|
||||
assertFalse(cp.wasDisableTableCalled());
|
||||
|
||||
assertFalse(cp.wasDisableTableHandlerCalled());
|
||||
admin.disableTable(TEST_TABLE);
|
||||
assertTrue(admin.isTableDisabled(TEST_TABLE));
|
||||
assertTrue("Coprocessor should have been called on table disable",
|
||||
cp.wasDisableTableCalled());
|
||||
assertTrue("Disable table handler should be called.",
|
||||
cp.wasDisableTableHandlerCalled());
|
||||
|
||||
// modify table
|
||||
htd.setMaxFileSize(512 * 1024 * 1024);
|
||||
admin.modifyTable(TEST_TABLE, htd);
|
||||
assertTrue("Test table should have been modified",
|
||||
cp.wasModifyTableCalled());
|
||||
|
||||
// add a column family
|
||||
admin.addColumn(TEST_TABLE, new HColumnDescriptor(TEST_FAMILY2));
|
||||
assertTrue("New column family should have been added to test table",
|
||||
cp.wasAddColumnCalled());
|
||||
assertTrue("Add column handler should be called.",
|
||||
cp.wasAddColumnHandlerCalled());
|
||||
|
||||
// modify a column family
|
||||
HColumnDescriptor hcd = new HColumnDescriptor(TEST_FAMILY2);
|
||||
|
@ -598,13 +860,18 @@ public class TestMasterObserver {
|
|||
admin.modifyColumn(TEST_TABLE, hcd);
|
||||
assertTrue("Second column family should be modified",
|
||||
cp.wasModifyColumnCalled());
|
||||
assertTrue("Modify table handler should be called.",
|
||||
cp.wasModifyColumnHandlerCalled());
|
||||
|
||||
// enable
|
||||
assertFalse(cp.wasEnableTableCalled());
|
||||
assertFalse(cp.wasEnableTableHandlerCalled());
|
||||
admin.enableTable(TEST_TABLE);
|
||||
assertTrue(admin.isTableEnabled(TEST_TABLE));
|
||||
assertTrue("Coprocessor should have been called on table enable",
|
||||
cp.wasEnableTableCalled());
|
||||
assertTrue("Enable table handler should be called.",
|
||||
cp.wasEnableTableHandlerCalled());
|
||||
|
||||
// disable again
|
||||
admin.disableTable(TEST_TABLE);
|
||||
|
@ -612,20 +879,28 @@ public class TestMasterObserver {
|
|||
|
||||
// delete column
|
||||
assertFalse("No column family deleted yet", cp.wasDeleteColumnCalled());
|
||||
assertFalse("Delete table column handler should not be called.",
|
||||
cp.wasDeleteColumnHandlerCalled());
|
||||
admin.deleteColumn(TEST_TABLE, TEST_FAMILY2);
|
||||
HTableDescriptor tableDesc = admin.getTableDescriptor(TEST_TABLE);
|
||||
assertNull("'"+Bytes.toString(TEST_FAMILY2)+"' should have been removed",
|
||||
tableDesc.getFamily(TEST_FAMILY2));
|
||||
assertTrue("Coprocessor should have been called on column delete",
|
||||
cp.wasDeleteColumnCalled());
|
||||
assertTrue("Delete table column handler should be called.",
|
||||
cp.wasDeleteColumnHandlerCalled());
|
||||
|
||||
// delete table
|
||||
assertFalse("No table deleted yet", cp.wasDeleteTableCalled());
|
||||
assertFalse("Delete table handler should not be called.",
|
||||
cp.wasDeleteTableHandlerCalled());
|
||||
admin.deleteTable(TEST_TABLE);
|
||||
assertFalse("Test table should have been deleted",
|
||||
admin.tableExists(TEST_TABLE));
|
||||
assertTrue("Coprocessor should have been called on table delete",
|
||||
cp.wasDeleteTableCalled());
|
||||
assertTrue("Delete table handler should be called.",
|
||||
cp.wasDeleteTableHandlerCalled());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -642,7 +917,7 @@ public class TestMasterObserver {
|
|||
HTable table = UTIL.createTable(TEST_TABLE, TEST_FAMILY);
|
||||
int countOfRegions = UTIL.createMultiRegions(table, TEST_FAMILY);
|
||||
UTIL.waitUntilAllRegionsAssigned(countOfRegions);
|
||||
|
||||
|
||||
NavigableMap<HRegionInfo, ServerName> regions = table.getRegionLocations();
|
||||
Map.Entry<HRegionInfo, ServerName> firstGoodPair = null;
|
||||
for (Map.Entry<HRegionInfo, ServerName> e: regions.entrySet()) {
|
||||
|
|
Loading…
Reference in New Issue