HBASE-14517 Show regionserver's version in master status page (Liu Shaohui)

This commit is contained in:
stack 2015-10-09 15:06:39 -07:00
parent 2e8e32f746
commit 445dbd8a0e
11 changed files with 1717 additions and 1486 deletions

View File

@ -3128,8 +3128,8 @@ public final class ProtobufUtil {
* *
* @return the converted protocol buffer VersionInfo * @return the converted protocol buffer VersionInfo
*/ */
public static RPCProtos.VersionInfo getVersionInfo() { public static HBaseProtos.VersionInfo getVersionInfo() {
RPCProtos.VersionInfo.Builder builder = RPCProtos.VersionInfo.newBuilder(); HBaseProtos.VersionInfo.Builder builder = HBaseProtos.VersionInfo.newBuilder();
builder.setVersion(VersionInfo.getVersion()); builder.setVersion(VersionInfo.getVersion());
builder.setUrl(VersionInfo.getUrl()); builder.setUrl(VersionInfo.getUrl());
builder.setRevision(VersionInfo.getRevision()); builder.setRevision(VersionInfo.getRevision());

View File

@ -231,9 +231,20 @@ message NamespaceDescriptor {
repeated NameStringPair configuration = 2; repeated NameStringPair configuration = 2;
} }
// Rpc client version info proto. Included in ConnectionHeader on connection setup
message VersionInfo {
required string version = 1;
required string url = 2;
required string revision = 3;
required string user = 4;
required string date = 5;
required string src_checksum = 6;
}
/** /**
* Description of the region server info * Description of the region server info
*/ */
message RegionServerInfo { message RegionServerInfo {
optional int32 infoPort = 1; optional int32 infoPort = 1;
optional VersionInfo version_info = 2;
} }

View File

@ -78,16 +78,6 @@ message UserInformation {
optional string real_user = 2; optional string real_user = 2;
} }
// Rpc client version info proto. Included in ConnectionHeader on connection setup
message VersionInfo {
required string version = 1;
required string url = 2;
required string revision = 3;
required string user = 4;
required string date = 5;
required string src_checksum = 6;
}
// This is sent on connection setup after the connection preamble is sent. // This is sent on connection setup after the connection preamble is sent.
message ConnectionHeader { message ConnectionHeader {
optional UserInformation user_info = 1; optional UserInformation user_info = 1;

View File

@ -25,17 +25,10 @@ HMaster master;
<%import> <%import>
java.util.*; java.util.*;
org.apache.hadoop.util.StringUtils;
org.apache.hadoop.hbase.util.Bytes;
org.apache.hadoop.hbase.util.JvmVersion;
org.apache.hadoop.hbase.util.FSUtils;
org.apache.hadoop.hbase.master.HMaster; org.apache.hadoop.hbase.master.HMaster;
org.apache.hadoop.hbase.HConstants;
org.apache.hadoop.hbase.ServerLoad; org.apache.hadoop.hbase.ServerLoad;
org.apache.hadoop.hbase.ServerName; org.apache.hadoop.hbase.ServerName;
org.apache.hadoop.hbase.client.HBaseAdmin; org.apache.hadoop.hbase.util.VersionInfo;
org.apache.hadoop.hbase.HTableDescriptor;
org.apache.hadoop.hbase.HBaseConfiguration;
</%import> </%import>
@ -83,15 +76,23 @@ Arrays.sort(serverNames);
<tr> <tr>
<th>ServerName</th> <th>ServerName</th>
<th>Start time</th> <th>Start time</th>
<th>Version</th>
<th>Requests Per Second</th> <th>Requests Per Second</th>
<th>Num. Regions</th> <th>Num. Regions</th>
</tr> </tr>
<%java> <%java>
int totalRegions = 0; int totalRegions = 0;
int totalRequests = 0; int totalRequests = 0;
int inconsistentNodeNum = 0;
String masterVersion = VersionInfo.getVersion();
for (ServerName serverName: serverNames) { for (ServerName serverName: serverNames) {
ServerLoad sl = master.getServerManager().getLoad(serverName); ServerLoad sl = master.getServerManager().getLoad(serverName);
String version = master.getRegionServerVersion(serverName);
if (!masterVersion.equals(version)) {
inconsistentNodeNum ++;
}
double requestsPerSecond = 0.0; double requestsPerSecond = 0.0;
int numRegionsOnline = 0; int numRegionsOnline = 0;
@ -107,6 +108,7 @@ Arrays.sort(serverNames);
<tr> <tr>
<td><& serverNameLink; serverName=serverName; serverLoad = sl; &></td> <td><& serverNameLink; serverName=serverName; serverLoad = sl; &></td>
<td><% new Date(startcode) %></td> <td><% new Date(startcode) %></td>
<td><% version %></td>
<td><% String.format("%.0f", requestsPerSecond) %></td> <td><% String.format("%.0f", requestsPerSecond) %></td>
<td><% numRegionsOnline %></td> <td><% numRegionsOnline %></td>
</tr> </tr>
@ -115,6 +117,11 @@ Arrays.sort(serverNames);
</%java> </%java>
<tr><td>Total:<% servers.size() %></td> <tr><td>Total:<% servers.size() %></td>
<td></td> <td></td>
<%if inconsistentNodeNum > 0%>
<td style="color:red;"><% inconsistentNodeNum %> nodes with inconsistent version</td>
<%else>
<td></td>
</%if>
<td><% totalRequests %></td> <td><% totalRequests %></td>
<td><% totalRegions %></td> <td><% totalRegions %></td>
</tr> </tr>
@ -285,7 +292,7 @@ if (sl.getTotalCompactingKVs() > 0) {
String url = "//" + serverName.getHostname() + ":" + infoPort + "/rs-status"; String url = "//" + serverName.getHostname() + ":" + infoPort + "/rs-status";
</%java> </%java>
<%if (infoPort > 0) %> <%if infoPort > 0%>
<a href="<% url %>"><% serverName.getServerName() %></a> <a href="<% url %>"><% serverName.getServerName() %></a>
<%else> <%else>
<% serverName.getServerName() %> <% serverName.getServerName() %>

View File

@ -19,9 +19,9 @@ package org.apache.hadoop.hbase.ipc;
import java.net.InetAddress; import java.net.InetAddress;
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.VersionInfo;
import org.apache.hadoop.hbase.security.User; import org.apache.hadoop.hbase.security.User;
import org.apache.hadoop.hbase.protobuf.generated.RPCProtos.VersionInfo;
public interface RpcCallContext extends Delayable { public interface RpcCallContext extends Delayable {
/** /**

View File

@ -85,13 +85,13 @@ import org.apache.hadoop.hbase.io.ByteBufferOutputStream;
import org.apache.hadoop.hbase.io.BoundedByteBufferPool; import org.apache.hadoop.hbase.io.BoundedByteBufferPool;
import org.apache.hadoop.hbase.monitoring.MonitoredRPCHandler; import org.apache.hadoop.hbase.monitoring.MonitoredRPCHandler;
import org.apache.hadoop.hbase.protobuf.ProtobufUtil; import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.VersionInfo;
import org.apache.hadoop.hbase.protobuf.generated.RPCProtos.CellBlockMeta; import org.apache.hadoop.hbase.protobuf.generated.RPCProtos.CellBlockMeta;
import org.apache.hadoop.hbase.protobuf.generated.RPCProtos.ConnectionHeader; import org.apache.hadoop.hbase.protobuf.generated.RPCProtos.ConnectionHeader;
import org.apache.hadoop.hbase.protobuf.generated.RPCProtos.ExceptionResponse; import org.apache.hadoop.hbase.protobuf.generated.RPCProtos.ExceptionResponse;
import org.apache.hadoop.hbase.protobuf.generated.RPCProtos.RequestHeader; import org.apache.hadoop.hbase.protobuf.generated.RPCProtos.RequestHeader;
import org.apache.hadoop.hbase.protobuf.generated.RPCProtos.ResponseHeader; import org.apache.hadoop.hbase.protobuf.generated.RPCProtos.ResponseHeader;
import org.apache.hadoop.hbase.protobuf.generated.RPCProtos.UserInformation; import org.apache.hadoop.hbase.protobuf.generated.RPCProtos.UserInformation;
import org.apache.hadoop.hbase.protobuf.generated.RPCProtos.VersionInfo;
import org.apache.hadoop.hbase.regionserver.HRegionServer; import org.apache.hadoop.hbase.regionserver.HRegionServer;
import org.apache.hadoop.hbase.security.AccessDeniedException; import org.apache.hadoop.hbase.security.AccessDeniedException;
import org.apache.hadoop.hbase.security.AuthMethod; import org.apache.hadoop.hbase.security.AuthMethod;

View File

@ -2107,6 +2107,14 @@ public class HMaster extends HRegionServer implements MasterServices, Server {
return info.getInfoPort(); return info.getInfoPort();
} }
public String getRegionServerVersion(final ServerName sn) {
RegionServerInfo info = this.regionServerTracker.getRegionServerInfo(sn);
if (info != null && info.hasVersionInfo()) {
return info.getVersionInfo().getVersion();
}
return "Unknown";
}
/** /**
* @return array of coprocessor SimpleNames. * @return array of coprocessor SimpleNames.
*/ */

View File

@ -27,7 +27,7 @@ import org.apache.hadoop.hbase.classification.InterfaceStability;
import org.apache.hadoop.hbase.ipc.RpcServer; import org.apache.hadoop.hbase.ipc.RpcServer;
import org.apache.hadoop.hbase.ipc.RpcCallContext; import org.apache.hadoop.hbase.ipc.RpcCallContext;
import org.apache.hadoop.hbase.procedure2.Procedure; import org.apache.hadoop.hbase.procedure2.Procedure;
import org.apache.hadoop.hbase.protobuf.generated.RPCProtos.VersionInfo; import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.VersionInfo;
/** /**
* Latch used by the Master to have the prepare() sync behaviour for old * Latch used by the Master to have the prepare() sync behaviour for old

View File

@ -1412,6 +1412,7 @@ public class HRegionServer extends HasThread implements
private void createMyEphemeralNode() throws KeeperException, IOException { private void createMyEphemeralNode() throws KeeperException, IOException {
RegionServerInfo.Builder rsInfo = RegionServerInfo.newBuilder(); RegionServerInfo.Builder rsInfo = RegionServerInfo.newBuilder();
rsInfo.setInfoPort(infoServer != null ? infoServer.getPort() : -1); rsInfo.setInfoPort(infoServer != null ? infoServer.getPort() : -1);
rsInfo.setVersionInfo(ProtobufUtil.getVersionInfo());
byte[] data = ProtobufUtil.prependPBMagic(rsInfo.build().toByteArray()); byte[] data = ProtobufUtil.prependPBMagic(rsInfo.build().toByteArray());
ZKUtil.createEphemeralNodeAndWatch(this.zooKeeper, ZKUtil.createEphemeralNodeAndWatch(this.zooKeeper,
getMyEphemeralNodePath(), data); getMyEphemeralNodePath(), data);