Running A grph with out Creating IThreadManager object

Hi Team,

I have created a graph file, I can i able to call the graph, through java by using following code

EngineInitializer.initEngine(“C:\\cloverETL.rel-3-0-0\\cloverETL\\plugins”, null, null);
String graphPath = “c:\\cloverETL.rel-3-0-0\\cloverETL\\bin\\graph\\test.grf”;
InputStream is = new BufferedInputStream(new FileInputStream(graphPath));

TransformationGraph graph = null;
// engine customizationnm
GraphRuntimeContext runtimeContext = new GraphRuntimeContext();
// graph loading
graph = TransformationGraphXMLReaderWriter.loadGraph(is,runtimeContext);
// engine initialization
EngineInitializer.initGraph(graph, runtimeContext);

// graph running
IThreadManager threadManager = new SimpleThreadManager();
WatchDog watchDog = new WatchDog(graph, runtimeContext);
threadManager.executeWatchDog(watchDog);

while executing the graph, i am creating the IThreadManager object.
ThreadManager is creating new thread and running it Separately.
I have a problem here, after calling the graph, i am excepting the result from the same thread(where i am executing the above code). Since graph execution is happening in new thread, I am not able to trace when the graph execution is completed.

Here my requirement is like this, once graph after the execution of the graph, i have to proceed the another process.

When i am calling the threadManager.executeWatchDog(watchDog) , the main thread is initiating other thread to execute the graph, once the new thread starts executing then main thread is call the next process in the flow. But the actual requirement is needed to wait till the graph execution complete and then has to proceed for others.

My problem in one line:-

Is it possible to execute the graph, with out creating the ThreadManager object.

Thank you
VENKAT

Hi VENKAT,

if I understand well, your only issue is, you would like to have a control over the graph result. In other words, you would like to run graphs one to each other. Correct me if I am wrong.

First of all, I would recommend you to use a little bit easier construction instead of obsolete:

// graph running
IThreadManager threadManager = new SimpleThreadManager();
WatchDog watchDog = new WatchDog(graph, runtimeContext);
threadManager.executeWatchDog(watchDog);

use this simple code instead:

// execute the graph
Future futureResult = runGraph.executeGraph(graph, runtimeContext);
// wait for a result
Result result = futureResult.get(); //this method blocks current thread until graph is finished

And this snipped of code shows you also how to wait for the graph result. The Future is something like a handler of running graph. For example you can trigger few graphs at once and this handlers can be used to grab graph results later. If you are interested in Futures, let’s look at http://download.oracle.com/javase/6/docs/api/java/util/concurrent/Future.html.

I hope it helped. Let me know if you need more help with clover integration.

Martin

Hi Martin,

Thanks for your solution. It is working fine.

Thanks
VENKAT