hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1516480 - /hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
Date Thu, 22 Aug 2013 15:08:02 GMT
Author: stack
Date: Thu Aug 22 15:08:02 2013
New Revision: 1516480

URL: http://svn.apache.org/r1516480
Log:
HBASE-8754 Log the client IP/port of the balancer invoker

Modified:
    hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java

Modified: hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java?rev=1516480&r1=1516479&r2=1516480&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
(original)
+++ hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
Thu Aug 22 15:08:02 2013
@@ -86,6 +86,7 @@ import org.apache.hadoop.hbase.executor.
 import org.apache.hadoop.hbase.executor.ExecutorType;
 import org.apache.hadoop.hbase.ipc.RpcServer;
 import org.apache.hadoop.hbase.ipc.RpcServer.BlockingServiceAndInterface;
+import org.apache.hadoop.hbase.ipc.RequestContext;
 import org.apache.hadoop.hbase.ipc.RpcServerInterface;
 import org.apache.hadoop.hbase.ipc.ServerRpcController;
 import org.apache.hadoop.hbase.master.balancer.BalancerChore;
@@ -1600,7 +1601,7 @@ MasterServices, Server {
       } catch (KeeperException ke) {
         throw new IOException(ke);
       }
-      LOG.info("BalanceSwitch=" + newValue);
+      LOG.info(getClientIdAuditPrefix() + " set balanceSwitch=" + newValue);
       if (this.cpHost != null) {
         this.cpHost.postBalanceSwitch(oldValue, newValue);
       }
@@ -1610,6 +1611,14 @@ MasterServices, Server {
     return oldValue;
   }
 
+  /**
+   * @return Client info for use as prefix on an audit log string; who did an action
+   */
+  String getClientIdAuditPrefix() {
+    return "Client=" + RequestContext.getRequestUserName() + "/" +
+      RequestContext.get().getRemoteAddress();
+  }
+
   public boolean synchronousBalanceSwitch(final boolean b) throws IOException {
     return switchBalancer(b, BalanceSwitchMode.SYNC);
   }
@@ -1760,7 +1769,7 @@ MasterServices, Server {
           return;
         }
       }
