Source Code Cross Referenced for InitPageOperation.java in  » Database-DBMS » db-derby-10.2 » org » apache » derby » impl » store » raw » data » 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 » db derby 10.2 » org.apache.derby.impl.store.raw.data 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:           Derby - Class org.apache.derby.impl.store.raw.data.InitPageOperation
004:
005:           Licensed to the Apache Software Foundation (ASF) under one or more
006:           contributor license agreements.  See the NOTICE file distributed with
007:           this work for additional information regarding copyright ownership.
008:           The ASF licenses this file to you under the Apache License, Version 2.0
009:           (the "License"); you may not use this file except in compliance with
010:           the License.  You may obtain a copy of the License at
011:
012:              http://www.apache.org/licenses/LICENSE-2.0
013:
014:           Unless required by applicable law or agreed to in writing, software
015:           distributed under the License is distributed on an "AS IS" BASIS,
016:           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017:           See the License for the specific language governing permissions and
018:           limitations under the License.
019:
020:         */
021:
022:        package org.apache.derby.impl.store.raw.data;
023:
024:        import org.apache.derby.impl.store.raw.data.BasePage;
025:
026:        import org.apache.derby.iapi.services.sanity.SanityManager;
027:        import org.apache.derby.iapi.services.io.FormatIdUtil;
028:        import org.apache.derby.iapi.services.io.StoredFormatIds;
029:
030:        import org.apache.derby.iapi.error.StandardException;
031:
032:        import org.apache.derby.iapi.store.raw.RecordHandle;
033:        import org.apache.derby.iapi.store.raw.Page;
034:        import org.apache.derby.iapi.store.raw.Transaction;
035:
036:        import org.apache.derby.iapi.store.raw.log.LogInstant;
037:
038:        import org.apache.derby.iapi.services.io.CompressedNumber;
039:
040:        import java.io.OutputStream;
041:        import java.io.ObjectOutput;
042:        import java.io.ObjectInput;
043:        import java.io.IOException;
044:        import org.apache.derby.iapi.services.io.LimitObjectInput;
045:
046:        /**
047:         This operation initializes the page that is being allocated,
048:         this operation does not change the alloc page information.
049:
050:         <PRE>
051:         @format_id	LOGOP_INIT_PAGE
052:         the formatId is written by FormatIdOutputStream when this object is
053:         written out by writeObject
054:         @purpose	initialized a page
055:         @upgrade
056:         @disk_layout
057:         PhysicalPageOperation the superclass
058:         nextRecordId(CompressedInt)	the next recordId this page should give out
059:         initFlag(CompressedInt)		initialization flag: reuse, overflow
060:         pageformat(int)				the page's formatId
061:
062:         OptionalData	none
063:         @end_format
064:         </PRE>
065:         */
066:        public final class InitPageOperation extends PhysicalPageOperation {
067:            protected int nextRecordId; // next recordId
068:            protected int initFlag;
069:            protected int pageFormatId;
070:            protected long pageOffset;
071:
072:            protected boolean reuse; // is this page being initialize for reuse, or for first time
073:            protected boolean overflowPage; // is this page an overflow page
074:
075:            public InitPageOperation(BasePage page, int flag, int formatid,
076:                    long offset) throws StandardException {
077:                super (page);
078:
079:                initFlag = flag;
080:                pageFormatId = formatid;
081:                pageOffset = offset;
082:
083:                // unless we specified recordId should be reusable, when we reuse a
084:                // page, we keep incrementing the existing recordId
085:                if ((initFlag & BasePage.INIT_PAGE_REUSE_RECORDID) == 0)
086:                    nextRecordId = page.newRecordId();
087:                else
088:                    nextRecordId = RecordHandle.FIRST_RECORD_ID;
089:            }
090:
091:            /*
092:             * Formatable methods
093:             */
094:
095:            // no-arg constructor, required by Formatable 
096:            public InitPageOperation() {
097:                super ();
098:            }
099:
100:            /**
101:            	Write this out.
102:            	@exception IOException error writing to log stream
103:             */
104:            public void writeExternal(ObjectOutput out) throws IOException {
105:                super .writeExternal(out);
106:                CompressedNumber.writeInt(out, nextRecordId);
107:                CompressedNumber.writeInt(out, initFlag);
108:                CompressedNumber.writeLong(out, pageOffset);
109:                out.writeInt(pageFormatId);
110:            }
111:
112:            /**
113:            	Read this in
114:            	@exception IOException error reading from log stream
115:            	@exception ClassNotFoundException log stream corrupted
116:             */
117:            public void readExternal(ObjectInput in) throws IOException,
118:                    ClassNotFoundException {
119:                super .readExternal(in);
120:                nextRecordId = CompressedNumber.readInt(in);
121:                initFlag = CompressedNumber.readInt(in);
122:                pageOffset = CompressedNumber.readLong(in);
123:                pageFormatId = in.readInt();
124:            }
125:
126:            /**
127:            	Return my format identifier.
128:             */
129:            public int getTypeFormatId() {
130:                return StoredFormatIds.LOGOP_INIT_PAGE;
131:            }
132:
133:            /*
134:             * Loggable methods
135:             */
136:            /**
137:            	Mark the page as valid, and clear out any crud from the page
138:
139:            	@exception IOException Can be thrown by any of the methods of ObjectInput.
140:            	@exception StandardException Standard Cloudscape policy.
141:
142:            	@see org.apache.derby.iapi.store.raw.Loggable#doMe
143:             */
144:            public void doMe(Transaction xact, LogInstant instant,
145:                    LimitObjectInput in) throws StandardException, IOException {
146:                boolean overflowPage = ((initFlag & BasePage.INIT_PAGE_OVERFLOW) != 0);
147:                boolean reuse = ((initFlag & BasePage.INIT_PAGE_REUSE) != 0);
148:
149:                this .page.initPage(instant, BasePage.VALID_PAGE, nextRecordId,
150:                        overflowPage, reuse);
151:            }
152:
153:            /*
154:             * Override PageBasicOperation's getPageForRedoRecovery
155:             */
156:            /**
157:            	If we are in load tran, this page may not exist for the container yet.
158:            	We need to create it first.
159:
160:            	This routine is called as the last resort of find page, the container
161:            	handle has already been found and it is not dropped.
162:
163:            	@exception StandardException Standard Cloudscape policy.
164:             */
165:            protected BasePage getPageForRedoRecovery(Transaction xact)
166:                    throws StandardException {
167:                BasePage p = super .getPageForRedoRecovery(xact);
168:                if (p != null)
169:                    return p;
170:
171:                // create the page
172:                // RESOLVE: we need the page format to properly recreate an Alloc page
173:                // NEED TO UPGRADE this log record.
174:                p = (BasePage) containerHdl.reCreatePageForRedoRecovery(
175:                        pageFormatId, getPageId().getPageNumber(), pageOffset);
176:                return p;
177:            }
178:
179:            /*
180:             * PhysicalPageOperation method
181:             */
182:
183:            /**
184:            	Mark the page as free
185:
186:            	@exception StandardException Thrown by methods I call
187:            	@exception IOException Thrown by methods I call
188:
189:            	@see PhysicalPageOperation#undoMe
190:             */
191:            public void undoMe(Transaction xact, BasePage undoPage,
192:                    LogInstant CLRInstant, LimitObjectInput in)
193:                    throws StandardException, IOException {
194:                undoPage.setPageStatus(CLRInstant, BasePage.INVALID_PAGE);
195:                // only set the page to invalid, cannot wipe out the page to zero's
196:                // becuase recovery may need to redo some operations that depend on the
197:                // content of the page.
198:
199:                undoPage.setAuxObject(null);
200:            }
201:
202:            /*
203:             * PageBasicOperation methods
204:             */
205:
206:            /** 
207:             * restore the before image of the page
208:             *
209:             * @exception StandardException Standard Cloudscape Error Policy
210:             * @exception IOException problem reading the complete log record from the
211:             * input stream
212:             */
213:            public void restoreMe(Transaction xact, BasePage undoPage,
214:                    LogInstant CLRInstant, LimitObjectInput in)
215:                    throws StandardException, IOException {
216:                undoMe(xact, undoPage, CLRInstant, in);
217:            }
218:
219:            public String toString() {
220:                if (SanityManager.DEBUG) {
221:                    boolean overflowPage = ((initFlag & BasePage.INIT_PAGE_OVERFLOW) != 0);
222:                    boolean reuse = ((initFlag & BasePage.INIT_PAGE_REUSE) != 0);
223:
224:                    return super .toString() + "Init Page.  Overflow = "
225:                            + overflowPage + " reuse " + reuse
226:                            + " nextRecordId " + nextRecordId;
227:                } else
228:                    return null;
229:            }
230:
231:        }
w_w__w_.__j_ava_2_s.__c__o_m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.