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

Daniel Templeton commented on MAPREDUCE-6542:
---------------------------------------------

[~piaoyu zhang], that looks like a reasonable way to test.  I wouldn't test 
that the old method breaks -- we don't really care.  What we want to prove is 
that the new method doesn't break.

I would add two things to the test.  First, instead of printing the times, 
assert that they're equal:

{code}
Assert.assertTrue("Method returned inconsistent results indicative of a race 
condition", time1.equals(time2))
{code}

I'd use the {{assertTrue()}} method instead of the {{assertEquals()}} method 
because {{assertEquals()}} implies that the first argument is the canonically 
correct value, but that's up to you.

Second, I'd start the {{run()}} method with a barrier so that you don't end up 
with a case where the threads happen to all run serially as they're spawned.  
It's probably pretty darned unlikely, but since the point of the test is to 
make the threads try to stomp on each other, it may be worth it.

> HistoryViewer use SimpleDateFormat,But SimpleDateFormat is not threadsafe
> -------------------------------------------------------------------------
>
>                 Key: MAPREDUCE-6542
>                 URL: https://issues.apache.org/jira/browse/MAPREDUCE-6542
>             Project: Hadoop Map/Reduce
>          Issue Type: Bug
>          Components: jobhistoryserver
>    Affects Versions: 2.2.0, 2.7.1
>         Environment: CentOS6.5 Hadoop  
>            Reporter: zhangyubiao
>            Assignee: zhangyubiao
>         Attachments: MAPREDUCE-6542-v2.patch, MAPREDUCE-6542-v3.patch, 
> MAPREDUCE-6542-v4.patch, MAPREDUCE-6542.patch
>
>
> I use SimpleDateFormat to Parse the JobHistory File before 
> {code}
> private static final SimpleDateFormat dateFormat =
>     new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
>  public static String getJobDetail(JobInfo job) {
>         StringBuffer jobDetails = new StringBuffer("");
>         SummarizedJob ts = new SummarizedJob(job);
>         jobDetails.append(job.getJobId().toString().trim()).append("\t");
>         jobDetails.append(job.getUsername()).append("\t");
>         jobDetails.append(job.getJobname().replaceAll("\\n", 
> "")).append("\t");
>         jobDetails.append(job.getJobQueueName()).append("\t");
>         jobDetails.append(job.getPriority()).append("\t");
>         jobDetails.append(job.getJobConfPath()).append("\t");
>         jobDetails.append(job.getUberized()).append("\t");
>         
> jobDetails.append(dateFormat.format(job.getSubmitTime())).append("\t");
>         
> jobDetails.append(dateFormat.format(job.getLaunchTime())).append("\t");
>         
> jobDetails.append(dateFormat.format(job.getFinishTime())).append("\t");
>        return jobDetails.toString();
> }
> {code}
> But I find I query the SubmitTime and LaunchTime in hive and compare 
> JobHistory File time , I find that the submitTime  and launchTime was wrong.
> Finally,I change to use the FastDateFormat to parse the time format and the 
> time become right



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to