--- /dev/null
+/*\r
+\r
+ Derby - Class org.apache.derby.impl.store.raw.data.InvalidatePageOperation\r
+\r
+ Licensed to the Apache Software Foundation (ASF) under one or more\r
+ contributor license agreements. See the NOTICE file distributed with\r
+ this work for additional information regarding copyright ownership.\r
+ The ASF licenses this file to you under the Apache License, Version 2.0\r
+ (the "License"); you may not use this file except in compliance with\r
+ the License. You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+\r
+ */\r
+\r
+package org.apache.derby.impl.store.raw.data;\r
+\r
+import org.apache.derby.impl.store.raw.data.BasePage;\r
+\r
+import org.apache.derby.iapi.services.sanity.SanityManager;\r
+import org.apache.derby.iapi.services.io.FormatIdUtil;\r
+import org.apache.derby.iapi.services.io.StoredFormatIds;\r
+\r
+import org.apache.derby.iapi.error.StandardException;\r
+\r
+import org.apache.derby.iapi.store.raw.Page;\r
+import org.apache.derby.iapi.store.raw.Transaction;\r
+\r
+import org.apache.derby.iapi.store.raw.log.LogInstant;\r
+\r
+import java.io.OutputStream;\r
+import java.io.ObjectOutput;\r
+import java.io.ObjectInput;\r
+import java.io.IOException;\r
+import org.apache.derby.iapi.services.io.LimitObjectInput;\r
+\r
+/**\r
+ Represents invalidating a page due to deallocation. \r
+ This operation invalidates the page that is being deallocated, as opposed\r
+ to deallocatePage that happens on the alloc page.\r
+\r
+ <PRE>\r
+ @format_id LOGOP_INVALIDATE_PAGE\r
+ the formatId is written by FormatIdOutputStream when this object is\r
+ written out by writeObject\r
+ @purpose invalidate a page\r
+ @upgrade\r
+ @disk_layout\r
+ PhysicalPageOperation the superclass\r
+ OptionalData none\r
+ @end_format\r
+ </PRE>\r
+*/\r
+public final class InvalidatePageOperation extends PhysicalPageOperation\r
+{\r
+ public InvalidatePageOperation(BasePage page)\r
+ {\r
+ super(page);\r
+ }\r
+\r
+ /*\r
+ * Formatable methods\r
+ */\r
+\r
+ // no-arg constructor, required by Formatable \r
+ public InvalidatePageOperation() { super(); }\r
+\r
+\r
+ /*\r
+ * If this page can be reused in the same transaction (of if committed\r
+ * transaction needs to be undone, then we need the before image of the\r
+ * page. Right now, the transaction that deallocate a page must commit\r
+ * before the page can be freed and reused, so we don't need to log the \r
+ * before image of the page\r
+ */\r
+ public void writeExternal(ObjectOutput out) throws IOException \r
+ {\r
+ // RESOLVE: may need to write out the page BI, see comment above\r
+ super.writeExternal(out);\r
+ }\r
+\r
+ /**\r
+ Read this in\r
+ @exception IOException error reading from log stream\r
+ @exception ClassNotFoundException log stream corrupted\r
+ */\r
+ public void readExternal(ObjectInput in)\r
+ throws IOException, ClassNotFoundException\r
+ {\r
+ super.readExternal(in);\r
+ }\r
+\r
+ /**\r
+ Return my format identifier.\r
+ */\r
+ public int getTypeFormatId() {\r
+ return StoredFormatIds.LOGOP_INVALIDATE_PAGE;\r
+ }\r
+\r
+ /*\r
+ * Loggable methods\r
+ */\r
+ /**\r
+ Mark the page as being invalidated\r
+\r
+ @exception IOException Can be thrown by any of the methods of ObjectInput.\r
+ @exception StandardException Standard Derby policy.\r
+\r
+ @see org.apache.derby.iapi.store.raw.Loggable#doMe\r
+ */\r
+ public void doMe(Transaction xact, LogInstant instant, LimitObjectInput in)\r
+ throws StandardException, IOException \r
+ {\r
+ this.page.setPageStatus(instant, BasePage.INVALID_PAGE);\r
+ }\r
+\r
+ /*\r
+ * PhysicalPageOperation\r
+ */\r
+\r
+ /**\r
+ Mark the page as being valid\r
+\r
+ @exception StandardException Thrown by methods I call\r
+ @exception IOException Thrown by methods I call\r
+\r
+ @see PhysicalPageOperation#undoMe\r
+ */\r
+ public void undoMe(Transaction xact, BasePage undoPage, LogInstant CLRInstant, \r
+ LimitObjectInput in)\r
+ throws StandardException, IOException \r
+ {\r
+ undoPage.setPageStatus(CLRInstant, BasePage.VALID_PAGE);\r
+ }\r
+\r
+\r
+ /*\r
+ * PageBasicOperation\r
+ */\r
+\r
+ /**\r
+ * restore the before image of the page\r
+ *\r
+ * @exception StandardException Standard Derby Error Policy\r
+ * @exception IOException problem reading the complete log record from the\r
+ * input stream\r
+ */\r
+ public void restoreMe(Transaction xact, BasePage undoPage,\r
+ LogInstant CLRInstant, LimitObjectInput in)\r
+ throws StandardException, IOException \r
+ {\r
+ undoMe(xact, undoPage, CLRInstant, in);\r
+ }\r
+\r
+ public String toString()\r
+ {\r
+ if (SanityManager.DEBUG)\r
+ return super.toString() + "Invalidate Page - it has been deallocated";\r
+ else\r
+ return null;\r
+ }\r
+\r
+}\r