01: /*
02: * Copyright (c) 2001 by Matt Welsh and The Regents of the University of
03: * California. All rights reserved.
04: *
05: * Permission to use, copy, modify, and distribute this software and its
06: * documentation for any purpose, without fee, and without written agreement is
07: * hereby granted, provided that the above copyright notice and the following
08: * two paragraphs appear in all copies of this software.
09: *
10: * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
11: * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
12: * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
13: * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14: *
15: * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
16: * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
17: * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
18: * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
19: * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
20: *
21: * Author: Matt Welsh <mdw@cs.berkeley.edu>
22: *
23: */
24:
25: package seda.apps.Haboob;
26:
27: import java.util.*;
28:
29: /**
30: * This class contains global counters used for recording server
31: * statistics.
32: */
33: public class HaboobStats {
34:
35: public static int numRequests;
36: public static int numErrors;
37:
38: // Cache statistics
39: public static int numStaticRequests;
40: public static int numCacheHits;
41: public static int numCacheMisses;
42: public static int cacheSizeBytes;
43: public static int cacheSizeEntries;
44:
45: // Profiling
46: public static long timeCacheLookup;
47: public static int numCacheLookup;
48: public static long timeCacheAllocate;
49: public static int numCacheAllocate;
50: public static long timeCacheReject;
51: public static int numCacheReject;
52: public static long timeFileRead;
53: public static int numFileRead;
54:
55: public static int numConnectionsEstablished;
56: public static int numConnectionsClosed;
57:
58: // Allow different modules to find each other
59: //public static seda.apps.Haboob.http.HttpSend httpSend;
60: //public static seda.apps.Haboob.http.HttpRecv httpRecv;
61:
62: public static Hashtable http_sender_table = new Hashtable();
63: public static Hashtable http_receiver_table = new Hashtable();
64:
65: public static seda.apps.Haboob.http.HttpRecv getReceiver(
66: String serverport) {
67: return (seda.apps.Haboob.http.HttpRecv) http_receiver_table
68: .get(serverport);
69: }
70:
71: public static void addReceiver(String serverport,
72: seda.apps.Haboob.http.HttpRecv rec) {
73: System.out.println("HaboobStats, add receiver, serverport="
74: + serverport);
75: http_receiver_table.put(serverport, rec);
76: }
77:
78: public static seda.apps.Haboob.http.HttpSend getSender(
79: String serverport) {
80: return (seda.apps.Haboob.http.HttpSend) http_sender_table
81: .get(serverport);
82: }
83:
84: public static void addSender(String serverport,
85: seda.apps.Haboob.http.HttpSend send) {
86: http_sender_table.put(serverport, send);
87: }
88: }
|