Source Code Cross Referenced for DTrace.java in  » Database-DBMS » db4o-6.4 » com » db4o » 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 DBMS » db4o 6.4 » com.db4o 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Copyright (C) 2004 - 2007  db4objects Inc.  http://www.db4o.com
002:
003:        This file is part of the db4o open source object database.
004:
005:        db4o is free software; you can redistribute it and/or modify it under
006:        the terms of version 2 of the GNU General Public License as published
007:        by the Free Software Foundation and as clarified by db4objects' GPL 
008:        interpretation policy, available at
009:        http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
010:        Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
011:        Suite 350, San Mateo, CA 94403, USA.
012:
013:        db4o is distributed in the hope that it will be useful, but WITHOUT ANY
014:        WARRANTY; without even the implied warranty of MERCHANTABILITY or
015:        FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
016:        for more details.
017:
018:        You should have received a copy of the GNU General Public License along
019:        with this program; if not, write to the Free Software Foundation, Inc.,
020:        59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. */
021:        package com.db4o;
022:
023:        import com.db4o.internal.slots.*;
024:
025:        /**
026:         * @exclude 
027:         */
028:        public class DTrace {
029:
030:            public static final boolean enabled = false;
031:
032:            private static void breakPoint() {
033:                if (enabled) { /* breakpoint here */
034:                }
035:            }
036:
037:            private static final void configure() {
038:                if (enabled) {
039:
040:                    // breakOnEvent(5);
041:
042:                    // addRange(4874);
043:
044:                    // addRangeWithEnd(3835808, 3836267);
045:
046:                    //        	 addRangeWithLength(6539,1);
047:                    addRangeWithLength(17673, 1);
048:
049:                    //            addRangeWithLength(455404,1);
050:                    //            
051:                    //            addRangeWithLength(455570,1);
052:                    //            
053:                    //            addRangeWithLength(455926,1);
054:                    //
055:
056:                    // addRangeWithLength(20161,1);
057:
058:                    trackEventsWithoutRange();
059:
060:                    //            turnAllOffExceptFor(new DTrace[] {YAPMETA_SET_ID});
061:
062:                    turnAllOffExceptFor(new DTrace[] { GET_POINTER_SLOT,
063:                            FREE_POINTER_ON_ROLLBACK });
064:
065:                    //          turnAllOffExceptFor(new DTrace[] {BTREE_NODE_COMMIT_OR_ROLLBACK });
066:                    //            turnAllOffExceptFor(new DTrace[] {BTREE_NODE_REMOVE, BTREE_NODE_COMMIT_OR_ROLLBACK YAPMETA_SET_ID});
067:                }
068:            }
069:
070:            private static final void init() {
071:                if (!enabled) {
072:                    return;
073:                }
074:                ADD_TO_CLASS_INDEX = new DTrace(true, true,
075:                        "add to class index tree", true);
076:                BEGIN_TOP_LEVEL_CALL = new DTrace(true, true,
077:                        "begin top level call", true);
078:                BIND = new DTrace(true, true, "bind", true);
079:                BTREE_NODE_REMOVE = new DTrace(true, true, "btreenode remove",
080:                        true);
081:                BTREE_NODE_COMMIT_OR_ROLLBACK = new DTrace(true, true,
082:                        "btreenode commit or rollback", true);
083:                CANDIDATE_READ = new DTrace(true, true, "candidate read", true);
084:                CLOSE = new DTrace(true, true, "close", true);
085:                COLLECT_CHILDREN = new DTrace(true, true, "collect children",
086:                        true);
087:                COMMIT = new DTrace(false, false, "commit", true);
088:                CONTINUESET = new DTrace(true, true, "continueset", true);
089:                CREATE_CANDIDATE = new DTrace(true, true, "create candidate",
090:                        true);
091:                DELETE = new DTrace(true, true, "delete", true);
092:                DONOTINCLUDE = new DTrace(true, true, "donotinclude", true);
093:                END_TOP_LEVEL_CALL = new DTrace(true, true,
094:                        "end top level call", true);
095:                EVALUATE_SELF = new DTrace(true, true, "evaluate self", true);
096:                FREE = new DTrace(true, true, "free", true);
097:                FILE_FREE = new DTrace(true, true, "fileFree", true);
098:                FREE_RAM = new DTrace(true, true, "freeRAM", true);
099:                FREE_ON_COMMIT = new DTrace(true, true, "trans freeOnCommit",
100:                        true);
101:                FREE_ON_ROLLBACK = new DTrace(true, true,
102:                        "trans freeOnRollback", true);
103:                FREE_POINTER_ON_ROLLBACK = new DTrace(true, true,
104:                        "freePointerOnRollback", true);
105:                GET_POINTER_SLOT = new DTrace(true, true, "getPointerSlot",
106:                        true);
107:                GET_SLOT = new DTrace(true, true, "getSlot", true);
108:                GET_FREESPACE = new DTrace(true, true, "getFreespace", true);
109:                GET_FREESPACE_RAM = new DTrace(true, true, "getFreespaceRam",
110:                        true);
111:                GET_YAPOBJECT = new DTrace(true, true, "get yapObject", true);
112:                ID_TREE_ADD = new DTrace(true, true, "id tree add", true);
113:                ID_TREE_REMOVE = new DTrace(true, true, "id tree remove", true);
114:                IO_COPY = new DTrace(true, true, "io copy", true);
115:                JUST_SET = new DTrace(true, true, "just set", true);
116:                NEW_INSTANCE = new DTrace(true, true, "newInstance", true);
117:                PRODUCE_SLOT_CHANGE = new DTrace(true, true,
118:                        "produce slot change", true);
119:                QUERY_PROCESS = new DTrace(true, true, "query process", true);
120:                READ_ARRAY_WRAPPER = new DTrace(true, true,
121:                        "read array wrapper", true);
122:                READ_BYTES = new DTrace(true, true, "readBytes", true);
123:                READ_ID = new DTrace(true, true, "read ID", true);
124:                READ_SLOT = new DTrace(true, true, "read slot", true);
125:                REFERENCE_REMOVED = new DTrace(true, true, "reference removed",
126:                        true);
127:                REGULAR_SEEK = new DTrace(true, true, "regular seek", true);
128:                REMOVE_FROM_CLASS_INDEX = new DTrace(true, true,
129:                        "trans removeFromClassIndexTree", true);
130:                REREAD_OLD_UUID = new DTrace(true, true, "reread old uuid",
131:                        true);
132:                SLOT_SET_POINTER = new DTrace(true, true, "slot set pointer",
133:                        true);
134:                SLOT_DELETE = new DTrace(true, true, "slot delete", true);
135:                SLOT_FREE_ON_COMMIT = new DTrace(true, true,
136:                        "slot free on commit", true);
137:                SLOT_FREE_ON_ROLLBACK_ID = new DTrace(true, true,
138:                        "slot free on rollback id", true);
139:                SLOT_FREE_ON_ROLLBACK_ADDRESS = new DTrace(true, true,
140:                        "slot free on rollback address", true);
141:                TRANS_COMMIT = new DTrace(false, false, "trans commit", false);
142:                TRANS_DELETE = new DTrace(true, true, "trans delete", true);
143:                TRANS_DONT_DELETE = new DTrace(true, true, "trans dontDelete",
144:                        true);
145:                TRANS_FLUSH = new DTrace(true, true, "trans flush", true);
146:                YAPMETA_WRITE = new DTrace(true, true, "yapmeta write", true);
147:                YAPCLASS_BY_ID = new DTrace(true, true, "yapclass by id", true);
148:                YAPCLASS_INIT = new DTrace(true, true, "yapclass init", true);
149:                YAPMETA_SET_ID = new DTrace(true, true, "yapmeta setid", true);
150:                WRITE_BYTES = new DTrace(true, true, "writeBytes", true);
151:                WRITE_POINTER = new DTrace(true, true, "write pointer", true);
152:                WRITE_UPDATE_DELETE_MEMBERS = new DTrace(true, true,
153:                        "trans writeUpdateDeleteMembers", true);
154:                WRITE_XBYTES = new DTrace(true, true, "writeXBytes", true);
155:                configure();
156:            }
157:
158:            private static void trackEventsWithoutRange() {
159:                _trackEventsWithoutRange = true;
160:            }
161:
162:            private DTrace(boolean enabled_, boolean break_, String tag_,
163:                    boolean log_) {
164:                if (enabled) {
165:                    _enabled = enabled_;
166:                    _break = break_;
167:                    _tag = tag_;
168:                    _log = log_;
169:                    if (all == null) {
170:                        all = new DTrace[100];
171:                    }
172:                    all[current++] = this ;
173:                }
174:            }
175:
176:            private boolean _enabled;
177:            private boolean _break;
178:            private boolean _log;
179:            private String _tag;
180:
181:            private static long[] _rangeStart;
182:            private static long[] _rangeEnd;
183:            private static int _rangeCount;
184:
185:            public static long _eventNr;
186:            private static long[] _breakEventNrs;
187:            private static int _breakEventCount;
188:
189:            private static boolean _trackEventsWithoutRange;
190:
191:            public static DTrace ADD_TO_CLASS_INDEX;
192:            public static DTrace BEGIN_TOP_LEVEL_CALL;
193:            public static DTrace BIND;
194:            public static DTrace BTREE_NODE_COMMIT_OR_ROLLBACK;
195:            public static DTrace BTREE_NODE_REMOVE;
196:            public static DTrace CANDIDATE_READ;
197:            public static DTrace CLOSE;
198:            public static DTrace COLLECT_CHILDREN;
199:            public static DTrace COMMIT;
200:            public static DTrace CONTINUESET;
201:            public static DTrace CREATE_CANDIDATE;
202:            public static DTrace DELETE;
203:            public static DTrace DONOTINCLUDE;
204:            public static DTrace END_TOP_LEVEL_CALL;
205:            public static DTrace EVALUATE_SELF;
206:            public static DTrace FILE_FREE;
207:            public static DTrace FREE;
208:            public static DTrace FREE_RAM;
209:            public static DTrace FREE_ON_COMMIT;
210:            public static DTrace FREE_ON_ROLLBACK;
211:            public static DTrace FREE_POINTER_ON_ROLLBACK;
212:            public static DTrace GET_SLOT;
213:            public static DTrace GET_POINTER_SLOT;
214:            public static DTrace GET_FREESPACE;
215:            public static DTrace GET_FREESPACE_RAM;
216:            public static DTrace GET_YAPOBJECT;
217:            public static DTrace ID_TREE_ADD;
218:            public static DTrace ID_TREE_REMOVE;
219:            public static DTrace IO_COPY;
220:            public static DTrace JUST_SET;
221:            public static DTrace NEW_INSTANCE;
222:            public static DTrace PRODUCE_SLOT_CHANGE;
223:            public static DTrace QUERY_PROCESS;
224:            public static DTrace READ_ARRAY_WRAPPER;
225:            public static DTrace READ_BYTES;
226:            public static DTrace READ_ID;
227:            public static DTrace READ_SLOT;
228:            public static DTrace REFERENCE_REMOVED;
229:            public static DTrace REGULAR_SEEK;
230:            public static DTrace REMOVE_FROM_CLASS_INDEX;
231:            public static DTrace REREAD_OLD_UUID;
232:            public static DTrace SLOT_SET_POINTER;
233:            public static DTrace SLOT_DELETE;
234:            public static DTrace SLOT_FREE_ON_COMMIT;
235:            public static DTrace SLOT_FREE_ON_ROLLBACK_ID;
236:            public static DTrace SLOT_FREE_ON_ROLLBACK_ADDRESS;
237:            public static DTrace TRANS_COMMIT;
238:            public static DTrace TRANS_DONT_DELETE;
239:            public static DTrace TRANS_DELETE;
240:            public static DTrace TRANS_FLUSH;
241:            public static DTrace YAPCLASS_BY_ID;
242:            public static DTrace YAPCLASS_INIT;
243:            public static DTrace YAPMETA_SET_ID;
244:            public static DTrace YAPMETA_WRITE;
245:            public static DTrace WRITE_BYTES;
246:            public static DTrace WRITE_POINTER;
247:            public static DTrace WRITE_XBYTES;
248:            public static DTrace WRITE_UPDATE_DELETE_MEMBERS;
249:
250:            static {
251:                init();
252:            }
253:
254:            private static DTrace[] all;
255:            private static int current;
256:
257:            public void log() {
258:                if (enabled) {
259:                    log(-1);
260:                }
261:            }
262:
263:            public void log(long p) {
264:                if (enabled) {
265:                    logLength(p, 1);
266:                }
267:            }
268:
269:            public void logInfo(String info) {
270:                if (enabled) {
271:                    logEnd(-1, 0, info);
272:                }
273:            }
274:
275:            public void log(long p, String info) {
276:                if (enabled) {
277:                    logEnd(p, 0, info);
278:                }
279:
280:            }
281:
282:            public void logLength(long start, long length) {
283:                if (enabled) {
284:                    logEnd(start, start + length - 1);
285:                }
286:            }
287:
288:            public void logLength(Slot slot) {
289:                if (enabled) {
290:                    logLength(slot.address(), slot.length());
291:                }
292:            }
293:
294:            public void logEnd(long start, long end) {
295:                if (enabled) {
296:                    logEnd(start, end, null);
297:                }
298:            }
299:
300:            public void logEnd(long start, long end, String info) {
301:                if (enabled) {
302:                    if (!_enabled) {
303:                        return;
304:                    }
305:                    boolean inRange = false;
306:
307:                    if (_rangeCount == 0) {
308:                        inRange = true;
309:                    }
310:
311:                    for (int i = 0; i < _rangeCount; i++) {
312:
313:                        // Case 1 start in range
314:                        if (start >= _rangeStart[i] && start <= _rangeEnd[i]) {
315:                            inRange = true;
316:                            break;
317:                        }
318:
319:                        if (end != 0) {
320:
321:                            // Case 2 end in range
322:                            if (end >= _rangeStart[i] && end <= _rangeEnd[i]) {
323:                                inRange = true;
324:                                break;
325:                            }
326:
327:                            // Case 3 start before range, end after range
328:                            if (start <= _rangeStart[i] && end >= _rangeEnd[i]) {
329:                                inRange = true;
330:                                break;
331:                            }
332:                        }
333:                    }
334:                    if (inRange || (_trackEventsWithoutRange && (start == -1))) {
335:                        if (_log) {
336:                            _eventNr++;
337:                            StringBuffer sb = new StringBuffer(":");
338:                            sb.append(formatInt(_eventNr, 6));
339:                            sb.append(":");
340:                            if (start != 0) {
341:                                sb.append(formatInt(start));
342:                                sb.append(":");
343:                            }
344:                            if (end != 0 && start != end) {
345:                                sb.append(formatInt(end));
346:                                sb.append(":");
347:                                sb.append(formatInt(end - start + 1));
348:                            } else {
349:                                sb.append(formatInt(0));
350:                            }
351:                            sb.append(":");
352:                            if (info != null) {
353:                                sb.append(" " + info + " ");
354:                                sb.append(":");
355:                            }
356:                            sb.append(" ");
357:                            sb.append(_tag);
358:                            System.out.println(sb);
359:                        }
360:                        if (_break) {
361:                            if (_breakEventCount > 0) {
362:                                for (int i = 0; i < _breakEventCount; i++) {
363:                                    if (_breakEventNrs[i] == _eventNr) {
364:                                        breakPoint();
365:                                        break;
366:                                    }
367:                                }
368:                            } else {
369:                                breakPoint();
370:                            }
371:                        }
372:                    }
373:                }
374:            }
375:
376:            public static void addRange(long pos) {
377:                if (enabled) {
378:                    addRangeWithEnd(pos, pos);
379:                }
380:            }
381:
382:            public static void addRangeWithLength(long start, long length) {
383:                if (enabled) {
384:                    addRangeWithEnd(start, start + length - 1);
385:                }
386:            }
387:
388:            public static void addRangeWithEnd(long start, long end) {
389:                if (enabled) {
390:                    if (_rangeStart == null) {
391:                        _rangeStart = new long[100];
392:                        _rangeEnd = new long[100];
393:                    }
394:                    _rangeStart[_rangeCount] = start;
395:                    _rangeEnd[_rangeCount] = end;
396:                    _rangeCount++;
397:                }
398:            }
399:
400:            private static void breakOnEvent(long eventNr) {
401:                if (enabled) {
402:                    if (_breakEventNrs == null) {
403:                        _breakEventNrs = new long[100];
404:                    }
405:                    _breakEventNrs[_breakEventCount] = eventNr;
406:                    _breakEventCount++;
407:                }
408:            }
409:
410:            private String formatInt(long i, int len) {
411:                if (enabled) {
412:                    String str = "              ";
413:                    if (i != 0) {
414:                        str += i + " ";
415:                    }
416:                    return str.substring(str.length() - len);
417:                }
418:                return null;
419:            }
420:
421:            private String formatInt(long i) {
422:                if (enabled) {
423:                    return formatInt(i, 10);
424:                }
425:                return null;
426:            }
427:
428:            private static void turnAllOffExceptFor(DTrace[] these) {
429:                if (enabled) {
430:                    for (int i = 0; i < all.length; i++) {
431:                        if (all[i] == null) {
432:                            break;
433:                        }
434:                        boolean turnOff = true;
435:                        for (int j = 0; j < these.length; j++) {
436:                            if (all[i] == these[j]) {
437:                                turnOff = false;
438:                                break;
439:                            }
440:                        }
441:                        if (turnOff) {
442:                            all[i]._break = false;
443:                            all[i]._enabled = false;
444:                            all[i]._log = false;
445:                        }
446:                    }
447:                }
448:            }
449:
450:            public static void noWarnings() {
451:                breakOnEvent(0);
452:                trackEventsWithoutRange();
453:            }
454:
455:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.