1
2
3
4
5
6
7
8
9
10 package org.mule.management.stats;
11
12
13
14
15
16 public class ApplicationStatistics extends FlowConstructStatistics
17 {
18 private AllStatistics parent;
19
20 public ApplicationStatistics(AllStatistics parent)
21 {
22 super("Application", "application totals", 0);
23 this.parent = parent;
24 }
25
26 @Override
27 public long getAverageProcessingTime()
28 {
29 long totalTime = 0;
30 long totalEvents = 0;
31 for (FlowConstructStatistics stats : parent.getServiceStatistics())
32 {
33 if (!(stats instanceof ApplicationStatistics))
34 {
35 totalEvents += stats.getProcessedEvents();
36 totalTime += stats.getTotalProcessingTime();
37 }
38 }
39 return totalEvents == 0 ? 0 : totalTime / totalEvents;
40 }
41
42 @Override
43 public long getProcessedEvents()
44 {
45 long total = 0;
46 for (FlowConstructStatistics stats : parent.getServiceStatistics())
47 {
48 if (!(stats instanceof ApplicationStatistics))
49 {
50 total += stats.getProcessedEvents();
51 }
52 }
53 return total;
54 }
55
56 @Override
57 public long getMinProcessingTime()
58 {
59 long min = 0;
60 boolean first = true;
61 for (FlowConstructStatistics stats : parent.getServiceStatistics())
62 {
63 if (!(stats instanceof ApplicationStatistics))
64 {
65 long flowMin = stats.getMinProcessingTime();
66 if (first)
67 {
68 min = flowMin;
69 }
70 else
71 {
72 min = Math.min(min, flowMin);
73 }
74 }
75 first = false;
76 }
77 return min;
78 }
79
80 @Override
81 public long getMaxProcessingTime()
82 {
83 long max = 0;
84 for (FlowConstructStatistics stats : parent.getServiceStatistics())
85 {
86 if (!(stats instanceof ApplicationStatistics))
87 {
88 max = Math.max(max, stats.getMaxProcessingTime());
89 }
90 }
91 return max;
92 }
93
94 @Override
95 public long getTotalProcessingTime()
96 {
97 long total = 0;
98 for (FlowConstructStatistics stats : parent.getServiceStatistics())
99 {
100 if (!(stats instanceof ApplicationStatistics))
101 {
102 total += stats.getTotalProcessingTime();
103 }
104 }
105 return total;
106 }
107
108 @Override
109 public long getExecutionErrors()
110 {
111 long total = 0;
112 for (FlowConstructStatistics stats : parent.getServiceStatistics())
113 {
114 if (!(stats instanceof ApplicationStatistics))
115 {
116 total += stats.getExecutionErrors();
117 }
118 }
119 return total;
120 }
121
122 @Override
123 public long getFatalErrors()
124 {
125 long total = 0;
126 for (FlowConstructStatistics stats : parent.getServiceStatistics())
127 {
128 if (!(stats instanceof ApplicationStatistics))
129 {
130 total += stats.getFatalErrors();
131 }
132 }
133 return total;
134 }
135
136 @Override
137 public long getAsyncEventsReceived()
138 {
139 long total = 0;
140 for (FlowConstructStatistics stats : parent.getServiceStatistics())
141 {
142 if (!(stats instanceof ApplicationStatistics))
143 {
144 total += stats.getAsyncEventsReceived();
145 }
146 }
147 return total;
148 }
149
150 @Override
151 public long getSyncEventsReceived()
152 {
153 long total = 0;
154 for (FlowConstructStatistics stats : parent.getServiceStatistics())
155 {
156 if (!(stats instanceof ApplicationStatistics))
157 {
158 total += stats.getSyncEventsReceived();
159 }
160 }
161 return total;
162 }
163
164 @Override
165 public long getTotalEventsReceived()
166 {
167 long total = 0;
168 for (FlowConstructStatistics stats : parent.getServiceStatistics())
169 {
170 if (!(stats instanceof ApplicationStatistics))
171 {
172 total += stats.getTotalEventsReceived();
173 }
174 }
175 return total;
176 }
177 }