HBASE-14309 Allow load balancer to operate when there is region in transition by adding force flag

This commit is contained in:
tedyu 2015-08-29 13:15:53 -07:00
parent 4256128fa2
commit df341c4299
10 changed files with 363 additions and 213 deletions

View File

@ -780,6 +780,16 @@ public interface Admin extends Abortable, Closeable {
*/ */
boolean balancer() throws IOException; boolean balancer() throws IOException;
/**
* Invoke the balancer. Will run the balancer and if regions to move, it will
* go ahead and do the reassignments. If there is region in transition, force parameter of true
* would still run balancer. Can *not* run for other reasons. Check
* logs.
* @param force whether we should force balance even if there is region in transition
* @return True if balancer ran, false otherwise.
*/
boolean balancer(boolean force) throws IOException;
/** /**
* Query the current state of the balancer * Query the current state of the balancer
* *

View File

@ -2153,7 +2153,17 @@ public class HBaseAdmin implements Admin {
return executeCallable(new MasterCallable<Boolean>(getConnection()) { return executeCallable(new MasterCallable<Boolean>(getConnection()) {
@Override @Override
public Boolean call(int callTimeout) throws ServiceException { public Boolean call(int callTimeout) throws ServiceException {
return master.balance(null, RequestConverter.buildBalanceRequest()).getBalancerRan(); return master.balance(null, RequestConverter.buildBalanceRequest(false)).getBalancerRan();
}
});
}
@Override
public boolean balancer(final boolean force) throws IOException {
return executeCallable(new MasterCallable<Boolean>(getConnection()) {
@Override
public Boolean call(int callTimeout) throws ServiceException {
return master.balance(null, RequestConverter.buildBalanceRequest(force)).getBalancerRan();
} }
}); });
} }

View File

@ -1351,8 +1351,8 @@ public final class RequestConverter {
* *
* @return a BalanceRequest * @return a BalanceRequest
*/ */
public static BalanceRequest buildBalanceRequest() { public static BalanceRequest buildBalanceRequest(boolean force) {
return BalanceRequest.newBuilder().build(); return BalanceRequest.newBuilder().setForce(force).build();
} }
/** /**

View File

@ -25568,6 +25568,16 @@ public final class MasterProtos {
public interface BalanceRequestOrBuilder public interface BalanceRequestOrBuilder
extends com.google.protobuf.MessageOrBuilder { extends com.google.protobuf.MessageOrBuilder {
// optional bool force = 1;
/**
* <code>optional bool force = 1;</code>
*/
boolean hasForce();
/**
* <code>optional bool force = 1;</code>
*/
boolean getForce();
} }
/** /**
* Protobuf type {@code hbase.pb.BalanceRequest} * Protobuf type {@code hbase.pb.BalanceRequest}
@ -25602,6 +25612,7 @@ public final class MasterProtos {
com.google.protobuf.ExtensionRegistryLite extensionRegistry) com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException { throws com.google.protobuf.InvalidProtocolBufferException {
initFields(); initFields();
int mutable_bitField0_ = 0;
com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.Builder unknownFields =
com.google.protobuf.UnknownFieldSet.newBuilder(); com.google.protobuf.UnknownFieldSet.newBuilder();
try { try {
@ -25619,6 +25630,11 @@ public final class MasterProtos {
} }
break; break;
} }
case 8: {
bitField0_ |= 0x00000001;
force_ = input.readBool();
break;
}
} }
} }
} catch (com.google.protobuf.InvalidProtocolBufferException e) { } catch (com.google.protobuf.InvalidProtocolBufferException e) {
@ -25658,7 +25674,25 @@ public final class MasterProtos {
return PARSER; return PARSER;
} }
private int bitField0_;
// optional bool force = 1;
public static final int FORCE_FIELD_NUMBER = 1;
private boolean force_;
/**
* <code>optional bool force = 1;</code>
*/
public boolean hasForce() {
return ((bitField0_ & 0x00000001) == 0x00000001);
}
/**
* <code>optional bool force = 1;</code>
*/
public boolean getForce() {
return force_;
}
private void initFields() { private void initFields() {
force_ = false;
} }
private byte memoizedIsInitialized = -1; private byte memoizedIsInitialized = -1;
public final boolean isInitialized() { public final boolean isInitialized() {
@ -25672,6 +25706,9 @@ public final class MasterProtos {
public void writeTo(com.google.protobuf.CodedOutputStream output) public void writeTo(com.google.protobuf.CodedOutputStream output)
throws java.io.IOException { throws java.io.IOException {
getSerializedSize(); getSerializedSize();
if (((bitField0_ & 0x00000001) == 0x00000001)) {
output.writeBool(1, force_);
}
getUnknownFields().writeTo(output); getUnknownFields().writeTo(output);
} }
@ -25681,6 +25718,10 @@ public final class MasterProtos {
if (size != -1) return size; if (size != -1) return size;
size = 0; size = 0;
if (((bitField0_ & 0x00000001) == 0x00000001)) {
size += com.google.protobuf.CodedOutputStream
.computeBoolSize(1, force_);
}
size += getUnknownFields().getSerializedSize(); size += getUnknownFields().getSerializedSize();
memoizedSerializedSize = size; memoizedSerializedSize = size;
return size; return size;
@ -25704,6 +25745,11 @@ public final class MasterProtos {
org.apache.hadoop.hbase.protobuf.generated.MasterProtos.BalanceRequest other = (org.apache.hadoop.hbase.protobuf.generated.MasterProtos.BalanceRequest) obj; org.apache.hadoop.hbase.protobuf.generated.MasterProtos.BalanceRequest other = (org.apache.hadoop.hbase.protobuf.generated.MasterProtos.BalanceRequest) obj;
boolean result = true; boolean result = true;
result = result && (hasForce() == other.hasForce());
if (hasForce()) {
result = result && (getForce()
== other.getForce());
}
result = result && result = result &&
getUnknownFields().equals(other.getUnknownFields()); getUnknownFields().equals(other.getUnknownFields());
return result; return result;
@ -25717,6 +25763,10 @@ public final class MasterProtos {
} }
int hash = 41; int hash = 41;
hash = (19 * hash) + getDescriptorForType().hashCode(); hash = (19 * hash) + getDescriptorForType().hashCode();
if (hasForce()) {
hash = (37 * hash) + FORCE_FIELD_NUMBER;
hash = (53 * hash) + hashBoolean(getForce());
}
hash = (29 * hash) + getUnknownFields().hashCode(); hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash; memoizedHashCode = hash;
return hash; return hash;
@ -25826,6 +25876,8 @@ public final class MasterProtos {
public Builder clear() { public Builder clear() {
super.clear(); super.clear();
force_ = false;
bitField0_ = (bitField0_ & ~0x00000001);
return this; return this;
} }
@ -25852,6 +25904,13 @@ public final class MasterProtos {
public org.apache.hadoop.hbase.protobuf.generated.MasterProtos.BalanceRequest buildPartial() { public org.apache.hadoop.hbase.protobuf.generated.MasterProtos.BalanceRequest buildPartial() {
org.apache.hadoop.hbase.protobuf.generated.MasterProtos.BalanceRequest result = new org.apache.hadoop.hbase.protobuf.generated.MasterProtos.BalanceRequest(this); org.apache.hadoop.hbase.protobuf.generated.MasterProtos.BalanceRequest result = new org.apache.hadoop.hbase.protobuf.generated.MasterProtos.BalanceRequest(this);
int from_bitField0_ = bitField0_;
int to_bitField0_ = 0;
if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
to_bitField0_ |= 0x00000001;
}
result.force_ = force_;
result.bitField0_ = to_bitField0_;
onBuilt(); onBuilt();
return result; return result;
} }
@ -25867,6 +25926,9 @@ public final class MasterProtos {
public Builder mergeFrom(org.apache.hadoop.hbase.protobuf.generated.MasterProtos.BalanceRequest other) { public Builder mergeFrom(org.apache.hadoop.hbase.protobuf.generated.MasterProtos.BalanceRequest other) {
if (other == org.apache.hadoop.hbase.protobuf.generated.MasterProtos.BalanceRequest.getDefaultInstance()) return this; if (other == org.apache.hadoop.hbase.protobuf.generated.MasterProtos.BalanceRequest.getDefaultInstance()) return this;
if (other.hasForce()) {
setForce(other.getForce());
}
this.mergeUnknownFields(other.getUnknownFields()); this.mergeUnknownFields(other.getUnknownFields());
return this; return this;
} }
@ -25892,6 +25954,40 @@ public final class MasterProtos {
} }
return this; return this;
} }
private int bitField0_;
// optional bool force = 1;
private boolean force_ ;
/**
* <code>optional bool force = 1;</code>
*/
public boolean hasForce() {
return ((bitField0_ & 0x00000001) == 0x00000001);
}
/**
* <code>optional bool force = 1;</code>
*/
public boolean getForce() {
return force_;
}
/**
* <code>optional bool force = 1;</code>
*/
public Builder setForce(boolean value) {
bitField0_ |= 0x00000001;
force_ = value;
onChanged();
return this;
}
/**
* <code>optional bool force = 1;</code>
*/
public Builder clearForce() {
bitField0_ = (bitField0_ & ~0x00000001);
force_ = false;
onChanged();
return this;
}
// @@protoc_insertion_point(builder_scope:hbase.pb.BalanceRequest) // @@protoc_insertion_point(builder_scope:hbase.pb.BalanceRequest)
} }
@ -56609,208 +56705,209 @@ public final class MasterProtos {
"paceResponse\022&\n\ttableName\030\001 \003(\0132\023.hbase.", "paceResponse\022&\n\ttableName\030\001 \003(\0132\023.hbase.",
"pb.TableName\"\021\n\017ShutdownRequest\"\022\n\020Shutd" + "pb.TableName\"\021\n\017ShutdownRequest\"\022\n\020Shutd" +
"ownResponse\"\023\n\021StopMasterRequest\"\024\n\022Stop" + "ownResponse\"\023\n\021StopMasterRequest\"\024\n\022Stop" +
"MasterResponse\"\020\n\016BalanceRequest\"\'\n\017Bala" + "MasterResponse\"\037\n\016BalanceRequest\022\r\n\005forc" +
"nceResponse\022\024\n\014balancer_ran\030\001 \002(\010\"<\n\031Set" + "e\030\001 \001(\010\"\'\n\017BalanceResponse\022\024\n\014balancer_r" +
"BalancerRunningRequest\022\n\n\002on\030\001 \002(\010\022\023\n\013sy" + "an\030\001 \002(\010\"<\n\031SetBalancerRunningRequest\022\n\n" +
"nchronous\030\002 \001(\010\"8\n\032SetBalancerRunningRes" + "\002on\030\001 \002(\010\022\023\n\013synchronous\030\002 \001(\010\"8\n\032SetBal" +
"ponse\022\032\n\022prev_balance_value\030\001 \001(\010\"\032\n\030IsB" + "ancerRunningResponse\022\032\n\022prev_balance_val" +
"alancerEnabledRequest\",\n\031IsBalancerEnabl" + "ue\030\001 \001(\010\"\032\n\030IsBalancerEnabledRequest\",\n\031" +
"edResponse\022\017\n\007enabled\030\001 \002(\010\"\027\n\025RunCatalo" + "IsBalancerEnabledResponse\022\017\n\007enabled\030\001 \002" +
"gScanRequest\"-\n\026RunCatalogScanResponse\022\023", "(\010\"\027\n\025RunCatalogScanRequest\"-\n\026RunCatalo",
"\n\013scan_result\030\001 \001(\005\"-\n\033EnableCatalogJani" + "gScanResponse\022\023\n\013scan_result\030\001 \001(\005\"-\n\033En" +
"torRequest\022\016\n\006enable\030\001 \002(\010\"2\n\034EnableCata" + "ableCatalogJanitorRequest\022\016\n\006enable\030\001 \002(" +
"logJanitorResponse\022\022\n\nprev_value\030\001 \001(\010\" " + "\010\"2\n\034EnableCatalogJanitorResponse\022\022\n\npre" +
"\n\036IsCatalogJanitorEnabledRequest\"0\n\037IsCa" + "v_value\030\001 \001(\010\" \n\036IsCatalogJanitorEnabled" +
"talogJanitorEnabledResponse\022\r\n\005value\030\001 \002" + "Request\"0\n\037IsCatalogJanitorEnabledRespon" +
"(\010\"B\n\017SnapshotRequest\022/\n\010snapshot\030\001 \002(\0132" + "se\022\r\n\005value\030\001 \002(\010\"B\n\017SnapshotRequest\022/\n\010" +
"\035.hbase.pb.SnapshotDescription\",\n\020Snapsh" + "snapshot\030\001 \002(\0132\035.hbase.pb.SnapshotDescri" +
"otResponse\022\030\n\020expected_timeout\030\001 \002(\003\"\036\n\034" + "ption\",\n\020SnapshotResponse\022\030\n\020expected_ti" +
"GetCompletedSnapshotsRequest\"Q\n\035GetCompl" + "meout\030\001 \002(\003\"\036\n\034GetCompletedSnapshotsRequ" +
"etedSnapshotsResponse\0220\n\tsnapshots\030\001 \003(\013", "est\"Q\n\035GetCompletedSnapshotsResponse\0220\n\t",
"2\035.hbase.pb.SnapshotDescription\"H\n\025Delet" + "snapshots\030\001 \003(\0132\035.hbase.pb.SnapshotDescr" +
"eSnapshotRequest\022/\n\010snapshot\030\001 \002(\0132\035.hba" + "iption\"H\n\025DeleteSnapshotRequest\022/\n\010snaps" +
"se.pb.SnapshotDescription\"\030\n\026DeleteSnaps" + "hot\030\001 \002(\0132\035.hbase.pb.SnapshotDescription" +
"hotResponse\"I\n\026RestoreSnapshotRequest\022/\n" + "\"\030\n\026DeleteSnapshotResponse\"I\n\026RestoreSna" +
"\010snapshot\030\001 \002(\0132\035.hbase.pb.SnapshotDescr" + "pshotRequest\022/\n\010snapshot\030\001 \002(\0132\035.hbase.p" +
"iption\"\031\n\027RestoreSnapshotResponse\"H\n\025IsS" + "b.SnapshotDescription\"\031\n\027RestoreSnapshot" +
"napshotDoneRequest\022/\n\010snapshot\030\001 \001(\0132\035.h" + "Response\"H\n\025IsSnapshotDoneRequest\022/\n\010sna" +
"base.pb.SnapshotDescription\"^\n\026IsSnapsho" + "pshot\030\001 \001(\0132\035.hbase.pb.SnapshotDescripti" +
"tDoneResponse\022\023\n\004done\030\001 \001(\010:\005false\022/\n\010sn" + "on\"^\n\026IsSnapshotDoneResponse\022\023\n\004done\030\001 \001" +
"apshot\030\002 \001(\0132\035.hbase.pb.SnapshotDescript", "(\010:\005false\022/\n\010snapshot\030\002 \001(\0132\035.hbase.pb.S",
"ion\"O\n\034IsRestoreSnapshotDoneRequest\022/\n\010s" + "napshotDescription\"O\n\034IsRestoreSnapshotD" +
"napshot\030\001 \001(\0132\035.hbase.pb.SnapshotDescrip" + "oneRequest\022/\n\010snapshot\030\001 \001(\0132\035.hbase.pb." +
"tion\"4\n\035IsRestoreSnapshotDoneResponse\022\023\n" + "SnapshotDescription\"4\n\035IsRestoreSnapshot" +
"\004done\030\001 \001(\010:\005false\"F\n\033GetSchemaAlterStat" + "DoneResponse\022\023\n\004done\030\001 \001(\010:\005false\"F\n\033Get" +
"usRequest\022\'\n\ntable_name\030\001 \002(\0132\023.hbase.pb" + "SchemaAlterStatusRequest\022\'\n\ntable_name\030\001" +
".TableName\"T\n\034GetSchemaAlterStatusRespon" + " \002(\0132\023.hbase.pb.TableName\"T\n\034GetSchemaAl" +
"se\022\035\n\025yet_to_update_regions\030\001 \001(\r\022\025\n\rtot" + "terStatusResponse\022\035\n\025yet_to_update_regio" +
"al_regions\030\002 \001(\r\"\213\001\n\032GetTableDescriptors" + "ns\030\001 \001(\r\022\025\n\rtotal_regions\030\002 \001(\r\"\213\001\n\032GetT" +
"Request\022(\n\013table_names\030\001 \003(\0132\023.hbase.pb." + "ableDescriptorsRequest\022(\n\013table_names\030\001 " +
"TableName\022\r\n\005regex\030\002 \001(\t\022!\n\022include_sys_", "\003(\0132\023.hbase.pb.TableName\022\r\n\005regex\030\002 \001(\t\022",
"tables\030\003 \001(\010:\005false\022\021\n\tnamespace\030\004 \001(\t\"J" + "!\n\022include_sys_tables\030\003 \001(\010:\005false\022\021\n\tna" +
"\n\033GetTableDescriptorsResponse\022+\n\014table_s" + "mespace\030\004 \001(\t\"J\n\033GetTableDescriptorsResp" +
"chema\030\001 \003(\0132\025.hbase.pb.TableSchema\"[\n\024Ge" + "onse\022+\n\014table_schema\030\001 \003(\0132\025.hbase.pb.Ta" +
"tTableNamesRequest\022\r\n\005regex\030\001 \001(\t\022!\n\022inc" + "bleSchema\"[\n\024GetTableNamesRequest\022\r\n\005reg" +
"lude_sys_tables\030\002 \001(\010:\005false\022\021\n\tnamespac" + "ex\030\001 \001(\t\022!\n\022include_sys_tables\030\002 \001(\010:\005fa" +
"e\030\003 \001(\t\"A\n\025GetTableNamesResponse\022(\n\013tabl" + "lse\022\021\n\tnamespace\030\003 \001(\t\"A\n\025GetTableNamesR" +
"e_names\030\001 \003(\0132\023.hbase.pb.TableName\"?\n\024Ge" + "esponse\022(\n\013table_names\030\001 \003(\0132\023.hbase.pb." +
"tTableStateRequest\022\'\n\ntable_name\030\001 \002(\0132\023" + "TableName\"?\n\024GetTableStateRequest\022\'\n\ntab" +
".hbase.pb.TableName\"B\n\025GetTableStateResp" + "le_name\030\001 \002(\0132\023.hbase.pb.TableName\"B\n\025Ge" +
"onse\022)\n\013table_state\030\001 \002(\0132\024.hbase.pb.Tab", "tTableStateResponse\022)\n\013table_state\030\001 \002(\013",
"leState\"\031\n\027GetClusterStatusRequest\"K\n\030Ge" + "2\024.hbase.pb.TableState\"\031\n\027GetClusterStat" +
"tClusterStatusResponse\022/\n\016cluster_status" + "usRequest\"K\n\030GetClusterStatusResponse\022/\n" +
"\030\001 \002(\0132\027.hbase.pb.ClusterStatus\"\030\n\026IsMas" + "\016cluster_status\030\001 \002(\0132\027.hbase.pb.Cluster" +
"terRunningRequest\"4\n\027IsMasterRunningResp" + "Status\"\030\n\026IsMasterRunningRequest\"4\n\027IsMa" +
"onse\022\031\n\021is_master_running\030\001 \002(\010\"I\n\024ExecP" + "sterRunningResponse\022\031\n\021is_master_running" +
"rocedureRequest\0221\n\tprocedure\030\001 \002(\0132\036.hba" + "\030\001 \002(\010\"I\n\024ExecProcedureRequest\0221\n\tproced" +
"se.pb.ProcedureDescription\"F\n\025ExecProced" + "ure\030\001 \002(\0132\036.hbase.pb.ProcedureDescriptio" +
"ureResponse\022\030\n\020expected_timeout\030\001 \001(\003\022\023\n" + "n\"F\n\025ExecProcedureResponse\022\030\n\020expected_t" +
"\013return_data\030\002 \001(\014\"K\n\026IsProcedureDoneReq" + "imeout\030\001 \001(\003\022\023\n\013return_data\030\002 \001(\014\"K\n\026IsP" +
"uest\0221\n\tprocedure\030\001 \001(\0132\036.hbase.pb.Proce", "rocedureDoneRequest\0221\n\tprocedure\030\001 \001(\0132\036",
"dureDescription\"`\n\027IsProcedureDoneRespon" + ".hbase.pb.ProcedureDescription\"`\n\027IsProc" +
"se\022\023\n\004done\030\001 \001(\010:\005false\0220\n\010snapshot\030\002 \001(" + "edureDoneResponse\022\023\n\004done\030\001 \001(\010:\005false\0220" +
"\0132\036.hbase.pb.ProcedureDescription\",\n\031Get" + "\n\010snapshot\030\002 \001(\0132\036.hbase.pb.ProcedureDes" +
"ProcedureResultRequest\022\017\n\007proc_id\030\001 \002(\004\"" + "cription\",\n\031GetProcedureResultRequest\022\017\n" +
"\371\001\n\032GetProcedureResultResponse\0229\n\005state\030" + "\007proc_id\030\001 \002(\004\"\371\001\n\032GetProcedureResultRes" +
"\001 \002(\0162*.hbase.pb.GetProcedureResultRespo" + "ponse\0229\n\005state\030\001 \002(\0162*.hbase.pb.GetProce" +
"nse.State\022\022\n\nstart_time\030\002 \001(\004\022\023\n\013last_up" + "dureResultResponse.State\022\022\n\nstart_time\030\002" +
"date\030\003 \001(\004\022\016\n\006result\030\004 \001(\014\0224\n\texception\030" + " \001(\004\022\023\n\013last_update\030\003 \001(\004\022\016\n\006result\030\004 \001(" +
"\005 \001(\0132!.hbase.pb.ForeignExceptionMessage" + "\014\0224\n\texception\030\005 \001(\0132!.hbase.pb.ForeignE" +
"\"1\n\005State\022\r\n\tNOT_FOUND\020\000\022\013\n\007RUNNING\020\001\022\014\n", "xceptionMessage\"1\n\005State\022\r\n\tNOT_FOUND\020\000\022",
"\010FINISHED\020\002\"\315\001\n\017SetQuotaRequest\022\021\n\tuser_" + "\013\n\007RUNNING\020\001\022\014\n\010FINISHED\020\002\"\315\001\n\017SetQuotaR" +
"name\030\001 \001(\t\022\022\n\nuser_group\030\002 \001(\t\022\021\n\tnamesp" + "equest\022\021\n\tuser_name\030\001 \001(\t\022\022\n\nuser_group\030" +
"ace\030\003 \001(\t\022\'\n\ntable_name\030\004 \001(\0132\023.hbase.pb" + "\002 \001(\t\022\021\n\tnamespace\030\003 \001(\t\022\'\n\ntable_name\030\004" +
".TableName\022\022\n\nremove_all\030\005 \001(\010\022\026\n\016bypass" + " \001(\0132\023.hbase.pb.TableName\022\022\n\nremove_all\030" +
"_globals\030\006 \001(\010\022+\n\010throttle\030\007 \001(\0132\031.hbase" + "\005 \001(\010\022\026\n\016bypass_globals\030\006 \001(\010\022+\n\010throttl" +
".pb.ThrottleRequest\"\022\n\020SetQuotaResponse\"" + "e\030\007 \001(\0132\031.hbase.pb.ThrottleRequest\"\022\n\020Se" +
"J\n\037MajorCompactionTimestampRequest\022\'\n\nta" + "tQuotaResponse\"J\n\037MajorCompactionTimesta" +
"ble_name\030\001 \002(\0132\023.hbase.pb.TableName\"U\n(M" + "mpRequest\022\'\n\ntable_name\030\001 \002(\0132\023.hbase.pb" +
"ajorCompactionTimestampForRegionRequest\022" + ".TableName\"U\n(MajorCompactionTimestampFo" +
")\n\006region\030\001 \002(\0132\031.hbase.pb.RegionSpecifi", "rRegionRequest\022)\n\006region\030\001 \002(\0132\031.hbase.p",
"er\"@\n MajorCompactionTimestampResponse\022\034" + "b.RegionSpecifier\"@\n MajorCompactionTime" +
"\n\024compaction_timestamp\030\001 \002(\003\"\035\n\033Security" + "stampResponse\022\034\n\024compaction_timestamp\030\001 " +
"CapabilitiesRequest\"\354\001\n\034SecurityCapabili" + "\002(\003\"\035\n\033SecurityCapabilitiesRequest\"\354\001\n\034S" +
"tiesResponse\022G\n\014capabilities\030\001 \003(\01621.hba" + "ecurityCapabilitiesResponse\022G\n\014capabilit" +
"se.pb.SecurityCapabilitiesResponse.Capab" + "ies\030\001 \003(\01621.hbase.pb.SecurityCapabilitie" +
"ility\"\202\001\n\nCapability\022\031\n\025SIMPLE_AUTHENTIC" + "sResponse.Capability\"\202\001\n\nCapability\022\031\n\025S" +
"ATION\020\000\022\031\n\025SECURE_AUTHENTICATION\020\001\022\021\n\rAU" + "IMPLE_AUTHENTICATION\020\000\022\031\n\025SECURE_AUTHENT" +
"THORIZATION\020\002\022\026\n\022CELL_AUTHORIZATION\020\003\022\023\n" + "ICATION\020\001\022\021\n\rAUTHORIZATION\020\002\022\026\n\022CELL_AUT" +
"\017CELL_VISIBILITY\020\0042\301#\n\rMasterService\022e\n\024" + "HORIZATION\020\003\022\023\n\017CELL_VISIBILITY\020\0042\301#\n\rMa" +
"GetSchemaAlterStatus\022%.hbase.pb.GetSchem", "sterService\022e\n\024GetSchemaAlterStatus\022%.hb",
"aAlterStatusRequest\032&.hbase.pb.GetSchema" + "ase.pb.GetSchemaAlterStatusRequest\032&.hba" +
"AlterStatusResponse\022b\n\023GetTableDescripto" + "se.pb.GetSchemaAlterStatusResponse\022b\n\023Ge" +
"rs\022$.hbase.pb.GetTableDescriptorsRequest" + "tTableDescriptors\022$.hbase.pb.GetTableDes" +
"\032%.hbase.pb.GetTableDescriptorsResponse\022" + "criptorsRequest\032%.hbase.pb.GetTableDescr" +
"P\n\rGetTableNames\022\036.hbase.pb.GetTableName" + "iptorsResponse\022P\n\rGetTableNames\022\036.hbase." +
"sRequest\032\037.hbase.pb.GetTableNamesRespons" + "pb.GetTableNamesRequest\032\037.hbase.pb.GetTa" +
"e\022Y\n\020GetClusterStatus\022!.hbase.pb.GetClus" + "bleNamesResponse\022Y\n\020GetClusterStatus\022!.h" +
"terStatusRequest\032\".hbase.pb.GetClusterSt" + "base.pb.GetClusterStatusRequest\032\".hbase." +
"atusResponse\022V\n\017IsMasterRunning\022 .hbase." + "pb.GetClusterStatusResponse\022V\n\017IsMasterR" +
"pb.IsMasterRunningRequest\032!.hbase.pb.IsM", "unning\022 .hbase.pb.IsMasterRunningRequest",
"asterRunningResponse\022D\n\tAddColumn\022\032.hbas" + "\032!.hbase.pb.IsMasterRunningResponse\022D\n\tA" +
"e.pb.AddColumnRequest\032\033.hbase.pb.AddColu" + "ddColumn\022\032.hbase.pb.AddColumnRequest\032\033.h" +
"mnResponse\022M\n\014DeleteColumn\022\035.hbase.pb.De" + "base.pb.AddColumnResponse\022M\n\014DeleteColum" +
"leteColumnRequest\032\036.hbase.pb.DeleteColum" + "n\022\035.hbase.pb.DeleteColumnRequest\032\036.hbase" +
"nResponse\022M\n\014ModifyColumn\022\035.hbase.pb.Mod" + ".pb.DeleteColumnResponse\022M\n\014ModifyColumn" +
"ifyColumnRequest\032\036.hbase.pb.ModifyColumn" + "\022\035.hbase.pb.ModifyColumnRequest\032\036.hbase." +
"Response\022G\n\nMoveRegion\022\033.hbase.pb.MoveRe" + "pb.ModifyColumnResponse\022G\n\nMoveRegion\022\033." +
"gionRequest\032\034.hbase.pb.MoveRegionRespons" + "hbase.pb.MoveRegionRequest\032\034.hbase.pb.Mo" +
"e\022k\n\026DispatchMergingRegions\022\'.hbase.pb.D" + "veRegionResponse\022k\n\026DispatchMergingRegio" +
"ispatchMergingRegionsRequest\032(.hbase.pb.", "ns\022\'.hbase.pb.DispatchMergingRegionsRequ",
"DispatchMergingRegionsResponse\022M\n\014Assign" + "est\032(.hbase.pb.DispatchMergingRegionsRes" +
"Region\022\035.hbase.pb.AssignRegionRequest\032\036." + "ponse\022M\n\014AssignRegion\022\035.hbase.pb.AssignR" +
"hbase.pb.AssignRegionResponse\022S\n\016Unassig" + "egionRequest\032\036.hbase.pb.AssignRegionResp" +
"nRegion\022\037.hbase.pb.UnassignRegionRequest" + "onse\022S\n\016UnassignRegion\022\037.hbase.pb.Unassi" +
"\032 .hbase.pb.UnassignRegionResponse\022P\n\rOf" + "gnRegionRequest\032 .hbase.pb.UnassignRegio" +
"flineRegion\022\036.hbase.pb.OfflineRegionRequ" + "nResponse\022P\n\rOfflineRegion\022\036.hbase.pb.Of" +
"est\032\037.hbase.pb.OfflineRegionResponse\022J\n\013" + "flineRegionRequest\032\037.hbase.pb.OfflineReg" +
"DeleteTable\022\034.hbase.pb.DeleteTableReques" + "ionResponse\022J\n\013DeleteTable\022\034.hbase.pb.De" +
"t\032\035.hbase.pb.DeleteTableResponse\022P\n\rtrun" + "leteTableRequest\032\035.hbase.pb.DeleteTableR" +
"cateTable\022\036.hbase.pb.TruncateTableReques", "esponse\022P\n\rtruncateTable\022\036.hbase.pb.Trun",
"t\032\037.hbase.pb.TruncateTableResponse\022J\n\013En" + "cateTableRequest\032\037.hbase.pb.TruncateTabl" +
"ableTable\022\034.hbase.pb.EnableTableRequest\032" + "eResponse\022J\n\013EnableTable\022\034.hbase.pb.Enab" +
"\035.hbase.pb.EnableTableResponse\022M\n\014Disabl" + "leTableRequest\032\035.hbase.pb.EnableTableRes" +
"eTable\022\035.hbase.pb.DisableTableRequest\032\036." + "ponse\022M\n\014DisableTable\022\035.hbase.pb.Disable" +
"hbase.pb.DisableTableResponse\022J\n\013ModifyT" + "TableRequest\032\036.hbase.pb.DisableTableResp" +
"able\022\034.hbase.pb.ModifyTableRequest\032\035.hba" + "onse\022J\n\013ModifyTable\022\034.hbase.pb.ModifyTab" +
"se.pb.ModifyTableResponse\022J\n\013CreateTable" + "leRequest\032\035.hbase.pb.ModifyTableResponse" +
"\022\034.hbase.pb.CreateTableRequest\032\035.hbase.p" + "\022J\n\013CreateTable\022\034.hbase.pb.CreateTableRe" +
"b.CreateTableResponse\022A\n\010Shutdown\022\031.hbas" + "quest\032\035.hbase.pb.CreateTableResponse\022A\n\010" +
"e.pb.ShutdownRequest\032\032.hbase.pb.Shutdown", "Shutdown\022\031.hbase.pb.ShutdownRequest\032\032.hb",
"Response\022G\n\nStopMaster\022\033.hbase.pb.StopMa" + "ase.pb.ShutdownResponse\022G\n\nStopMaster\022\033." +
"sterRequest\032\034.hbase.pb.StopMasterRespons" + "hbase.pb.StopMasterRequest\032\034.hbase.pb.St" +
"e\022>\n\007Balance\022\030.hbase.pb.BalanceRequest\032\031" + "opMasterResponse\022>\n\007Balance\022\030.hbase.pb.B" +
".hbase.pb.BalanceResponse\022_\n\022SetBalancer" + "alanceRequest\032\031.hbase.pb.BalanceResponse" +
"Running\022#.hbase.pb.SetBalancerRunningReq" + "\022_\n\022SetBalancerRunning\022#.hbase.pb.SetBal" +
"uest\032$.hbase.pb.SetBalancerRunningRespon" + "ancerRunningRequest\032$.hbase.pb.SetBalanc" +
"se\022\\\n\021IsBalancerEnabled\022\".hbase.pb.IsBal" + "erRunningResponse\022\\\n\021IsBalancerEnabled\022\"" +
"ancerEnabledRequest\032#.hbase.pb.IsBalance" + ".hbase.pb.IsBalancerEnabledRequest\032#.hba" +
"rEnabledResponse\022S\n\016RunCatalogScan\022\037.hba" + "se.pb.IsBalancerEnabledResponse\022S\n\016RunCa" +
"se.pb.RunCatalogScanRequest\032 .hbase.pb.R", "talogScan\022\037.hbase.pb.RunCatalogScanReque",
"unCatalogScanResponse\022e\n\024EnableCatalogJa" + "st\032 .hbase.pb.RunCatalogScanResponse\022e\n\024" +
"nitor\022%.hbase.pb.EnableCatalogJanitorReq" + "EnableCatalogJanitor\022%.hbase.pb.EnableCa" +
"uest\032&.hbase.pb.EnableCatalogJanitorResp" + "talogJanitorRequest\032&.hbase.pb.EnableCat" +
"onse\022n\n\027IsCatalogJanitorEnabled\022(.hbase." + "alogJanitorResponse\022n\n\027IsCatalogJanitorE" +
"pb.IsCatalogJanitorEnabledRequest\032).hbas" + "nabled\022(.hbase.pb.IsCatalogJanitorEnable" +
"e.pb.IsCatalogJanitorEnabledResponse\022^\n\021" + "dRequest\032).hbase.pb.IsCatalogJanitorEnab" +
"ExecMasterService\022#.hbase.pb.Coprocessor" + "ledResponse\022^\n\021ExecMasterService\022#.hbase" +
"ServiceRequest\032$.hbase.pb.CoprocessorSer" + ".pb.CoprocessorServiceRequest\032$.hbase.pb" +
"viceResponse\022A\n\010Snapshot\022\031.hbase.pb.Snap" + ".CoprocessorServiceResponse\022A\n\010Snapshot\022" +
"shotRequest\032\032.hbase.pb.SnapshotResponse\022", "\031.hbase.pb.SnapshotRequest\032\032.hbase.pb.Sn",
"h\n\025GetCompletedSnapshots\022&.hbase.pb.GetC" + "apshotResponse\022h\n\025GetCompletedSnapshots\022" +
"ompletedSnapshotsRequest\032\'.hbase.pb.GetC" + "&.hbase.pb.GetCompletedSnapshotsRequest\032" +
"ompletedSnapshotsResponse\022S\n\016DeleteSnaps" + "\'.hbase.pb.GetCompletedSnapshotsResponse" +
"hot\022\037.hbase.pb.DeleteSnapshotRequest\032 .h" + "\022S\n\016DeleteSnapshot\022\037.hbase.pb.DeleteSnap" +
"base.pb.DeleteSnapshotResponse\022S\n\016IsSnap" + "shotRequest\032 .hbase.pb.DeleteSnapshotRes" +
"shotDone\022\037.hbase.pb.IsSnapshotDoneReques" + "ponse\022S\n\016IsSnapshotDone\022\037.hbase.pb.IsSna" +
"t\032 .hbase.pb.IsSnapshotDoneResponse\022V\n\017R" + "pshotDoneRequest\032 .hbase.pb.IsSnapshotDo" +
"estoreSnapshot\022 .hbase.pb.RestoreSnapsho" + "neResponse\022V\n\017RestoreSnapshot\022 .hbase.pb" +
"tRequest\032!.hbase.pb.RestoreSnapshotRespo" + ".RestoreSnapshotRequest\032!.hbase.pb.Resto" +
"nse\022h\n\025IsRestoreSnapshotDone\022&.hbase.pb.", "reSnapshotResponse\022h\n\025IsRestoreSnapshotD",
"IsRestoreSnapshotDoneRequest\032\'.hbase.pb." + "one\022&.hbase.pb.IsRestoreSnapshotDoneRequ" +
"IsRestoreSnapshotDoneResponse\022P\n\rExecPro" + "est\032\'.hbase.pb.IsRestoreSnapshotDoneResp" +
"cedure\022\036.hbase.pb.ExecProcedureRequest\032\037" + "onse\022P\n\rExecProcedure\022\036.hbase.pb.ExecPro" +
".hbase.pb.ExecProcedureResponse\022W\n\024ExecP" + "cedureRequest\032\037.hbase.pb.ExecProcedureRe" +
"rocedureWithRet\022\036.hbase.pb.ExecProcedure" + "sponse\022W\n\024ExecProcedureWithRet\022\036.hbase.p" +
"Request\032\037.hbase.pb.ExecProcedureResponse" + "b.ExecProcedureRequest\032\037.hbase.pb.ExecPr" +
"\022V\n\017IsProcedureDone\022 .hbase.pb.IsProcedu" + "ocedureResponse\022V\n\017IsProcedureDone\022 .hba" +
"reDoneRequest\032!.hbase.pb.IsProcedureDone" + "se.pb.IsProcedureDoneRequest\032!.hbase.pb." +
"Response\022V\n\017ModifyNamespace\022 .hbase.pb.M" + "IsProcedureDoneResponse\022V\n\017ModifyNamespa" +
"odifyNamespaceRequest\032!.hbase.pb.ModifyN", "ce\022 .hbase.pb.ModifyNamespaceRequest\032!.h",
"amespaceResponse\022V\n\017CreateNamespace\022 .hb" + "base.pb.ModifyNamespaceResponse\022V\n\017Creat" +
"ase.pb.CreateNamespaceRequest\032!.hbase.pb" + "eNamespace\022 .hbase.pb.CreateNamespaceReq" +
".CreateNamespaceResponse\022V\n\017DeleteNamesp" + "uest\032!.hbase.pb.CreateNamespaceResponse\022" +
"ace\022 .hbase.pb.DeleteNamespaceRequest\032!." + "V\n\017DeleteNamespace\022 .hbase.pb.DeleteName" +
"hbase.pb.DeleteNamespaceResponse\022k\n\026GetN" + "spaceRequest\032!.hbase.pb.DeleteNamespaceR" +
"amespaceDescriptor\022\'.hbase.pb.GetNamespa" + "esponse\022k\n\026GetNamespaceDescriptor\022\'.hbas" +
"ceDescriptorRequest\032(.hbase.pb.GetNamesp" + "e.pb.GetNamespaceDescriptorRequest\032(.hba" +
"aceDescriptorResponse\022q\n\030ListNamespaceDe" + "se.pb.GetNamespaceDescriptorResponse\022q\n\030" +
"scriptors\022).hbase.pb.ListNamespaceDescri" + "ListNamespaceDescriptors\022).hbase.pb.List" +
"ptorsRequest\032*.hbase.pb.ListNamespaceDes", "NamespaceDescriptorsRequest\032*.hbase.pb.L",
"criptorsResponse\022\206\001\n\037ListTableDescriptor" + "istNamespaceDescriptorsResponse\022\206\001\n\037List" +
"sByNamespace\0220.hbase.pb.ListTableDescrip" + "TableDescriptorsByNamespace\0220.hbase.pb.L" +
"torsByNamespaceRequest\0321.hbase.pb.ListTa" + "istTableDescriptorsByNamespaceRequest\0321." +
"bleDescriptorsByNamespaceResponse\022t\n\031Lis" + "hbase.pb.ListTableDescriptorsByNamespace" +
"tTableNamesByNamespace\022*.hbase.pb.ListTa" + "Response\022t\n\031ListTableNamesByNamespace\022*." +
"bleNamesByNamespaceRequest\032+.hbase.pb.Li" + "hbase.pb.ListTableNamesByNamespaceReques" +
"stTableNamesByNamespaceResponse\022P\n\rGetTa" + "t\032+.hbase.pb.ListTableNamesByNamespaceRe" +
"bleState\022\036.hbase.pb.GetTableStateRequest" + "sponse\022P\n\rGetTableState\022\036.hbase.pb.GetTa" +
"\032\037.hbase.pb.GetTableStateResponse\022A\n\010Set" + "bleStateRequest\032\037.hbase.pb.GetTableState" +
"Quota\022\031.hbase.pb.SetQuotaRequest\032\032.hbase", "Response\022A\n\010SetQuota\022\031.hbase.pb.SetQuota",
".pb.SetQuotaResponse\022x\n\037getLastMajorComp" + "Request\032\032.hbase.pb.SetQuotaResponse\022x\n\037g" +
"actionTimestamp\022).hbase.pb.MajorCompacti" + "etLastMajorCompactionTimestamp\022).hbase.p" +
"onTimestampRequest\032*.hbase.pb.MajorCompa" + "b.MajorCompactionTimestampRequest\032*.hbas" +
"ctionTimestampResponse\022\212\001\n(getLastMajorC" + "e.pb.MajorCompactionTimestampResponse\022\212\001" +
"ompactionTimestampForRegion\0222.hbase.pb.M" + "\n(getLastMajorCompactionTimestampForRegi" +
"ajorCompactionTimestampForRegionRequest\032" + "on\0222.hbase.pb.MajorCompactionTimestampFo" +
"*.hbase.pb.MajorCompactionTimestampRespo" + "rRegionRequest\032*.hbase.pb.MajorCompactio" +
"nse\022_\n\022getProcedureResult\022#.hbase.pb.Get" + "nTimestampResponse\022_\n\022getProcedureResult" +
"ProcedureResultRequest\032$.hbase.pb.GetPro" + "\022#.hbase.pb.GetProcedureResultRequest\032$." +
"cedureResultResponse\022h\n\027getSecurityCapab", "hbase.pb.GetProcedureResultResponse\022h\n\027g",
"ilities\022%.hbase.pb.SecurityCapabilitiesR" + "etSecurityCapabilities\022%.hbase.pb.Securi" +
"equest\032&.hbase.pb.SecurityCapabilitiesRe" + "tyCapabilitiesRequest\032&.hbase.pb.Securit" +
"sponseBB\n*org.apache.hadoop.hbase.protob" + "yCapabilitiesResponseBB\n*org.apache.hado" +
"uf.generatedB\014MasterProtosH\001\210\001\001\240\001\001" "op.hbase.protobuf.generatedB\014MasterProto" +
"sH\001\210\001\001\240\001\001"
}; };
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
@ -57098,7 +57195,7 @@ public final class MasterProtos {
internal_static_hbase_pb_BalanceRequest_fieldAccessorTable = new internal_static_hbase_pb_BalanceRequest_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable( com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_hbase_pb_BalanceRequest_descriptor, internal_static_hbase_pb_BalanceRequest_descriptor,
new java.lang.String[] { }); new java.lang.String[] { "Force", });
internal_static_hbase_pb_BalanceResponse_descriptor = internal_static_hbase_pb_BalanceResponse_descriptor =
getDescriptor().getMessageTypes().get(47); getDescriptor().getMessageTypes().get(47);
internal_static_hbase_pb_BalanceResponse_fieldAccessorTable = new internal_static_hbase_pb_BalanceResponse_fieldAccessorTable = new

