Home » synapse-1.2-src » org.apache.synapse.statistics » [javadoc | source]

    1   /*
    2    *  Licensed to the Apache Software Foundation (ASF) under one
    3    *  or more contributor license agreements.  See the NOTICE file
    4    *  distributed with this work for additional information
    5    *  regarding copyright ownership.  The ASF licenses this file
    6    *  to you under the Apache License, Version 2.0 (the
    7    *  "License"); you may not use this file except in compliance
    8    *  with the License.  You may obtain a copy of the License at
    9    *
   10    *   http://www.apache.org/licenses/LICENSE-2.0
   11    *
   12    *  Unless required by applicable law or agreed to in writing,
   13    *  software distributed under the License is distributed on an
   14    *   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   15    *  KIND, either express or implied.  See the License for the
   16    *  specific language governing permissions and limitations
   17    *  under the License.
   18    */
   19   package org.apache.synapse.statistics;
   20   
   21   /**
   22    * To hold statistics that will collected during both of in and out message mediation
   23    */
   24   
   25   public class StatisticsHolder {
   26   
   27       private int statisticsCategory ;
   28   
   29       private String key ;
   30   
   31       /**  The statistics that will collect during in coming message mediation  */
   32       private Statistics inFlowStatistics;
   33   
   34       /**  The statistics that will collect during out going message mediation  */
   35       private Statistics outFlowStatistics;
   36   
   37       /**
   38        * To update the statistics
   39        *
   40        * @param isResponse - A boolean value that indicate whether message flow is in or out
   41        * @param inTime     - The processing start time
   42        * @param outTime    - The processing end time
   43        * @param isFault    - A boolean value that indicate whether falut has occured or not
   44        */
   45       public synchronized void update(boolean isResponse, long inTime, long outTime,
   46                                       boolean isFault) {
   47           if (isResponse) {
   48               if (outFlowStatistics == null) {
   49                   outFlowStatistics = new Statistics();
   50               }
   51               outFlowStatistics.update(inTime, outTime, isFault);
   52           } else {
   53               if (inFlowStatistics == null) {
   54                   inFlowStatistics = new Statistics();
   55               }
   56               inFlowStatistics.update(inTime, outTime, isFault);
   57           }
   58   
   59       }
   60   
   61       /**
   62        * To get Statistics related to the In Flow
   63        * @return  Statistics related to the In Flow
   64        */
   65       public synchronized Statistics getInFlowStatistics() {
   66           return inFlowStatistics;
   67       }
   68   
   69       /**
   70        * To get Statistics related to the Out Flow
   71        * @return  Statistics related to the Out Flow
   72        */
   73       public synchronized Statistics getOutFlowStatistics() {
   74           return outFlowStatistics;
   75       }
   76   
   77       /**
   78        * To get statistics category
   79        * @return  Statistics Category
   80        */
   81       public int getStatisticsCategory() {
   82           return statisticsCategory;
   83       }
   84   
   85       /**
   86        * To set statistics category
   87        * @param statisticsCategory
   88        */
   89       public void setStatisticsCategory(int statisticsCategory) {
   90           this.statisticsCategory = statisticsCategory;
   91       }
   92   
   93       /**
   94        * To get key of statistics
   95        * @return   key of statistics
   96        */
   97       public String getKey() {
   98           return key;
   99       }
  100   
  101       /**
  102        * To set key of statistics
  103        * @param key
  104        */
  105       public void setKey(String key) {
  106           this.key = key;
  107       }
  108   
  109       /**
  110        * To clear stored statistics
  111        */
  112       public synchronized void clearStatistics(){
  113           this.inFlowStatistics =null;
  114           this.outFlowStatistics=null;
  115       }
  116   }

Home » synapse-1.2-src » org.apache.synapse.statistics » [javadoc | source]