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