Hi All,
I need to import many files sequentially , should I create a new graph for each file? or I can use the same graph ? please I need details.
thanks,
// create Graph + Node + 2 connections (edges)
TransformationGraph graph = new TransformationGraph();
Edge inEdge=new Edge(“InEdge”,metadataIn);
Edge outEdge=new Edge(“OutEdge”,metadataIn);
Node nodeRead=new DataReader(“DataParser”,arg[DATA_FILE_PROPERTY_INDEX]);
String sortKeys=arg[KEY_PROPERTY_INDEX].split(“,”);
Node nodeSort=new ExtSort(“Sorter”,sortKeys, true);
Node nodeWrite=new DataWriter(“DataWriter”,arg[OUTPUT_FILE_PROPERTY_INDEX],“UTF-8”,false);
// assign ports (input & output)
nodeRead.addOutputPort(0,inEdge);
nodeSort.addInputPort(0,inEdge);
nodeSort.addOutputPort(0,outEdge);
nodeWrite.addInputPort(0,outEdge);
// add Edges & Nodes & Phases to graph
try {
graph.addPhase(_PHASE_1);
_PHASE_1.addNode(nodeRead);
_PHASE_1.addNode(nodeSort);
graph.addPhase(_PHASE_2);
_PHASE_2.addNode(nodeWrite);
graph.addEdge(inEdge);
graph.addEdge(outEdge);
}catch (GraphConfigurationException ex){
ex.printStackTrace();
}
//prepare runtime parameters - JMX is turned off
GraphRuntimeContext runtimeContext = new GraphRuntimeContext();
runtimeContext.setUseJMX(false);
Future result;
try{
result = runGraph.executeGraph(graph, runtimeContext);
while (result.isDone()) {;}
if (!result.get().equals(Result.FINISHED_OK)){
System.out.println(“Failed graph execution!\n”);
return;
}
}catch (Exception e) {
System.out.println(“Failed graph execution!\n” + e.getMessage());
return;
}