< prev index next >

src/java.corba/share/classes/com/sun/corba/se/spi/monitoring/StatisticMonitoredAttribute.java

Print this page




  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package com.sun.corba.se.spi.monitoring;
  26 
  27 import java.util.*;
  28 
  29 /**
  30  * <p>
  31  *
  32  * @author Hemanth Puttaswamy
  33  * </p>
  34  * <p>
  35  * StatisticsMonitoredAttribute is provided as a convenience to collect the
  36  * Statistics of any entity. The getValue() call will be delegated to the
  37  * StatisticsAccumulator set by the user.
  38  * </p>
  39  */
  40 public class StatisticMonitoredAttribute extends MonitoredAttributeBase {
  41 
  42 
  43     // Every StatisticMonitoredAttribute will have a StatisticAccumulator. User
  44     // will use Statisticsaccumulator to accumulate the samples associated with
  45     // this Monitored Attribute
  46     private StatisticsAccumulator statisticsAccumulator;
  47 
  48     // Mutex is passed from the user class which is providing the sample values.
  49     // getValue() and clearState() is synchronized on this user provided mutex
  50     private Object  mutex;
  51 
  52 
  53   ///////////////////////////////////////
  54   // operations
  55 
  56 
  57 /**
  58  * <p>
  59  * Constructs the StaisticMonitoredAttribute, builds the required
  60  * MonitoredAttributeInfo with Long as the class type and is always
  61  * readonly attribute.
  62  * </p>
  63  * <p>
  64  *
  65  * @param name Of this attribute
  66  * </p>
  67  * <p>
  68  * @return a StatisticMonitoredAttribute
  69  * </p>
  70  * <p>
  71  * @param desc should provide a good description on the kind of statistics
  72  * collected, a good example is "Connection Response Time Stats will Provide the
  73  * detailed stats based on the samples provided from every request completion
  74  * time"
  75  * </p>
  76  * <p>
  77  * @param s is the StatisticsAcumulator that user will use to accumulate the
  78  * samples and this Attribute Object will get the computed statistics values
  79  * from.
  80  * </p>
  81  * <p>
  82  * @param mutex using which clearState() and getValue() calls need to be locked.
  83  * </p>
  84  */
  85     public  StatisticMonitoredAttribute(String name, String desc,
  86         StatisticsAccumulator s, Object mutex)
  87     {
  88         super( name );
  89         MonitoredAttributeInfoFactory f =
  90             MonitoringFactories.getMonitoredAttributeInfoFactory();
  91         MonitoredAttributeInfo maInfo = f.createMonitoredAttributeInfo(
  92                 desc, String.class, false, true );
  93 
  94         this.setMonitoredAttributeInfo( maInfo );
  95         this.statisticsAccumulator = s;
  96         this.mutex = mutex;
  97     } // end StatisticMonitoredAttribute
  98 
  99 
 100 
 101 /**
 102  *  Gets the value from the StatisticsAccumulator, the value will be a formatted
 103  *  String with the computed statistics based on the samples accumulated in the




  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package com.sun.corba.se.spi.monitoring;
  26 
  27 import java.util.*;
  28 
  29 /**


  30  * @author Hemanth Puttaswamy
  31  *

  32  * StatisticsMonitoredAttribute is provided as a convenience to collect the
  33  * Statistics of any entity. The getValue() call will be delegated to the
  34  * StatisticsAccumulator set by the user.

  35  */
  36 public class StatisticMonitoredAttribute extends MonitoredAttributeBase {
  37 
  38 
  39     // Every StatisticMonitoredAttribute will have a StatisticAccumulator. User
  40     // will use Statisticsaccumulator to accumulate the samples associated with
  41     // this Monitored Attribute
  42     private StatisticsAccumulator statisticsAccumulator;
  43 
  44     // Mutex is passed from the user class which is providing the sample values.
  45     // getValue() and clearState() is synchronized on this user provided mutex
  46     private Object  mutex;
  47 
  48 
  49   ///////////////////////////////////////
  50   // operations
  51 
  52 
  53 /**

  54  * Constructs the StaisticMonitoredAttribute, builds the required
  55  * MonitoredAttributeInfo with Long as the class type and is always
  56  * readonly attribute.


  57  *
  58  * @param name Of this attribute





  59  * @param desc should provide a good description on the kind of statistics
  60  * collected, a good example is "Connection Response Time Stats will Provide the
  61  * detailed stats based on the samples provided from every request completion
  62  * time"


  63  * @param s is the StatisticsAcumulator that user will use to accumulate the
  64  * samples and this Attribute Object will get the computed statistics values
  65  * from.


  66  * @param mutex using which clearState() and getValue() calls need to be locked.

  67  */
  68     public  StatisticMonitoredAttribute(String name, String desc,
  69         StatisticsAccumulator s, Object mutex)
  70     {
  71         super( name );
  72         MonitoredAttributeInfoFactory f =
  73             MonitoringFactories.getMonitoredAttributeInfoFactory();
  74         MonitoredAttributeInfo maInfo = f.createMonitoredAttributeInfo(
  75                 desc, String.class, false, true );
  76 
  77         this.setMonitoredAttributeInfo( maInfo );
  78         this.statisticsAccumulator = s;
  79         this.mutex = mutex;
  80     } // end StatisticMonitoredAttribute
  81 
  82 
  83 
  84 /**
  85  *  Gets the value from the StatisticsAccumulator, the value will be a formatted
  86  *  String with the computed statistics based on the samples accumulated in the


< prev index next >