You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by dd...@apache.org on 2010/02/22 23:26:04 UTC
svn commit: r915095 - in /hadoop/common/trunk: CHANGES.txt
src/java/org/apache/hadoop/ipc/Server.java
src/java/org/apache/hadoop/ipc/metrics/RpcMetrics.java
src/test/core/org/apache/hadoop/ipc/TestRPC.java
Author: ddas
Date: Mon Feb 22 22:26:03 2010
New Revision: 915095
URL: http://svn.apache.org/viewvc?rev=915095&view=rev
Log:
HADOOP-6583. Captures authentication and authorization metrics. Contributed by Devaraj Das.
Modified:
hadoop/common/trunk/CHANGES.txt
hadoop/common/trunk/src/java/org/apache/hadoop/ipc/Server.java
hadoop/common/trunk/src/java/org/apache/hadoop/ipc/metrics/RpcMetrics.java
hadoop/common/trunk/src/test/core/org/apache/hadoop/ipc/TestRPC.java
Modified: hadoop/common/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/CHANGES.txt?rev=915095&r1=915094&r2=915095&view=diff
==============================================================================
--- hadoop/common/trunk/CHANGES.txt (original)
+++ hadoop/common/trunk/CHANGES.txt Mon Feb 22 22:26:03 2010
@@ -156,6 +156,8 @@
meaningful exceptions when there are failures instead of returning
false. (omalley)
+ HADOOP-6583. Captures authentication and authorization metrics. (ddas)
+
OPTIMIZATIONS
BUG FIXES
Modified: hadoop/common/trunk/src/java/org/apache/hadoop/ipc/Server.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/ipc/Server.java?rev=915095&r1=915094&r2=915095&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/ipc/Server.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/ipc/Server.java Mon Feb 22 22:26:03 2010
@@ -220,6 +220,11 @@
}
}
}
+
+ /*Returns a handle to the rpcMetrics (required in tests)*/
+ public RpcMetrics getRpcMetrics() {
+ return rpcMetrics;
+ }
/** A call queued for handling. */
private static class Call {
@@ -877,7 +882,13 @@
if (LOG.isDebugEnabled())
LOG.debug("Have read input token of size " + saslToken.length
+ " for processing by saslServer.evaluateResponse()");
- byte[] replyToken = saslServer.evaluateResponse(saslToken);
+ byte[] replyToken;
+ try {
+ replyToken = saslServer.evaluateResponse(saslToken);
+ } catch (SaslException se) {
+ rpcMetrics.authenticationFailures.inc();
+ throw se;
+ }
if (replyToken != null) {
if (LOG.isDebugEnabled())
LOG.debug("Will send token of size " + replyToken.length
@@ -1078,6 +1089,7 @@
private void processOneRpc(byte[] buf) throws IOException,
InterruptedException {
+ rpcMetrics.authenticationSuccesses.inc();
if (headerRead) {
processData(buf);
} else {
@@ -1121,7 +1133,9 @@
if (LOG.isDebugEnabled()) {
LOG.debug("Successfully authorized " + header);
}
+ rpcMetrics.authorizationSuccesses.inc();
} catch (AuthorizationException ae) {
+ rpcMetrics.authorizationFailures.inc();
authFailedCall.connection = this;
setupResponse(authFailedResponse, authFailedCall, Status.FATAL, null,
ae.getClass().getName(), ae.getMessage());
Modified: hadoop/common/trunk/src/java/org/apache/hadoop/ipc/metrics/RpcMetrics.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/ipc/metrics/RpcMetrics.java?rev=915095&r1=915094&r2=915095&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/ipc/metrics/RpcMetrics.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/ipc/metrics/RpcMetrics.java Mon Feb 22 22:26:03 2010
@@ -27,6 +27,7 @@
import org.apache.hadoop.metrics.util.MetricsBase;
import org.apache.hadoop.metrics.util.MetricsIntValue;
import org.apache.hadoop.metrics.util.MetricsRegistry;
+import org.apache.hadoop.metrics.util.MetricsTimeVaryingInt;
import org.apache.hadoop.metrics.util.MetricsTimeVaryingRate;
/**
@@ -79,7 +80,14 @@
new MetricsIntValue("NumOpenConnections", registry);
public MetricsIntValue callQueueLen =
new MetricsIntValue("callQueueLen", registry);
-
+ public MetricsTimeVaryingInt authenticationFailures =
+ new MetricsTimeVaryingInt("rpcAuthenticationFailures", registry);
+ public MetricsTimeVaryingInt authenticationSuccesses =
+ new MetricsTimeVaryingInt("rpcAuthenticationSuccesses", registry);
+ public MetricsTimeVaryingInt authorizationFailures =
+ new MetricsTimeVaryingInt("rpcAuthorizationFailures", registry);
+ public MetricsTimeVaryingInt authorizationSuccesses =
+ new MetricsTimeVaryingInt("rpcAuthorizationSuccesses", registry);
/**
* Push the metrics to the monitoring subsystem on doUpdate() call.
*/
Modified: hadoop/common/trunk/src/test/core/org/apache/hadoop/ipc/TestRPC.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/test/core/org/apache/hadoop/ipc/TestRPC.java?rev=915095&r1=915094&r2=915095&view=diff
==============================================================================
--- hadoop/common/trunk/src/test/core/org/apache/hadoop/ipc/TestRPC.java (original)
+++ hadoop/common/trunk/src/test/core/org/apache/hadoop/ipc/TestRPC.java Mon Feb 22 22:26:03 2010
@@ -368,6 +368,31 @@
if (proxy != null) {
RPC.stopProxy(proxy);
}
+ if (expectFailure) {
+ assertTrue("Expected 1 but got " +
+ server.getRpcMetrics().authorizationFailures
+ .getCurrentIntervalValue(),
+ server.getRpcMetrics().authorizationFailures
+ .getCurrentIntervalValue() == 1);
+ } else {
+ assertTrue("Expected 1 but got " +
+ server.getRpcMetrics().authorizationSuccesses
+ .getCurrentIntervalValue(),
+ server.getRpcMetrics().authorizationSuccesses
+ .getCurrentIntervalValue() == 1);
+ }
+ //since we don't have authentication turned ON, we should see
+ // >0 for the authentication successes and 0 for failure
+ assertTrue("Expected 0 but got " +
+ server.getRpcMetrics().authenticationFailures
+ .getCurrentIntervalValue(),
+ server.getRpcMetrics().authenticationFailures
+ .getCurrentIntervalValue() == 0);
+ assertTrue("Expected greater than 0 but got " +
+ server.getRpcMetrics().authenticationSuccesses
+ .getCurrentIntervalValue(),
+ server.getRpcMetrics().authenticationSuccesses
+ .getCurrentIntervalValue() > 0);
}
}