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:
parent
3b23a837af
commit
e0c1dded33
|
@ -27,8 +27,10 @@ import org.apache.hadoop.hbase.CoprocessorEnvironment;
|
||||||
import org.apache.hadoop.hbase.HTableDescriptor;
|
import org.apache.hadoop.hbase.HTableDescriptor;
|
||||||
import org.apache.hadoop.hbase.ServerName;
|
import org.apache.hadoop.hbase.ServerName;
|
||||||
import org.apache.hadoop.hbase.UnknownRegionException;
|
import org.apache.hadoop.hbase.UnknownRegionException;
|
||||||
|
import org.apache.hadoop.hbase.master.RegionPlan;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@InterfaceAudience.Public
|
@InterfaceAudience.Public
|
||||||
@InterfaceStability.Evolving
|
@InterfaceStability.Evolving
|
||||||
|
@ -236,7 +238,7 @@ public class BaseMasterObserver implements MasterObserver {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postBalance(ObserverContext<MasterCoprocessorEnvironment> ctx)
|
public void postBalance(ObserverContext<MasterCoprocessorEnvironment> ctx, List<RegionPlan> plans)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,11 +19,17 @@
|
||||||
|
|
||||||
package org.apache.hadoop.hbase.coprocessor;
|
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.InterfaceAudience;
|
||||||
import org.apache.hadoop.classification.InterfaceStability;
|
import org.apache.hadoop.classification.InterfaceStability;
|
||||||
import org.apache.hadoop.hbase.*;
|
import org.apache.hadoop.hbase.Coprocessor;
|
||||||
|
import org.apache.hadoop.hbase.HColumnDescriptor;
|
||||||
import java.io.IOException;
|
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
|
* 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.
|
* Called after the balancing plan has been submitted.
|
||||||
* @param ctx the environment to interact with the framework and master
|
* @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;
|
throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1332,7 +1332,7 @@ Server {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.cpHost != null) {
|
if (this.cpHost != null) {
|
||||||
this.cpHost.postBalance();
|
this.cpHost.postBalance(rpCount < plans.size() ? plans.subList(0, rpCount) : plans);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return balancerRan;
|
return balancerRan;
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.apache.hadoop.hbase.*;
|
||||||
import org.apache.hadoop.hbase.coprocessor.*;
|
import org.apache.hadoop.hbase.coprocessor.*;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides the coprocessor framework and environment for master oriented
|
* Provides the coprocessor framework and environment for master oriented
|
||||||
|
@ -827,13 +828,13 @@ public class MasterCoprocessorHost
|
||||||
return bypass;
|
return bypass;
|
||||||
}
|
}
|
||||||
|
|
||||||
void postBalance() throws IOException {
|
void postBalance(List<RegionPlan> plans) throws IOException {
|
||||||
ObserverContext<MasterCoprocessorEnvironment> ctx = null;
|
ObserverContext<MasterCoprocessorEnvironment> ctx = null;
|
||||||
for (MasterEnvironment env: coprocessors) {
|
for (MasterEnvironment env: coprocessors) {
|
||||||
if (env.getInstance() instanceof MasterObserver) {
|
if (env.getInstance() instanceof MasterObserver) {
|
||||||
ctx = ObserverContext.createAndPrepare(env, ctx);
|
ctx = ObserverContext.createAndPrepare(env, ctx);
|
||||||
try {
|
try {
|
||||||
((MasterObserver)env.getInstance()).postBalance(ctx);
|
((MasterObserver)env.getInstance()).postBalance(ctx, plans);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
handleCoprocessorThrowable(env, e);
|
handleCoprocessorThrowable(env, e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ import java.io.Serializable;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
import org.apache.hadoop.classification.InterfaceAudience;
|
import org.apache.hadoop.classification.InterfaceAudience;
|
||||||
|
import org.apache.hadoop.classification.InterfaceStability;
|
||||||
import org.apache.hadoop.hbase.HRegionInfo;
|
import org.apache.hadoop.hbase.HRegionInfo;
|
||||||
import org.apache.hadoop.hbase.ServerName;
|
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
|
* The comparable implementation of this class compares only the region
|
||||||
* information and not the source/dest server info.
|
* information and not the source/dest server info.
|
||||||
*/
|
*/
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.LimitedPrivate("Coprocessors")
|
||||||
|
@InterfaceStability.Evolving
|
||||||
public class RegionPlan implements Comparable<RegionPlan> {
|
public class RegionPlan implements Comparable<RegionPlan> {
|
||||||
private final HRegionInfo hri;
|
private final HRegionInfo hri;
|
||||||
private final ServerName source;
|
private final ServerName source;
|
||||||
|
|
|
@ -50,6 +50,7 @@ import org.apache.hadoop.hbase.filter.ByteArrayComparable;
|
||||||
import org.apache.hadoop.hbase.ipc.HBaseRPC;
|
import org.apache.hadoop.hbase.ipc.HBaseRPC;
|
||||||
import org.apache.hadoop.hbase.ipc.ProtocolSignature;
|
import org.apache.hadoop.hbase.ipc.ProtocolSignature;
|
||||||
import org.apache.hadoop.hbase.ipc.RequestContext;
|
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.ProtobufUtil;
|
||||||
import org.apache.hadoop.hbase.protobuf.ResponseConverter;
|
import org.apache.hadoop.hbase.protobuf.ResponseConverter;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.AccessControlProtos;
|
import org.apache.hadoop.hbase.protobuf.generated.AccessControlProtos;
|
||||||
|
@ -727,7 +728,7 @@ public class AccessController extends BaseRegionObserver
|
||||||
requirePermission(Permission.Action.ADMIN);
|
requirePermission(Permission.Action.ADMIN);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void postBalance(ObserverContext<MasterCoprocessorEnvironment> c)
|
public void postBalance(ObserverContext<MasterCoprocessorEnvironment> c, List<RegionPlan> plans)
|
||||||
throws IOException {}
|
throws IOException {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -42,6 +42,7 @@ import org.apache.hadoop.hbase.client.HTable;
|
||||||
import org.apache.hadoop.hbase.master.AssignmentManager;
|
import org.apache.hadoop.hbase.master.AssignmentManager;
|
||||||
import org.apache.hadoop.hbase.master.HMaster;
|
import org.apache.hadoop.hbase.master.HMaster;
|
||||||
import org.apache.hadoop.hbase.master.MasterCoprocessorHost;
|
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.master.RegionState;
|
||||||
import org.apache.hadoop.hbase.protobuf.RequestConverter;
|
import org.apache.hadoop.hbase.protobuf.RequestConverter;
|
||||||
import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
|
import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
|
||||||
|
@ -434,8 +435,8 @@ public class TestMasterObserver {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postBalance(ObserverContext<MasterCoprocessorEnvironment> env)
|
public void postBalance(ObserverContext<MasterCoprocessorEnvironment> env,
|
||||||
throws IOException {
|
List<RegionPlan> plans) throws IOException {
|
||||||
postBalanceCalled = true;
|
postBalanceCalled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue