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  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 3  
  * The software in this package is published under the terms of the CPAL v1.0
 4  
  * license, a copy of which has been included with this distribution in the
 5  
  * LICENSE.txt file.
 6  
  */
 7  
 package org.mule.management.stats;
 8  
 
 9  
 import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicLong;
 10  
 import org.mule.api.management.stats.Statistics;
 11  
 
 12  
 /**
 13  
  * Statistics common to flows and services
 14  
  */
 15  
 public abstract class AbstractFlowConstructStatistics implements Statistics
 16  
 {
 17  
     private static final long serialVersionUID = 5337576392583767442L;
 18  
 
 19  
     protected final String flowConstructType;
 20  
     protected String name;
 21  0
     protected boolean enabled = false;
 22  0
     private long samplePeriod = 0;
 23  0
     protected final AtomicLong receivedEventSync = new AtomicLong(0);
 24  0
     protected final AtomicLong receivedEventASync = new AtomicLong(0);
 25  
 
 26  
     public AbstractFlowConstructStatistics(String flowConstructType, String name)
 27  0
     {
 28  0
         this.name = name;
 29  0
         this.flowConstructType = flowConstructType;
 30  0
     }
 31  
 
 32  
     /**
 33  
      * Enable statistics logs (this is a dynamic parameter)
 34  
      */
 35  
     public synchronized void setEnabled(boolean b)
 36  
     {
 37  0
         enabled = b;
 38  0
     }
 39  
 
 40  
     /**
 41  
      * Are statistics logged
 42  
      */
 43  
     public boolean isEnabled()
 44  
     {
 45  0
         return enabled;
 46  
     }
 47  
 
 48  
     public synchronized String getName()
 49  
     {
 50  0
         return name;
 51  
     }
 52  
 
 53  
     public synchronized void setName(String name)
 54  
     {
 55  0
         this.name = name;
 56  0
     }
 57  
 
 58  
     public synchronized void clear()
 59  
     {
 60  0
         receivedEventSync.set(0);
 61  0
         receivedEventASync.set(0);
 62  0
         samplePeriod = System.currentTimeMillis();
 63  0
     }
 64  
 
 65  
 
 66  
     public void incReceivedEventSync()
 67  
     {
 68  0
         receivedEventSync.addAndGet(1);
 69  0
     }
 70  
 
 71  
     public void incReceivedEventASync()
 72  
     {
 73  0
         receivedEventASync.addAndGet(1);
 74  0
     }
 75  
 
 76  
     public long getAsyncEventsReceived()
 77  
     {
 78  0
         return receivedEventASync.get();
 79  
     }
 80  
 
 81  
     public long getSyncEventsReceived()
 82  
     {
 83  0
         return receivedEventSync.get();
 84  
     }
 85  
 
 86  
     public long getTotalEventsReceived()
 87  
     {
 88  0
         return getSyncEventsReceived() + getAsyncEventsReceived();
 89  
     }
 90  
 
 91  
     public String getFlowConstructType()
 92  
     {
 93  0
         return flowConstructType;
 94  
     }
 95  
 
 96  
     public long getSamplePeriod()
 97  
     {
 98  0
         return System.currentTimeMillis() - samplePeriod;
 99  
     }
 100  
 }