View Javadoc

1   /*
2    * $Id: FlowConstructStatistics.java 19191 2010-08-25 21:05:23Z tcarlson $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.management.stats;
12  
13  import org.mule.api.management.stats.Statistics;
14  
15  import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicLong;
16  
17  public class FlowConstructStatistics implements Statistics
18  {
19      private static final long serialVersionUID = 5337576392583767442L;
20  
21      protected String name;
22      protected boolean enabled = false;
23      protected final AtomicLong receivedEventSync = new AtomicLong(0);
24      protected final AtomicLong receivedEventASync = new AtomicLong(0);
25  
26      public FlowConstructStatistics(String name)
27      {
28          this.name = name;
29      }
30  
31      /**
32       * Are statistics logged
33       */
34      public boolean isEnabled()
35      {
36          return enabled;
37      }
38  
39      /**
40       * Enable statistics logs (this is a dynamic parameter)
41       */
42      public synchronized void setEnabled(boolean b)
43      {
44          enabled = b;
45      }
46  
47      public synchronized String getName()
48      {
49          return name;
50      }
51  
52      public synchronized void setName(String name)
53      {
54          this.name = name;
55      }
56  
57      public synchronized void clear()
58      {
59          receivedEventSync.set(0);
60          receivedEventASync.set(0);
61      }
62  
63      public void incReceivedEventSync()
64      {
65          receivedEventSync.addAndGet(1);
66      }
67  
68      public void incReceivedEventASync()
69      {
70          receivedEventASync.addAndGet(1);
71      }
72  
73      public long getAsyncEventsReceived()
74      {
75          return receivedEventASync.get();
76      }
77  
78      public long getSyncEventsReceived()
79      {
80          return receivedEventSync.get();
81      }
82  
83  }