1
2
3
4
5
6
7
8
9
10
11 package org.mule.management.stats;
12
13 import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicLong;
14
15 public class FlowConstructStatistics extends AbstractFlowConstructStatistics
16 {
17 private static final long serialVersionUID = 5337576392583767442L;
18 private final AtomicLong executionError = new AtomicLong(0);
19 private final AtomicLong fatalError = new AtomicLong(0);
20 private int threadPoolSize = 0;
21 protected final ComponentStatistics flowStatistics = new ComponentStatistics();
22
23 public FlowConstructStatistics(String flowConstructType, String name, int threadPoolSize)
24 {
25 super(flowConstructType, name);
26 this.threadPoolSize = threadPoolSize;
27 flowStatistics.setEnabled(enabled);
28 if (this.getClass() == FlowConstructStatistics.class)
29 {
30 clear();
31 }
32 }
33
34
35
36
37 public boolean isEnabled()
38 {
39 return enabled;
40 }
41
42 public void incExecutionError()
43 {
44 executionError.addAndGet(1);
45 }
46
47 public void incFatalError()
48 {
49 fatalError.addAndGet(1);
50 }
51
52
53
54
55 public synchronized void setEnabled(boolean b)
56 {
57 super.setEnabled(b);
58 flowStatistics.setEnabled(enabled);
59 }
60
61 public synchronized void clear()
62 {
63 super.clear();
64
65 executionError.set(0);
66 fatalError.set(0);
67 if (flowStatistics != null)
68 {
69 flowStatistics.clear();
70 }
71 }
72
73 public void addCompleteFlowExecutionTime(long time)
74 {
75 flowStatistics.addCompleteExecutionTime(time);
76 }
77
78 public void addFlowExecutionBranchTime(long time, long total)
79 {
80 flowStatistics.addExecutionBranchTime(time == total, time, total);
81 }
82
83 public long getAverageProcessingTime()
84 {
85 return flowStatistics.getAverageExecutionTime();
86 }
87
88 public long getProcessedEvents()
89 {
90 return flowStatistics.getExecutedEvents();
91 }
92
93 public long getMaxProcessingTime()
94 {
95 return flowStatistics.getMaxExecutionTime();
96 }
97
98 public long getMinProcessingTime()
99 {
100 return flowStatistics.getMinExecutionTime();
101 }
102
103 public long getTotalProcessingTime()
104 {
105 return flowStatistics.getTotalExecutionTime();
106 }
107
108 public long getExecutionErrors()
109 {
110 return executionError.get();
111 }
112
113 public long getFatalErrors()
114 {
115 return fatalError.get();
116 }
117
118 public int getThreadPoolSize()
119 {
120 return threadPoolSize;
121 }
122
123 }