Jagger
 All Classes Namespaces Files Functions Variables Enumerator Groups Pages
SuccessRateAggregatorProvider.java
Go to the documentation of this file.
1 package com.griddynamics.jagger.engine.e1.collector;
2 
3 import static com.griddynamics.jagger.util.StandardMetricsNamesUtil.SUCCESS_RATE_AGGREGATOR_OK_ID;
4 
15 
17  @Override
19  {
20  return new SuccessRateAggregator();
21  }
22 
23  private static class SuccessRateAggregator implements MetricAggregator<Number>
24  {
25  private long passNum = 0;
26  private long failNum = 0;
27 
28  @Override
29  public void append(Number calculated)
30  {
31  if (calculated.intValue() != 0)
32  passNum++;
33  else
34  failNum++;
35  }
36 
37  @Override
38  public Double getAggregated() {
39  if ((failNum + passNum) == 0)
40  return 0.0;
41  else
42  return (double) (passNum) / (double) (failNum + passNum);
43  }
44 
45  @Override
46  public void reset() {
47  }
48 
49  @Override
50  public String getName() {
51  return SUCCESS_RATE_AGGREGATOR_OK_ID;
52  }
53  }
54 }