Bug 4726

Summary: Change Metric interface enum values to conform to Java convention.
Product: jbatch Reporter: cvignola
Component: sourceAssignee: cvignola
Status: RESOLVED FIXED    
Severity: normal CC: cf126330, issues, ScottKurz
Priority: P5    
Version: 1   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description cvignola 2013-03-01 16:50:13 UTC
From public mailing list:

 [jsr352-public] MetricName naming convention, string values ("readCount", "writeCount"...)
Cheng Fang 
to:
public
03/01/2013 11:17 AM
Hide Details 
From: Cheng Fang <cf126330@gmail.com>

To: public@jbatch.java.net









Please respond to public@jbatch.java.net



Default custom expiration date: 03/01/2014
 

1, MetricName is currently defined as:

public enum MetricName {READCOUNT, WRITECOUNT, COMMITCOUNT, 
           ROLLBACKCOUNT, READSKIPCOUNT, PROCESSSKIPCOUNT, FILTERCOUNT, 
           WRITESKIPCOUNT}

Can we add underscore as word separator, to make it more readable, also stick to java naming convention?

This is an example of other enum namings in EE, which use enum names like  BAD_REQUEST:
http://docs.oracle.com/javaee/6/api/javax/ws/rs/core/Response.Status.html


2, Metric javadoc still include string values ("readCount", "writeCount", etc)of the expected metric name, and probably also in the spec.  Do we still need them?  If no, then we should remove them.

If we think "readCount" gives more readable display name than READCOUNT or READ_COUNT, then we can assign it to the enum as the custom display name:

WRITE_SKIP_COUNT("writeSkipCount");


Thanks,
Cheng
Comment 1 cvignola 2013-03-01 16:52:50 UTC
Yes, agreed.  Those constants look terrible.  Also the getName() method doesn't make any sense.  Here is the updated interface definition:

package javax.batch.runtime;
/**
  * 
  * The Metric interface defines job metrics recorded by
  * the batch runtime.
  *
  */
public interface Metric {
	public enum MetricType {READ_COUNT, WRITE_COUNT, COMMIT_COUNT, 
	       ROLLBACK_COUNT, READ_SKIP_COUNT, PROCESS_SKIP_COUNT, FILTER_COUNT, 
	       WRITE_SKIPCOUNT}
	/**
	 * The getName method returns the metric type. 
	 * @return metric type.
	 */
	public MetricType getType(); 
	/**
	 * The getValue method returns the metric value.
	 * @return metric value.
	 */
	public long getValue();
}

Update will appear in PFD v1.5.
Comment 2 cf126330 2013-04-08 20:02:14 UTC
Just noticed WRITE_SKIPCOUNT is missing a separator between SKIP and COUNT, which makes it different from others (READ_SKIP_COUNT, PROCESS_SKIP_COUNT, etc).
Comment 3 ScottKurz 2013-04-09 15:19:23 UTC
Will go ahead and fix this in the RI/TCK today. So I'm assuming Chris will get to it in the spec.