2020
2121import static org .apache .hadoop .metrics2 .lib .Interns .info ;
2222
23+ import java .text .DecimalFormat ;
2324import java .util .Map ;
2425import java .util .concurrent .Executors ;
2526import java .util .concurrent .ScheduledExecutorService ;
@@ -90,18 +91,19 @@ public MutableQuantiles(String name, String description, String sampleName,
9091 String desc = StringUtils .uncapitalize (description );
9192 String lsName = StringUtils .uncapitalize (sampleName );
9293 String lvName = StringUtils .uncapitalize (valueName );
94+ DecimalFormat df = new DecimalFormat ("###.####" );
9395
9496 setNumInfo (info (ucName + "Num" + usName , String .format (
9597 "Number of %s for %s with %ds interval" , lsName , desc , interval )));
9698 // Construct the MetricsInfos for the quantiles, converting to percentiles
9799 setQuantileInfos (quantiles .length );
98- String nameTemplate = ucName + "%dthPercentile " + uvName ;
99- String descTemplate = "%d percentile " + lvName + " with " + interval
100+ String nameTemplate = "thPercentile " + uvName ;
101+ String descTemplate = " percentile " + lvName + " with " + interval
100102 + " second interval for " + desc ;
101103 for (int i = 0 ; i < quantiles .length ; i ++) {
102104 double percentile = 100 * quantiles [i ].quantile ;
103- addQuantileInfo (i , info (String .format (nameTemplate , percentile ),
104- String .format (descTemplate , percentile )));
105+ addQuantileInfo (i , info (ucName + df .format (percentile ) + nameTemplate ,
106+ df .format (percentile ) + descTemplate ));
105107 }
106108
107109 setEstimator (new SampleQuantiles (quantiles ));
@@ -166,7 +168,7 @@ public synchronized void addQuantileInfo(int i, MetricsInfo info) {
166168 /**
167169 * Set the rollover interval (in seconds) of the estimator.
168170 *
169- * @param pIntervalSecs (in seconds) of the estimator.
171+ * @param pIntervalSecs of the estimator.
170172 */
171173 public synchronized void setInterval (int pIntervalSecs ) {
172174 this .intervalSecs = pIntervalSecs ;
@@ -175,7 +177,7 @@ public synchronized void setInterval(int pIntervalSecs) {
175177 /**
176178 * Get the rollover interval (in seconds) of the estimator.
177179 *
178- * @return intervalSecs (in seconds) of the estimator.
180+ * @return intervalSecs of the estimator.
179181 */
180182 public synchronized int getInterval () {
181183 return intervalSecs ;
0 commit comments