KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > store > raw > data > InvalidatePageOperation


1 /*
2
3    Derby - Class org.apache.derby.impl.store.raw.data.InvalidatePageOperation
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.impl.store.raw.data;
23
24 import org.apache.derby.impl.store.raw.data.BasePage;
25
26 import org.apache.derby.iapi.services.sanity.SanityManager;
27 import org.apache.derby.iapi.services.io.FormatIdUtil;
28 import org.apache.derby.iapi.services.io.StoredFormatIds;
29
30 import org.apache.derby.iapi.error.StandardException;
31
32 import org.apache.derby.iapi.store.raw.Page;
33 import org.apache.derby.iapi.store.raw.Transaction;
34
35 import org.apache.derby.iapi.store.raw.log.LogInstant;
36
37 import java.io.OutputStream JavaDoc;
38 import java.io.ObjectOutput JavaDoc;
39 import java.io.ObjectInput JavaDoc;
40 import java.io.IOException JavaDoc;
41 import org.apache.derby.iapi.services.io.LimitObjectInput;
42
43 /**
44     Represents invalidating a page due to deallocation.
45     This operation invalidates the page that is being deallocated, as opposed
46     to deallocatePage that happens on the alloc page.
47
48     <PRE>
49     @format_id LOGOP_INVALIDATE_PAGE
50         the formatId is written by FormatIdOutputStream when this object is
51         written out by writeObject
52     @purpose invalidate a page
53     @upgrade
54     @disk_layout
55         PhysicalPageOperation the superclass
56         OptionalData none
57     @end_format
58     </PRE>
59 */

60 public final class InvalidatePageOperation extends PhysicalPageOperation
61 {
62     public InvalidatePageOperation(BasePage page)
63     {
64         super(page);
65     }
66
67     /*
68      * Formatable methods
69      */

70
71     // no-arg constructor, required by Formatable
72
public InvalidatePageOperation() { super(); }
73
74
75     /*
76      * If this page can be reused in the same transaction (of if committed
77      * transaction needs to be undone, then we need the before image of the
78      * page. Right now, the transaction that deallocate a page must commit
79      * before the page can be freed and reused, so we don't need to log the
80      * before image of the page
81      */

82     public void writeExternal(ObjectOutput JavaDoc out) throws IOException JavaDoc
83     {
84         // RESOLVE: may need to write out the page BI, see comment above
85
super.writeExternal(out);
86     }
87
88     /**
89         Read this in
90         @exception IOException error reading from log stream
91         @exception ClassNotFoundException log stream corrupted
92     */

93     public void readExternal(ObjectInput JavaDoc in)
94          throws IOException JavaDoc, ClassNotFoundException JavaDoc
95     {
96         super.readExternal(in);
97     }
98
99     /**
100         Return my format identifier.
101     */

102     public int getTypeFormatId() {
103         return StoredFormatIds.LOGOP_INVALIDATE_PAGE;
104     }
105
106     /*
107      * Loggable methods
108      */

109     /**
110         Mark the page as being invalidated
111
112         @exception IOException Can be thrown by any of the methods of ObjectInput.
113         @exception StandardException Standard Cloudscape policy.
114
115         @see org.apache.derby.iapi.store.raw.Loggable#doMe
116     */

117     public void doMe(Transaction xact, LogInstant instant, LimitObjectInput in)
118          throws StandardException, IOException JavaDoc
119     {
120         this.page.setPageStatus(instant, BasePage.INVALID_PAGE);
121     }
122
123     /*
124      * PhysicalPageOperation
125      */

126
127     /**
128         Mark the page as being valid
129
130         @exception StandardException Thrown by methods I call
131         @exception IOException Thrown by methods I call
132
133         @see PhysicalPageOperation#undoMe
134     */

135     public void undoMe(Transaction xact, BasePage undoPage, LogInstant CLRInstant,
136                        LimitObjectInput in)
137          throws StandardException, IOException JavaDoc
138     {
139         undoPage.setPageStatus(CLRInstant, BasePage.VALID_PAGE);
140     }
141
142
143     /*
144      * PageBasicOperation
145      */

146
147     /**
148      * restore the before image of the page
149      *
150      * @exception StandardException Standard Cloudscape Error Policy
151      * @exception IOException problem reading the complete log record from the
152      * input stream
153      */

154     public void restoreMe(Transaction xact, BasePage undoPage,
155                        LogInstant CLRInstant, LimitObjectInput in)
156          throws StandardException, IOException JavaDoc
157     {
158         undoMe(xact, undoPage, CLRInstant, in);
159     }
160
161     public String JavaDoc toString()
162     {
163         if (SanityManager.DEBUG)
164             return super.toString() + "Invalidate Page - it has been deallocated";
165         else
166             return null;
167     }
168
169 }
170
Popular Tags