1 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.io.FormatIdUtil; 27 import org.apache.derby.iapi.services.io.StoredFormatIds; 28 import org.apache.derby.iapi.services.sanity.SanityManager; 29 30 import org.apache.derby.iapi.store.raw.Compensation; 31 import org.apache.derby.iapi.store.raw.Loggable; 32 import org.apache.derby.iapi.store.raw.Page; 33 import org.apache.derby.iapi.store.raw.Transaction; 34 import org.apache.derby.iapi.store.raw.Undoable; 35 36 import org.apache.derby.iapi.store.raw.log.LogInstant; 37 38 import org.apache.derby.iapi.error.StandardException; 39 import org.apache.derby.iapi.util.ByteArray; 40 41 import java.io.OutputStream ; 42 import java.io.ObjectInput ; 43 import java.io.IOException ; 44 import org.apache.derby.iapi.services.io.LimitObjectInput; 45 46 47 65 public class PhysicalUndoOperation extends PageBasicOperation implements Compensation { 66 67 68 transient private PhysicalPageOperation undoOp; 69 70 protected PhysicalUndoOperation(BasePage page) 71 { 72 super(page); 73 } 74 75 76 public PhysicalUndoOperation(BasePage page, PhysicalPageOperation op) 77 { 78 super(page); 79 undoOp = op; 80 } 81 82 85 86 public PhysicalUndoOperation() { super(); } 88 89 public int getTypeFormatId() { 90 return StoredFormatIds.LOGOP_PAGE_PHYSICAL_UNDO; 91 } 92 93 95 98 99 100 public void setUndoOp(Undoable op) 101 { 102 if (SanityManager.DEBUG) { 103 SanityManager.ASSERT(op instanceof PhysicalPageOperation); 104 } 105 undoOp = (PhysicalPageOperation)op; 106 } 107 108 109 112 113 124 public final void doMe(Transaction xact, LogInstant instant, LimitObjectInput in) 125 throws StandardException, IOException 126 { 127 128 long oldversion = 0; LogInstant oldLogInstant = null; if (SanityManager.DEBUG) 131 { 132 oldLogInstant = this.page.getLastLogInstant(); 133 oldversion = this.page.getPageVersion(); 134 135 SanityManager.ASSERT(oldversion == this.getPageVersion()); 136 SanityManager.ASSERT(oldLogInstant == null || instant == null 137 || oldLogInstant.lessThan(instant)); 138 } 139 140 undoOp.undoMe(xact, this.page, instant, in); 148 149 if (SanityManager.DEBUG) { 150 151 if (oldversion >= this.page.getPageVersion()) 152 { 153 SanityManager.THROWASSERT( 154 "oldversion = " + oldversion + 155 ";page version = " + this.page.getPageVersion() + 156 "page = " + page + 157 "; my class name is " + getClass().getName() + 158 " undoOp is " + undoOp.getClass().getName() ); 159 } 160 SanityManager.ASSERT( 161 oldversion < this.page.getPageVersion()); 162 163 if (instant != null && 164 ! instant.equals(this.page.getLastLogInstant())) 165 SanityManager.THROWASSERT( 166 "my class name is " + getClass().getName() + 167 " undoOp is " + undoOp.getClass().getName() ); 168 } 169 170 releaseResource(xact); 171 } 172 173 174 public void releaseResource(Transaction xact) 175 { 176 if (undoOp != null) 177 undoOp.releaseResource(xact); 178 super.releaseResource(xact); 179 } 180 181 182 public int group() 183 { 184 return super.group() | Loggable.COMPENSATION | Loggable.RAWSTORE; 185 } 186 187 public final ByteArray getPreparedLog() { 188 return (ByteArray) null; 194 } 195 196 public void restoreMe(Transaction xact, BasePage undoPage, 197 LogInstant CLRinstant, LimitObjectInput in) 198 { 199 if (SanityManager.DEBUG) 201 SanityManager.THROWASSERT("cannot call restore me on PhysicalUndoOperation"); 202 } 203 204 207 public String toString() 208 { 209 if (SanityManager.DEBUG) 210 { 211 String str = "CLR (Physical Undo): " + super.toString(); 212 if (undoOp != null) 213 str += "\n" + undoOp.toString(); 214 else 215 str += "undo Operation not set"; 216 217 return str; 218 } 219 else 220 return null; 221 } 222 223 } 224 | Popular Tags |