Source Code Cross Referenced for LoggingStorageManagerFactory.java in  » Testing » PolePosition-0.20 » com » versant » core » storagemanager » logging » 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 » Testing » PolePosition 0.20 » com.versant.core.storagemanager.logging 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 1998 - 2005 Versant Corporation
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         * Versant Corporation - initial API and implementation
010:         */
011:        package com.versant.core.storagemanager.logging;
012:
013:        import com.versant.core.storagemanager.StorageManagerFactory;
014:        import com.versant.core.storagemanager.StorageManager;
015:        import com.versant.core.metric.HasMetrics;
016:        import com.versant.core.metadata.ModelMetaData;
017:        import com.versant.core.server.DataStoreInfo;
018:        import com.versant.core.server.CompiledQueryCache;
019:        import com.versant.core.metric.BaseMetric;
020:        import com.versant.core.metric.Metric;
021:        import com.versant.core.metric.HasMetrics;
022:        import com.versant.core.logging.LogEventStore;
023:
024:        import java.util.List;
025:        import java.util.Set;
026:
027:        /**
028:         * Decorates another SMF to create SMs that log events and maintain
029:         * performance counters.
030:         */
031:        public final class LoggingStorageManagerFactory implements 
032:                StorageManagerFactory, HasMetrics {
033:
034:            private final StorageManagerFactory smf;
035:            private final LogEventStore pes;
036:
037:            public int txCount;
038:            public int txCommitCount;
039:            public int txCommitErrorCount;
040:            public int txRollbackCount;
041:            public int txFlushCount;
042:            public int txFlushErrorCount;
043:            public int fetchCount;
044:            public int fetchErrorCount;
045:            public int queryCount;
046:            public int queryErrorCount;
047:
048:            private static final String CAT_MEM = "Memory";
049:
050:            private final BaseMetric metricMemoryFree = new BaseMetric(
051:                    "MemFreeKB", "Mem Free KB", CAT_MEM,
052:                    "Available heap memory in KB", 0, Metric.CALC_AVERAGE);
053:            private final BaseMetric metricMemoryTotal = new BaseMetric(
054:                    "MemTotalKB", "Mem Total KB", CAT_MEM,
055:                    "Total heap memory in KB", 0, Metric.CALC_AVERAGE);
056:
057:            private static final String CAT_TX = "Transactions";
058:
059:            private final BaseMetric metricTx = new BaseMetric("Tx", "Tx",
060:                    CAT_TX, "Transactions started", 3,
061:                    Metric.CALC_DELTA_PER_SECOND);
062:            private final BaseMetric metricTxCommit = new BaseMetric(
063:                    "TxCommit", "Tx Commit", CAT_TX, "Transactions committed",
064:                    3, Metric.CALC_DELTA_PER_SECOND);
065:            private final BaseMetric metricTxCommitError = new BaseMetric(
066:                    "TxCommitError", "Tx Commit Error", CAT_TX,
067:                    "Transactions that failed with an error during commit", 3,
068:                    Metric.CALC_DELTA_PER_SECOND);
069:            private final BaseMetric metricTxRollback = new BaseMetric(
070:                    "TxRollback", "Tx Rollback", CAT_TX,
071:                    "Transactions rolled back", 3, Metric.CALC_DELTA);
072:            private final BaseMetric metricTxFlush = new BaseMetric("TxFlush",
073:                    "Tx Flush", CAT_TX, "Flushes prior to transaction commit",
074:                    3, Metric.CALC_DELTA_PER_SECOND);
075:            private final BaseMetric metricTxFlushError = new BaseMetric(
076:                    "TxFlushError", "Tx Flush Error", CAT_TX,
077:                    "Flushes that failed with an error", 3,
078:                    Metric.CALC_DELTA_PER_SECOND);
079:
080:            private static final String CAT_FETCH = "Fetches";
081:
082:            private final BaseMetric metricFetch = new BaseMetric("Fetch",
083:                    "Fetch", CAT_FETCH, "Number of calls to fetch data", 3,
084:                    Metric.CALC_DELTA_PER_SECOND);
085:            private final BaseMetric metricFetchError = new BaseMetric(
086:                    "FetchError", "Fetch Error", CAT_FETCH,
087:                    "Number of calls to fetch data that failed with an error",
088:                    3, Metric.CALC_DELTA_PER_SECOND);
089:            private final BaseMetric metricQuery = new BaseMetric("Query",
090:                    "Query", CAT_FETCH, "Number of queries executed", 3,
091:                    Metric.CALC_DELTA_PER_SECOND);
092:            private final BaseMetric metricQueryError = new BaseMetric(
093:                    "QueryError", "Query Error", CAT_FETCH,
094:                    "Number of queries executed that failed with an error", 3,
095:                    Metric.CALC_DELTA_PER_SECOND);
096:
097:            public LoggingStorageManagerFactory(StorageManagerFactory smf,
098:                    LogEventStore pes) {
099:                this .smf = smf;
100:                this .pes = pes;
101:            }
102:
103:            public LogEventStore getLogEventStore() {
104:                return pes;
105:            }
106:
107:            public void init(boolean full, ClassLoader loader) {
108:                smf.init(full, loader);
109:            }
110:
111:            public void destroy() {
112:                smf.destroy();
113:            }
114:
115:            public StorageManager getStorageManager() {
116:                StorageManager sm = smf.getStorageManager();
117:                return new LoggingStorageManager(this , sm);
118:            }
119:
120:            public void returnStorageManager(StorageManager sm) {
121:                smf.returnStorageManager(sm);
122:            }
123:
124:            public ModelMetaData getModelMetaData() {
125:                return smf.getModelMetaData();
126:            }
127:
128:            public Object getDatastoreConnection() {
129:                return smf.getDatastoreConnection();
130:            }
131:
132:            public void closeIdleDatastoreConnections() {
133:                smf.closeIdleDatastoreConnections();
134:            }
135:
136:            public DataStoreInfo getDataStoreInfo() {
137:                return smf.getDataStoreInfo();
138:            }
139:
140:            public StorageManagerFactory getInnerStorageManagerFactory() {
141:                return smf;
142:            }
143:
144:            public void addMetrics(List list) {
145:                list.add(metricMemoryFree);
146:                list.add(metricMemoryTotal);
147:                list.add(metricTx);
148:                list.add(metricTxCommit);
149:                list.add(metricTxCommitError);
150:                list.add(metricTxRollback);
151:                list.add(metricTxFlush);
152:                list.add(metricTxFlushError);
153:                list.add(metricFetch);
154:                list.add(metricFetchError);
155:                list.add(metricQuery);
156:                list.add(metricQueryError);
157:                if (smf instanceof  HasMetrics) {
158:                    ((HasMetrics) smf).addMetrics(list);
159:                }
160:            }
161:
162:            public void sampleMetrics(int[][] buf, int pos) {
163:                Runtime r = Runtime.getRuntime();
164:                buf[metricMemoryFree.getIndex()][pos] = (int) (r.freeMemory() >> 10);
165:                buf[metricMemoryTotal.getIndex()][pos] = (int) (r.totalMemory() >> 10);
166:                buf[metricTx.getIndex()][pos] = txCount;
167:                buf[metricTxCommit.getIndex()][pos] = txCommitCount;
168:                buf[metricTxCommitError.getIndex()][pos] = txCommitErrorCount;
169:                buf[metricTxRollback.getIndex()][pos] = txRollbackCount;
170:                buf[metricTxFlush.getIndex()][pos] = txFlushCount;
171:                buf[metricTxFlushError.getIndex()][pos] = txFlushErrorCount;
172:                buf[metricFetch.getIndex()][pos] = fetchCount;
173:                buf[metricFetchError.getIndex()][pos] = fetchErrorCount;
174:                buf[metricQuery.getIndex()][pos] = queryCount;
175:                buf[metricQueryError.getIndex()][pos] = queryErrorCount;
176:                if (smf instanceof  HasMetrics) {
177:                    ((HasMetrics) smf).sampleMetrics(buf, pos);
178:                }
179:            }
180:
181:            public void supportedOptions(Set options) {
182:                smf.supportedOptions(options);
183:            }
184:
185:            public CompiledQueryCache getCompiledQueryCache() {
186:                return smf.getCompiledQueryCache();
187:            }
188:
189:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.