HBASE-18566 [RSGROUP]Log the client IP/port of the rsgroup admin (Guangxu Cheng)

This commit is contained in:
tedyu 2017-08-13 21:21:43 -07:00
parent 35aa7aae3a
commit de22fabed2
4 changed files with 23 additions and 1 deletions

View File

@ -121,6 +121,8 @@ public class RSGroupAdminEndpoint implements MasterObserver, CoprocessorService
GetRSGroupInfoRequest request, RpcCallback<GetRSGroupInfoResponse> done) {
GetRSGroupInfoResponse.Builder builder = GetRSGroupInfoResponse.newBuilder();
String groupName = request.getRSGroupName();
LOG.info(master.getClientIdAuditPrefix() + " initiates rsgroup info retrieval, group="
+ groupName);
try {
RSGroupInfo rsGroupInfo = groupAdminServer.getRSGroupInfo(groupName);
if (rsGroupInfo != null) {
@ -138,6 +140,8 @@ public class RSGroupAdminEndpoint implements MasterObserver, CoprocessorService
GetRSGroupInfoOfTableResponse.Builder builder = GetRSGroupInfoOfTableResponse.newBuilder();
try {
TableName tableName = ProtobufUtil.toTableName(request.getTableName());
LOG.info(master.getClientIdAuditPrefix() + " initiates rsgroup info retrieval, table="
+ tableName);
RSGroupInfo RSGroupInfo = groupAdminServer.getRSGroupInfoOfTable(tableName);
if (RSGroupInfo != null) {
builder.setRSGroupInfo(RSGroupProtobufUtil.toProtoGroupInfo(RSGroupInfo));
@ -157,6 +161,8 @@ public class RSGroupAdminEndpoint implements MasterObserver, CoprocessorService
for (HBaseProtos.ServerName el : request.getServersList()) {
hostPorts.add(Address.fromParts(el.getHostName(), el.getPort()));
}
LOG.info(master.getClientIdAuditPrefix() + " move servers " + hostPorts +" to rsgroup "
+ request.getTargetGroup());
groupAdminServer.moveServers(hostPorts, request.getTargetGroup());
} catch (IOException e) {
CoprocessorRpcUtils.setControllerException(controller, e);
@ -173,6 +179,8 @@ public class RSGroupAdminEndpoint implements MasterObserver, CoprocessorService
for (TableProtos.TableName tableName : request.getTableNameList()) {
tables.add(ProtobufUtil.toTableName(tableName));
}
LOG.info(master.getClientIdAuditPrefix() + " move tables " + tables +" to rsgroup "
+ request.getTargetGroup());
groupAdminServer.moveTables(tables, request.getTargetGroup());
} catch (IOException e) {
CoprocessorRpcUtils.setControllerException(controller, e);
@ -184,6 +192,7 @@ public class RSGroupAdminEndpoint implements MasterObserver, CoprocessorService
public void addRSGroup(RpcController controller, AddRSGroupRequest request,
RpcCallback<AddRSGroupResponse> done) {
AddRSGroupResponse.Builder builder = AddRSGroupResponse.newBuilder();
LOG.info(master.getClientIdAuditPrefix() + " add rsgroup " + request.getRSGroupName());
try {
groupAdminServer.addRSGroup(request.getRSGroupName());
} catch (IOException e) {
@ -197,6 +206,7 @@ public class RSGroupAdminEndpoint implements MasterObserver, CoprocessorService
RemoveRSGroupRequest request, RpcCallback<RemoveRSGroupResponse> done) {
RemoveRSGroupResponse.Builder builder =
RemoveRSGroupResponse.newBuilder();
LOG.info(master.getClientIdAuditPrefix() + " remove rsgroup " + request.getRSGroupName());
try {
groupAdminServer.removeRSGroup(request.getRSGroupName());
} catch (IOException e) {
@ -209,6 +219,7 @@ public class RSGroupAdminEndpoint implements MasterObserver, CoprocessorService
public void balanceRSGroup(RpcController controller,
BalanceRSGroupRequest request, RpcCallback<BalanceRSGroupResponse> done) {
BalanceRSGroupResponse.Builder builder = BalanceRSGroupResponse.newBuilder();
LOG.info(master.getClientIdAuditPrefix() + " balance rsgroup, group=" + request.getRSGroupName());
try {
builder.setBalanceRan(groupAdminServer.balanceRSGroup(request.getRSGroupName()));
} catch (IOException e) {
@ -222,6 +233,7 @@ public class RSGroupAdminEndpoint implements MasterObserver, CoprocessorService
public void listRSGroupInfos(RpcController controller,
ListRSGroupInfosRequest request, RpcCallback<ListRSGroupInfosResponse> done) {
ListRSGroupInfosResponse.Builder builder = ListRSGroupInfosResponse.newBuilder();
LOG.info(master.getClientIdAuditPrefix() + " list rsgroup");
try {
for (RSGroupInfo RSGroupInfo : groupAdminServer.listRSGroups()) {
builder.addRSGroupInfo(RSGroupProtobufUtil.toProtoGroupInfo(RSGroupInfo));
@ -239,6 +251,7 @@ public class RSGroupAdminEndpoint implements MasterObserver, CoprocessorService
try {
Address hp = Address.fromParts(request.getServer().getHostName(),
request.getServer().getPort());
LOG.info(master.getClientIdAuditPrefix() + " initiates rsgroup info retrieval, server=" + hp);
RSGroupInfo RSGroupInfo = groupAdminServer.getRSGroupOfServer(hp);
if (RSGroupInfo != null) {
builder.setRSGroupInfo(RSGroupProtobufUtil.toProtoGroupInfo(RSGroupInfo));
@ -262,6 +275,8 @@ public class RSGroupAdminEndpoint implements MasterObserver, CoprocessorService
for (TableProtos.TableName tableName : request.getTableNameList()) {
tables.add(ProtobufUtil.toTableName(tableName));
}
LOG.info(master.getClientIdAuditPrefix() + " move servers " + hostPorts
+ " and tables " + tables + " to rsgroup" + request.getTargetGroup());
groupAdminServer.moveServersAndTables(hostPorts, tables, request.getTargetGroup());
} catch (IOException e) {
CoprocessorRpcUtils.setControllerException(controller, e);

View File

@ -1517,7 +1517,7 @@ public class HMaster extends HRegionServer implements MasterServices {
/**
* @return Client info for use as prefix on an audit log string; who did an action
*/
String getClientIdAuditPrefix() {
public String getClientIdAuditPrefix() {
return "Client=" + RpcServer.getRequestUserName() + "/" + RpcServer.getRemoteAddress();
}

View File

@ -508,4 +508,6 @@ public interface MasterServices extends Server {
* method to make sure meta is initialized.
*/
boolean recoverMeta() throws IOException;
String getClientIdAuditPrefix();
}

View File

@ -459,6 +459,11 @@ public class MockNoopMasterServices implements MasterServices, Server {
return false;
}
@Override
public String getClientIdAuditPrefix() {
return null;
}
@Override
public ProcedureEvent getInitializedEvent() {
// TODO Auto-generated method stub