Andras Salamon created OOZIE-3486:
-------------------------------------

             Summary: duplicate code in ControlNodeHandler
                 Key: OOZIE-3486
                 URL: https://issues.apache.org/jira/browse/OOZIE-3486
             Project: Oozie
          Issue Type: Improvement
    Affects Versions: trunk
            Reporter: Andras Salamon


There are duplicate code blocks in ControlNodeHandler and JoinNodeDef classes.

section of the {{enter}} method of {{ControlNodeHandler:}}
{noformat}
    ...
    else if (nodeClass.equals(JoinNodeDef.class)) {
            String parentExecutionPath = 
context.getParentExecutionPath(context.getExecutionPath());
            String forkCount = context.getVar(FORK_COUNT_PREFIX + 
parentExecutionPath);

            if (forkCount == null) {
                throw new WorkflowException(ErrorCode.E0720, 
context.getNodeDef().getName());
            }
            int count = Integer.parseInt(forkCount) - 1;
            if (count > 0) {
                context.setVar(FORK_COUNT_PREFIX + parentExecutionPath, "" + 
count);
                context.deleteExecutionPath();
            }
            else {
                context.setVar(FORK_COUNT_PREFIX + parentExecutionPath, null);
            }
            LOG.debug("count = " + count + " for parent execution path " + 
parentExecutionPath);

            doTouch = (count == 0);
        }
    ....{noformat}
{{enter}} method of {{JoinNodeDef}}:
{noformat}
public boolean enter(Context context) throws WorkflowException {
            String parentExecutionPath = 
context.getParentExecutionPath(context.getExecutionPath());
            String forkCount = 
context.getVar(ControlNodeHandler.FORK_COUNT_PREFIX + parentExecutionPath);
            if (forkCount == null) {
                throw new WorkflowException(ErrorCode.E0720, 
context.getNodeDef().getName());
            }
            int count = Integer.parseInt(forkCount) - 1;
            if (count > 0) {
                context.setVar(ControlNodeHandler.FORK_COUNT_PREFIX + 
parentExecutionPath, "" + count);
                context.deleteExecutionPath();
            }
            else {
                context.setVar(ControlNodeHandler.FORK_COUNT_PREFIX + 
parentExecutionPath, null);
            }
            return (count == 0);
        }
{noformat}
Similarly one section of {{loopDetection}} can be found in {{JoinNodeDef}}, one 
section of {{multiExit}} can be found in {{ForkNodeDef}}.

We should eliminate the code duplication.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to