1 21 22 package org.apache.derby.impl.store.raw.data; 23 24 import org.apache.derby.impl.store.raw.data.PhysicalPageOperation; 25 import org.apache.derby.impl.store.raw.data.BasePage; 26 27 import org.apache.derby.iapi.services.io.FormatIdUtil; 28 import org.apache.derby.iapi.services.io.StoredFormatIds; 29 import org.apache.derby.iapi.services.sanity.SanityManager; 30 31 import org.apache.derby.iapi.error.StandardException; 32 import org.apache.derby.iapi.store.raw.data.RawContainerHandle; 33 import org.apache.derby.iapi.store.raw.Transaction; 34 import org.apache.derby.iapi.store.raw.log.LogInstant; 35 36 import org.apache.derby.iapi.services.io.CompressedNumber; 37 38 import java.io.OutputStream ; 39 import java.io.ObjectOutput ; 40 import java.io.ObjectInput ; 41 import java.io.IOException ; 42 import org.apache.derby.iapi.services.io.LimitObjectInput; 43 44 45 public final class AllocPageOperation extends PhysicalPageOperation 47 { 48 49 protected long newPageNumber; protected int doStatus; protected int undoStatus; 53 public AllocPageOperation(AllocPage allocPage, long pageNumber, int doStatus, int undoStatus) 54 throws StandardException 55 { 56 super(allocPage); 57 58 newPageNumber = pageNumber; 59 this.doStatus = doStatus; 60 this.undoStatus = undoStatus; 61 } 62 63 66 67 public AllocPageOperation() { super(); } 69 70 public void writeExternal(ObjectOutput out) throws IOException 71 { 72 super.writeExternal(out); 73 CompressedNumber.writeLong(out, newPageNumber); 74 CompressedNumber.writeInt(out, doStatus); 75 CompressedNumber.writeInt(out, undoStatus); 76 } 77 78 82 public void readExternal(ObjectInput in) 83 throws IOException , ClassNotFoundException 84 { 85 super.readExternal(in); 86 newPageNumber = CompressedNumber.readLong(in); 87 doStatus = CompressedNumber.readInt(in); 88 undoStatus = CompressedNumber.readInt(in); 89 } 90 91 94 public int getTypeFormatId() { 95 return StoredFormatIds.LOGOP_ALLOC_PAGE; 96 } 97 98 101 105 public final void doMe(Transaction tran, LogInstant instant, LimitObjectInput in) 106 throws StandardException 107 { 108 if (SanityManager.DEBUG) { 109 SanityManager.ASSERT(this.page instanceof AllocPage); 110 } 111 112 ((AllocPage)page).setPageStatus(instant, newPageNumber, doStatus); 113 } 114 115 118 119 126 public void undoMe(Transaction xact, BasePage undoPage, LogInstant CLRInstant, 127 LimitObjectInput in) 128 throws StandardException 129 { 130 if (SanityManager.DEBUG) { 131 SanityManager.ASSERT(undoPage != null, "undo Page null"); 132 SanityManager.ASSERT(undoPage instanceof AllocPage, 133 "undo Page is not an allocPage"); 134 } 135 136 ((AllocPage)undoPage).setPageStatus(CLRInstant, newPageNumber, undoStatus); 142 } 143 144 147 public void restoreMe(Transaction xact, BasePage undoPage, LogInstant CLRinstant, LimitObjectInput in) 148 { 149 if (SanityManager.DEBUG) 152 SanityManager.THROWASSERT("cannot call restoreMe on BI_AllocPageOperation"); 153 } 154 155 156 157 public String toString() 158 { 159 if (SanityManager.DEBUG) 160 { 161 String str = super.toString(); 162 str += " Change page allocation status of " + newPageNumber + 163 " to " + doStatus + "(undo " + undoStatus + ")"; 164 return str; 165 } 166 else 167 return null; 168 } 169 170 } 171 172 | Popular Tags |