Coverage Report - org.mule.management.stats.AbstractFlowConstructStatistics
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractFlowConstructStatistics
0%
0/27
N/A
1
 
 1  
 /*
 2  
  * $Id: AbstractFlowConstructStatistics.java 20203 2010-11-17 01:54:38Z mike.schilling $
 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 edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicLong;
 14  
 import org.mule.api.management.stats.Statistics;
 15  
 
 16  
 /**
 17  
  * Statistics common to flows and services
 18  
  */
 19  
 public abstract class AbstractFlowConstructStatistics implements Statistics
 20  
 {
 21  
     private static final long serialVersionUID = 5337576392583767442L;
 22  
 
 23  
     protected final String flowConstructType;
 24  
     protected String name;
 25  0
     protected boolean enabled = false;
 26  0
     private long samplePeriod = 0;
 27  0
     protected final AtomicLong receivedEventSync = new AtomicLong(0);
 28  0
     protected final AtomicLong receivedEventASync = new AtomicLong(0);
 29  
 
 30  
     public AbstractFlowConstructStatistics(String flowConstructType, String name)
 31  0
     {
 32  0
         this.name = name;
 33  0
         this.flowConstructType = flowConstructType;
 34  0
     }
 35  
 
 36  
     /**
 37  
      * Enable statistics logs (this is a dynamic parameter)
 38  
      */
 39  
     public synchronized void setEnabled(boolean b)
 40  
     {
 41  0
         enabled = b;
 42  0
     }
 43  
 
 44  
     /**
 45  
      * Are statistics logged
 46  
      */
 47  
     public boolean isEnabled()
 48  
     {
 49  0
         return enabled;
 50  
     }
 51  
 
 52  
     public synchronized String getName()
 53  
     {
 54  0
         return name;
 55  
     }
 56  
 
 57  
     public synchronized void setName(String name)
 58  
     {
 59  0
         this.name = name;
 60  0
     }
 61  
 
 62  
     public synchronized void clear()
 63  
     {
 64  0
         receivedEventSync.set(0);
 65  0
         receivedEventASync.set(0);
 66  0
         samplePeriod = System.currentTimeMillis();
 67  0
     }
 68  
 
 69  
 
 70  
     public void incReceivedEventSync()
 71  
     {
 72  0
         receivedEventSync.addAndGet(1);
 73  0
     }
 74  
 
 75  
     public void incReceivedEventASync()
 76  
     {
 77  0
         receivedEventASync.addAndGet(1);
 78  0
     }
 79  
 
 80  
     public long getAsyncEventsReceived()
 81  
     {
 82  0
         return receivedEventASync.get();
 83  
     }
 84  
 
 85  
     public long getSyncEventsReceived()
 86  
     {
 87  0
         return receivedEventSync.get();
 88  
     }
 89  
 
 90  
     public long getTotalEventsReceived()
 91  
     {
 92  0
         return getSyncEventsReceived() + getAsyncEventsReceived();
 93  
     }
 94  
 
 95  
     public String getFlowConstructType()
 96  
     {
 97  0
         return flowConstructType;
 98  
     }
 99  
 
 100  
     public long getSamplePeriod()
 101  
     {
 102  0
         return System.currentTimeMillis() - samplePeriod;
 103  
     }
 104  
 }