metrics are at step level. These are the metrics types collected (not configurable):
To get step metrics, call StepExecution.getMetrics():
Can we override these step metrics (or) are these read only properties?
I tried in my itemprocessor.process(), but the values are incorrect. Is it the right place to override step metrics?
StepExecutionImpl executionImpl = new StepExecutionImpl(stepContext.getStepName()); StepMetrics smetrics =executionImpl.getStepMetrics(); smetrics.set(MetricType.WRITE_COUNT, this.itemsWritten);
step metrics are kept and owned by the batch runtime, and should not be modified by applications.
Applications should not instantiate JBeret internal classes like StepExecutionImpl. Any such instances created by applications are not known to JBeret.
You can get StepExecution from JobOperator.
YOu can also inject StepContext into your step-level batch artifacts, and get step metrics from stepContext.
If you really need to, your application can keep stats as part of application data, separate from the step metrics from JBeret.
Thanks for the suggestion.
our itemprocessor returns 707 rows from table and each row contains array of strings with default delimiter as ','
In our job.xml, beanIOItemWriter/beanmapping.xml, we gave delimiter values as '\n' , which shows the count as 7568.
Default stepmetrics gives write count as 707(ideally true), but since we are writing to a file as 7568 lines, we would like get the write count as 7568.
I wrote my stepListener which give me this number(7568) by using stepcontext.getTransientData(Object), but is there any settings out of the box that we can configure, so that after apply delimiter saying these many no of lines were written into file.
there is no such configuration for step metrics. Step item reader, processor, and writer each counts the number of items it received, and so there is no other meansurement units like number of lines/words.