Source Code Cross Referenced for TrackedFileSummary.java in  » JMX » je » com » sleepycat » je » cleaner » 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 » JMX » je » com.sleepycat.je.cleaner 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*-
002:         * See the file LICENSE for redistribution information.
003:         *
004:         * Copyright (c) 2002,2008 Oracle.  All rights reserved.
005:         *
006:         * $Id: TrackedFileSummary.java,v 1.9.2.4 2008/01/07 15:14:08 cwl Exp $
007:         */
008:
009:        package com.sleepycat.je.cleaner;
010:
011:        import com.sleepycat.je.dbi.MemoryBudget;
012:
013:        /**
014:         * Delta file summary info for a tracked file.  Tracked files are managed by
015:         * the UtilizationTracker.
016:         *
017:         * <p>The methods in this class for reading obsolete offsets may be used by
018:         * multiple threads without synchronization even while another thread is adding
019:         * offsets.  This is possible because elements are never deleted from the
020:         * lists.  The thread adding obsolete offsets does so under the log write
021:         * latch to prevent multiple threads from adding concurrently.</p>
022:         */
023:        public class TrackedFileSummary extends FileSummary {
024:
025:            private UtilizationTracker tracker;
026:            private long fileNum;
027:            private OffsetList obsoleteOffsets;
028:            private int memSize;
029:            private boolean trackDetail;
030:            private boolean allowFlush = true;
031:
032:            /**
033:             * Creates an empty tracked summary.
034:             */
035:            TrackedFileSummary(UtilizationTracker tracker, long fileNum,
036:                    boolean trackDetail) {
037:                this .tracker = tracker;
038:                this .fileNum = fileNum;
039:                this .trackDetail = trackDetail;
040:            }
041:
042:            /**
043:             * Returns whether this summary is allowed or prohibited from being flushed
044:             * or evicted during cleaning.  By default, flushing is allowed.
045:             */
046:            public boolean getAllowFlush() {
047:                return allowFlush;
048:            }
049:
050:            /**
051:             * Allows or prohibits this summary from being flushed or evicted during
052:             * cleaning.  By default, flushing is allowed.
053:             */
054:            void setAllowFlush(boolean allowFlush) {
055:                this .allowFlush = allowFlush;
056:            }
057:
058:            /**
059:             * Returns the file number being tracked.
060:             */
061:            public long getFileNumber() {
062:                return fileNum;
063:            }
064:
065:            /**
066:             * Return the total memory size for this object.  We only bother to budget
067:             * obsolete detail, not the overhead for this object, for two reasons:
068:             * 1) The number of these objects is very small, and 2) unit tests disable
069:             * detail tracking as a way to prevent budget adjustments here.
070:             */
071:            int getMemorySize() {
072:                return memSize;
073:            }
074:
075:            /**
076:             * Overrides reset for a tracked file, and is called when a FileSummaryLN
077:             * is written to the log.
078:             *
079:             * <p>Must be called under the log write latch.</p>
080:             */
081:            public void reset() {
082:
083:                obsoleteOffsets = null;
084:
085:                tracker.resetFile(this );
086:
087:                if (memSize > 0) {
088:                    updateMemoryBudget(0 - memSize);
089:                }
090:
091:                super .reset();
092:            }
093:
094:            /**
095:             * Tracks the given offset as obsolete or non-obsolete.
096:             *
097:             * <p>Must be called under the log write latch.</p>
098:             */
099:            void trackObsolete(long offset) {
100:
101:                if (!trackDetail) {
102:                    return;
103:                }
104:                int adjustMem = 0;
105:                if (obsoleteOffsets == null) {
106:                    obsoleteOffsets = new OffsetList();
107:                    adjustMem += MemoryBudget.TFS_LIST_INITIAL_OVERHEAD;
108:                }
109:                if (obsoleteOffsets.add(offset, tracker.getEnvironment()
110:                        .isOpen())) {
111:                    adjustMem += MemoryBudget.TFS_LIST_SEGMENT_OVERHEAD;
112:                }
113:                if (adjustMem != 0) {
114:                    updateMemoryBudget(adjustMem);
115:                }
116:            }
117:
118:            /**
119:             * Adds the obsolete offsets as well as the totals of the given object.
120:             */
121:            void addTrackedSummary(TrackedFileSummary other) {
122:
123:                /* Add the totals. */
124:                add(other);
125:
126:                /*
127:                 * Add the offsets and the memory used [#15505] by the other tracker.
128:                 * The memory budget has already been updated for the offsets to be
129:                 * added, so we only need to account for a possible difference of one
130:                 * segment when we merge them.
131:                 */
132:                memSize += other.memSize;
133:                if (other.obsoleteOffsets != null) {
134:                    if (obsoleteOffsets != null) {
135:                        /* Merge the other offsets into our list. */
136:                        if (obsoleteOffsets.merge(other.obsoleteOffsets)) {
137:                            /* There is one segment less as a result of the merge. */
138:                            updateMemoryBudget(-MemoryBudget.TFS_LIST_SEGMENT_OVERHEAD);
139:                        }
140:                    } else {
141:                        /* Adopt the other's offsets as our own. */
142:                        obsoleteOffsets = other.obsoleteOffsets;
143:                    }
144:                }
145:            }
146:
147:            /**
148:             * Returns obsolete offsets as an array of longs, or null if none.
149:             */
150:            public long[] getObsoleteOffsets() {
151:
152:                if (obsoleteOffsets != null) {
153:                    return obsoleteOffsets.toArray();
154:                } else {
155:                    return null;
156:                }
157:            }
158:
159:            /**
160:             * Returns whether the given offset is present in the tracked offsets.
161:             * This does not indicate whether the offset is obsolete in general, but
162:             * only if it is known to be obsolete in this version of the tracked
163:             * information.
164:             */
165:            boolean containsObsoleteOffset(long offset) {
166:
167:                if (obsoleteOffsets != null) {
168:                    return obsoleteOffsets.contains(offset);
169:                } else {
170:                    return false;
171:                }
172:            }
173:
174:            private void updateMemoryBudget(int delta) {
175:                memSize += delta;
176:                tracker.getEnvironment().getMemoryBudget()
177:                        .updateMiscMemoryUsage(delta);
178:            }
179:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.