Coverage Report - org.mule.management.stats.FlowConstructStatistics
 
Classes in this File Line Coverage Branch Coverage Complexity
FlowConstructStatistics
0%
0/36
0%
0/6
1.125
 
 1  
 /*
 2  
  * $Id: FlowConstructStatistics.java 20370 2010-11-28 01:31:24Z 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  
 
 15  
 public class FlowConstructStatistics extends AbstractFlowConstructStatistics
 16  
 {
 17  
     private static final long serialVersionUID = 5337576392583767442L;
 18  0
     private final AtomicLong executionError = new AtomicLong(0);
 19  0
     private final AtomicLong fatalError = new AtomicLong(0);
 20  0
     private int threadPoolSize = 0;
 21  0
     protected final ComponentStatistics flowStatistics = new ComponentStatistics();
 22  
 
 23  
     public FlowConstructStatistics(String flowConstructType, String name, int threadPoolSize)
 24  
     {
 25  0
         super(flowConstructType, name);
 26  0
         this.threadPoolSize = threadPoolSize;
 27  0
         flowStatistics.setEnabled(enabled);
 28  0
         if (this.getClass() == FlowConstructStatistics.class)
 29  
         {
 30  0
             clear();
 31  
         }
 32  0
     }
 33  
 
 34  
     /**
 35  
      * Are statistics logged
 36  
      */
 37  
     public boolean isEnabled()
 38  
     {
 39  0
         return enabled;
 40  
     }
 41  
 
 42  
     public void incExecutionError()
 43  
     {
 44  0
         executionError.addAndGet(1);
 45  0
     }
 46  
 
 47  
     public void incFatalError()
 48  
     {
 49  0
         fatalError.addAndGet(1);
 50  0
     }
 51  
 
 52  
     /**
 53  
      * Enable statistics logs (this is a dynamic parameter)
 54  
      */
 55  
     public synchronized void setEnabled(boolean b)
 56  
     {
 57  0
         super.setEnabled(b);
 58  0
         flowStatistics.setEnabled(enabled);
 59  0
     }
 60  
 
 61  
     public synchronized void clear()
 62  
     {
 63  0
         super.clear();
 64  
 
 65  0
         executionError.set(0);
 66  0
         fatalError.set(0);        
 67  0
         if (flowStatistics != null)
 68  
         {
 69  0
             flowStatistics.clear();
 70  
         }
 71  0
     }
 72  
 
 73  
     public void addCompleteFlowExecutionTime(long time)
 74  
     {
 75  0
         flowStatistics.addCompleteExecutionTime(time);
 76  0
     }
 77  
 
 78  
     public void addFlowExecutionBranchTime(long time, long total)
 79  
     {
 80  0
         flowStatistics.addExecutionBranchTime(time == total, time, total);
 81  0
     }
 82  
 
 83  
     public long getAverageProcessingTime()
 84  
     {
 85  0
         return flowStatistics.getAverageExecutionTime();
 86  
     }
 87  
 
 88  
     public long getProcessedEvents()
 89  
     {
 90  0
         return flowStatistics.getExecutedEvents();
 91  
     }
 92  
 
 93  
     public long getMaxProcessingTime()
 94  
     {
 95  0
         return flowStatistics.getMaxExecutionTime();
 96  
     }
 97  
 
 98  
     public long getMinProcessingTime()
 99  
     {
 100  0
         return flowStatistics.getMinExecutionTime();
 101  
     }
 102  
 
 103  
     public long getTotalProcessingTime()
 104  
     {
 105  0
         return flowStatistics.getTotalExecutionTime();
 106  
     }
 107  
 
 108  
     public long getExecutionErrors()
 109  
     {
 110  0
         return executionError.get();
 111  
     }
 112  
 
 113  
     public long getFatalErrors()
 114  
     {
 115  0
         return fatalError.get();
 116  
     }
 117  
 
 118  
     public int getThreadPoolSize()
 119  
     {
 120  0
         return threadPoolSize;
 121  
     }
 122  
 
 123  
 }