HBASE-7340 Master coprocessor notification for assignmentManager.balance() is inconsistent (Ted Yu)

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1421537 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Zhihong Yu 2012-12-13 21:11:43 +00:00
parent 3b23a837af
commit e0c1dded33
7 changed files with 28 additions and 12 deletions

View File

@ -27,8 +27,10 @@ import org.apache.hadoop.hbase.CoprocessorEnvironment;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.UnknownRegionException;
import org.apache.hadoop.hbase.master.RegionPlan;
import java.io.IOException;
import java.util.List;
@InterfaceAudience.Public
@InterfaceStability.Evolving
@ -236,7 +238,7 @@ public class BaseMasterObserver implements MasterObserver {
}
@Override
public void postBalance(ObserverContext<MasterCoprocessorEnvironment> ctx)
public void postBalance(ObserverContext<MasterCoprocessorEnvironment> ctx, List<RegionPlan> plans)
throws IOException {
}

View File

@ -19,11 +19,17 @@
package org.apache.hadoop.hbase.coprocessor;
import java.io.IOException;
import java.util.List;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.hbase.*;
import java.io.IOException;
import org.apache.hadoop.hbase.Coprocessor;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.master.RegionPlan;
/**
* Defines coprocessor hooks for interacting with operations on the
@ -444,8 +450,11 @@ public interface MasterObserver extends Coprocessor {
/**
* Called after the balancing plan has been submitted.
* @param ctx the environment to interact with the framework and master
* @param plans the RegionPlans which master has executed. RegionPlan serves as hint
* as for the final destination for the underlying region but may not represent the
* final state of assignment
*/
void postBalance(final ObserverContext<MasterCoprocessorEnvironment> ctx)
void postBalance(final ObserverContext<MasterCoprocessorEnvironment> ctx, List<RegionPlan> plans)
throws IOException;
/**

View File

@ -1332,7 +1332,7 @@ Server {
}
}
if (this.cpHost != null) {
this.cpHost.postBalance();
this.cpHost.postBalance(rpCount < plans.size() ? plans.subList(0, rpCount) : plans);
}
}
return balancerRan;

View File

@ -27,6 +27,7 @@ import org.apache.hadoop.hbase.*;
import org.apache.hadoop.hbase.coprocessor.*;
import java.io.IOException;
import java.util.List;
/**
* Provides the coprocessor framework and environment for master oriented
@ -827,13 +828,13 @@ public class MasterCoprocessorHost
return bypass;
}
void postBalance() throws IOException {
void postBalance(List<RegionPlan> plans) throws IOException {
ObserverContext<MasterCoprocessorEnvironment> ctx = null;
for (MasterEnvironment env: coprocessors) {
if (env.getInstance() instanceof MasterObserver) {
ctx = ObserverContext.createAndPrepare(env, ctx);
try {
((MasterObserver)env.getInstance()).postBalance(ctx);
((MasterObserver)env.getInstance()).postBalance(ctx, plans);
} catch (Throwable e) {
handleCoprocessorThrowable(env, e);
}

View File

@ -21,6 +21,7 @@ import java.io.Serializable;
import java.util.Comparator;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.ServerName;
@ -34,7 +35,8 @@ import org.apache.hadoop.hbase.ServerName;
* The comparable implementation of this class compares only the region
* information and not the source/dest server info.
*/
@InterfaceAudience.Private
@InterfaceAudience.LimitedPrivate("Coprocessors")
@InterfaceStability.Evolving
public class RegionPlan implements Comparable<RegionPlan> {
private final HRegionInfo hri;
private final ServerName source;

View File

@ -50,6 +50,7 @@ import org.apache.hadoop.hbase.filter.ByteArrayComparable;
import org.apache.hadoop.hbase.ipc.HBaseRPC;
import org.apache.hadoop.hbase.ipc.ProtocolSignature;
import org.apache.hadoop.hbase.ipc.RequestContext;
import org.apache.hadoop.hbase.master.RegionPlan;
import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
import org.apache.hadoop.hbase.protobuf.ResponseConverter;
import org.apache.hadoop.hbase.protobuf.generated.AccessControlProtos;
@ -727,7 +728,7 @@ public class AccessController extends BaseRegionObserver
requirePermission(Permission.Action.ADMIN);
}
@Override
public void postBalance(ObserverContext<MasterCoprocessorEnvironment> c)
public void postBalance(ObserverContext<MasterCoprocessorEnvironment> c, List<RegionPlan> plans)
throws IOException {}
@Override

View File

@ -42,6 +42,7 @@ import org.apache.hadoop.hbase.client.HTable;
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.RegionPlan;
import org.apache.hadoop.hbase.master.RegionState;
import org.apache.hadoop.hbase.protobuf.RequestConverter;
import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
@ -434,8 +435,8 @@ public class TestMasterObserver {
}
@Override
public void postBalance(ObserverContext<MasterCoprocessorEnvironment> env)
throws IOException {
public void postBalance(ObserverContext<MasterCoprocessorEnvironment> env,
List<RegionPlan> plans) throws IOException {
postBalanceCalled = true;
}