Source Code Cross Referenced for CacheStatistics.java in  » Database-JDBC-Connection-Pool » sequoia-2.10.9 » org » continuent » sequoia » controller » cache » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database JDBC Connection Pool » sequoia 2.10.9 » org.continuent.sequoia.controller.cache 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Sequoia: Database clustering technology.
003:         * Copyright (C) 2002-2004 French National Institute For Research In Computer
004:         * Science And Control (INRIA).
005:         * Contact: sequoia@continuent.org
006:         * 
007:         * Licensed under the Apache License, Version 2.0 (the "License");
008:         * you may not use this file except in compliance with the License.
009:         * You may obtain a copy of the License at
010:         * 
011:         * http://www.apache.org/licenses/LICENSE-2.0
012:         * 
013:         * Unless required by applicable law or agreed to in writing, software
014:         * distributed under the License is distributed on an "AS IS" BASIS,
015:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016:         * See the License for the specific language governing permissions and
017:         * limitations under the License. 
018:         *
019:         * Initial developer(s): Emmanuel Cecchet.
020:         * Contributor(s): ______________________________________.
021:         */package org.continuent.sequoia.controller.cache;
022:
023:        import org.continuent.sequoia.common.util.Stats;
024:
025:        /**
026:         * This class handles the statistics for request caches.
027:         * 
028:         * @author <a href="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet </a>
029:         * @version 1.0
030:         */
031:        public class CacheStatistics {
032:            // Cache statistics
033:            private Stats select;
034:            private Stats hits;
035:            private Stats insert;
036:            private Stats update;
037:            private Stats uncacheable;
038:            private Stats delete;
039:            private Stats unknown;
040:            private Stats remove;
041:            private Stats create;
042:            private Stats drop;
043:
044:            /**
045:             * Creates a new CacheStatistics object.
046:             */
047:            public CacheStatistics() {
048:                select = new Stats("select");
049:                hits = new Stats("hits");
050:                insert = new Stats("insert");
051:                update = new Stats("update");
052:                uncacheable = new Stats("uncacheable");
053:                delete = new Stats("delete");
054:                unknown = new Stats("unknown");
055:                remove = new Stats("remove");
056:                create = new Stats("create");
057:                drop = new Stats("drop");
058:            }
059:
060:            /**
061:             * Resets all stats to zero.
062:             */
063:            public void reset() {
064:                select.reset();
065:                hits.reset();
066:                insert.reset();
067:                update.reset();
068:                uncacheable.reset();
069:                delete.reset();
070:                unknown.reset();
071:                remove.reset();
072:                create.reset();
073:                drop.reset();
074:            }
075:
076:            /**
077:             * Returns the create.
078:             * 
079:             * @return an <code>int</code> value
080:             */
081:            public int getCreate() {
082:                return create.getCount();
083:            }
084:
085:            /**
086:             * Returns the delete.
087:             * 
088:             * @return an <code>int</code> value
089:             */
090:            public int getDelete() {
091:                return delete.getCount();
092:            }
093:
094:            /**
095:             * Returns the drop.
096:             * 
097:             * @return an <code>int</code> value
098:             */
099:            public int getDrop() {
100:                return drop.getCount();
101:            }
102:
103:            /**
104:             * Returns the hits.
105:             * 
106:             * @return an <code>int</code> value
107:             */
108:            public int getHits() {
109:                return hits.getCount();
110:            }
111:
112:            /**
113:             * Returns the insert.
114:             * 
115:             * @return an <code>int</code> value
116:             */
117:            public int getInsert() {
118:                return insert.getCount();
119:            }
120:
121:            /**
122:             * Returns the remove.
123:             * 
124:             * @return an <code>int</code> value
125:             */
126:            public int getRemove() {
127:                return remove.getCount();
128:            }
129:
130:            /**
131:             * Returns the select.
132:             * 
133:             * @return an <code>int</code> value
134:             */
135:            public int getSelect() {
136:                return select.getCount();
137:            }
138:
139:            /**
140:             * Returns the unknown.
141:             * 
142:             * @return an <code>int</code> value
143:             */
144:            public int getUnknown() {
145:                return unknown.getCount();
146:            }
147:
148:            /**
149:             * Returns the update.
150:             * 
151:             * @return an <code>int</code> value
152:             */
153:            public int getUpdate() {
154:                return update.getCount();
155:            }
156:
157:            /**
158:             * Returns the uncacheable.
159:             * 
160:             * @return an <code>int</code> value
161:             */
162:            public int getUncacheable() {
163:                return uncacheable.getCount();
164:            }
165:
166:            /**
167:             * Increments the create count.
168:             */
169:            public void addCreate() {
170:                create.incrementCount();
171:            }
172:
173:            /**
174:             * Increments the delete count.
175:             */
176:            public void addDelete() {
177:                delete.incrementCount();
178:            }
179:
180:            /**
181:             * Increments the drop count.
182:             */
183:            public void addDrop() {
184:                drop.incrementCount();
185:            }
186:
187:            /**
188:             * Increments the hits count.
189:             */
190:            public void addHits() {
191:                hits.incrementCount();
192:            }
193:
194:            /**
195:             * Increments the insert count.
196:             */
197:            public void addInsert() {
198:                insert.incrementCount();
199:            }
200:
201:            /**
202:             * Increments the remove count.
203:             */
204:            public void addRemove() {
205:                remove.incrementCount();
206:            }
207:
208:            /**
209:             * Increments the select count.
210:             */
211:            public void addSelect() {
212:                select.incrementCount();
213:            }
214:
215:            /**
216:             * Increments the unkwnown count.
217:             */
218:            public void addUnknown() {
219:                unknown.incrementCount();
220:            }
221:
222:            /**
223:             * Increments the update count.
224:             */
225:            public void addUpdate() {
226:                update.incrementCount();
227:            }
228:
229:            /**
230:             * Increments the uncacheable count.
231:             */
232:            public void addUncacheable() {
233:                uncacheable.incrementCount();
234:            }
235:
236:            /**
237:             * Retrieve cache statistics as a table
238:             * 
239:             * @return an array of String containing the different cache values, like
240:             *         number of select, number of hits ...
241:             */
242:            public String[] getCacheStatsData() {
243:                String[] stats = new String[11];
244:                stats[0] = "" + getSelect();
245:                stats[1] = "" + getHits();
246:                stats[2] = "" + getInsert();
247:                stats[3] = "" + getUpdate();
248:                stats[4] = "" + getUncacheable();
249:                stats[5] = "" + getDelete();
250:                stats[6] = "" + getUnknown();
251:                stats[7] = "" + getRemove();
252:                stats[8] = "" + getCreate();
253:                stats[9] = "" + getDrop();
254:                stats[10] = "" + getCacheHitRatio();
255:                return stats;
256:            }
257:
258:            /**
259:             * Get percentage of hits
260:             * 
261:             * @return hits / select
262:             */
263:            public long getCacheHitRatio() {
264:                if (select.getCount() == 0)
265:                    return 0;
266:                else
267:                    return (long) ((float) hits.getCount()
268:                            / (float) select.getCount() * 100.0);
269:            }
270:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.