DISCLAIMER: I am a Java beginner so I am really ignorant about a LOT of stuff. You’ve been warned.
--------------------------------------------------------------------
I am using “Clover.ETL” to push/pull data contained in our different databases.
We bought a scheduler (“Quartz”) to fire many jobs based on a pre-defined schedule. I have written classes that launch my ETL jobs on schedule like this:
public class ETL_job1 extends QuartzJob {
public void run() {
try {
System.out.flush();
Runtime rt = Runtime.getRuntime();
Process proc = rt
.exec(“/j2sdk1.4.2_10/bin/java -cp /clover/work/cloverETL.zip org.jetel.main.runGraph -v /home/clover/work/ETL_job1.grf”);
…
It works great but it is poor design (the paths…). The JavaDoc for “Clover.ETL” reads this:
“org.jetel.main.runGraph” has only one method “static void main(java.lang.String args)” and a unique constructor “runGraph()”. What I’m wondering is how to do I call runGraph() to run “ETL_job1.grf”. I got to this point:
import org.jetel.main.runGraph;
public class RunThisGraph extends runGraph {
public RunThisGraph() {
super();
}
}
but I am stuck. How do I pass arguments i.e. the name of my graph layout?
Thanks in advance for any help (especially IQ points you can spare…) you can provide.
Al.
I have done more research. I re-wrote my class to this
-------------------------------------
import java.io.FileInputStream;
import org.apache.log4j.Logger;
import org.jetel.graph.TransformationGraph;
import org.jetel.graph.TransformationGraphXMLReaderWriter;
public class RunThisGraph {
static Logger mylog = Logger.getLogger(“RunThisGraph.class”);
static String GRF_NM = “/clover/Velocity.grf”;
public static void main(String args) {
try {
FileInputStream in=null;
in = new FileInputStream(GRF_NM);
TransformationGraphXMLReaderWriter graphReader = TransformationGraphXMLReaderWriter.getReference();
TransformationGraph graph = TransformationGraph.getReference();
graphReader.read(graph, in);
mylog.info(“We init. the graph here!”);
graph.init();
graph.loadGraphProperties(GRF_NM);
mylog.info(“We run the graph here!”);
graph.run();
} catch (Throwable t) {
mylog.fatal(t.getMessage() + “Fatal Error. STOP”);
t.printStackTrace();
}
}
}
-------------------------------------
It fails with several error messages:
-------------------------------------
ava.lang.RuntimeException: java.lang.RuntimeException: Unknown component: DB_INPUT_TABLE class: DB_INPUT_TABLE
at org.jetel.graph.TransformationGraphXMLReaderWriter.read(Unknown Source)
at RunThisGraph.main(RunThisGraph.java:20)
Caused by: java.lang.RuntimeException: Unknown component: DB_INPUT_TABLE class: DB_INPUT_TABLE
at org.jetel.component.ComponentFactory.createComponent(Unknown Source)
at org.jetel.graph.TransformationGraphXMLReaderWriter.instantiateNodes(Unknown Source)
at org.jetel.graph.TransformationGraphXMLReaderWriter.instantiatePhases(Unknown Source)
… 2 more
-------------------------------------
What I do not understand is that the same graph “/clover/Velocity.grf” runs successfully when launched from the command line.
Where could be the problem in my code? Any idea?
Al.
Hello Alan.
Sorry for late reaction. I’m not sure if i understand what is your requierement. Your last implementation of class RunThisGraph look like our runGraph class (with some mistakes), only with hard-coded name of xml graph definition. If you want to run graph direct from your code, you can for example call direct main method of runGraph class and as parameters pass name of xml file (eventually other command line parameters of clover engine). Please better specify your goal and than we will help you sure.
OtaSanek