View File

@ -249,6 +249,7 @@ message StopMasterResponse {
} }
message BalanceRequest { message BalanceRequest {
optional bool force = 1;
} }
message BalanceResponse { message BalanceResponse {

View File

@ -1224,6 +1224,10 @@ public class HMaster extends HRegionServer implements MasterServices, Server {
} }
public boolean balance() throws IOException { public boolean balance() throws IOException {
return balance(false);
}
public boolean balance(boolean force) throws IOException {
// if master not initialized, don't run balancer. // if master not initialized, don't run balancer.
if (!this.initialized) { if (!this.initialized) {
LOG.debug("Master has not been initialized, don't run balancer."); LOG.debug("Master has not been initialized, don't run balancer.");
@ -1238,10 +1242,14 @@ public class HMaster extends HRegionServer implements MasterServices, Server {
if (this.assignmentManager.getRegionStates().isRegionsInTransition()) { if (this.assignmentManager.getRegionStates().isRegionsInTransition()) {
Map<String, RegionState> regionsInTransition = Map<String, RegionState> regionsInTransition =
this.assignmentManager.getRegionStates().getRegionsInTransition(); this.assignmentManager.getRegionStates().getRegionsInTransition();
LOG.debug("Not running balancer because " + regionsInTransition.size() + // if hbase:meta region is in transition, result of assignment cannot be recorded
// ignore the force flag in that case
boolean metaInTransition = assignmentManager.getRegionStates().isMetaRegionInTransition();
String prefix = force && !metaInTransition ? "R" : "Not r";
LOG.debug(prefix + "unning balancer because " + regionsInTransition.size() +
" region(s) in transition: " + org.apache.commons.lang.StringUtils. " region(s) in transition: " + org.apache.commons.lang.StringUtils.
abbreviate(regionsInTransition.toString(), 256)); abbreviate(regionsInTransition.toString(), 256));
return false; if (!force || metaInTransition) return false;
} }
if (this.serverManager.areDeadServersInProgress()) { if (this.serverManager.areDeadServersInProgress()) {
LOG.debug("Not running balancer because processing dead regionserver(s): " + LOG.debug("Not running balancer because processing dead regionserver(s): " +

View File

@ -413,7 +413,8 @@ public class MasterRpcServices extends RSRpcServices
public BalanceResponse balance(RpcController controller, public BalanceResponse balance(RpcController controller,
BalanceRequest request) throws ServiceException { BalanceRequest request) throws ServiceException {
try { try {
return BalanceResponse.newBuilder().setBalancerRan(master.balance()).build(); return BalanceResponse.newBuilder().setBalancerRan(master.balance(
request.hasForce() ? request.getForce() : false)).build();
} catch (IOException ex) { } catch (IOException ex) {
throw new ServiceException(ex); throw new ServiceException(ex);
} }

View File

@ -228,6 +228,16 @@ public class RegionStates {
return !regionsInTransition.isEmpty(); return !regionsInTransition.isEmpty();
} }
/**
* @return True if hbase:meta table region is in transition.
*/
public synchronized boolean isMetaRegionInTransition() {
for (RegionState state : regionsInTransition.values()) {
if (state.getRegion().isMetaRegion()) return true;
}
return false;
}
/** /**
* @return True if specified region assigned, and not in transition. * @return True if specified region assigned, and not in transition.
*/ */

View File

@ -102,8 +102,8 @@ module Hbase
#---------------------------------------------------------------------------------------------- #----------------------------------------------------------------------------------------------
# Requests a cluster balance # Requests a cluster balance
# Returns true if balancer ran # Returns true if balancer ran
def balancer() def balancer(force)
@admin.balancer() @admin.balancer(java.lang.Boolean::valueOf(force))
end end
#---------------------------------------------------------------------------------------------- #----------------------------------------------------------------------------------------------

View File

@ -25,13 +25,26 @@ module Shell
Trigger the cluster balancer. Returns true if balancer ran and was able to Trigger the cluster balancer. Returns true if balancer ran and was able to
tell the region servers to unassign all the regions to balance (the re-assignment itself is async). tell the region servers to unassign all the regions to balance (the re-assignment itself is async).
Otherwise false (Will not run if regions in transition). Otherwise false (Will not run if regions in transition).
Parameter tells master whether we should force balance even if there is region in transition.
WARNING: For experts only. Forcing a balance may do more damage than repair
when assignment is confused
Examples:
hbase> balancer
hbase> balancer "force"
EOF EOF
end end
def command() def command(force=nil)
format_simple_command do format_simple_command do
formatter.row([ formatter.row([
admin.balancer()? "true": "false" if force.nil?
admin.balancer("false")? "true": "false"
elsif force == "force"
admin.balancer("true")? "true": "false"
end
]) ])
end end
end end