Coverage Report - org.mule.management.stats.AllStatistics
 
Classes in this File Line Coverage Branch Coverage Complexity
AllStatistics
0%
0/35
0%
0/12
0
 
 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 org.mule.management.stats.printers.AbstractTablePrinter;
 10  
 import org.mule.management.stats.printers.SimplePrinter;
 11  
 
 12  
 import java.io.PrintWriter;
 13  
 import java.util.Collection;
 14  
 import java.util.HashMap;
 15  
 import java.util.Map;
 16  
 
 17  
 /**
 18  
  * <code>AllStatistics</code> TODO
 19  
  */
 20  
 public class AllStatistics
 21  
 {
 22  
     private boolean isStatisticsEnabled;
 23  
     private long startTime;
 24  
     private ApplicationStatistics appStats;
 25  0
     private Map<String, FlowConstructStatistics> flowConstructStats = new HashMap<String, FlowConstructStatistics>();
 26  
 
 27  
     /**
 28  
      * 
 29  
      */
 30  
     public AllStatistics()
 31  0
     {
 32  0
         clear();
 33  0
         appStats = new ApplicationStatistics(this);
 34  0
         appStats.setEnabled(isStatisticsEnabled);
 35  0
         add(appStats);
 36  0
     }
 37  
 
 38  
     public void logSummary()
 39  
     {
 40  0
         logSummary(new SimplePrinter(System.out));
 41  0
     }
 42  
 
 43  
     public void logSummary(PrintWriter printer)
 44  
     {
 45  
 
 46  0
         if (printer instanceof AbstractTablePrinter)
 47  
         {
 48  0
             printer.print(flowConstructStats.values());
 49  
         }
 50  
         else
 51  
         {
 52  0
             for (FlowConstructStatistics statistics : flowConstructStats.values())
 53  
             {
 54  0
                 printer.print(statistics);
 55  
             }
 56  
         }
 57  
         // printer.println("-----------------------------");
 58  
         // printer.println("duration (ms): " + (System.currentTimeMillis() -
 59  
         // startTime));
 60  0
     }
 61  
 
 62  
     public synchronized void clear()
 63  
     {
 64  0
         for (FlowConstructStatistics statistics : getServiceStatistics())
 65  
         {
 66  0
             statistics.clear();
 67  
         }
 68  0
         startTime = System.currentTimeMillis();
 69  0
     }
 70  
 
 71  
     /**
 72  
      * Are statistics logged
 73  
      */
 74  
     public boolean isEnabled()
 75  
     {
 76  0
         return isStatisticsEnabled;
 77  
     }
 78  
 
 79  
     /**
 80  
      * Enable statistics logs (this is a dynamic parameter)
 81  
      */
 82  
     public void setEnabled(boolean b)
 83  
     {
 84  0
         isStatisticsEnabled = b;
 85  
 
 86  0
         for (FlowConstructStatistics statistics : flowConstructStats.values())
 87  
         {
 88  0
             statistics.setEnabled(b);
 89  
         }
 90  0
     }
 91  
 
 92  
     public synchronized long getStartTime()
 93  
     {
 94  0
         return startTime;
 95  
     }
 96  
 
 97  
     public synchronized void setStartTime(long startTime)
 98  
     {
 99  0
         this.startTime = startTime;
 100  0
     }
 101  
 
 102  
     public synchronized void add(FlowConstructStatistics stat)
 103  
     {
 104  0
         if (stat != null)
 105  
         {
 106  0
             flowConstructStats.put(stat.getName(), stat);
 107  
         }
 108  0
     }
 109  
 
 110  
     public synchronized void remove(FlowConstructStatistics stat)
 111  
     {
 112  0
         if (stat != null)
 113  
         {
 114  0
             flowConstructStats.remove(stat.getName());
 115  
         }
 116  0
     }
 117  
 
 118  
     /**
 119  
      * @deprecated use #getServiceStatistics
 120  
      */
 121  
     @Deprecated
 122  
     public synchronized Collection<FlowConstructStatistics> getComponentStatistics()
 123  
     {
 124  0
         return flowConstructStats.values();
 125  
     }
 126  
 
 127  
     public synchronized Collection<FlowConstructStatistics> getServiceStatistics()
 128  
     {
 129  0
         return flowConstructStats.values();
 130  
     }
 131  
 
 132  
     public FlowConstructStatistics getApplicationStatistics()
 133  
     {
 134  0
         return appStats;
 135  
     }
 136  
 }