[
https://issues.apache.org/jira/browse/MAPREDUCE-4762?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13503913#comment-13503913
]
Robert Joseph Evans commented on MAPREDUCE-4762:
------------------------------------------------
There are other places in the code that do things similar to #1. They tend to
inject a TokenRenewer implementation instead of injecting a ServiceLoader, so I
would prefer to see something like that.
{code}
private static ServiceLoader<TokenRenewer> renewers =
ServiceLoader.load(TokenRenewer.class);
private static TokenRenewer testRenewer = null;
@VisibleForTesting
static void setTestRenewer(TokenRenewer test) {
synchronized (renewers) {
testRenewer = test;
}
}
private synchronized TokenRenewer getRenewer() throws IOException {
if (renewer != null) {
return renewer;
}
renewer = TRIVIAL_RENEWER;
synchronized (renewers) {
if (testRenewer != null && testRenewer.handleKind(this.kind)) {
renewer = testRenewer;
return renewer;
}
for (TokenRenewer canidate : renewers) {
if (canidate.handleKind(this.kind)) {
renewer = canidate;
return renewer;
}
}
}
LOG.warn("No TokenRenewer defined for token kind " + this.kind);
return renewer;
}
{code}
SecurityUtil.java does something very similar for SecurityInfo but with an
array of SecurityInfo's instead, which might be preferable.
> repair test
> org.apache.hadoop.mapreduce.security.token.TestDelegationTokenRenewal
> ---------------------------------------------------------------------------------
>
> Key: MAPREDUCE-4762
> URL: https://issues.apache.org/jira/browse/MAPREDUCE-4762
> Project: Hadoop Map/Reduce
> Issue Type: Improvement
> Reporter: Ivan A. Veselovsky
> Attachments: MAPREDUCE-4762-trunk.patch
>
>
> The test
> org.apache.hadoop.mapreduce.security.token.TestDelegationTokenRenewal is
> @Ignor-ed.
> Due to that several classes in package
> org.apache.hadoop.mapreduce.security.token have zero unit-test coverage.
> The problem is that the test assumed that class
> org.apache.hadoop.mapreduce.security.token.TestDelegationTokenRenewal.Renewer
> is used as a custom implementation of the
> org.apache.hadoop.security.token.TokenRenewer service, but that did not
> happen, because this custom service implementation was not registered.
> We solved this problem by using special classloader that is invoked to find
> the resource META-INF/services/org.apache.hadoop.security.token.TokenRenewer
> , and supplies some custom content for it. This way the custom service
> implementation gets instantiated.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira