[ 
https://issues.apache.org/jira/browse/HADOOP-18167?focusedWorklogId=758079&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-758079
 ]

ASF GitHub Bot logged work on HADOOP-18167:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 18/Apr/22 19:18
            Start Date: 18/Apr/22 19:18
    Worklog Time Spent: 10m 
      Work Description: hchaverri commented on code in PR #4092:
URL: https://github.com/apache/hadoop/pull/4092#discussion_r852348271


##########
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/token/delegation/TestDelegationToken.java:
##########
@@ -579,4 +616,55 @@ public void testEmptyToken() throws IOException {
     assertEquals(token1, token2);
     assertEquals(token1.encodeToUrlString(), token2.encodeToUrlString());
   }
+
+  @Test
+  public void testDelegationTokenSecretManagerMetrics() throws Exception {
+    TestDelegationTokenSecretManager dtSecretManager =
+        new TestDelegationTokenSecretManager(24*60*60*1000,
+            10*1000, 1*1000, 60*60*1000);
+    try {
+      dtSecretManager.startThreads();
+
+      Assert.assertEquals(0, 
dtSecretManager.metrics.storeToken.lastStat().numSamples());
+      final Token<TestDelegationTokenIdentifier> token =
+          generateDelegationToken(dtSecretManager, "SomeUser", "JobTracker");
+      Assert.assertEquals(1, 
dtSecretManager.metrics.storeToken.lastStat().numSamples());
+
+      Assert.assertEquals(0, 
dtSecretManager.metrics.updateToken.lastStat().numSamples());
+      dtSecretManager.renewToken(token, "JobTracker");
+      Assert.assertEquals(1, 
dtSecretManager.metrics.updateToken.lastStat().numSamples());
+
+      Assert.assertEquals(0, 
dtSecretManager.metrics.removeToken.lastStat().numSamples());
+      dtSecretManager.cancelToken(token, "JobTracker");
+      Assert.assertEquals(1, 
dtSecretManager.metrics.removeToken.lastStat().numSamples());
+    } finally {
+      dtSecretManager.stopThreads();
+    }
+  }
+
+  @Test
+  public void testDelegationTokenSecretManagerMetricsFailures() throws 
Exception {
+    TestFailureDelegationTokenSecretManager dtSecretManager = new 
TestFailureDelegationTokenSecretManager();
+
+    try {
+      dtSecretManager.startThreads();
+
+      final Token<TestDelegationTokenIdentifier> token =
+          generateDelegationToken(dtSecretManager, "SomeUser", "JobTracker");
+
+      dtSecretManager.setThrowError(true);
+
+      Assert.assertEquals(0, dtSecretManager.metrics.tokenFailure.value());
+      generateDelegationToken(dtSecretManager, "SomeUser", "JobTracker");
+      Assert.assertEquals(1, dtSecretManager.metrics.tokenFailure.value());
+
+      LambdaTestUtils.intercept(Exception.class, () -> 
dtSecretManager.renewToken(token, "JobTracker"));

Review Comment:
   I've updated this to expect IOException, since that's the exception we throw 
in TestFailureDelegationTokenSecretManager. We're currently not tracking 
duration of failures per a previous comment by @omalley 



##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/AbstractDelegationTokenSecretManager.java:
##########
@@ -96,6 +108,10 @@ private String formatTokenId(TokenIdent id) {
    * Access to currentKey is protected by this object lock
    */
   private DelegationKey currentKey;
+  /**
+   * Metrics to track token management operations

Review Comment:
   Fixed





Issue Time Tracking
-------------------

    Worklog Id:     (was: 758079)
    Time Spent: 3h 50m  (was: 3h 40m)

> Add metrics to track delegation token secret manager operations
> ---------------------------------------------------------------
>
>                 Key: HADOOP-18167
>                 URL: https://issues.apache.org/jira/browse/HADOOP-18167
>             Project: Hadoop Common
>          Issue Type: Improvement
>            Reporter: Hector Sandoval Chaverri
>            Priority: Major
>              Labels: pull-request-available
>         Attachments: HADOOP-18167-branch-2.10-2.patch, 
> HADOOP-18167-branch-2.10-3.patch, HADOOP-18167-branch-2.10.patch
>
>          Time Spent: 3h 50m
>  Remaining Estimate: 0h
>
> New metrics to track operations that store, update and remove delegation 
> tokens in implementations of AbstractDelegationTokenSecretManager. This will 
> help evaluate the impact of using different secret managers and add 
> optimizations.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org

Reply via email to