KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > excalibur > instrument > client > http > AbstractHTTPInstrumentSampleElementData


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14  * implied.
15  *
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */

19
20 package org.apache.excalibur.instrument.client.http;
21
22 import org.apache.excalibur.instrument.client.InstrumentSampleElementData;
23
24 import org.apache.avalon.framework.configuration.Configuration;
25 import org.apache.avalon.framework.configuration.ConfigurationException;
26
27 abstract class AbstractHTTPInstrumentSampleElementData
28     extends AbstractHTTPElementData
29     implements InstrumentSampleElementData
30 {
31     /** The sample interval. */
32     private long m_interval;
33     
34     /** The size of the sample history. */
35     private int m_size;
36     
37     /** The type of the Instrument Sample. */
38     private int m_type;
39     
40     /** The sample value. */
41     private int m_value;
42     
43     /** The UNIX time of the beginning of the sample. */
44     private long m_time;
45     
46     /** The UNIX time when the lease expires. */
47     private long m_leaseExpirationTime;
48     
49     /*---------------------------------------------------------------
50      * Constructors
51      *-------------------------------------------------------------*/

52     /**
53      * Creates a new AbstractHTTPInstrumentSampleElementData.
54      *
55      * @param connection The connection used to communicate with the server.
56      * @param parent The parent data element.
57      * @param name The name of the data element.
58      */

59     AbstractHTTPInstrumentSampleElementData( HTTPInstrumentManagerConnection connection,
60                                              AbstractHTTPData parent,
61                                              String JavaDoc name )
62     {
63         super( connection, parent, name );
64     }
65     
66     /*---------------------------------------------------------------
67      * AbstractHTTPElementData Methods
68      *-------------------------------------------------------------*/

69     /**
70      * Update the contents of the object using values from the Configuration object.
71      *
72      * @param configuration Configuration object to load from.
73      *
74      * @throws ConfigurationException If there are any problems.
75      */

76     protected void update( Configuration configuration )
77         throws ConfigurationException
78     {
79         super.update( configuration );
80         
81         m_interval = configuration.getAttributeAsLong( "interval" );
82         m_size = configuration.getAttributeAsInteger( "size" );
83         m_type = configuration.getAttributeAsInteger( "type" );
84         m_value = configuration.getAttributeAsInteger( "value" );
85         m_time = configuration.getAttributeAsLong( "time" );
86         m_leaseExpirationTime = configuration.getAttributeAsLong( "expiration-time" );
87     }
88     
89     /*---------------------------------------------------------------
90      * InstrumentSampleElementData Methods
91      *-------------------------------------------------------------*/

92     /**
93      * Returns the sample interval. The period of each sample in millisends.
94      *
95      * @return The sample interval.
96      */

97     public long getInterval()
98     {
99         return m_interval;
100     }
101     
102     /**
103      * Returns the number of samples in the sample history.
104      *
105      * @return The size of the sample history.
106      */

107     public int getSize()
108     {
109         return m_size;
110     }
111     
112     /**
113      * Returns the type of the Instrument Sample. Possible values include
114      * InstrumentSampleData.INSTRUMENT_SAMPLE_TYPE_COUNTER,
115      * InstrumentSampleData.INSTRUMENT_SAMPLE_TYPE_MAXIMUM,
116      * InstrumentSampleData.INSTRUMENT_SAMPLE_TYPE_MEAN, or
117      * InstrumentSampleData.INSTRUMENT_SAMPLE_TYPE_MINIMUM.
118      *
119      * @return The type of the Instrument Sample.
120      */

121     public int getType()
122     {
123         return m_type;
124     }
125     
126     /**
127      * Obtain the value of the sample. All samples are integers, so the profiled
128      * objects must measure quantity (numbers of items), rate (items/period), time in
129      * milliseconds, etc.
130      *
131      * @return The sample value.
132      */

133     public int getValue()
134     {
135         return m_value;
136     }
137     
138     /**
139      * Obtain the UNIX time of the beginning of the sample.
140      *
141      * @return The UNIX time of the beginning of the sample.
142      */

143     public long getTime()
144     {
145         return m_time;
146     }
147     
148     /**
149      * Obtain the UNIX time when the lease expires.
150      *
151      * @return The UNIX time when the lease expires.
152      */

153     public long getLeaseExpirationTime()
154     {
155         return m_leaseExpirationTime;
156     }
157     
158     /**
159      * Returns the Type of the Instrument which can use the sample. This
160      * should be the same for all instances of a class.
161      * <p>
162      * Should be one of the following: InstrumentData.PROFILE_POINT_TYPE_COUNTER
163      * or InstrumentData.PROFILE_POINT_TYPE_VALUE
164      *
165      * @return The Type of the Instrument which can use the sample.
166      */

167     public int getInstrumentType()
168     {
169         return ((HTTPInstrumentData)getParent()).getType();
170     }
171     
172     /*---------------------------------------------------------------
173      * Methods
174      *-------------------------------------------------------------*/

175 }
Popular Tags