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 br...@apache.org on 2018/11/13 07:43:48 UTC
[4/4] hadoop git commit: HDFS-14070. Refactor NameNodeWebHdfsMethods
to allow better extensibility. Contributed by CR Hota
HDFS-14070. Refactor NameNodeWebHdfsMethods to allow better extensibility. Contributed by CR Hota
(cherry picked from commit e7b63baca1e10b28d8b4462fd80537b871951aa3)
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/04bba915
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/04bba915
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/04bba915
Branch: refs/heads/branch-3.0
Commit: 04bba915855bd7a5e055c3349d3068188f4dc645
Parents: ff1cbb4
Author: Brahma Reddy Battula <br...@apache.org>
Authored: Tue Nov 13 12:45:13 2018 +0530
Committer: Brahma Reddy Battula <br...@apache.org>
Committed: Tue Nov 13 13:12:56 2018 +0530
----------------------------------------------------------------------
.../web/resources/NamenodeWebHdfsMethods.java | 26 ++++++++++++++------
1 file changed, 19 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/04bba915/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/web/resources/NamenodeWebHdfsMethods.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/web/resources/NamenodeWebHdfsMethods.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/web/resources/NamenodeWebHdfsMethods.java
index e9f5628..238b529 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/web/resources/NamenodeWebHdfsMethods.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/web/resources/NamenodeWebHdfsMethods.java
@@ -333,9 +333,22 @@ public class NamenodeWebHdfsMethods {
throw new IOException("No active nodes contain this block");
}
- private Token<? extends TokenIdentifier> generateDelegationToken(
- final NameNode namenode, final UserGroupInformation ugi,
+ public long renewDelegationToken(Token<DelegationTokenIdentifier> token)
+ throws IOException {
+ ClientProtocol cp = getRpcClientProtocol();
+ return cp.renewDelegationToken(token);
+ }
+
+ public void cancelDelegationToken(Token<DelegationTokenIdentifier> token)
+ throws IOException {
+ ClientProtocol cp = getRpcClientProtocol();
+ cp.cancelDelegationToken(token);
+ }
+
+ public Token<? extends TokenIdentifier> generateDelegationToken(
+ final UserGroupInformation ugi,
final String renewer) throws IOException {
+ final NameNode namenode = (NameNode)context.getAttribute("name.node");
final Credentials c = DelegationTokenSecretManager.createCredentials(
namenode, ugi, renewer != null? renewer: ugi.getShortUserName());
if (c == null) {
@@ -380,7 +393,7 @@ public class NamenodeWebHdfsMethods {
} else {
//generate a token
final Token<? extends TokenIdentifier> t = generateDelegationToken(
- namenode, ugi, null);
+ ugi, null);
delegationQuery = "&" + new DelegationParam(t.encodeToUrlString());
}
@@ -701,7 +714,7 @@ public class NamenodeWebHdfsMethods {
validateOpParams(op, delegationTokenArgument);
final Token<DelegationTokenIdentifier> token = new Token<DelegationTokenIdentifier>();
token.decodeFromUrlString(delegationTokenArgument.getValue());
- final long expiryTime = cp.renewDelegationToken(token);
+ final long expiryTime = renewDelegationToken(token);
final String js = JsonUtil.toJsonString("long", expiryTime);
return Response.ok(js).type(MediaType.APPLICATION_JSON).build();
}
@@ -710,7 +723,7 @@ public class NamenodeWebHdfsMethods {
validateOpParams(op, delegationTokenArgument);
final Token<DelegationTokenIdentifier> token = new Token<DelegationTokenIdentifier>();
token.decodeFromUrlString(delegationTokenArgument.getValue());
- cp.cancelDelegationToken(token);
+ cancelDelegationToken(token);
return Response.ok().type(MediaType.APPLICATION_OCTET_STREAM).build();
}
case MODIFYACLENTRIES: {
@@ -1120,9 +1133,8 @@ public class NamenodeWebHdfsMethods {
throw new IllegalArgumentException(delegation.getName()
+ " parameter is not null.");
}
- final NameNode namenode = (NameNode)context.getAttribute("name.node");
final Token<? extends TokenIdentifier> token = generateDelegationToken(
- namenode, ugi, renewer.getValue());
+ ugi, renewer.getValue());
final String setServiceName = tokenService.getValue();
final String setKind = tokenKind.getValue();
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org