[ 
https://issues.apache.org/jira/browse/HADOOP-9989?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14112608#comment-14112608
 ] 

zhihai xu commented on HADOOP-9989:
-----------------------------------

[~daryn] I think there is another way to fix this problem using 
"mapreduce.job.credentials.binary" instead of "mapreduce.job.credentials.json" 
for 
 -tokenCacheFile in the following code:
{code}
     UserGroupInformation.getCurrentUser().addCredentials(
          Credentials.readTokenStorageFile(p, conf));
      conf.set("mapreduce.job.credentials.json", p.toString(),
               "from -tokenCacheFile command line option");
{code}
Currently the -tokenCacheFile option is broken for both MapReduce MR2 and MR1:
The following code in JobSubmitter.java will parse the file from  
-tokenCacheFile as JSON file not as binary file.
But Credentials.readTokenStorageFile(p, conf) will expect it as binary file not 
 JSON file.
{code}
    String tokensFileName = conf.get("mapreduce.job.credentials.json");
    if(tokensFileName != null) {
      LOG.info("loading user's secret keys from " + tokensFileName);
      String localFileName = new Path(tokensFileName).toUri().getPath();

      boolean json_error = false;
      try {
        // read JSON
        ObjectMapper mapper = new ObjectMapper();
        Map<String, String> nm = 
          mapper.readValue(new File(localFileName), Map.class);

        for(Map.Entry<String, String> ent: nm.entrySet()) {
          credentials.addSecretKey(new Text(ent.getKey()), ent.getValue()
              .getBytes(Charsets.UTF_8));
        }
      } catch (JsonMappingException e) {
        json_error = true;
      } catch (JsonParseException e) {
        json_error = true;
      }
      if(json_error)
        LOG.warn("couldn't parse Token Cache JSON file with user secret keys");
    }
  }
{code}


> Bug introduced in HADOOP-9374, which parses the -tokenCacheFile as binary 
> file but set it to the configuration as JSON file.
> ----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HADOOP-9989
>                 URL: https://issues.apache.org/jira/browse/HADOOP-9989
>             Project: Hadoop Common
>          Issue Type: Bug
>          Components: security, util
>    Affects Versions: 2.1.0-beta
>         Environment: Red Hat Enterprise 6 with Sun Java 1.7 and IBM Java 1.6
>            Reporter: Jinghui Wang
>         Attachments: HADOOP-9989.patch
>
>   Original Estimate: 0h
>  Remaining Estimate: 0h
>
> The code in JIRA HADOOP-9374's patch introduced a bug, where the value of the 
> tokenCacheFile parameter is being parsed as a binary file and set it to the
> mapreduce.job.credentials.json parameter in GenericOptionsParser, which 
> cannot be parsed by JobSubmitter when it gets the value.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to