Package Com. ***. DCI;
ImportJava. Io. file;
ImportJava. Io. filenotfoundexception;
ImportJava. Io. fileoutputstream;
ImportJava. Io. filewriter;
ImportJava. Io. ioexception;
ImportJava. util. arraylist;
ImportJava. util. date;
ImportJava. util. hashmap;
ImportJava. util. iterator;
ImportJava. util. List;
ImportJava. util. Map;
ImportJava. util. Map. entry;
ImportOrg. logicalcobwebs. proxool. admin. servlet. adminservlet;
ImportOrg. pentaho. Di. Core. Exception. kettleexception;
ImportOrg. pentaho. Di. Core. util. envutil;
ImportOrg. pentaho. Di. Trans. steploader;
ImportOrg. pentaho. Di. Trans. Trans;
ImportOrg. pentaho. Di. Trans. transmeta;
ImportOrg. pentaho. Di. Trans. performance. stepperformancesnapshot;
Public ClassTest {
/**
* @ Param ARGs
* @ throws ioexception
*/
Public static void main (string [] ARGs) throws ioexception {
// explanation
runtransformation (" C:/SS. ktr ");
}
Public Static VoidRuntransformation (string filename)ThrowsIoexception {
Try{
// Initialize a task
Steploader. INIT ();
Envutil. environmentinit ();
Transmeta = New Transmeta (filename );
Transmeta. setcapturingstepperformancesnapshots ( True );
Trans trans = New Trans (transmeta );
Trans. setmonitored ( True );
Trans. setinitializing (True );
Trans. setpreparing ( True );
Trans. setrunning ( True );
Trans. setsafemodeenabled ( True );
Trans.exe cute ( Null ); // You can pass arguments instead of null.
// Store results in a map
Hashmap map = New Hashmap ();
Trans. setstepperformancesnapshots (MAP );
While (! Trans. isfinished ()){
If (Trans. getstepperformancesnapshots ()! = Null & Amp; Trans. getstepperformancesnapshots (). Size ()> 0 ){
// Get all steps
Map <string, list <stepperformancesnapshot> snapshots = trans. getstepperformancesnapshots ();
// Output dynamic monitoring
Iterator it = snapshots. entryset (). iterator ();
String onetimeonestepinfo = "";
String onttimeallstepinfo = "";
While (It. hasnext ())
{
Entry en = (entry) it. Next ();
// Current steps
Arraylist snapshotlist = (arraylist) en. getvalue ();
If (Snapshotlist! = Null & Snapshotlist. Size ()> 0 ){
Stepperformancesnapshot snapshot = (stepperformancesnapshot) snapshotlist. Get (snapshotlist. Size ()-1 );
Onetimeonestepinfo = ("stepname:" + snapshot. getstepname () + ";"
+ "Errors:" + snapshot. geterrors () + ";"
+ "Inputbuffersize:" + snapshot. getinputbuffersize () + ";"
+ "Linesinput:" + snapshot. getlinesinput () + ";"
+ "Linesoutput:" + snapshot. getlinesoutput () + ";"
+ "Linesread:" + snapshot. getlinesread () + ";"
+ "Linesrejected:" + snapshot. getlinesrejected () + ";"
+ "Linesupdated:" + snapshot. getlinesupdated () + ";"
+ "Lineswritten:" + snapshot. getlineswritten () + ";"
+ "Outputbuffersize:" + snapshot. getoutputbuffersize () + ";"
+ "Stepcopy:" + snapshot. getstepcopy () + ";"
+ "Timedifference:" + snapshot. gettimedifference () + ";"
+ "Totalerrors:" + snapshot. gettotalerrors () + ";"
+ "Totallinesinput:" + snapshot. gettotallinesinput () + ";"
+ "Totallinesoutput:" + snapshot. gettotallinesoutput () + ";"
+ "Totallinesread:" + snapshot. gettotallinesread () + ";"
+ "Totallinesrejected:" + snapshot. gettotallinesrejected () + ";"
+ "Totallinesupdated:" + snapshot. gettotallinesupdated () + ";"
+ "Totallineswritten:" + snapshot. gettotallineswritten () + ";"
+ "Date:" + snapshot. getdate () + "\ n ");
Onttimeallstepinfo + = onetimeonestepinfo;
}
System. Out. println (onttimeallstepinfo + "\ n ");
}
}
}
System. Out. println ("End ............");
}Catch(Kettleexception e ){
//Todo put your exception-handling code here.
System. Out. println (E );
}
}
}