KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2
3    Derby - Class org.apache.derby.impl.store.raw.data.PhysicalPageOperation
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.store.raw.Compensation;
27
28 import org.apache.derby.iapi.store.raw.log.LogInstant;
29
30 import org.apache.derby.iapi.store.raw.Transaction;
31 import org.apache.derby.iapi.store.raw.Undoable;
32
33 import org.apache.derby.iapi.error.StandardException;
34
35 import java.io.InputStream JavaDoc;
36 import java.io.ObjectInput JavaDoc;
37 import java.io.IOException JavaDoc;
38 import org.apache.derby.iapi.services.io.LimitObjectInput;
39
40 /**
41     An abstract class that is used for physical log operation. A physical log
42     operation is one where the undo of the operation must be applied to the
43     same page as the original operation, and the undo operation must store the
44     byte image of the row(s) changed to its before image. (If a logical page
45     operation happened to the page or if another transaction altered other rows
46     on the page, the undo of this operation will only restore the before image
47     of the row(s) affected).
48
49     <PRE>
50     @format_id no format id, an abstract class.
51     @purpose provide methods for physical undo
52     @upgrade
53     @disk_layout
54         PageBasicOperation the super class
55     @end_format
56     </PRE>
57 */

58
59 public abstract class PhysicalPageOperation extends PageBasicOperation implements Undoable
60 {
61     protected PhysicalPageOperation(BasePage page)
62     {
63         super(page);
64     }
65
66     /*
67      * Formatable methods
68      */

69
70     // no-arg constructor, required by Formatable
71
public PhysicalPageOperation() { super(); }
72
73     // no fields, therefore no writeExternal or readExternal
74

75     /**
76         Undoable method
77     */

78
79     /**
80       Generate a Compensation (PageUndoOperation) that will rollback the
81       changes of this page operation. If this Page operation cannot or need not
82       be rolled back (redo only), overwrite this function to return null.
83
84       <P><B>Note</B><BR> For operation that needs logical undo, use
85       LogicalUndoOperation instead</B> This implementation just finds
86       the same page that the PageOperation was applied on - i.e., only works
87       for undo on the same page.
88
89       <P>During recovery redo, the logging system is page oriented and will use
90       the pageID stored in the PageUndoOperation to find the page. The
91       page will be latched and released using the default findpage and
92       releaseResource - this.releaseResource() will still be called so it has
93       to know not to release any resource it did not acquire.
94
95       @param xact the transaction doing the compensating
96       @param in optional input
97
98       @return the compensation operation that will rollback this change
99
100       @exception StandardException Standard Cloudscape policy.
101
102       @see PageBasicOperation
103       @see Undoable#generateUndo
104       
105     */

106     public Compensation generateUndo(Transaction xact, LimitObjectInput in)
107          throws StandardException
108     {
109         // findpage will have the page latched.
110
// CompensationOperation.doMe must call this.releaseResource the page
111
// when it is done
112
BasePage undoPage = findpage(xact);
113
114         // Needs to pre-dirty this page so that if a checkpoint is taken any
115
// time after the CLR is sent to the log stream, it will wait for the
116
// actual undo to happen on the page. We need this to preserve the
117
// integrity of the redoLWM.
118
undoPage.preDirty();
119
120         return new PhysicalUndoOperation(undoPage, this);
121     }
122
123
124     /**
125         Undo the change indicated by this log operation and optional data.
126         The page the undo should apply to is the latched undoPage, the
127         recordId is the same as the roll forward operation.
128         
129         <BR><B>In this RawStore implementation, should only only be called via
130         CompOp.doMe</B>.
131
132         <P> The available() method of in indicates how much data can be read, i.e.
133         how much was originally written.
134
135         @param xact the Transaction doing the rollback
136         @param undoPage the page to rollback changes on
137         @param CLRinstant the log instant of this (PageUndo) operation
138         @param in optional data for the rollback operation
139
140         @exception IOException Can be thrown by any of the methods of ObjectInput.
141         @exception StandardException Standard Cloudscape policy.
142     */

143     abstract public void undoMe(Transaction xact, BasePage undoPage,
144                                    LogInstant CLRinstant, LimitObjectInput in)
145          throws StandardException, IOException JavaDoc;
146
147
148 }
149
150
Popular Tags