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