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

Gera Shegalov commented on MAPREDUCE-6298:
------------------------------------------

Thanks for v4, [~lars_francke]!

In terms of the logic I was suggesting, one detail is not there yet. We may 
have a valid status object before the job failed. Thus, it should be:
{code}
    } else if (status == null) {
      return "Job state: " + state;
    }

   // otherwise fall through
{code}

I would like to make sure that we reduce the changes to the absolute minimum 
required to fix the JIRA. 
- Please undo the change {{catch (IOException | InterruptedException e)}}
- We can keep the code starting with {{StringBuffer sb = new StringBuffer();}}. 
Using {{StringBuilder}} is the right option here. Since + is just a syntactic 
sugar, the only change we need here is: {{StringBuilder sb = new 
StringBuilder();}}.
- I wouldn't bother about line separator in this JIRA. 

Regardless what return statement we take from toString, we should now indicate 
whether we are connected to the cluster.
Maybe something like:
{code}
String connectedStr = "connected to cluster: " + (cluster != null);
...
    } else {
      return "Job state: " + state + "\n" + connectedStr;
    }
...

   sb.append("reason for failure: ").append(reasonforFailure).append("\n");
   sb.append(connectedStr);
....
{code}

> Job#toString throws an exception when not in state RUNNING
> ----------------------------------------------------------
>
>                 Key: MAPREDUCE-6298
>                 URL: https://issues.apache.org/jira/browse/MAPREDUCE-6298
>             Project: Hadoop Map/Reduce
>          Issue Type: Bug
>            Reporter: Lars Francke
>            Assignee: Lars Francke
>            Priority: Minor
>              Labels: BB2015-05-TBR
>         Attachments: MAPREDUCE-6298.1.patch, MAPREDUCE-6298.2.patch, 
> MAPREDUCE-6298.3.patch, MAPREDUCE-6298.4.patch
>
>
> Job#toString calls {{ensureState(JobState.RUNNING);}} as the very first 
> thing. That method causes an Exception to be thrown which is not nice.
> One thing this breaks is usage of Job on the Scala (e.g. Spark) REPL as that 
> calls toString after every invocation and that fails every time.
> I'll attach a patch that checks state and if it's RUNNING prints the original 
> message and if not prints something else.



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

Reply via email to