KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mr > core > stats > cmc > CMCAgentStats


1 /*
2  * Copyright 2002 by
3  * <a HREF="http://www.coridan.com">Coridan</a>
4  * <a HREF="mailto: support@coridan.com ">support@coridan.com</a>
5  *
6  * The contents of this file are subject to the Mozilla Public License Version
7  * 1.1 (the "License"); you may not use this file except in compliance with the
8  * License. You may obtain a copy of the License at
9  * http://www.mozilla.org/MPL/
10  *
11  * Software distributed under the License is distributed on an "AS IS" basis,
12  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13  * for the specific language governing rights and limitations under the
14  * License.
15  *
16  * The Original Code is "MantaRay" (TM).
17  *
18  * The Initial Developer of the Original Code is Uri Schneider.
19  * Portions created by the Initial Developer are Copyright (C) 2006
20  * Coridan Inc. All Rights Reserved.
21  *
22  * Contributor(s): all the names of the contributors are added in the source
23  * code where applicable.
24  *
25  * Alternatively, the contents of this file may be used under the terms of the
26  * LGPL license (the "GNU LESSER GENERAL PUBLIC LICENSE"), in which case the
27  * provisions of LGPL are applicable instead of those above. If you wish to
28  * allow use of your version of this file only under the terms of the LGPL
29  * License and not to allow others to use your version of this file under
30  * the MPL, indicate your decision by deleting the provisions above and
31  * replace them with the notice and other provisions required by the LGPL.
32  * If you do not delete the provisions above, a recipient may use your version
33  * of this file under either the MPL or the GNU LESSER GENERAL PUBLIC LICENSE.
34  
35  *
36  * This library is free software; you can redistribute it and/or modify it
37  * under the terms of the MPL as stated above or under the terms of the GNU
38  * Lesser General Public License as published by the Free Software Foundation;
39  * either version 2.1 of the License, or any later version.
40  *
41  * This library is distributed in the hope that it will be useful, but WITHOUT
42  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
43  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
44  * License for more details.
45  */

46 package org.mr.core.stats.cmc;
47
48 import java.io.IOException JavaDoc;
49
50 import org.mr.core.util.byteable.Byteable;
51 import org.mr.core.util.byteable.ByteableInputStream;
52 import org.mr.core.util.byteable.ByteableOutputStream;
53 import org.mr.core.util.byteable.ByteableRegistry;
54
55 /**
56  * CMCAgentStats.java
57  *
58  *
59  * Created: Thu May 20 13:40:01 2004
60  *
61  * @author Uri Schneider
62  * @version 1.0
63  */

64 public class CMCAgentStats implements Byteable {
65     private long totalMem;
66     private long freeMem;
67     private long totalMessages;
68     private long totalBytes;
69     private long fiveMinMessages;
70     private long fiveMinBytes;
71
72     public CMCAgentStats() {} // CMCAgentStats constructor
73

74     /**
75      * Get the TotalMem value.
76      * @return the TotalMem value.
77      */

78     public long getTotalMem() {
79         return totalMem;
80     }
81
82     /**
83      * Set the TotalMem value.
84      * @param newTotalMem The new TotalMem value.
85      */

86     public void setTotalMem(long newTotalMem) {
87         this.totalMem = newTotalMem;
88     }
89
90     /**
91      * Get the FreeMem value.
92      * @return the FreeMem value.
93      */

94     public long getFreeMem() {
95         return freeMem;
96     }
97
98     /**
99      * Set the FreeMem value.
100      * @param newFreeMem The new FreeMem value.
101      */

102     public void setFreeMem(long newFreeMem) {
103         this.freeMem = newFreeMem;
104     }
105
106     /**
107      * Get the TotalMessages value.
108      * @return the TotalMessages value.
109      */

110     public long getTotalMessages() {
111         return totalMessages;
112     }
113
114     /**
115      * Set the TotalMessages value.
116      * @param newTotalMessages The new TotalMessages value.
117      */

118     public void setTotalMessages(long newTotalMessages) {
119         this.totalMessages = newTotalMessages;
120     }
121
122     /**
123      * Get the TotalBytes value.
124      * @return the TotalBytes value.
125      */

126     public long getTotalBytes() {
127         return totalBytes;
128     }
129
130     /**
131      * Set the TotalBytes value.
132      * @param newTotalBytes The new TotalBytes value.
133      */

134     public void setTotalBytes(long newTotalBytes) {
135         this.totalBytes = newTotalBytes;
136     }
137
138     // implementation of interface Byteable
139
public String JavaDoc getByteableName() {
140         return "org.mr.core.stats.cmc.CMCAgentStats";
141     }
142
143     public void toBytes(ByteableOutputStream out) throws IOException JavaDoc {
144         out.writeLong(this.totalMem);
145         out.writeLong(this.freeMem);
146         out.writeLong(this.totalMessages);
147         out.writeLong(this.totalBytes);
148         out.writeLong(this.fiveMinMessages);
149         out.writeLong(this.fiveMinBytes);
150     }
151
152     public Byteable createInstance(ByteableInputStream in) throws IOException JavaDoc {
153         CMCAgentStats stats = new CMCAgentStats();
154         stats.totalMem = in.readLong();
155         stats.freeMem = in.readLong();
156         stats.totalMessages = in.readLong();
157         stats.totalBytes = in.readLong();
158         stats.fiveMinMessages = in.readLong();
159         stats.fiveMinBytes = in.readLong();
160         return stats;
161     }
162
163     public void registerToByteableRegistry() {
164         ByteableRegistry.registerByteableFactory(getByteableName(), this);
165     }
166
167     public static void register() {
168         CMCAgentStats stats = new CMCAgentStats();
169         stats.registerToByteableRegistry();
170     }
171     /**
172      * @return Returns the fiveMinBytes.
173      */

174     public long getFiveMinBytes() {
175         return fiveMinBytes;
176     }
177     /**
178      * @param fiveMinBytes The fiveMinBytes to set.
179      */

180     public void setFiveMinBytes(long fiveMinBytes) {
181         this.fiveMinBytes = fiveMinBytes;
182     }
183     /**
184      * @return Returns the fiveMinMessages.
185      */

186     public long getFiveMinMessages() {
187         return fiveMinMessages;
188     }
189     /**
190      * @param fiveMinMessages The fiveMinMessages to set.
191      */

192     public void setFiveMinMessages(long fiveMinMessages) {
193         this.fiveMinMessages = fiveMinMessages;
194     }
195 } // CMCAgentStats
196
Popular Tags