HBASE-18566 [RSGROUP]Log the client IP/port of the rsgroup admin (Guangxu Cheng)
This commit is contained in:
parent
35aa7aae3a
commit
de22fabed2
|
@ -121,6 +121,8 @@ public class RSGroupAdminEndpoint implements MasterObserver, CoprocessorService
|
||||||
GetRSGroupInfoRequest request, RpcCallback<GetRSGroupInfoResponse> done) {
|
GetRSGroupInfoRequest request, RpcCallback<GetRSGroupInfoResponse> done) {
|
||||||
GetRSGroupInfoResponse.Builder builder = GetRSGroupInfoResponse.newBuilder();
|
GetRSGroupInfoResponse.Builder builder = GetRSGroupInfoResponse.newBuilder();
|
||||||
String groupName = request.getRSGroupName();
|
String groupName = request.getRSGroupName();
|
||||||
|
LOG.info(master.getClientIdAuditPrefix() + " initiates rsgroup info retrieval, group="
|
||||||
|
+ groupName);
|
||||||
try {
|
try {
|
||||||
RSGroupInfo rsGroupInfo = groupAdminServer.getRSGroupInfo(groupName);
|
RSGroupInfo rsGroupInfo = groupAdminServer.getRSGroupInfo(groupName);
|
||||||
if (rsGroupInfo != null) {
|
if (rsGroupInfo != null) {
|
||||||
|
@ -138,6 +140,8 @@ public class RSGroupAdminEndpoint implements MasterObserver, CoprocessorService
|
||||||
GetRSGroupInfoOfTableResponse.Builder builder = GetRSGroupInfoOfTableResponse.newBuilder();
|
GetRSGroupInfoOfTableResponse.Builder builder = GetRSGroupInfoOfTableResponse.newBuilder();
|
||||||
try {
|
try {
|
||||||
TableName tableName = ProtobufUtil.toTableName(request.getTableName());
|
TableName tableName = ProtobufUtil.toTableName(request.getTableName());
|
||||||
|
LOG.info(master.getClientIdAuditPrefix() + " initiates rsgroup info retrieval, table="
|
||||||
|
+ tableName);
|
||||||
RSGroupInfo RSGroupInfo = groupAdminServer.getRSGroupInfoOfTable(tableName);
|
RSGroupInfo RSGroupInfo = groupAdminServer.getRSGroupInfoOfTable(tableName);
|
||||||
if (RSGroupInfo != null) {
|
if (RSGroupInfo != null) {
|
||||||
builder.setRSGroupInfo(RSGroupProtobufUtil.toProtoGroupInfo(RSGroupInfo));
|
builder.setRSGroupInfo(RSGroupProtobufUtil.toProtoGroupInfo(RSGroupInfo));
|
||||||
|
@ -157,6 +161,8 @@ public class RSGroupAdminEndpoint implements MasterObserver, CoprocessorService
|
||||||
for (HBaseProtos.ServerName el : request.getServersList()) {
|
for (HBaseProtos.ServerName el : request.getServersList()) {
|
||||||
hostPorts.add(Address.fromParts(el.getHostName(), el.getPort()));
|
hostPorts.add(Address.fromParts(el.getHostName(), el.getPort()));
|
||||||
}
|
}
|
||||||
|
LOG.info(master.getClientIdAuditPrefix() + " move servers " + hostPorts +" to rsgroup "
|
||||||
|
+ request.getTargetGroup());
|
||||||
groupAdminServer.moveServers(hostPorts, request.getTargetGroup());
|
groupAdminServer.moveServers(hostPorts, request.getTargetGroup());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
CoprocessorRpcUtils.setControllerException(controller, e);
|
CoprocessorRpcUtils.setControllerException(controller, e);
|
||||||
|
@ -173,6 +179,8 @@ public class RSGroupAdminEndpoint implements MasterObserver, CoprocessorService
|
||||||
for (TableProtos.TableName tableName : request.getTableNameList()) {
|
for (TableProtos.TableName tableName : request.getTableNameList()) {
|
||||||
tables.add(ProtobufUtil.toTableName(tableName));
|
tables.add(ProtobufUtil.toTableName(tableName));
|
||||||
}
|
}
|
||||||
|
LOG.info(master.getClientIdAuditPrefix() + " move tables " + tables +" to rsgroup "
|
||||||
|
+ request.getTargetGroup());
|
||||||
groupAdminServer.moveTables(tables, request.getTargetGroup());
|
groupAdminServer.moveTables(tables, request.getTargetGroup());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
CoprocessorRpcUtils.setControllerException(controller, e);
|
CoprocessorRpcUtils.setControllerException(controller, e);
|
||||||
|
@ -184,6 +192,7 @@ public class RSGroupAdminEndpoint implements MasterObserver, CoprocessorService
|
||||||
public void addRSGroup(RpcController controller, AddRSGroupRequest request,
|
public void addRSGroup(RpcController controller, AddRSGroupRequest request,
|
||||||
RpcCallback<AddRSGroupResponse> done) {
|
RpcCallback<AddRSGroupResponse> done) {
|
||||||
AddRSGroupResponse.Builder builder = AddRSGroupResponse.newBuilder();
|
AddRSGroupResponse.Builder builder = AddRSGroupResponse.newBuilder();
|
||||||
|
LOG.info(master.getClientIdAuditPrefix() + " add rsgroup " + request.getRSGroupName());
|
||||||
try {
|
try {
|
||||||
groupAdminServer.addRSGroup(request.getRSGroupName());
|
groupAdminServer.addRSGroup(request.getRSGroupName());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -197,6 +206,7 @@ public class RSGroupAdminEndpoint implements MasterObserver, CoprocessorService
|
||||||
RemoveRSGroupRequest request, RpcCallback<RemoveRSGroupResponse> done) {
|
RemoveRSGroupRequest request, RpcCallback<RemoveRSGroupResponse> done) {
|
||||||
RemoveRSGroupResponse.Builder builder =
|
RemoveRSGroupResponse.Builder builder =
|
||||||
RemoveRSGroupResponse.newBuilder();
|
RemoveRSGroupResponse.newBuilder();
|
||||||
|
LOG.info(master.getClientIdAuditPrefix() + " remove rsgroup " + request.getRSGroupName());
|
||||||
try {
|
try {
|
||||||
groupAdminServer.removeRSGroup(request.getRSGroupName());
|
groupAdminServer.removeRSGroup(request.getRSGroupName());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -209,6 +219,7 @@ public class RSGroupAdminEndpoint implements MasterObserver, CoprocessorService
|
||||||
public void balanceRSGroup(RpcController controller,
|
public void balanceRSGroup(RpcController controller,
|
||||||
BalanceRSGroupRequest request, RpcCallback<BalanceRSGroupResponse> done) {
|
BalanceRSGroupRequest request, RpcCallback<BalanceRSGroupResponse> done) {
|
||||||
BalanceRSGroupResponse.Builder builder = BalanceRSGroupResponse.newBuilder();
|
BalanceRSGroupResponse.Builder builder = BalanceRSGroupResponse.newBuilder();
|
||||||
|
LOG.info(master.getClientIdAuditPrefix() + " balance rsgroup, group=" + request.getRSGroupName());
|
||||||
try {
|
try {
|
||||||
builder.setBalanceRan(groupAdminServer.balanceRSGroup(request.getRSGroupName()));
|
builder.setBalanceRan(groupAdminServer.balanceRSGroup(request.getRSGroupName()));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -222,6 +233,7 @@ public class RSGroupAdminEndpoint implements MasterObserver, CoprocessorService
|
||||||
public void listRSGroupInfos(RpcController controller,
|
public void listRSGroupInfos(RpcController controller,
|
||||||
ListRSGroupInfosRequest request, RpcCallback<ListRSGroupInfosResponse> done) {
|
ListRSGroupInfosRequest request, RpcCallback<ListRSGroupInfosResponse> done) {
|
||||||
ListRSGroupInfosResponse.Builder builder = ListRSGroupInfosResponse.newBuilder();
|
ListRSGroupInfosResponse.Builder builder = ListRSGroupInfosResponse.newBuilder();
|
||||||
|
LOG.info(master.getClientIdAuditPrefix() + " list rsgroup");
|
||||||
try {
|
try {
|
||||||
for (RSGroupInfo RSGroupInfo : groupAdminServer.listRSGroups()) {
|
for (RSGroupInfo RSGroupInfo : groupAdminServer.listRSGroups()) {
|
||||||
builder.addRSGroupInfo(RSGroupProtobufUtil.toProtoGroupInfo(RSGroupInfo));
|
builder.addRSGroupInfo(RSGroupProtobufUtil.toProtoGroupInfo(RSGroupInfo));
|
||||||
|
@ -239,6 +251,7 @@ public class RSGroupAdminEndpoint implements MasterObserver, CoprocessorService
|
||||||
try {
|
try {
|
||||||
Address hp = Address.fromParts(request.getServer().getHostName(),
|
Address hp = Address.fromParts(request.getServer().getHostName(),
|
||||||
request.getServer().getPort());
|
request.getServer().getPort());
|
||||||
|
LOG.info(master.getClientIdAuditPrefix() + " initiates rsgroup info retrieval, server=" + hp);
|
||||||
RSGroupInfo RSGroupInfo = groupAdminServer.getRSGroupOfServer(hp);
|
RSGroupInfo RSGroupInfo = groupAdminServer.getRSGroupOfServer(hp);
|
||||||
if (RSGroupInfo != null) {
|
if (RSGroupInfo != null) {
|
||||||
builder.setRSGroupInfo(RSGroupProtobufUtil.toProtoGroupInfo(RSGroupInfo));
|
builder.setRSGroupInfo(RSGroupProtobufUtil.toProtoGroupInfo(RSGroupInfo));
|
||||||
|
@ -262,6 +275,8 @@ public class RSGroupAdminEndpoint implements MasterObserver, CoprocessorService
|
||||||
for (TableProtos.TableName tableName : request.getTableNameList()) {
|
for (TableProtos.TableName tableName : request.getTableNameList()) {
|
||||||
tables.add(ProtobufUtil.toTableName(tableName));
|
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());
|
groupAdminServer.moveServersAndTables(hostPorts, tables, request.getTargetGroup());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
CoprocessorRpcUtils.setControllerException(controller, e);
|
CoprocessorRpcUtils.setControllerException(controller, e);
|
||||||
|
|
|
@ -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
|
* @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();
|
return "Client=" + RpcServer.getRequestUserName() + "/" + RpcServer.getRemoteAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -508,4 +508,6 @@ public interface MasterServices extends Server {
|
||||||
* method to make sure meta is initialized.
|
* method to make sure meta is initialized.
|
||||||
*/
|
*/
|
||||||
boolean recoverMeta() throws IOException;
|
boolean recoverMeta() throws IOException;
|
||||||
|
|
||||||
|
String getClientIdAuditPrefix();
|
||||||
}
|
}
|
||||||
|
|
|
@ -459,6 +459,11 @@ public class MockNoopMasterServices implements MasterServices, Server {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getClientIdAuditPrefix() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ProcedureEvent getInitializedEvent() {
|
public ProcedureEvent getInitializedEvent() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
Loading…
Reference in New Issue