Skip to content

Commit

Permalink
Added rounding to all the values
Browse files Browse the repository at this point in the history
  • Loading branch information
abeytom07 committed May 14, 2014
1 parent c2b64a5 commit 7711415
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ private void extractData(String statLabel, Metric[] metrics, Xml[] response, Sta
} else {
value = aggregate.getSum();
}
if(value!=null){
if (value != null) {
String label = StringUtils.trim(metric.getAggregateLabel(), "|");
String metricPath = statLabel + "|" + label;
if (metric.getMultiplier() != null) {
Expand All @@ -163,12 +163,15 @@ private MetricType getMetricType(Metric metric, Stat stat) {
}

private String multiply(String value, BigDecimal multiplier) {
if (value != null && multiplier != null) {
BigDecimal multiply = new BigDecimal(value).multiply(multiplier);
return multiply.setScale(0, RoundingMode.HALF_UP).toString();
} else {
return value;
if (StringUtils.hasText(value)) {
if (multiplier != null) {
BigDecimal multiply = new BigDecimal(value).multiply(multiplier);
return multiply.setScale(0, RoundingMode.HALF_UP).toString();
} else {
return new BigDecimal(value).setScale(0, RoundingMode.HALF_UP).toString();
}
}
return null;
}

private String getLabel(Xml xml, Metric metric) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ public DataPowerMonitorTest() {

//HTTPMeanTransactionTime
put("DP|Transactions|helloworld_xmlfw|Average Response Time (ms)","8", "COLLECTIVE_OBSERVED_AVERAGE");
put("DP|Transactions|userws_proxy|Average Response Time (ms)","15", "COLLECTIVE_OBSERVED_AVERAGE");
put("DP|Transactions|wsproxy|Average Response Time (ms)","0", "COLLECTIVE_OBSERVED_AVERAGE");
put("DP|Transactions|Average Response Time (ms)","8", "COLLECTIVE_OBSERVED_AVERAGE");
put("DP|Transactions|userws_proxy|Average Response Time (ms)","17", "COLLECTIVE_OBSERVED_AVERAGE");
put("DP|Transactions|Average Response Time (ms)","12", "COLLECTIVE_OBSERVED_AVERAGE");
//HTTPTransactions
put("DP|Transactions|helloworld_xmlfw|Calls per Minute","180", "COLLECTIVE_OBSERVED_CURRENT");
put("DP|Transactions|userws_proxy|Calls per Minute","420", "COLLECTIVE_OBSERVED_CURRENT");
Expand Down
6 changes: 3 additions & 3 deletions src/test/resources/output/HTTPMeanTransactionTime.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@
<dp:status>
<HTTPMeanTransactionTime xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<proxy>helloworld_xmlfw</proxy>
<tenSeconds>8</tenSeconds>
<tenSeconds>8.03</tenSeconds>
<oneMinute>8</oneMinute>
<tenMinutes>29</tenMinutes>
<oneHour>30</oneHour>
<oneDay>31</oneDay>
</HTTPMeanTransactionTime>
<HTTPMeanTransactionTime xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<proxy>userws_proxy</proxy>
<tenSeconds>15</tenSeconds>
<tenSeconds>16.52</tenSeconds>
<oneMinute>15</oneMinute>
<tenMinutes>17</tenMinutes>
<oneHour>18</oneHour>
<oneDay>18</oneDay>
</HTTPMeanTransactionTime>
<HTTPMeanTransactionTime xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<proxy>wsproxy</proxy>
<tenSeconds>0</tenSeconds>
<tenSeconds></tenSeconds>
<oneMinute>0</oneMinute>
<tenMinutes>0</tenMinutes>
<oneHour>0</oneHour>
Expand Down

0 comments on commit 7711415

Please sign in to comment.