One Star

[resolved] tChronometerStart and tChronometerStop return null durations

Hi,
I haven't found any post mentioning this, and I have no idea where the problem is.
I am using a tChronometerStart and tChronometerStop in my job to get the start time and execution time of the job, and i am trying to access those values from a tJava component but I am always getting null values even though the tChronometerStop is displaying correctly the result on the console.
I have attached a picture of my simple job. As you can see on the console, the values in the Java code are null, but the tChronometerStop is displaying correctly the result.
The code in my tJava_1 component is the following:
System.out.println("Duration : " + ((String)globalMap.get("tChronometerStop_1_DURATION")));
System.out.println("Start Time : " + ((String)globalMap.get("tChronometerStart_1_STARTTIME")));

Does anyone know where the problem is and how to access those values from a Java component?
Thank you in advance.
System:
OS: Windows XP
Talend version: TIS 3.2.2r33000
Generated language: Java
1 ACCEPTED SOLUTION

Accepted Solutions
Community Manager

Re: [resolved] tChronometerStart and tChronometerStop return null durations

Hello
Yes, the two global vars are not avaliable now, you can report a bug on our bugtracker.
((String)globalMap.get("tChronometerStop_1_DURATION"))
((String)globalMap.get("tChronometerStart_1_STARTTIME"))
For now, you can extract those values on tJava like this:
long startTime=(Long)globalMap.get("tChronometerStart_1");
java.util.Calendar c=java.util.Calendar.getInstance();
c.setTimeInMillis(startTime);
java.util.Date date=c.getTime();
System.out.println("Start Time : " +TalendDate.formatDate("yyyy-MM-dd HH:mm:ss",date));
System.out.println("Duration : " +(((Long)globalMap.get("tChronometerStop_1"))-((Long)globalMap.get("tChronometerStart_1")))+"milliseconds");

output result:
Start Time : 2010-01-28 11:00:17
Duration : 125milliseconds

Best regards
shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
7 REPLIES
One Star

Re: [resolved] tChronometerStart and tChronometerStop return null durations

Hi,
Could it be a bug? Was anyone able to extract those values?
Community Manager

Re: [resolved] tChronometerStart and tChronometerStop return null durations

Hello
Yes, the two global vars are not avaliable now, you can report a bug on our bugtracker.
((String)globalMap.get("tChronometerStop_1_DURATION"))
((String)globalMap.get("tChronometerStart_1_STARTTIME"))
For now, you can extract those values on tJava like this:
long startTime=(Long)globalMap.get("tChronometerStart_1");
java.util.Calendar c=java.util.Calendar.getInstance();
c.setTimeInMillis(startTime);
java.util.Date date=c.getTime();
System.out.println("Start Time : " +TalendDate.formatDate("yyyy-MM-dd HH:mm:ss",date));
System.out.println("Duration : " +(((Long)globalMap.get("tChronometerStop_1"))-((Long)globalMap.get("tChronometerStart_1")))+"milliseconds");

output result:
Start Time : 2010-01-28 11:00:17
Duration : 125milliseconds

Best regards
shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] tChronometerStart and tChronometerStop return null durations

Thanks Shong for your answer. For now I'll stick to the workaround.
This issue has been reported as a bug (id 11390) on the bugtracker.
Link to the bug: http://www.talendforge.org/bugs/view.php?id=11390
Thanks.
Employee

Re: [resolved] tChronometerStart and tChronometerStop return null durations

Hi,
Other related report at 10978.
For using last components, it can be download from:
TOS Trunk component directory
After updates for this two components, input code likes:
System.out.println(new Date((Long)globalMap.get("tChronometerStart_1_STARTTIME"))); 
System.out.println((Long)globalMap.get("tChronometerStop_1_DURATION"));

Regards.
One Star

Re: [resolved] tChronometerStart and tChronometerStop return null durations

Hi,
I want to write the duration n start time into a file,
how can I do that?
right now, i'm thinking like having 2 context variables liek duration n start_time
which will be assigned values using tJava during run time,
but I don't know how to write into a file.
Please advice.

Re: [resolved] tChronometerStart and tChronometerStop return null durations

Hi I got the duration working in a job a while ago
See post
http://www.talendforge.org/forum/viewtopic.php?id=15187
Regards
Brandon
Seven Stars

Re: [resolved] tChronometerStart and tChronometerStop return null durations

Use tFixedFlowInput to create a row(s) containing your output and link it to tFileOutputDelimited