Skip to content

Commit 602e11c

Browse files
author
Liu Shaohui
committed
HBASE-13216 Add version info in RPC connection header (Shaohui Liu)
1 parent 6709fee commit 602e11c

File tree

6 files changed

+1682
-24
lines changed

6 files changed

+1682
-24
lines changed

hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/AsyncRpcChannel.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import org.apache.hadoop.hbase.HConstants;
5151
import org.apache.hadoop.hbase.classification.InterfaceAudience;
5252
import org.apache.hadoop.hbase.exceptions.ConnectionClosingException;
53+
import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
5354
import org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos;
5455
import org.apache.hadoop.hbase.protobuf.generated.RPCProtos;
5556
import org.apache.hadoop.hbase.protobuf.generated.TracingProtos;
@@ -379,6 +380,7 @@ private ChannelFuture writeChannelHeader(Channel channel) throws IOException {
379380
headerBuilder.setCellBlockCompressorClass(client.compressor.getClass().getCanonicalName());
380381
}
381382

383+
headerBuilder.setVersionInfo(ProtobufUtil.getVersionInfo());
382384
RPCProtos.ConnectionHeader header = headerBuilder.build();
383385

384386

hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/RpcClientImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.apache.hadoop.hbase.classification.InterfaceAudience;
3232
import org.apache.hadoop.hbase.codec.Codec;
3333
import org.apache.hadoop.hbase.exceptions.ConnectionClosingException;
34+
import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
3435
import org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos;
3536
import org.apache.hadoop.hbase.protobuf.generated.RPCProtos.CellBlockMeta;
3637
import org.apache.hadoop.hbase.protobuf.generated.RPCProtos.ConnectionHeader;
@@ -357,6 +358,7 @@ private void cleanup() {
357358
if (this.compressor != null) {
358359
builder.setCellBlockCompressorClass(this.compressor.getClass().getCanonicalName());
359360
}
361+
builder.setVersionInfo(ProtobufUtil.getVersionInfo());
360362
this.header = builder.build();
361363

362364
this.setName("IPC Client (" + socketFactory.hashCode() +") connection to " +

hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableDescriptorsResponse;
118118
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.MasterService;
119119
import org.apache.hadoop.hbase.protobuf.generated.QuotaProtos;
120+
import org.apache.hadoop.hbase.protobuf.generated.RPCProtos;
120121
import org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos.RegionServerReportRequest;
121122
import org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos.RegionServerStartupRequest;
122123
import org.apache.hadoop.hbase.protobuf.generated.WALProtos;
@@ -144,6 +145,7 @@
144145
import org.apache.hadoop.hbase.util.ExceptionUtil;
145146
import org.apache.hadoop.hbase.util.Methods;
146147
import org.apache.hadoop.hbase.util.Pair;
148+
import org.apache.hadoop.hbase.util.VersionInfo;
147149
import org.apache.hadoop.io.Text;
148150
import org.apache.hadoop.ipc.RemoteException;
149151
import org.apache.hadoop.security.token.Token;
@@ -3020,4 +3022,19 @@ public static List<ReplicationLoadSource> toReplicationLoadSourceList(
30203022
return rlsList;
30213023
}
30223024

3025+
/**
3026+
* Get a protocol buffer VersionInfo
3027+
*
3028+
* @return the converted protocol buffer VersionInfo
3029+
*/
3030+
public static RPCProtos.VersionInfo getVersionInfo() {
3031+
RPCProtos.VersionInfo.Builder builder = RPCProtos.VersionInfo.newBuilder();
3032+
builder.setVersion(VersionInfo.getVersion());
3033+
builder.setUrl(VersionInfo.getUrl());
3034+
builder.setRevision(VersionInfo.getRevision());
3035+
builder.setUser(VersionInfo.getUser());
3036+
builder.setDate(VersionInfo.getDate());
3037+
builder.setSrcChecksum(VersionInfo.getSrcChecksum());
3038+
return builder.build();
3039+
}
30233040
}

0 commit comments

Comments
 (0)