Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -878,6 +878,10 @@ private void printJob(WorkflowJob job, boolean localtime, boolean verbose) throw | |
System.out.println("Last Modified : " + maskDate(job.getLastModifiedTime(), localtime)); | ||
System.out.println("Ended : " + maskDate(job.getEndTime(), localtime)); | ||
System.out.println("CoordAction ID: " + maskIfNull(job.getParentId())); | ||
if (job.getProgress() >= 0) { // -1.0f means no progress is available, therefore do not display. | ||
System.out.printf("%% Complete : %.2f%%\n", job.getProgress() * 100f); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
brookwc
Owner
|
||
} | ||
|
||
|
||
List<WorkflowAction> actions = job.getActions(); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,6 +94,7 @@ public Property(String label, Class type, boolean isList) { | |
WF_JOB.put("getRun", new Property(JsonTags.WORKFLOW_RUN, Integer.TYPE)); | ||
WF_JOB.put("getConsoleUrl", new Property(JsonTags.WORKFLOW_CONSOLE_URL, String.class)); | ||
WF_JOB.put("getActions", new Property(JsonTags.WORKFLOW_ACTIONS, WorkflowAction.class, true)); | ||
WF_JOB.put("getProgress", new Property(JsonTags.WORKFLOW_PROGRESS, Float.TYPE)); | ||
WF_JOB.put("getParentId", new Property(JsonTags.WORKFLOW_PARENT_ID, String.class)); | ||
WF_JOB.put("toString", new Property(JsonTags.TO_STRING, String.class)); | ||
|
||
|
@@ -216,6 +217,9 @@ else if (type == Integer.TYPE) { | |
else if (type == Long.TYPE) { | ||
return (obj != null) ? obj : new Long(0); | ||
} | ||
else if (type == Float.TYPE) { | ||
return (obj != null) ? new Float(((Double) obj).floatValue()) : new Float(-1); | ||
This comment has been minimized.
Sorry, something went wrong.
tucu00
Collaborator
|
||
} | ||
else if (type == Date.class) { | ||
return JsonUtils.parseDateRfc822((String) obj); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,5 +65,19 @@ static Date parseDateRfc822(String str) { | |
} | ||
return null; | ||
} | ||
|
||
/** | ||
* Return a float value from a JSONObject. | ||
* This is used only for getting job's progress value. | ||
* | ||
* @param map JSON object. | ||
* @param name name of the property. | ||
* @return the float value associated with it, or -1.0 if not defined. | ||
*/ | ||
public static float getFloatValue(JSONObject map, String name) { | ||
Double d = (Double) map.get(name); | ||
|
||
return (d != null) ? d.floatValue() : -1.0f; | ||
This comment has been minimized.
Sorry, something went wrong.
tucu00
Collaborator
|
||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,15 +14,22 @@ | |
*/ | ||
package org.apache.oozie.command.wf; | ||
|
||
import java.util.List; | ||
|
||
import org.apache.oozie.ErrorCode; | ||
import org.apache.oozie.WorkflowJobBean; | ||
import org.apache.oozie.action.decision.DecisionActionExecutor; | ||
import org.apache.oozie.command.CommandException; | ||
import org.apache.oozie.command.PreconditionException; | ||
import org.apache.oozie.executor.jpa.JPAExecutorException; | ||
import org.apache.oozie.executor.jpa.WorkflowInfoWithActionsSubsetGetJPAExecutor; | ||
import org.apache.oozie.service.JPAService; | ||
import org.apache.oozie.service.Services; | ||
import org.apache.oozie.util.ParamChecker; | ||
import org.apache.oozie.workflow.lite.LiteWorkflowApp; | ||
import org.apache.oozie.workflow.lite.LiteWorkflowInstance; | ||
import org.apache.oozie.client.WorkflowAction; | ||
import org.apache.oozie.client.WorkflowJob; | ||
|
||
/** | ||
* This Xcommand is returning the workflow with action within the range. | ||
|
@@ -63,6 +70,17 @@ protected WorkflowJobBean execute() throws CommandException { | |
throw new CommandException(ErrorCode.E0610, this.id); | ||
} | ||
this.workflow.setConsoleUrl(getJobConsoleUrl(id)); | ||
|
||
// Estimate job progress | ||
if (workflow.getStatus() == WorkflowJob.Status.PREP) { | ||
workflow.setProgress(0.0f); | ||
} | ||
else if (workflow.getStatus() == WorkflowJob.Status.SUCCEEDED) { | ||
workflow.setProgress(1.0f); | ||
} | ||
else { | ||
workflow.setProgress(getJobProgress(workflow)); | ||
} | ||
} | ||
catch (JPAExecutorException ex) { | ||
throw new CommandException(ex); | ||
|
@@ -112,4 +130,33 @@ protected void loadState() throws CommandException { | |
@Override | ||
protected void verifyPrecondition() throws CommandException, PreconditionException { | ||
} | ||
|
||
/** | ||
* Compute job progress that is defined as fraction of done actions. | ||
* | ||
* @param wf workflow job bean | ||
* @return job progress | ||
*/ | ||
static float getJobProgress(WorkflowJobBean wf) { | ||
LiteWorkflowInstance wfInstance = (LiteWorkflowInstance) wf.getWorkflowInstance(); | ||
LiteWorkflowApp wfApp = (LiteWorkflowApp) wfInstance.getApp(); | ||
|
||
int executionPathLengthEstimate = wfApp.getExecutionPathLengthEstimate(); | ||
if (executionPathLengthEstimate == 0) { // noop wf | ||
return 1.0f; | ||
This comment has been minimized.
Sorry, something went wrong.
tucu00
Collaborator
|
||
} | ||
List<WorkflowAction> actions = wf.getActions(); | ||
int doneActions = 0; | ||
for (WorkflowAction action : actions) { | ||
// Skip decision nodes, note start, kill, end, fork/join will not have action entry. | ||
if (action.getType().equals(DecisionActionExecutor.ACTION_TYPE)) { | ||
continue; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
} | ||
if (action.getStatus() == WorkflowAction.Status.OK || action.getStatus() == WorkflowAction.Status.DONE) { | ||
This comment has been minimized.
Sorry, something went wrong.
mislam77-zz
Collaborator
|
||
doneActions++; | ||
} | ||
} | ||
|
||
return (doneActions * 1.0f) / executionPathLengthEstimate; | ||
} | ||
} |
1 comment
on commit f7cab5e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't be easier to for users if the progress is an integer representing the percentage, then is always 2 digits, easier to display
Why it is displaying conditionally? It will make the output inconsistent. For example, if someone is parsing this output, he will need to consider the presence and non-presence of this field. Moreover, when we will add more columns, it will be hard to isolate this column. If there is no work done, could not we show 0%?