Source Code Cross Referenced for LNFileReader.java in  » JMX » je » com » sleepycat » je » log » 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.log 
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: LNFileReader.java,v 1.59.2.5 2008/01/07 15:14:13 cwl Exp $
007:         */
008:
009:        package com.sleepycat.je.log;
010:
011:        import java.io.IOException;
012:        import java.nio.ByteBuffer;
013:        import java.util.HashMap;
014:        import java.util.Map;
015:
016:        import javax.transaction.xa.Xid;
017:
018:        import com.sleepycat.je.DatabaseException;
019:        import com.sleepycat.je.dbi.DatabaseId;
020:        import com.sleepycat.je.dbi.EnvironmentImpl;
021:        import com.sleepycat.je.log.entry.LNLogEntry;
022:        import com.sleepycat.je.log.entry.LogEntry;
023:        import com.sleepycat.je.tree.LN;
024:        import com.sleepycat.je.txn.TxnAbort;
025:        import com.sleepycat.je.txn.TxnCommit;
026:        import com.sleepycat.je.txn.TxnPrepare;
027:
028:        /**
029:         * LNFileReader scans log files for LNs. Also, if it's going backwards for the
030:         * undo phase in recovery, it reads transaction commit entries.
031:         */
032:        public class LNFileReader extends FileReader {
033:
034:            /*
035:             * targetEntryMap maps DbLogEntryTypes to log entries. We use this
036:             * collection to find the right LogEntry instance to read in the current
037:             * entry.
038:             */
039:            protected Map targetEntryMap;
040:            protected LogEntry targetLogEntry;
041:
042:            /**
043:             * Create this reader to start at a given LSN.
044:             * @param env The relevant EnvironmentImpl
045:             * @param readBufferSize buffer size in bytes for reading in log
046:             * @param startLsn where to start in the log
047:             * @param redo If true, we're going to go forward from
048:             *             the start LSN to the end of the log. If false, we're going
049:             *             backwards from the end of the log to the start LSN.
050:             * @param finishLsn the last LSN to read in the log.  May be null if we
051:             *  want to read to the end of the log.
052:             * @param endOfFileLsn the virtual LSN that marks the end of the log. (The
053:             *  one off the end of the log). Only used if we're reading backwards.
054:             *  Different from the startLsn because the startLsn tells us where the
055:             *  beginning of the start entry is, but not the length/end of the start
056:             *  entry. May be null if we're going foward.
057:             */
058:            public LNFileReader(EnvironmentImpl env, int readBufferSize,
059:                    long startLsn, boolean redo, long endOfFileLsn,
060:                    long finishLsn, Long singleFileNum) throws IOException,
061:                    DatabaseException {
062:
063:                super (env, readBufferSize, redo, startLsn, singleFileNum,
064:                        endOfFileLsn, finishLsn);
065:
066:                targetEntryMap = new HashMap();
067:            }
068:
069:            public void addTargetType(LogEntryType entryType)
070:                    throws DatabaseException {
071:
072:                targetEntryMap.put(entryType, entryType.getNewLogEntry());
073:            }
074:
075:            /**
076:             * @return true if this is a transactional LN or Locker Commit entry.
077:             */
078:            protected boolean isTargetEntry(byte entryTypeNum,
079:                    byte entryTypeVersion) {
080:
081:                if (LogEntryType.isEntryProvisional(entryTypeVersion)) {
082:                    /* Skip provisionial entries */
083:                    targetLogEntry = null;
084:                } else {
085:                    LogEntryType fromLogType = new LogEntryType(entryTypeNum,
086:                            entryTypeVersion);
087:
088:                    /* Is it a target entry? */
089:                    targetLogEntry = (LogEntry) targetEntryMap.get(fromLogType);
090:                }
091:                return (targetLogEntry != null);
092:            }
093:
094:            /**
095:             * This reader instantiates an LN and key for every LN entry.
096:             */
097:            protected boolean processEntry(ByteBuffer entryBuffer)
098:                    throws DatabaseException {
099:
100:                readEntry(targetLogEntry, entryBuffer, true); // readFullItem
101:                return true;
102:            }
103:
104:            /**
105:             * @return true if the last entry was an LN.
106:             */
107:            public boolean isLN() {
108:                return (targetLogEntry instanceof  LNLogEntry);
109:            }
110:
111:            /**
112:             * Get the last LN seen by the reader.
113:             */
114:            public LN getLN() {
115:                return ((LNLogEntry) targetLogEntry).getLN();
116:            }
117:
118:            /**
119:             * Get the last databaseId seen by the reader.
120:             */
121:            public DatabaseId getDatabaseId() {
122:                return ((LNLogEntry) targetLogEntry).getDbId();
123:            }
124:
125:            /**
126:             * Get the last key seen by the reader.
127:             */
128:            public byte[] getKey() {
129:                return ((LNLogEntry) targetLogEntry).getKey();
130:            }
131:
132:            /**
133:             * Get the last key seen by the reader.
134:             */
135:            public byte[] getDupTreeKey() {
136:                return ((LNLogEntry) targetLogEntry).getDupKey();
137:            }
138:
139:            /**
140:             * @return the transaction id of the current entry.
141:             */
142:            public Long getTxnId() {
143:                return ((LNLogEntry) targetLogEntry).getTxnId();
144:            }
145:
146:            /*
147:             * @return true if the last entry was a TxnPrepare record.
148:             */
149:            public boolean isPrepare() {
150:                return (targetLogEntry.getMainItem() instanceof  TxnPrepare);
151:            }
152:
153:            /**
154:             * Get the last txn prepare id seen by the reader.
155:             */
156:            public long getTxnPrepareId() {
157:                return ((TxnPrepare) targetLogEntry.getMainItem()).getId();
158:            }
159:
160:            /**
161:             * Get the last txn prepare Xid seen by the reader.
162:             */
163:            public Xid getTxnPrepareXid() {
164:                return ((TxnPrepare) targetLogEntry.getMainItem()).getXid();
165:            }
166:
167:            /*
168:             * @return true if the last entry was a TxnAbort record.
169:             */
170:            public boolean isAbort() {
171:                return (targetLogEntry.getMainItem() instanceof  TxnAbort);
172:            }
173:
174:            /**
175:             * Get the last txn abort id seen by the reader.
176:             */
177:            public long getTxnAbortId() {
178:                return ((TxnAbort) targetLogEntry.getMainItem()).getId();
179:            }
180:
181:            /**
182:             * Get the last txn commit id seen by the reader.
183:             */
184:            public long getTxnCommitId() {
185:                return ((TxnCommit) targetLogEntry.getMainItem()).getId();
186:            }
187:
188:            /**
189:             * Get node id of current LN.
190:             */
191:            public long getNodeId() {
192:                return ((LNLogEntry) targetLogEntry).getLN().getNodeId();
193:            }
194:
195:            /**
196:             * Get last abort LSN seen by the reader (may be null).
197:             */
198:            public long getAbortLsn() {
199:                return ((LNLogEntry) targetLogEntry).getAbortLsn();
200:            }
201:
202:            /**
203:             * Get last abort known deleted seen by the reader.
204:             */
205:            public boolean getAbortKnownDeleted() {
206:                return ((LNLogEntry) targetLogEntry).getAbortKnownDeleted();
207:            }
208:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.