Index: hbase-protocol/src/main/protobuf/Client.proto =================================================================== --- hbase-protocol/src/main/protobuf/Client.proto (revision 1577026) +++ hbase-protocol/src/main/protobuf/Client.proto (working copy) @@ -377,7 +377,14 @@ repeated RegionActionResult regionActionResult = 1; } +message GetAllServerAddressRequest { +} + +message GetAllServerAddressResponse { + repeated string hostsAndPort = 1; +} + service ClientService { rpc Get(GetRequest) returns(GetResponse); @@ -396,4 +403,7 @@ rpc Multi(MultiRequest) returns(MultiResponse); + + rpc GetAllServerAddress(GetAllServerAddressRequest) + returns(GetAllServerAddressResponse); } Index: hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/generated/ClientProtos.java =================================================================== --- hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/generated/ClientProtos.java (revision 1577026) +++ hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/generated/ClientProtos.java (working copy) @@ -29358,7 +29358,877 @@ // @@protoc_insertion_point(class_scope:MultiResponse) } + public interface GetAllServerAddressRequestOrBuilder + extends com.google.protobuf.MessageOrBuilder { + } /** + * Protobuf type {@code GetAllServerAddressRequest} + */ + public static final class GetAllServerAddressRequest extends + com.google.protobuf.GeneratedMessage + implements GetAllServerAddressRequestOrBuilder { + // Use GetAllServerAddressRequest.newBuilder() to construct. + private GetAllServerAddressRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private GetAllServerAddressRequest(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final GetAllServerAddressRequest defaultInstance; + public static GetAllServerAddressRequest getDefaultInstance() { + return defaultInstance; + } + + public GetAllServerAddressRequest getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private GetAllServerAddressRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.apache.hadoop.hbase.protobuf.generated.ClientProtos.internal_static_GetAllServerAddressRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.apache.hadoop.hbase.protobuf.generated.ClientProtos.internal_static_GetAllServerAddressRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest.class, org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public GetAllServerAddressRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new GetAllServerAddressRequest(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private void initFields() { + } + 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(); + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + 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.ClientProtos.GetAllServerAddressRequest)) { + return super.equals(obj); + } + org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest other = (org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest) obj; + + boolean result = true; + result = result && + getUnknownFields().equals(other.getUnknownFields()); + return result; + } + + private int memoizedHashCode = 0; + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptorForType().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest 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; + } + /** + * Protobuf type {@code GetAllServerAddressRequest} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.apache.hadoop.hbase.protobuf.generated.ClientProtos.internal_static_GetAllServerAddressRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.apache.hadoop.hbase.protobuf.generated.ClientProtos.internal_static_GetAllServerAddressRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest.class, org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest.Builder.class); + } + + // Construct using org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.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(); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.apache.hadoop.hbase.protobuf.generated.ClientProtos.internal_static_GetAllServerAddressRequest_descriptor; + } + + public org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest getDefaultInstanceForType() { + return org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest.getDefaultInstance(); + } + + public org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest build() { + org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest buildPartial() { + org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest result = new org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest(this); + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest) { + return mergeFrom((org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest other) { + if (other == org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest.getDefaultInstance()) return this; + 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 { + org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + // @@protoc_insertion_point(builder_scope:GetAllServerAddressRequest) + } + + static { + defaultInstance = new GetAllServerAddressRequest(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:GetAllServerAddressRequest) + } + + public interface GetAllServerAddressResponseOrBuilder + extends com.google.protobuf.MessageOrBuilder { + + // repeated string hostsAndPort = 1; + /** + * repeated string hostsAndPort = 1; + */ + java.util.List + getHostsAndPortList(); + /** + * repeated string hostsAndPort = 1; + */ + int getHostsAndPortCount(); + /** + * repeated string hostsAndPort = 1; + */ + java.lang.String getHostsAndPort(int index); + /** + * repeated string hostsAndPort = 1; + */ + com.google.protobuf.ByteString + getHostsAndPortBytes(int index); + } + /** + * Protobuf type {@code GetAllServerAddressResponse} + */ + public static final class GetAllServerAddressResponse extends + com.google.protobuf.GeneratedMessage + implements GetAllServerAddressResponseOrBuilder { + // Use GetAllServerAddressResponse.newBuilder() to construct. + private GetAllServerAddressResponse(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private GetAllServerAddressResponse(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final GetAllServerAddressResponse defaultInstance; + public static GetAllServerAddressResponse getDefaultInstance() { + return defaultInstance; + } + + public GetAllServerAddressResponse getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private GetAllServerAddressResponse( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + hostsAndPort_ = new com.google.protobuf.LazyStringArrayList(); + mutable_bitField0_ |= 0x00000001; + } + hostsAndPort_.add(input.readBytes()); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + hostsAndPort_ = new com.google.protobuf.UnmodifiableLazyStringList(hostsAndPort_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.apache.hadoop.hbase.protobuf.generated.ClientProtos.internal_static_GetAllServerAddressResponse_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.apache.hadoop.hbase.protobuf.generated.ClientProtos.internal_static_GetAllServerAddressResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse.class, org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public GetAllServerAddressResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new GetAllServerAddressResponse(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + // repeated string hostsAndPort = 1; + public static final int HOSTSANDPORT_FIELD_NUMBER = 1; + private com.google.protobuf.LazyStringList hostsAndPort_; + /** + * repeated string hostsAndPort = 1; + */ + public java.util.List + getHostsAndPortList() { + return hostsAndPort_; + } + /** + * repeated string hostsAndPort = 1; + */ + public int getHostsAndPortCount() { + return hostsAndPort_.size(); + } + /** + * repeated string hostsAndPort = 1; + */ + public java.lang.String getHostsAndPort(int index) { + return hostsAndPort_.get(index); + } + /** + * repeated string hostsAndPort = 1; + */ + public com.google.protobuf.ByteString + getHostsAndPortBytes(int index) { + return hostsAndPort_.getByteString(index); + } + + private void initFields() { + hostsAndPort_ = com.google.protobuf.LazyStringArrayList.EMPTY; + } + 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(); + for (int i = 0; i < hostsAndPort_.size(); i++) { + output.writeBytes(1, hostsAndPort_.getByteString(i)); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + { + int dataSize = 0; + for (int i = 0; i < hostsAndPort_.size(); i++) { + dataSize += com.google.protobuf.CodedOutputStream + .computeBytesSizeNoTag(hostsAndPort_.getByteString(i)); + } + size += dataSize; + size += 1 * getHostsAndPortList().size(); + } + 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.ClientProtos.GetAllServerAddressResponse)) { + return super.equals(obj); + } + org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse other = (org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse) obj; + + boolean result = true; + result = result && getHostsAndPortList() + .equals(other.getHostsAndPortList()); + result = result && + getUnknownFields().equals(other.getUnknownFields()); + return result; + } + + private int memoizedHashCode = 0; + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptorForType().hashCode(); + if (getHostsAndPortCount() > 0) { + hash = (37 * hash) + HOSTSANDPORT_FIELD_NUMBER; + hash = (53 * hash) + getHostsAndPortList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse 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; + } + /** + * Protobuf type {@code GetAllServerAddressResponse} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.apache.hadoop.hbase.protobuf.generated.ClientProtos.internal_static_GetAllServerAddressResponse_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.apache.hadoop.hbase.protobuf.generated.ClientProtos.internal_static_GetAllServerAddressResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse.class, org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse.Builder.class); + } + + // Construct using org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.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(); + hostsAndPort_ = com.google.protobuf.LazyStringArrayList.EMPTY; + 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.ClientProtos.internal_static_GetAllServerAddressResponse_descriptor; + } + + public org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse getDefaultInstanceForType() { + return org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse.getDefaultInstance(); + } + + public org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse build() { + org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse buildPartial() { + org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse result = new org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse(this); + int from_bitField0_ = bitField0_; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + hostsAndPort_ = new com.google.protobuf.UnmodifiableLazyStringList( + hostsAndPort_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.hostsAndPort_ = hostsAndPort_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse) { + return mergeFrom((org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse other) { + if (other == org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse.getDefaultInstance()) return this; + if (!other.hostsAndPort_.isEmpty()) { + if (hostsAndPort_.isEmpty()) { + hostsAndPort_ = other.hostsAndPort_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureHostsAndPortIsMutable(); + hostsAndPort_.addAll(other.hostsAndPort_); + } + onChanged(); + } + 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 { + org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + // repeated string hostsAndPort = 1; + private com.google.protobuf.LazyStringList hostsAndPort_ = com.google.protobuf.LazyStringArrayList.EMPTY; + private void ensureHostsAndPortIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + hostsAndPort_ = new com.google.protobuf.LazyStringArrayList(hostsAndPort_); + bitField0_ |= 0x00000001; + } + } + /** + * repeated string hostsAndPort = 1; + */ + public java.util.List + getHostsAndPortList() { + return java.util.Collections.unmodifiableList(hostsAndPort_); + } + /** + * repeated string hostsAndPort = 1; + */ + public int getHostsAndPortCount() { + return hostsAndPort_.size(); + } + /** + * repeated string hostsAndPort = 1; + */ + public java.lang.String getHostsAndPort(int index) { + return hostsAndPort_.get(index); + } + /** + * repeated string hostsAndPort = 1; + */ + public com.google.protobuf.ByteString + getHostsAndPortBytes(int index) { + return hostsAndPort_.getByteString(index); + } + /** + * repeated string hostsAndPort = 1; + */ + public Builder setHostsAndPort( + int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureHostsAndPortIsMutable(); + hostsAndPort_.set(index, value); + onChanged(); + return this; + } + /** + * repeated string hostsAndPort = 1; + */ + public Builder addHostsAndPort( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureHostsAndPortIsMutable(); + hostsAndPort_.add(value); + onChanged(); + return this; + } + /** + * repeated string hostsAndPort = 1; + */ + public Builder addAllHostsAndPort( + java.lang.Iterable values) { + ensureHostsAndPortIsMutable(); + super.addAll(values, hostsAndPort_); + onChanged(); + return this; + } + /** + * repeated string hostsAndPort = 1; + */ + public Builder clearHostsAndPort() { + hostsAndPort_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * repeated string hostsAndPort = 1; + */ + public Builder addHostsAndPortBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + ensureHostsAndPortIsMutable(); + hostsAndPort_.add(value); + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:GetAllServerAddressResponse) + } + + static { + defaultInstance = new GetAllServerAddressResponse(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:GetAllServerAddressResponse) + } + + /** * Protobuf service {@code ClientService} */ public static abstract class ClientService @@ -29414,6 +30284,14 @@ org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MultiRequest request, com.google.protobuf.RpcCallback done); + /** + * rpc GetAllServerAddress(.GetAllServerAddressRequest) returns (.GetAllServerAddressResponse); + */ + public abstract void getAllServerAddress( + com.google.protobuf.RpcController controller, + org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest request, + com.google.protobuf.RpcCallback done); + } public static com.google.protobuf.Service newReflectiveService( @@ -29467,6 +30345,14 @@ impl.multi(controller, request, done); } + @java.lang.Override + public void getAllServerAddress( + com.google.protobuf.RpcController controller, + org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest request, + com.google.protobuf.RpcCallback done) { + impl.getAllServerAddress(controller, request, done); + } + }; } @@ -29501,6 +30387,8 @@ return impl.execService(controller, (org.apache.hadoop.hbase.protobuf.generated.ClientProtos.CoprocessorServiceRequest)request); case 5: return impl.multi(controller, (org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MultiRequest)request); + case 6: + return impl.getAllServerAddress(controller, (org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest)request); default: throw new java.lang.AssertionError("Can't get here."); } @@ -29527,6 +30415,8 @@ return org.apache.hadoop.hbase.protobuf.generated.ClientProtos.CoprocessorServiceRequest.getDefaultInstance(); case 5: return org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MultiRequest.getDefaultInstance(); + case 6: + return org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest.getDefaultInstance(); default: throw new java.lang.AssertionError("Can't get here."); } @@ -29553,6 +30443,8 @@ return org.apache.hadoop.hbase.protobuf.generated.ClientProtos.CoprocessorServiceResponse.getDefaultInstance(); case 5: return org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MultiResponse.getDefaultInstance(); + case 6: + return org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse.getDefaultInstance(); default: throw new java.lang.AssertionError("Can't get here."); } @@ -29609,6 +30501,14 @@ org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MultiRequest request, com.google.protobuf.RpcCallback done); + /** + * rpc GetAllServerAddress(.GetAllServerAddressRequest) returns (.GetAllServerAddressResponse); + */ + public abstract void getAllServerAddress( + com.google.protobuf.RpcController controller, + org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest request, + com.google.protobuf.RpcCallback done); + public static final com.google.protobuf.Descriptors.ServiceDescriptor getDescriptor() { @@ -29661,6 +30561,11 @@ com.google.protobuf.RpcUtil.specializeCallback( done)); return; + case 6: + this.getAllServerAddress(controller, (org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest)request, + com.google.protobuf.RpcUtil.specializeCallback( + done)); + return; default: throw new java.lang.AssertionError("Can't get here."); } @@ -29687,6 +30592,8 @@ return org.apache.hadoop.hbase.protobuf.generated.ClientProtos.CoprocessorServiceRequest.getDefaultInstance(); case 5: return org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MultiRequest.getDefaultInstance(); + case 6: + return org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest.getDefaultInstance(); default: throw new java.lang.AssertionError("Can't get here."); } @@ -29713,6 +30620,8 @@ return org.apache.hadoop.hbase.protobuf.generated.ClientProtos.CoprocessorServiceResponse.getDefaultInstance(); case 5: return org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MultiResponse.getDefaultInstance(); + case 6: + return org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse.getDefaultInstance(); default: throw new java.lang.AssertionError("Can't get here."); } @@ -29823,6 +30732,21 @@ org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MultiResponse.class, org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MultiResponse.getDefaultInstance())); } + + public void getAllServerAddress( + com.google.protobuf.RpcController controller, + org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest request, + com.google.protobuf.RpcCallback done) { + channel.callMethod( + getDescriptor().getMethods().get(6), + controller, + request, + org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse.getDefaultInstance(), + com.google.protobuf.RpcUtil.generalizeCallback( + done, + org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse.class, + org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse.getDefaultInstance())); + } } public static BlockingInterface newBlockingStub( @@ -29860,6 +30784,11 @@ com.google.protobuf.RpcController controller, org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MultiRequest request) throws com.google.protobuf.ServiceException; + + public org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse getAllServerAddress( + com.google.protobuf.RpcController controller, + org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest request) + throws com.google.protobuf.ServiceException; } private static final class BlockingStub implements BlockingInterface { @@ -29940,6 +30869,18 @@ org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MultiResponse.getDefaultInstance()); } + + public org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse getAllServerAddress( + com.google.protobuf.RpcController controller, + org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest request) + throws com.google.protobuf.ServiceException { + return (org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse) channel.callBlockingMethod( + getDescriptor().getMethods().get(6), + controller, + request, + org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse.getDefaultInstance()); + } + } // @@protoc_insertion_point(class_scope:ClientService) @@ -30090,6 +31031,16 @@ private static com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_MultiResponse_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_GetAllServerAddressRequest_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_GetAllServerAddressRequest_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_GetAllServerAddressResponse_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_GetAllServerAddressResponse_fieldAccessorTable; public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { @@ -30191,16 +31142,20 @@ "\014regionAction\030\001 \003(\0132\r.RegionAction\022\022\n\nno", "nceGroup\030\002 \001(\004\"@\n\rMultiResponse\022/\n\022regio" + "nActionResult\030\001 \003(\0132\023.RegionActionResult" + - "2\261\002\n\rClientService\022 \n\003Get\022\013.GetRequest\032\014" + - ".GetResponse\022)\n\006Mutate\022\016.MutateRequest\032\017" + - ".MutateResponse\022#\n\004Scan\022\014.ScanRequest\032\r." + - "ScanResponse\022>\n\rBulkLoadHFile\022\025.BulkLoad" + - "HFileRequest\032\026.BulkLoadHFileResponse\022F\n\013" + - "ExecService\022\032.CoprocessorServiceRequest\032" + - "\033.CoprocessorServiceResponse\022&\n\005Multi\022\r." + - "MultiRequest\032\016.MultiResponseBB\n*org.apac", - "he.hadoop.hbase.protobuf.generatedB\014Clie" + - "ntProtosH\001\210\001\001\240\001\001" + "\"\034\n\032GetAllServerAddressRequest\"3\n\033GetAll" + + "ServerAddressResponse\022\024\n\014hostsAndPort\030\001 " + + "\003(\t2\203\003\n\rClientService\022 \n\003Get\022\013.GetReques" + + "t\032\014.GetResponse\022)\n\006Mutate\022\016.MutateReques" + + "t\032\017.MutateResponse\022#\n\004Scan\022\014.ScanRequest" + + "\032\r.ScanResponse\022>\n\rBulkLoadHFile\022\025.BulkL" + + "oadHFileRequest\032\026.BulkLoadHFileResponse\022" + + "F\n\013ExecService\022\032.CoprocessorServiceReque", + "st\032\033.CoprocessorServiceResponse\022&\n\005Multi" + + "\022\r.MultiRequest\032\016.MultiResponse\022P\n\023GetAl" + + "lServerAddress\022\033.GetAllServerAddressRequ" + + "est\032\034.GetAllServerAddressResponseBB\n*org" + + ".apache.hadoop.hbase.protobuf.generatedB" + + "\014ClientProtosH\001\210\001\001\240\001\001" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { @@ -30381,6 +31336,18 @@ com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_MultiResponse_descriptor, new java.lang.String[] { "RegionActionResult", }); + internal_static_GetAllServerAddressRequest_descriptor = + getDescriptor().getMessageTypes().get(26); + internal_static_GetAllServerAddressRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_GetAllServerAddressRequest_descriptor, + new java.lang.String[] { }); + internal_static_GetAllServerAddressResponse_descriptor = + getDescriptor().getMessageTypes().get(27); + internal_static_GetAllServerAddressResponse_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_GetAllServerAddressResponse_descriptor, + new java.lang.String[] { "HostsAndPort", }); return null; } }; Index: hbase-server/src/test/java/org/apache/hadoop/hbase/master/MockRegionServer.java =================================================================== --- hbase-server/src/test/java/org/apache/hadoop/hbase/master/MockRegionServer.java (revision 1577026) +++ hbase-server/src/test/java/org/apache/hadoop/hbase/master/MockRegionServer.java (working copy) @@ -77,6 +77,8 @@ import org.apache.hadoop.hbase.protobuf.generated.ClientProtos; import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.BulkLoadHFileRequest; import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.BulkLoadHFileResponse; +import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest; +import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse; import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetRequest; import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetResponse; import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MultiRequest; @@ -407,6 +409,13 @@ } @Override + public GetAllServerAddressResponse getAllServerAddress( + RpcController controller, GetAllServerAddressRequest request) throws ServiceException { + // TODO Auto-generated method stub + return null; + } + + @Override public GetRegionInfoResponse getRegionInfo(RpcController controller, GetRegionInfoRequest request) throws ServiceException { GetRegionInfoResponse.Builder builder = GetRegionInfoResponse.newBuilder(); Index: hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java =================================================================== --- hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (revision 1577026) +++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (working copy) @@ -27,11 +27,16 @@ import java.lang.management.MemoryUsage; import java.lang.reflect.Constructor; import java.net.BindException; +import java.net.Inet4Address; +import java.net.InetAddress; import java.net.InetSocketAddress; +import java.net.NetworkInterface; +import java.net.SocketException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Comparator; +import java.util.Enumeration; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -163,6 +168,8 @@ import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.Condition; import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.CoprocessorServiceRequest; import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.CoprocessorServiceResponse; +import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest; +import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse; import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetRequest; import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetResponse; import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MultiRequest; @@ -523,6 +530,10 @@ private UserProvider userProvider; + private List allAvailableServerAddress; + + private boolean useMultiEthernetCard; + /** * Starts a HRegionServer at the default location * @@ -631,6 +642,14 @@ // that port is occupied. Adjust serverInfo if this is the case. this.rsInfo.setInfoPort(putUpWebUI()); this.distributedLogReplay = HLogSplitter.isDistributedLogReplay(this.conf); + + // probe all available addresses of different ethernet cards + this.allAvailableServerAddress = getAllAvailableServerAddress(); + LOG.info("RegionServer all available serveraddress"); + for (String addr : this.allAvailableServerAddress) { + LOG.info(" " + addr); + } + this.useMultiEthernetCard = conf.getBoolean("hbase.regionserver.multi.ethernetcard.enable", false); } /** @@ -1207,6 +1226,31 @@ } } + List getAllAvailableServerAddress() { + List ret = new ArrayList(); + try { + Enumeration nics = NetworkInterface.getNetworkInterfaces(); + while (nics.hasMoreElements()) { + NetworkInterface iterface = (NetworkInterface)nics.nextElement(); + if (iterface.isLoopback() || iterface.isVirtual() || !iterface.isUp()) { + continue; + } + Enumeration rawAdrs = iterface.getInetAddresses(); + while (rawAdrs.hasMoreElements()) { + InetAddress inet = (InetAddress)rawAdrs.nextElement(); + // Don't consider the ipv6 address + if ( inet instanceof Inet4Address ) { + String hostnameAndPort = inet.getHostName() + ":" + this.isa.getPort(); + ret.add(hostnameAndPort); + } + } + } + } catch(Exception e) { + LOG.warn("Obtain all available server address failed!", e); + } + return ret; + } + /* * Run init. Sets up hlog and starts up all server threads. * @@ -3272,6 +3316,18 @@ } @Override + public GetAllServerAddressResponse getAllServerAddress(final RpcController controller, + final GetAllServerAddressRequest request) throws ServiceException { + GetAllServerAddressResponse.Builder builder = GetAllServerAddressResponse.newBuilder(); + if (useMultiEthernetCard) { + for (int i = 0; i < this.allAvailableServerAddress.size(); i++) { + builder.addHostsAndPort(this.allAvailableServerAddress.get(i)); + } + } + return builder.build(); + } + + @Override public CoprocessorServiceResponse execService(final RpcController controller, final CoprocessorServiceRequest request) throws ServiceException { try { Index: hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestClientNoCluster.java =================================================================== --- hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestClientNoCluster.java (revision 1577026) +++ hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestClientNoCluster.java (working copy) @@ -56,6 +56,8 @@ import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ClientService.BlockingInterface; import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.CoprocessorServiceRequest; import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.CoprocessorServiceResponse; +import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest; +import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse; import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetRequest; import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetResponse; import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MultiRequest; @@ -495,6 +497,12 @@ this.multiInvocationsCount.decrementAndGet(); } } + + @Override + public GetAllServerAddressResponse getAllServerAddress(RpcController controller, + GetAllServerAddressRequest request) throws ServiceException { + throw new NotImplementedException(); + } } static ScanResponse doMetaScanResponse(final SortedMap> meta, @@ -811,4 +819,4 @@ public static void main(String[] args) throws Exception { System.exit(ToolRunner.run(HBaseConfiguration.create(), new TestClientNoCluster(), args)); } -} \ No newline at end of file +} Index: hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java =================================================================== --- hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java (revision 1577026) +++ hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java (working copy) @@ -23,15 +23,19 @@ import java.io.InterruptedIOException; import java.lang.reflect.Constructor; import java.lang.reflect.UndeclaredThrowableException; +import java.net.InetSocketAddress; +import java.net.Socket; import java.net.SocketException; import java.util.ArrayList; import java.util.Date; import java.util.HashSet; +import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.NavigableMap; +import java.util.Random; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; @@ -45,6 +49,8 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; +import javax.net.SocketFactory; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.classification.InterfaceAudience; @@ -76,6 +82,8 @@ import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ClientService; import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.CoprocessorServiceRequest; import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.CoprocessorServiceResponse; +import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressRequest; +import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetAllServerAddressResponse; import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.AddColumnResponse; import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.AssignRegionResponse; import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.BalanceResponse; @@ -124,6 +132,7 @@ import org.apache.hadoop.hbase.zookeeper.ZKUtil; import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher; import org.apache.hadoop.ipc.RemoteException; +import org.apache.hadoop.net.NetUtils; import org.apache.zookeeper.KeeperException; import com.google.common.annotations.VisibleForTesting; @@ -632,6 +641,10 @@ private User user; + private boolean useMultiEthernetCard; + // server -> all available ethernet address of a server. + private ConcurrentSkipListMap> serverAddressMap; + /** * Cluster registry of basic info such as clusterid and meta region location. */ @@ -728,6 +741,9 @@ this.prefetchRegionLimit = conf.getInt( HConstants.HBASE_CLIENT_PREFETCH_LIMIT, HConstants.DEFAULT_HBASE_CLIENT_PREFETCH_LIMIT); + + this.useMultiEthernetCard = conf.getBoolean("hbase.client.multi.ethernetcard.enable", false); + this.serverAddressMap = new ConcurrentSkipListMap>(); } @Override @@ -1142,6 +1158,11 @@ if (serverName == null) { return true; // don't cache it } + + // select a serverName + ClientService.BlockingInterface service = getClient(serverName); + serverName = selectServerName(service ,serverName); + // instantiate the location long seqNum = HRegionInfo.getSeqNumDuringOpen(result); HRegionLocation loc = new HRegionLocation(regionInfo, serverName, seqNum); @@ -1166,6 +1187,66 @@ } } + private boolean serverNameFastDetect(ServerName sn) throws IOException { + Socket socket = null; + try { + socket = SocketFactory.getDefault().createSocket(); + InetSocketAddress serverAddr = new InetSocketAddress(sn.getHostname(), sn.getPort()); + NetUtils.connect(socket, serverAddr, conf.getInt("hbase.client.fast.detect.timeout", 2000)); + } catch (Exception e) { + LOG.info("ServerName fast detect failed!", e); + return false; + } finally { + if (socket != null) { + socket.close(); + } + } + return true; + } + + private ServerName selectServerName(final ClientService.BlockingInterface client, + final ServerName serverName) { + ServerName newServerName = serverName; + if (useMultiEthernetCard) { + try { + List hostsAndPort = null; + // Use the serverAddressMap cache in order to avoid repeated RPC + hostsAndPort = serverAddressMap.get(serverName.getHostname()); + if (hostsAndPort == null) { + GetAllServerAddressRequest.Builder requestBuilder = GetAllServerAddressRequest.newBuilder(); + hostsAndPort = + client.getAllServerAddress(null, requestBuilder.build()).getHostsAndPortList(); + serverAddressMap.put(serverName.getHostname(), hostsAndPort); + } + if ( hostsAndPort != null && hostsAndPort.size() > 0 ) { + Random r = new Random(System.nanoTime()); + int idx = r.nextInt(hostsAndPort.size()); + String hostAndPort = hostsAndPort.get(idx); + newServerName = ServerName.valueOf(hostAndPort, serverName.getStartcode()); + if (!serverNameFastDetect(newServerName)) { + List newList = new ArrayList(); + String invaliadAddress = newServerName.getHostname() + ":" + newServerName.getPort(); + for (String address : hostsAndPort) { + if (!invaliadAddress.equals(address)) { + newList.add(address); + } + } + serverAddressMap.put(serverName.getHostname(), newList); + newServerName = serverName; + } + } + } catch (ServiceException se) { + LOG.info("SelectServerName failed, remote exception=", se); + newServerName = serverName; + } catch (Exception e) { + LOG.info("SelectServerName failed, exception=", e); + newServerName = serverName; + } + } + LOG.info("Change servername from " + serverName + " to " + newServerName); + return newServerName; + } + /* * Search the hbase:meta table for the HRegionLocation * info that contains the table and row we're seeking. @@ -1279,6 +1360,10 @@ regionInfo.getRegionNameAsString()+" is managed by the server " + serverName + ", but it is dead."); } + + // select a serverName + service = getClient(serverName); + serverName = selectServerName(service, serverName); // Instantiate the location location = new HRegionLocation(regionInfo, serverName,