Skip to content

Commit

Permalink
HOP-2216 (#404)
Browse files Browse the repository at this point in the history
  • Loading branch information
hansva committed Nov 23, 2020
1 parent b9d8dad commit ed2f5cd
Showing 1 changed file with 32 additions and 12 deletions.
44 changes: 32 additions & 12 deletions engine/src/main/java/org/apache/hop/run/HopRun.java
Expand Up @@ -24,8 +24,6 @@

import org.apache.commons.lang.StringUtils;
import org.apache.hop.IExecutionConfiguration;
import org.apache.hop.metadata.api.IHasHopMetadataProvider;
import org.apache.hop.server.HopServer;
import org.apache.hop.core.Const;
import org.apache.hop.core.HopEnvironment;
import org.apache.hop.core.exception.HopException;
Expand All @@ -38,13 +36,15 @@
import org.apache.hop.core.parameters.UnknownParamException;
import org.apache.hop.core.variables.IVariables;
import org.apache.hop.core.variables.Variables;
import org.apache.hop.metadata.api.IHasHopMetadataProvider;
import org.apache.hop.metadata.api.IHopMetadataProvider;
import org.apache.hop.metadata.api.IHopMetadataSerializer;
import org.apache.hop.metadata.util.HopMetadataUtil;
import org.apache.hop.pipeline.PipelineExecutionConfiguration;
import org.apache.hop.pipeline.PipelineMeta;
import org.apache.hop.pipeline.engine.IPipelineEngine;
import org.apache.hop.pipeline.engine.PipelineEngineFactory;
import org.apache.hop.server.HopServer;
import org.apache.hop.workflow.WorkflowExecutionConfiguration;
import org.apache.hop.workflow.WorkflowMeta;
import org.apache.hop.workflow.engine.IWorkflowEngine;
Expand Down Expand Up @@ -95,6 +95,7 @@ public class HopRun implements Runnable, IHasHopMetadataProvider {
private CommandLine cmd;
private ILogChannel log;
private IHopMetadataProvider metadataProvider;
private boolean finishedWithoutError;

public void run() {
validateOptions();
Expand Down Expand Up @@ -139,7 +140,6 @@ private void initialize( CommandLine cmd ) {
}
}
}

// Picks up these system settings in the variables
//
buildVariableSpace();
Expand Down Expand Up @@ -190,7 +190,6 @@ private void runPipeline( CommandLine cmd, ILogChannel log ) {
// Now run the pipeline using the run configuration
//
runPipeline( cmd, log, configuration, pipelineMeta );

} catch ( Exception e ) {
throw new ExecutionException( cmd, "There was an error during execution of pipeline '" + filename + "'", e );
}
Expand Down Expand Up @@ -227,6 +226,8 @@ private void runPipeline( CommandLine cmd, ILogChannel log, PipelineExecutionCon
pipeline.prepareExecution();
pipeline.startThreads();
pipeline.waitUntilFinished();
//TODO: how to see if a pipeline fails? getresult always return true
setFinishedWithoutError(true);
} catch ( Exception e ) {
throw new ExecutionException( cmd, "Error running pipeline locally", e );
}
Expand Down Expand Up @@ -287,6 +288,7 @@ private void runWorkflow( CommandLine cmd, ILogChannel log, WorkflowExecutionCon
workflow.activateParameters();

workflow.startExecution();
setFinishedWithoutError(workflow.getResult().getResult());
} catch ( Exception e ) {
throw new ExecutionException( cmd, "Error running workflow locally", e );
}
Expand Down Expand Up @@ -322,11 +324,9 @@ private boolean isPipeline() {
}
if (filename.toLowerCase().endsWith( ".hpl" )) {
return true;
}
if (filename.toLowerCase().endsWith( ".hwf" )) {
} else {
return false;
}
return false;
}

private boolean isWorkflow() {
Expand All @@ -335,11 +335,9 @@ private boolean isWorkflow() {
}
if (filename.toLowerCase().endsWith( ".hwf" )) {
return true;
}
if (filename.toLowerCase().endsWith( ".hpl" )) {
} else {
return false;
}
return false;
}


Expand Down Expand Up @@ -673,7 +671,23 @@ public void setMetadataProvider( IHopMetadataProvider metadataProvider ) {
this.metadataProvider = metadataProvider;
}

public static void main( String[] args ) {
/**
* Gets finished status of pipeline or workflow
*
* @return boolean indicating no errors
*/
public boolean isFinishedWithoutError() {
return finishedWithoutError;
}

/**
* @param finishedWithoutError Boolean indicating if pipeline or workflow finished without errors
*/
public void setFinishedWithoutError(boolean finishedWithoutError) {
this.finishedWithoutError = finishedWithoutError;
}

public static void main(String[] args ) {

HopRun hopRun = new HopRun();
try {
Expand All @@ -684,7 +698,13 @@ public static void main( String[] args ) {
System.exit( 1 );
} else {
hopRun.run();
System.exit( 0 );
System.out.println(hopRun.isFinishedWithoutError());
if (hopRun.isFinishedWithoutError()) {
System.exit( 0 );
} else {
System.exit( 1);
}

}
} catch ( ParameterException e ) {
System.err.println( e.getMessage() );
Expand Down

0 comments on commit ed2f5cd

Please sign in to comment.