001: /*
002: * This software is released under a licence similar to the Apache Software Licence.
003: * See org.logicalcobwebs.proxool.package.html for details.
004: * The latest version is available at http://proxool.sourceforge.net
005: */
006: package org.logicalcobwebs.proxool.admin;
007:
008: import org.apache.commons.logging.Log;
009: import org.apache.commons.logging.LogFactory;
010: import org.logicalcobwebs.proxool.ConnectionInfoIF;
011:
012: import java.util.Collection;
013: import java.util.Date;
014:
015: /**
016: * Implementation of SnapshotIF
017: *
018: * @version $Revision: 1.5 $, $Date: 2006/01/18 14:39:57 $
019: * @author bill
020: * @author $Author: billhorsman $ (current maintainer)
021: * @since Proxool 0.7
022: */
023: class Snapshot implements SnapshotIF {
024:
025: private static final Log LOG = LogFactory.getLog(Snapshot.class);
026:
027: private Date dateStarted;
028:
029: private long servedCount;
030:
031: private long refusedCount;
032:
033: private int activeConnectionCount;
034:
035: private int availableConnectionCount;
036:
037: private int offlineConnectionCount;
038:
039: private int maximumConnectionCount;
040:
041: private Date snapshotDate;
042:
043: private Collection connectionInfos;
044:
045: private long connectionCount;
046:
047: /**
048: * @param snapshotDate see {@link org.logicalcobwebs.proxool.admin.SnapshotIF#getSnapshotDate}
049: */
050: public Snapshot(Date snapshotDate) {
051: this .snapshotDate = snapshotDate;
052: }
053:
054: /**
055: * @see org.logicalcobwebs.proxool.admin.SnapshotIF#getDateStarted
056: */
057: public Date getDateStarted() {
058: return dateStarted;
059: }
060:
061: /**
062: * @see org.logicalcobwebs.proxool.admin.SnapshotIF#getDateStarted
063: */
064: public void setDateStarted(Date dateStarted) {
065: this .dateStarted = dateStarted;
066: }
067:
068: /**
069: * @see org.logicalcobwebs.proxool.admin.SnapshotIF#getServedCount
070: */
071: public long getServedCount() {
072: return servedCount;
073: }
074:
075: /**
076: * @see org.logicalcobwebs.proxool.admin.SnapshotIF#getServedCount
077: */
078: public void setServedCount(long servedCount) {
079: this .servedCount = servedCount;
080: }
081:
082: /**
083: * @see org.logicalcobwebs.proxool.admin.SnapshotIF#getRefusedCount
084: */
085: public long getRefusedCount() {
086: return refusedCount;
087: }
088:
089: /**
090: * @see org.logicalcobwebs.proxool.admin.SnapshotIF#getRefusedCount
091: */
092: public void setRefusedCount(long refusedCount) {
093: this .refusedCount = refusedCount;
094: }
095:
096: /**
097: * @see org.logicalcobwebs.proxool.admin.SnapshotIF#getActiveConnectionCount
098: */
099: public int getActiveConnectionCount() {
100: return activeConnectionCount;
101: }
102:
103: /**
104: * @see org.logicalcobwebs.proxool.admin.SnapshotIF#getActiveConnectionCount
105: */
106: public void setActiveConnectionCount(int activeConnectionCount) {
107: this .activeConnectionCount = activeConnectionCount;
108: }
109:
110: /**
111: * @see org.logicalcobwebs.proxool.admin.SnapshotIF#getAvailableConnectionCount
112: */
113: public int getAvailableConnectionCount() {
114: return availableConnectionCount;
115: }
116:
117: /**
118: * @see org.logicalcobwebs.proxool.admin.SnapshotIF#getAvailableConnectionCount
119: */
120: public void setAvailableConnectionCount(int availableConnectionCount) {
121: this .availableConnectionCount = availableConnectionCount;
122: }
123:
124: /**
125: * @see org.logicalcobwebs.proxool.admin.SnapshotIF#getOfflineConnectionCount
126: */
127: public int getOfflineConnectionCount() {
128: return offlineConnectionCount;
129: }
130:
131: /**
132: * @see org.logicalcobwebs.proxool.admin.SnapshotIF#getOfflineConnectionCount
133: */
134: public void setOfflineConnectionCount(int offlineConnectionCount) {
135: this .offlineConnectionCount = offlineConnectionCount;
136: }
137:
138: /**
139: * @see org.logicalcobwebs.proxool.admin.SnapshotIF#getMaximumConnectionCount
140: */
141: public int getMaximumConnectionCount() {
142: return maximumConnectionCount;
143: }
144:
145: /**
146: * @see org.logicalcobwebs.proxool.admin.SnapshotIF#getMaximumConnectionCount
147: */
148: public void setMaximumConnectionCount(int maximumConnectionCount) {
149: this .maximumConnectionCount = maximumConnectionCount;
150: }
151:
152: /**
153: * @see org.logicalcobwebs.proxool.admin.SnapshotIF#getSnapshotDate
154: */
155: public Date getSnapshotDate() {
156: return snapshotDate;
157: }
158:
159: /**
160: * @see SnapshotIF#getConnectionInfos
161: */
162: public ConnectionInfoIF[] getConnectionInfos() {
163: return (ConnectionInfoIF[]) connectionInfos
164: .toArray(new ConnectionInfoIF[connectionInfos.size()]);
165: }
166:
167: /**
168: * @see SnapshotIF#getConnectionInfos
169: */
170: public void setConnectionInfos(Collection connectionInfos) {
171: this .connectionInfos = connectionInfos;
172: }
173:
174: /**
175: * @see SnapshotIF#getConnectionInfo
176: */
177: public ConnectionInfoIF getConnectionInfo(long id) {
178: ConnectionInfoIF connectionInfo = null;
179: ConnectionInfoIF[] connectionInfos = getConnectionInfos();
180: for (int i = 0; i < connectionInfos.length; i++) {
181: if (connectionInfos[i].getId() == id) {
182: connectionInfo = connectionInfos[i];
183: }
184: }
185: return connectionInfo;
186: }
187:
188: /**
189: * @see SnapshotIF#isDetail
190: */
191: public boolean isDetail() {
192: return connectionInfos != null;
193: }
194:
195: public long getConnectionCount() {
196: return connectionCount;
197: }
198:
199: public void setConnectionCount(long connectionCount) {
200: this .connectionCount = connectionCount;
201: }
202: }
203:
204: /*
205: Revision history:
206: $Log: Snapshot.java,v $
207: Revision 1.5 2006/01/18 14:39:57 billhorsman
208: Unbundled Jakarta's Commons Logging.
209:
210: Revision 1.4 2005/10/02 12:32:01 billhorsman
211: Make connectionCount available to statistics
212:
213: Revision 1.3 2003/03/10 15:26:51 billhorsman
214: refactoringn of concurrency stuff (and some import
215: optimisation)
216:
217: Revision 1.2 2003/03/03 11:11:59 billhorsman
218: fixed licence
219:
220: Revision 1.1 2003/02/19 23:36:51 billhorsman
221: renamed monitor package to admin
222:
223: Revision 1.4 2003/02/12 12:28:28 billhorsman
224: added url, proxyHashcode and delegateHashcode to
225: ConnectionInfoIF
226:
227: Revision 1.3 2003/02/06 17:41:06 billhorsman
228: now uses imported logging
229:
230: Revision 1.2 2003/01/31 16:38:53 billhorsman
231: doc (and removing public modifier for classes where possible)
232:
233: Revision 1.1 2003/01/31 11:35:57 billhorsman
234: improvements to servlet (including connection details)
235:
236: Revision 1.1 2003/01/30 17:20:09 billhorsman
237: fixes, improvements and doc
238:
239: */
|