You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2014/02/07 23:06:30 UTC
svn commit: r1565828 - in /hbase/branches/0.94/src/main:
jamon/org/apache/hadoop/hbase/tmpl/master/ java/org/apache/hadoop/hbase/
java/org/apache/hadoop/hbase/master/
java/org/apache/hadoop/hbase/protobuf/generated/
java/org/apache/hadoop/hbase/regions...
Author: stack
Date: Fri Feb 7 22:06:29 2014
New Revision: 1565828
URL: http://svn.apache.org/r1565828
Log:
HBASE-10340 [BACKPORT] HBASE-9892 Add info port to ServerName to support multi instances in a node
Modified:
hbase/branches/0.94/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/MasterStatusTmpl.jamon
hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/HConstants.java
hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/LocalHBaseCluster.java
hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/HMasterCommandLine.java
hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/protobuf/generated/HBaseProtos.java
hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/RSDumpServlet.java
hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/RSStatusServlet.java
hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/zookeeper/RegionServerTracker.java
hbase/branches/0.94/src/main/protobuf/hbase.proto
hbase/branches/0.94/src/main/resources/hbase-webapps/master/table.jsp
Modified: hbase/branches/0.94/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/MasterStatusTmpl.jamon
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/MasterStatusTmpl.jamon?rev=1565828&r1=1565827&r2=1565828&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/MasterStatusTmpl.jamon (original)
+++ hbase/branches/0.94/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/MasterStatusTmpl.jamon Fri Feb 7 22:06:29 2014
@@ -253,9 +253,7 @@ AssignmentManager assignmentManager = ma
ServerName [] serverNames = servers.toArray(new ServerName[servers.size()]);
Arrays.sort(serverNames);
for (ServerName serverName: serverNames) {
- // TODO: this is incorrect since this conf might differ from RS to RS
- // or be set to 0 to get ephemeral ports
- int infoPort = master.getConfiguration().getInt("hbase.regionserver.info.port", 60030);
+ int infoPort = master.getRegionServerInfoPort(serverName);
String url = "//" + serverName.getHostname() + ":" + infoPort + "/";
HServerLoad hsl = master.getServerManager().getLoad(serverName);
String loadStr = hsl == null? "-": hsl.toString();
@@ -286,7 +284,6 @@ AssignmentManager assignmentManager = ma
ServerName [] deadServerNames = deadServers.toArray(new ServerName[deadServers.size()]);
Arrays.sort(deadServerNames);
for (ServerName deadServerName: deadServerNames) {
- int infoPort = master.getConfiguration().getInt("hbase.regionserver.info.port", 60030);
</%java>
<tr><td><% deadServerName %></td></tr>
<%java>
Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/HConstants.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/HConstants.java?rev=1565828&r1=1565827&r2=1565828&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/HConstants.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/HConstants.java Fri Feb 7 22:06:29 2014
@@ -167,6 +167,9 @@ public final class HConstants {
/** Parameter name for port region server listens on. */
public static final String REGIONSERVER_PORT = "hbase.regionserver.port";
+ /** Parameter name for port region server's info server listens on. */
+ public static final String REGIONSERVER_INFO_PORT = "hbase.regionserver.info.port";
+
/** Default port region server listens on. */
public static final int DEFAULT_REGIONSERVER_PORT = 60020;
Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/LocalHBaseCluster.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/LocalHBaseCluster.java?rev=1565828&r1=1565827&r2=1565828&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/LocalHBaseCluster.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/LocalHBaseCluster.java Fri Feb 7 22:06:29 2014
@@ -140,6 +140,8 @@ public class LocalHBaseCluster {
// clash over default ports.
conf.set(HConstants.MASTER_PORT, "0");
conf.set(HConstants.REGIONSERVER_PORT, "0");
+ conf.set(HConstants.REGIONSERVER_INFO_PORT, "0");
+
this.masterClass = (Class<? extends HMaster>)
conf.getClass(HConstants.MASTER_IMPL, masterClass);
// Start the HMasters.
Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/HMaster.java?rev=1565828&r1=1565827&r2=1565828&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/HMaster.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/HMaster.java Fri Feb 7 22:06:29 2014
@@ -100,6 +100,7 @@ import org.apache.hadoop.hbase.master.sn
import org.apache.hadoop.hbase.monitoring.MemoryBoundedLogMessageBuffer;
import org.apache.hadoop.hbase.monitoring.MonitoredTask;
import org.apache.hadoop.hbase.monitoring.TaskMonitor;
+import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionServerInfo;
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription;
import org.apache.hadoop.hbase.regionserver.wal.HLog;
import org.apache.hadoop.hbase.replication.regionserver.Replication;
@@ -1602,6 +1603,15 @@ Server {
return masterActiveTime;
}
+ public int getRegionServerInfoPort(final ServerName sn) {
+ RegionServerInfo info = this.regionServerTracker.getRegionServerInfo(sn);
+ if (info == null || info.getInfoPort() == 0) {
+ return conf.getInt(HConstants.REGIONSERVER_INFO_PORT,
+ HConstants.DEFAULT_REGIONSERVER_INFOPORT);
+ }
+ return info.getInfoPort();
+ }
+
/**
* @return array of coprocessor SimpleNames.
*/
Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/HMasterCommandLine.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/HMasterCommandLine.java?rev=1565828&r1=1565827&r2=1565828&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/HMasterCommandLine.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/HMasterCommandLine.java Fri Feb 7 22:06:29 2014
@@ -143,7 +143,7 @@ public class HMasterCommandLine extends
Integer.toString(clientPort));
// Need to have the zk cluster shutdown when master is shutdown.
// Run a subclass that does the zk cluster shutdown on its way out.
- LocalHBaseCluster cluster = new LocalHBaseCluster(conf, 1, 1,
+ LocalHBaseCluster cluster = new LocalHBaseCluster(conf, 1, 3,
LocalHMaster.class, HRegionServer.class);
((LocalHMaster)cluster.getMaster(0)).setZKCluster(zooKeeperCluster);
cluster.startup();
Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/protobuf/generated/HBaseProtos.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/protobuf/generated/HBaseProtos.java?rev=1565828&r1=1565827&r2=1565828&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/protobuf/generated/HBaseProtos.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/protobuf/generated/HBaseProtos.java Fri Feb 7 22:06:29 2014
@@ -803,11 +803,387 @@ public final class HBaseProtos {
// @@protoc_insertion_point(class_scope:SnapshotDescription)
}
+ public interface RegionServerInfoOrBuilder
+ extends com.google.protobuf.MessageOrBuilder {
+
+ // optional int32 infoPort = 1;
+ boolean hasInfoPort();
+ int getInfoPort();
+ }
+ public static final class RegionServerInfo extends
+ com.google.protobuf.GeneratedMessage
+ implements RegionServerInfoOrBuilder {
+ // Use RegionServerInfo.newBuilder() to construct.
+ private RegionServerInfo(Builder builder) {
+ super(builder);
+ }
+ private RegionServerInfo(boolean noInit) {}
+
+ private static final RegionServerInfo defaultInstance;
+ public static RegionServerInfo getDefaultInstance() {
+ return defaultInstance;
+ }
+
+ public RegionServerInfo getDefaultInstanceForType() {
+ return defaultInstance;
+ }
+
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.internal_static_RegionServerInfo_descriptor;
+ }
+
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.internal_static_RegionServerInfo_fieldAccessorTable;
+ }
+
+ private int bitField0_;
+ // optional int32 infoPort = 1;
+ public static final int INFOPORT_FIELD_NUMBER = 1;
+ private int infoPort_;
+ public boolean hasInfoPort() {
+ return ((bitField0_ & 0x00000001) == 0x00000001);
+ }
+ public int getInfoPort() {
+ return infoPort_;
+ }
+
+ private void initFields() {
+ infoPort_ = 0;
+ }
+ private byte memoizedIsInitialized = -1;
+ public final boolean isInitialized() {
+ byte isInitialized = memoizedIsInitialized;
+ if (isInitialized != -1) return isInitialized == 1;
+
+ memoizedIsInitialized = 1;
+ return true;
+ }
+
+ public void writeTo(com.google.protobuf.CodedOutputStream output)
+ throws java.io.IOException {
+ getSerializedSize();
+ if (((bitField0_ & 0x00000001) == 0x00000001)) {
+ output.writeInt32(1, infoPort_);
+ }
+ getUnknownFields().writeTo(output);
+ }
+
+ private int memoizedSerializedSize = -1;
+ public int getSerializedSize() {
+ int size = memoizedSerializedSize;
+ if (size != -1) return size;
+
+ size = 0;
+ if (((bitField0_ & 0x00000001) == 0x00000001)) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeInt32Size(1, infoPort_);
+ }
+ size += getUnknownFields().getSerializedSize();
+ memoizedSerializedSize = size;
+ return size;
+ }
+
+ private static final long serialVersionUID = 0L;
+ @java.lang.Override
+ protected java.lang.Object writeReplace()
+ throws java.io.ObjectStreamException {
+ return super.writeReplace();
+ }
+
+ @java.lang.Override
+ public boolean equals(final java.lang.Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionServerInfo)) {
+ return super.equals(obj);
+ }
+ org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionServerInfo other = (org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionServerInfo) obj;
+
+ boolean result = true;
+ result = result && (hasInfoPort() == other.hasInfoPort());
+ if (hasInfoPort()) {
+ result = result && (getInfoPort()
+ == other.getInfoPort());
+ }
+ result = result &&
+ getUnknownFields().equals(other.getUnknownFields());
+ return result;
+ }
+
+ @java.lang.Override
+ public int hashCode() {
+ int hash = 41;
+ hash = (19 * hash) + getDescriptorForType().hashCode();
+ if (hasInfoPort()) {
+ hash = (37 * hash) + INFOPORT_FIELD_NUMBER;
+ hash = (53 * hash) + getInfoPort();
+ }
+ hash = (29 * hash) + getUnknownFields().hashCode();
+ return hash;
+ }
+
+ public static org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionServerInfo parseFrom(
+ com.google.protobuf.ByteString data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data).buildParsed();
+ }
+ public static org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionServerInfo parseFrom(
+ com.google.protobuf.ByteString data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data, extensionRegistry)
+ .buildParsed();
+ }
+ public static org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionServerInfo parseFrom(byte[] data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data).buildParsed();
+ }
+ public static org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionServerInfo parseFrom(
+ byte[] data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data, extensionRegistry)
+ .buildParsed();
+ }
+ public static org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionServerInfo parseFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input).buildParsed();
+ }
+ public static org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionServerInfo parseFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input, extensionRegistry)
+ .buildParsed();
+ }
+ public static org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionServerInfo parseDelimitedFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ Builder builder = newBuilder();
+ if (builder.mergeDelimitedFrom(input)) {
+ return builder.buildParsed();
+ } else {
+ return null;
+ }
+ }
+ public static org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionServerInfo parseDelimitedFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ Builder builder = newBuilder();
+ if (builder.mergeDelimitedFrom(input, extensionRegistry)) {
+ return builder.buildParsed();
+ } else {
+ return null;
+ }
+ }
+ public static org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionServerInfo parseFrom(
+ com.google.protobuf.CodedInputStream input)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input).buildParsed();
+ }
+ public static org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionServerInfo parseFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input, extensionRegistry)
+ .buildParsed();
+ }
+
+ public static Builder newBuilder() { return Builder.create(); }
+ public Builder newBuilderForType() { return newBuilder(); }
+ public static Builder newBuilder(org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionServerInfo prototype) {
+ return newBuilder().mergeFrom(prototype);
+ }
+ public Builder toBuilder() { return newBuilder(this); }
+
+ @java.lang.Override
+ protected Builder newBuilderForType(
+ com.google.protobuf.GeneratedMessage.BuilderParent parent) {
+ Builder builder = new Builder(parent);
+ return builder;
+ }
+ public static final class Builder extends
+ com.google.protobuf.GeneratedMessage.Builder<Builder>
+ implements org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionServerInfoOrBuilder {
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.internal_static_RegionServerInfo_descriptor;
+ }
+
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.internal_static_RegionServerInfo_fieldAccessorTable;
+ }
+
+ // Construct using org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionServerInfo.newBuilder()
+ private Builder() {
+ maybeForceBuilderInitialization();
+ }
+
+ private Builder(BuilderParent parent) {
+ super(parent);
+ maybeForceBuilderInitialization();
+ }
+ private void maybeForceBuilderInitialization() {
+ if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
+ }
+ }
+ private static Builder create() {
+ return new Builder();
+ }
+
+ public Builder clear() {
+ super.clear();
+ infoPort_ = 0;
+ bitField0_ = (bitField0_ & ~0x00000001);
+ return this;
+ }
+
+ public Builder clone() {
+ return create().mergeFrom(buildPartial());
+ }
+
+ public com.google.protobuf.Descriptors.Descriptor
+ getDescriptorForType() {
+ return org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionServerInfo.getDescriptor();
+ }
+
+ public org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionServerInfo getDefaultInstanceForType() {
+ return org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionServerInfo.getDefaultInstance();
+ }
+
+ public org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionServerInfo build() {
+ org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionServerInfo result = buildPartial();
+ if (!result.isInitialized()) {
+ throw newUninitializedMessageException(result);
+ }
+ return result;
+ }
+
+ private org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionServerInfo buildParsed()
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionServerInfo result = buildPartial();
+ if (!result.isInitialized()) {
+ throw newUninitializedMessageException(
+ result).asInvalidProtocolBufferException();
+ }
+ return result;
+ }
+
+ public org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionServerInfo buildPartial() {
+ org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionServerInfo result = new org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionServerInfo(this);
+ int from_bitField0_ = bitField0_;
+ int to_bitField0_ = 0;
+ if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
+ to_bitField0_ |= 0x00000001;
+ }
+ result.infoPort_ = infoPort_;
+ result.bitField0_ = to_bitField0_;
+ onBuilt();
+ return result;
+ }
+
+ public Builder mergeFrom(com.google.protobuf.Message other) {
+ if (other instanceof org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionServerInfo) {
+ return mergeFrom((org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionServerInfo)other);
+ } else {
+ super.mergeFrom(other);
+ return this;
+ }
+ }
+
+ public Builder mergeFrom(org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionServerInfo other) {
+ if (other == org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionServerInfo.getDefaultInstance()) return this;
+ if (other.hasInfoPort()) {
+ setInfoPort(other.getInfoPort());
+ }
+ this.mergeUnknownFields(other.getUnknownFields());
+ return this;
+ }
+
+ public final boolean isInitialized() {
+ return true;
+ }
+
+ public Builder mergeFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ com.google.protobuf.UnknownFieldSet.Builder unknownFields =
+ com.google.protobuf.UnknownFieldSet.newBuilder(
+ this.getUnknownFields());
+ while (true) {
+ int tag = input.readTag();
+ switch (tag) {
+ case 0:
+ this.setUnknownFields(unknownFields.build());
+ onChanged();
+ return this;
+ default: {
+ if (!parseUnknownField(input, unknownFields,
+ extensionRegistry, tag)) {
+ this.setUnknownFields(unknownFields.build());
+ onChanged();
+ return this;
+ }
+ break;
+ }
+ case 8: {
+ bitField0_ |= 0x00000001;
+ infoPort_ = input.readInt32();
+ break;
+ }
+ }
+ }
+ }
+
+ private int bitField0_;
+
+ // optional int32 infoPort = 1;
+ private int infoPort_ ;
+ public boolean hasInfoPort() {
+ return ((bitField0_ & 0x00000001) == 0x00000001);
+ }
+ public int getInfoPort() {
+ return infoPort_;
+ }
+ public Builder setInfoPort(int value) {
+ bitField0_ |= 0x00000001;
+ infoPort_ = value;
+ onChanged();
+ return this;
+ }
+ public Builder clearInfoPort() {
+ bitField0_ = (bitField0_ & ~0x00000001);
+ infoPort_ = 0;
+ onChanged();
+ return this;
+ }
+
+ // @@protoc_insertion_point(builder_scope:RegionServerInfo)
+ }
+
+ static {
+ defaultInstance = new RegionServerInfo(true);
+ defaultInstance.initFields();
+ }
+
+ // @@protoc_insertion_point(class_scope:RegionServerInfo)
+ }
+
private static com.google.protobuf.Descriptors.Descriptor
internal_static_SnapshotDescription_descriptor;
private static
com.google.protobuf.GeneratedMessage.FieldAccessorTable
internal_static_SnapshotDescription_fieldAccessorTable;
+ private static com.google.protobuf.Descriptors.Descriptor
+ internal_static_RegionServerInfo_descriptor;
+ private static
+ com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internal_static_RegionServerInfo_fieldAccessorTable;
public static com.google.protobuf.Descriptors.FileDescriptor
getDescriptor() {
@@ -821,9 +1197,10 @@ public final class HBaseProtos {
"\004name\030\001 \002(\t\022\r\n\005table\030\002 \001(\t\022\027\n\014creationTi" +
"me\030\003 \001(\003:\0010\022.\n\004type\030\004 \001(\0162\031.SnapshotDesc" +
"ription.Type:\005FLUSH\022\017\n\007version\030\005 \001(\005\"\037\n\004" +
- "Type\022\014\n\010DISABLED\020\000\022\t\n\005FLUSH\020\001B>\n*org.apa" +
- "che.hadoop.hbase.protobuf.generatedB\013HBa" +
- "seProtosH\001\240\001\001"
+ "Type\022\014\n\010DISABLED\020\000\022\t\n\005FLUSH\020\001\"$\n\020RegionS" +
+ "erverInfo\022\020\n\010infoPort\030\001 \001(\005B>\n*org.apach" +
+ "e.hadoop.hbase.protobuf.generatedB\013HBase" +
+ "ProtosH\001\240\001\001"
};
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
@@ -838,6 +1215,14 @@ public final class HBaseProtos {
new java.lang.String[] { "Name", "Table", "CreationTime", "Type", "Version", },
org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription.class,
org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription.Builder.class);
+ internal_static_RegionServerInfo_descriptor =
+ getDescriptor().getMessageTypes().get(1);
+ internal_static_RegionServerInfo_fieldAccessorTable = new
+ com.google.protobuf.GeneratedMessage.FieldAccessorTable(
+ internal_static_RegionServerInfo_descriptor,
+ new java.lang.String[] { "InfoPort", },
+ org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionServerInfo.class,
+ org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionServerInfo.Builder.class);
return null;
}
};
Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java?rev=1565828&r1=1565827&r2=1565828&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java Fri Feb 7 22:06:29 2014
@@ -128,6 +128,8 @@ import org.apache.hadoop.hbase.ipc.Proto
import org.apache.hadoop.hbase.ipc.RpcEngine;
import org.apache.hadoop.hbase.ipc.RpcServer;
import org.apache.hadoop.hbase.ipc.ServerNotRunningYetException;
+import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
+import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionServerInfo;
import org.apache.hadoop.hbase.regionserver.Leases.LeaseStillHeldException;
import org.apache.hadoop.hbase.regionserver.compactions.CompactionProgress;
import org.apache.hadoop.hbase.regionserver.compactions.CompactionRequest;
@@ -356,8 +358,8 @@ public class HRegionServer implements HR
*/
private ServerName serverNameFromMasterPOV;
- // Port we put up the webui on.
- private int webuiport = -1;
+ // region server static info like info port
+ private RegionServerInfo.Builder rsInfo;
/**
* This servers startcode.
@@ -483,6 +485,10 @@ public class HRegionServer implements HR
abort("Uncaught exception in service thread " + t.getName(), e);
}
};
+ this.rsInfo = RegionServerInfo.newBuilder();
+ // Put up the webui. Webui may come up on port other than configured if
+ // that port is occupied. Adjust serverInfo if this is the case.
+ this.rsInfo.setInfoPort(putUpWebUI());
}
/** Handle all the snapshot requests to this server */
@@ -1126,9 +1132,10 @@ public class HRegionServer implements HR
return ZKUtil.joinZNode(this.zooKeeper.rsZNode, getServerName().toString());
}
- private void createMyEphemeralNode() throws KeeperException {
- ZKUtil.createEphemeralNodeAndWatch(this.zooKeeper, getMyEphemeralNodePath(),
- HConstants.EMPTY_BYTE_ARRAY);
+ private void createMyEphemeralNode() throws KeeperException, IOException {
+ byte[] data = ProtobufUtil.prependPBMagic(rsInfo.build().toByteArray());
+ ZKUtil.createEphemeralNodeAndWatch(this.zooKeeper,
+ getMyEphemeralNodePath(), data);
}
private void deleteMyEphemeralNode() throws KeeperException {
@@ -1710,10 +1717,6 @@ public class HRegionServer implements HR
this.leases.setName(n + ".leaseChecker");
this.leases.start();
- // Put up the webui. Webui may come up on port other than configured if
- // that port is occupied. Adjust serverInfo if this is the case.
- this.webuiport = putUpWebUI();
-
if (this.replicationSourceHandler == this.replicationSinkHandler &&
this.replicationSourceHandler != null) {
this.replicationSourceHandler.startReplicationService();
@@ -1769,7 +1772,7 @@ public class HRegionServer implements HR
port++;
}
}
- return port;
+ return this.infoServer.getPort();
}
/*
@@ -3790,7 +3793,7 @@ public class HRegionServer implements HR
public HServerInfo getHServerInfo() throws IOException {
checkOpen();
return new HServerInfo(new HServerAddress(this.isa),
- this.startcode, this.webuiport);
+ this.startcode, this.rsInfo.getInfoPort());
}
@SuppressWarnings("unchecked")
Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/RSDumpServlet.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/RSDumpServlet.java?rev=1565828&r1=1565827&r2=1565828&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/RSDumpServlet.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/RSDumpServlet.java Fri Feb 7 22:06:29 2014
@@ -50,6 +50,13 @@ public class RSDumpServlet extends State
assert hrsconf != null : "No RS conf in context";
response.setContentType("text/plain");
+
+ if (!hrs.isOnline()) {
+ response.getWriter().write("The RegionServer is initializing!");
+ response.getWriter().close();
+ return;
+ }
+
OutputStream os = response.getOutputStream();
PrintWriter out = new PrintWriter(os);
Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/RSStatusServlet.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/RSStatusServlet.java?rev=1565828&r1=1565827&r2=1565828&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/RSStatusServlet.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/RSStatusServlet.java Fri Feb 7 22:06:29 2014
@@ -40,6 +40,13 @@ public class RSStatusServlet extends Htt
assert hrs != null : "No RS in context!";
resp.setContentType("text/html");
+
+ if (!hrs.isOnline()) {
+ resp.getWriter().write("The RegionServer is initializing!");
+ resp.getWriter().close();
+ return;
+ }
+
RSStatusTmpl tmpl = new RSStatusTmpl();
if (req.getParameter("format") != null)
tmpl.setFormat(req.getParameter("format"));
Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/zookeeper/RegionServerTracker.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/zookeeper/RegionServerTracker.java?rev=1565828&r1=1565827&r2=1565828&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/zookeeper/RegionServerTracker.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/zookeeper/RegionServerTracker.java Fri Feb 7 22:06:29 2014
@@ -22,14 +22,17 @@ package org.apache.hadoop.hbase.zookeepe
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-import java.util.NavigableSet;
-import java.util.TreeSet;
+import java.util.NavigableMap;
+import java.util.TreeMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.Abortable;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.master.ServerManager;
+import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
+import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionServerInfo;
+import org.apache.hadoop.hbase.util.Bytes;
import org.apache.zookeeper.KeeperException;
/**
@@ -44,7 +47,8 @@ import org.apache.zookeeper.KeeperExcept
*/
public class RegionServerTracker extends ZooKeeperListener {
private static final Log LOG = LogFactory.getLog(RegionServerTracker.class);
- private NavigableSet<ServerName> regionServers = new TreeSet<ServerName>();
+ private NavigableMap<ServerName, RegionServerInfo> regionServers =
+ new TreeMap<ServerName, RegionServerInfo>();
private ServerManager serverManager;
private Abortable abortable;
@@ -75,7 +79,23 @@ public class RegionServerTracker extends
this.regionServers.clear();
for (String n: servers) {
ServerName sn = ServerName.parseServerName(ZKUtil.getNodeName(n));
- this.regionServers.add(sn);
+ if (regionServers.get(sn) == null) {
+ RegionServerInfo.Builder rsInfoBuilder = RegionServerInfo.newBuilder();
+ try {
+ String nodePath = ZKUtil.joinZNode(watcher.rsZNode, n);
+ byte[] data = ZKUtil.getData(watcher, nodePath);
+ LOG.info("Rs node: " + nodePath + " data: " + Bytes.toString(data));
+ if (data != null && data.length > 0 && ProtobufUtil.isPBMagicPrefix(data)) {
+ int magicLen = ProtobufUtil.lengthOfPBMagic();
+ rsInfoBuilder.mergeFrom(data, magicLen, data.length - magicLen);
+ }
+ } catch (KeeperException e) {
+ LOG.warn("Get Rs info port from ephemeral node", e);
+ } catch (IOException e) {
+ LOG.warn("Illegal data from ephemeral node", e);
+ }
+ this.regionServers.put(sn, rsInfoBuilder.build());
+ }
}
}
}
@@ -118,13 +138,17 @@ public class RegionServerTracker extends
}
}
+ public RegionServerInfo getRegionServerInfo(final ServerName sn) {
+ return regionServers.get(sn);
+ }
+
/**
* Gets the online servers.
* @return list of online servers
*/
public List<ServerName> getOnlineServers() {
synchronized (this.regionServers) {
- return new ArrayList<ServerName>(this.regionServers);
+ return new ArrayList<ServerName>(this.regionServers.keySet());
}
}
}
Modified: hbase/branches/0.94/src/main/protobuf/hbase.proto
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/protobuf/hbase.proto?rev=1565828&r1=1565827&r2=1565828&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/protobuf/hbase.proto (original)
+++ hbase/branches/0.94/src/main/protobuf/hbase.proto Fri Feb 7 22:06:29 2014
@@ -37,3 +37,10 @@ message SnapshotDescription {
optional Type type = 4 [default = FLUSH];
optional int32 version = 5;
}
+
+/**
+ * Description of the region server info
+ */
+message RegionServerInfo {
+ optional int32 infoPort = 1;
+}
Modified: hbase/branches/0.94/src/main/resources/hbase-webapps/master/table.jsp
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/resources/hbase-webapps/master/table.jsp?rev=1565828&r1=1565827&r2=1565828&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/resources/hbase-webapps/master/table.jsp (original)
+++ hbase/branches/0.94/src/main/resources/hbase-webapps/master/table.jsp Fri Feb 7 22:06:29 2014
@@ -18,7 +18,7 @@
*/
--%>
<%@ page contentType="text/html;charset=UTF-8"
- import="java.util.HashMap"
+ import="java.util.TreeMap"
import="org.apache.hadoop.io.Writable"
import="org.apache.hadoop.conf.Configuration"
import="org.apache.hadoop.hbase.client.HTable"
@@ -50,9 +50,6 @@
if (showFragmentation) {
frags = FSUtils.getTableFragmentation(master);
}
- // HARDCODED FOR NOW TODO: FIX GET FROM ZK
- // This port might be wrong if RS actually ended up using something else.
- int infoPort = conf.getInt("hbase.regionserver.info.port", 60030);
%>
<?xml version="1.0" encoding="UTF-8" ?>
@@ -118,7 +115,7 @@
%>
<%= tableHeader %>
<%
- String url = "//" + rl.getHostname() + ":" + infoPort + "/";
+ String url = "//" + rl.getHostname() + ":" + master.getRegionServerInfoPort(rl) + "/";
%>
<tr>
<td><%= tableName %></td>
@@ -137,11 +134,11 @@
HRegionInfo meta = HRegionInfo.FIRST_META_REGIONINFO;
ServerName metaLocation = master.getCatalogTracker().waitForMeta(1);
for (int i = 0; i < 1; i++) {
- String url = "//" + metaLocation.getHostname() + ":" + infoPort + "/";
+ String url = "//" + metaLocation.getHostname() + ":" + master.getRegionServerInfoPort(metaLocation) + "/";
%>
<tr>
<td><%= meta.getRegionNameAsString() %></td>
- <td><a href="<%= url %>"><%= metaLocation.getHostname().toString() + ":" + infoPort %></a></td>
+ <td><a href="<%= url %>"><%= metaLocation.getHostname().toString() + ":" + metaLocation.getPort() %></a></td>
<td>-</td><td><%= Bytes.toString(meta.getStartKey()) %></td><td><%= Bytes.toString(meta.getEndKey()) %></td>
</tr>
<% } %>
@@ -173,7 +170,7 @@
<% } %>
</table>
<%
- Map<String, Integer> regDistribution = new HashMap<String, Integer>();
+ Map<ServerName, Integer> regDistribution = new TreeMap<ServerName, Integer>();
Map<HRegionInfo, ServerName> regions = table.getRegionLocations();
if(regions != null && regions.size() > 0) { %>
<%= tableHeader %>
@@ -192,21 +189,19 @@
if (map.containsKey(regionInfo.getRegionName())) {
req = map.get(regionInfo.getRegionName()).getRequestsCount();
}
- // This port might be wrong if RS actually ended up using something else.
- regionServer = addr.getHostname().toString() + ":" + infoPort;
- Integer i = regDistribution.get(regionServer);
+ Integer i = regDistribution.get(addr);
if (null == i) i = new Integer(0);
- regDistribution.put(regionServer, i+1);
+ regDistribution.put(addr, i+1);
}
}
%>
<tr>
<td><%= Bytes.toStringBinary(regionInfo.getRegionName())%></td>
<%
- if (regionServer != null) {
+ if (addr != null) {
%>
<td>
- <a href="<%= "//" + regionServer + "/" %>"><%= regionServer %></a>
+ <a href="<%= "//" + addr.getHostname() + ":" + master.getRegionServerInfoPort(addr) + "/" %>"><%= addr %></a>
</td>
<%
} else {
@@ -224,10 +219,12 @@
<h2>Regions by Region Server</h2>
<table><tr><th>Region Server</th><th>Region Count</th></tr>
<%
- for (Map.Entry<String, Integer> rdEntry : regDistribution.entrySet()) {
+ for (Map.Entry<ServerName, Integer> rdEntry : regDistribution.entrySet()) {
+ ServerName addr = rdEntry.getKey();
+ String url = "//" + addr.getHostname() + ":" + master.getRegionServerInfoPort(addr) + "/";
%>
<tr>
- <td><a href="<%= "//" + rdEntry.getKey() + "/" %>"><%= rdEntry.getKey() %></a></td>
+ <td><a href="<%= "//" + url %>"><%= rdEntry.getKey() %></a></td>
<td><%= rdEntry.getValue()%></td>
</tr>
<% } %>