-      LOG.info("Added move plan " + rp + ", running balancer");
+      LOG.info(getClientIdAuditPrefix() + " move " + rp + ", running balancer");
       this.assignmentManager.balance(rp);
       if (this.cpHost != null) {
         this.cpHost.postMove(hri, rp.getSource(), rp.getDestination());
@@ -1792,7 +1801,7 @@ MasterServices, Server {
     if (cpHost != null) {
       cpHost.preCreateTable(hTableDescriptor, newRegions);
     }
-
+    LOG.info(getClientIdAuditPrefix() + " create " + hTableDescriptor);
     this.executorService.submit(new CreateTableHandler(this,
       this.fileSystemManager, hTableDescriptor, conf,
       newRegions, this).prepare());
@@ -1861,6 +1870,7 @@ MasterServices, Server {
     if (cpHost != null) {
       cpHost.preDeleteTable(tableName);
     }
+    LOG.info(getClientIdAuditPrefix() + " delete " + tableName);
     this.executorService.submit(new DeleteTableHandler(tableName, this, this).prepare());
     if (cpHost != null) {
       cpHost.postDeleteTable(tableName);
@@ -1916,8 +1926,7 @@ MasterServices, Server {
       }
     }
     //TODO: we should process this (and some others) in an executor
-    new TableAddFamilyHandler(tableName, column, this, this)
-      .prepare().process();
+    new TableAddFamilyHandler(tableName, column, this, this).prepare().process();
     if (cpHost != null) {
       cpHost.postAddColumn(tableName, column);
     }
@@ -1945,6 +1954,7 @@ MasterServices, Server {
         return;
       }
     }
+    LOG.info(getClientIdAuditPrefix() + " modify " + descriptor);
     new TableModifyFamilyHandler(tableName, descriptor, this, this)
       .prepare().process();
     if (cpHost != null) {
@@ -1973,6 +1983,7 @@ MasterServices, Server {
         return;
       }
     }
+    LOG.info(getClientIdAuditPrefix() + " delete " + Bytes.toString(columnName));
     new TableDeleteFamilyHandler(tableName, columnName, this, this).prepare().process();
     if (cpHost != null) {
       cpHost.postDeleteColumn(tableName, columnName);
@@ -1997,6 +2008,7 @@ MasterServices, Server {
     if (cpHost != null) {
       cpHost.preEnableTable(tableName);
     }
+    LOG.info(getClientIdAuditPrefix() + " enable " + tableName);
     this.executorService.submit(new EnableTableHandler(this, tableName,
       catalogTracker, assignmentManager, tableLockManager, false).prepare());
     if (cpHost != null) {
@@ -2021,6 +2033,7 @@ MasterServices, Server {
     if (cpHost != null) {
       cpHost.preDisableTable(tableName);
     }
+    LOG.info(getClientIdAuditPrefix() + " disable " + tableName);
     this.executorService.submit(new DisableTableHandler(this, tableName,
       catalogTracker, assignmentManager, tableLockManager, false).prepare());
     if (cpHost != null) {
@@ -2082,6 +2095,7 @@ MasterServices, Server {
     if (cpHost != null) {
       cpHost.preModifyTable(tableName, descriptor);
     }
+    LOG.info(getClientIdAuditPrefix() + " modify " + tableName);
     new ModifyTableHandler(tableName, descriptor, this, this).prepare().process();
     if (cpHost != null) {
       cpHost.postModifyTable(tableName, descriptor);
@@ -2391,6 +2405,7 @@ MasterServices, Server {
   @Override
   public ShutdownResponse shutdown(RpcController controller, ShutdownRequest request)
   throws ServiceException {
+    LOG.info(getClientIdAuditPrefix() + " shutdown");
     shutdown();
     return ShutdownResponse.newBuilder().build();
   }
@@ -2409,6 +2424,7 @@ MasterServices, Server {
   @Override
   public StopMasterResponse stopMaster(RpcController controller, StopMasterRequest request)
   throws ServiceException {
+    LOG.info(getClientIdAuditPrefix() + " stop");
     stopMaster();
     return StopMasterResponse.newBuilder().build();
   }
@@ -2509,6 +2525,7 @@ MasterServices, Server {
           return arr;
         }
       }
+      LOG.info(getClientIdAuditPrefix() + " assign " + regionInfo.getRegionNameAsString());
       assignmentManager.assign(regionInfo, true, true);
       if (cpHost != null) {
         cpHost.postAssign(regionInfo);
@@ -2547,8 +2564,8 @@ MasterServices, Server {
           return urr;
         }
       }
-      LOG.debug("Close region " + hri.getRegionNameAsString()
-          + " on current location if it is online and reassign.force=" + force);
+      LOG.debug(getClientIdAuditPrefix() + " unassign " + hri.getRegionNameAsString()
+          + " in current location if it is online and reassign.force=" + force);
       this.assignmentManager.unassign(hri, force);
       if (!this.assignmentManager.getRegionStates().isRegionInTransition(hri)
           && !this.assignmentManager.getRegionStates().isRegionAssigned(hri)) {
@@ -2702,6 +2719,7 @@ MasterServices, Server {
       if (cpHost != null) {
         cpHost.preRegionOffline(hri);
       }
+      LOG.info(getClientIdAuditPrefix() + " offline " + hri.getRegionNameAsString());
       this.assignmentManager.regionOffline(hri);
       if (cpHost != null) {
         cpHost.postRegionOffline(hri);
@@ -2843,7 +2861,7 @@ MasterServices, Server {
       throw new ServiceException(e);
     }
 
-    LOG.debug("Submitting snapshot request for:" +
+    LOG.info(getClientIdAuditPrefix() + " snapshot request for:" +
         ClientSnapshotDescriptionUtils.toString(request.getSnapshot()));
     // get the snapshot information
     SnapshotDescription snapshot = SnapshotDescriptionUtils.validate(request.getSnapshot(),
@@ -2897,6 +2915,7 @@ MasterServices, Server {
     }
 
     try {
+      LOG.info(getClientIdAuditPrefix() + " delete " + request.getSnapshot());
       snapshotManager.deleteSnapshot(request.getSnapshot());
       return DeleteSnapshotResponse.newBuilder().build();
     } catch (IOException e) {
@@ -3004,7 +3023,8 @@ MasterServices, Server {
   }
 
   @Override
-  public MasterAdminProtos.DeleteNamespaceResponse deleteNamespace(RpcController controller,
MasterAdminProtos.DeleteNamespaceRequest request) throws ServiceException {
+  public MasterAdminProtos.DeleteNamespaceResponse deleteNamespace(RpcController controller,
+      MasterAdminProtos.DeleteNamespaceRequest request) throws ServiceException {
     try {
       deleteNamespace(request.getNamespaceName());
       return MasterAdminProtos.DeleteNamespaceResponse.getDefaultInstance();
@@ -3087,6 +3107,7 @@ MasterServices, Server {
         return;
       }
     }
+    LOG.info(getClientIdAuditPrefix() + " creating " + descriptor);
     tableNamespaceManager.create(descriptor);
     if (cpHost != null) {
       cpHost.postCreateNamespace(descriptor);
@@ -3100,6 +3121,7 @@ MasterServices, Server {
         return;
       }
     }
+    LOG.info(getClientIdAuditPrefix() + " modify " + descriptor);
     tableNamespaceManager.update(descriptor);
     if (cpHost != null) {
       cpHost.postModifyNamespace(descriptor);
@@ -3112,6 +3134,7 @@ MasterServices, Server {
         return;
       }
     }
+    LOG.info(getClientIdAuditPrefix() + " delete " + name);
     tableNamespaceManager.remove(name);
     if (cpHost != null) {
       cpHost.postDeleteNamespace(name);



Mime
View raw message