001: /*
002:
003: Derby - Class org.apache.derby.impl.store.raw.data.LoggableAllocActions
004:
005: Licensed to the Apache Software Foundation (ASF) under one or more
006: contributor license agreements. See the NOTICE file distributed with
007: this work for additional information regarding copyright ownership.
008: The ASF licenses this file to you under the Apache License, Version 2.0
009: (the "License"); you may not use this file except in compliance with
010: the License. You may obtain a copy of the License at
011:
012: http://www.apache.org/licenses/LICENSE-2.0
013:
014: Unless required by applicable law or agreed to in writing, software
015: distributed under the License is distributed on an "AS IS" BASIS,
016: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: See the License for the specific language governing permissions and
018: limitations under the License.
019:
020: */
021:
022: package org.apache.derby.impl.store.raw.data;
023:
024: import org.apache.derby.impl.store.raw.data.AllocationActions;
025: import org.apache.derby.impl.store.raw.data.BasePage;
026:
027: import org.apache.derby.iapi.services.sanity.SanityManager;
028: import org.apache.derby.iapi.services.io.FormatIdUtil;
029:
030: import org.apache.derby.iapi.store.raw.Loggable;
031: import org.apache.derby.iapi.store.raw.xact.RawTransaction;
032: import org.apache.derby.iapi.store.raw.log.LogInstant;
033:
034: import org.apache.derby.iapi.error.StandardException;
035:
036: public class LoggableAllocActions implements AllocationActions {
037:
038: /**
039: Set the allocation status of pageNumber to doStatus. To undo this
040: operation, set the allocation status of pageNumber to undoStatus
041:
042: @param t The transaction
043: @param allocPage the allocation page
044: @param pageNumber the page to allocation or deallocation
045: @param doStatus set the allocation status of the page this value
046: @param undoStatus on undo, set the allocation status of the page
047: this value
048:
049: @exception StandardException Standard Cloudscape error policy
050: */
051: public void actionAllocatePage(RawTransaction t,
052: BasePage allocPage, long pageNumber, int doStatus,
053: int undoStatus) throws StandardException {
054: Loggable lop = new AllocPageOperation((AllocPage) allocPage,
055: pageNumber, doStatus, undoStatus);
056:
057: // mark the page as pre-dirtied so that if a checkpoint happens after
058: // the log record is sent to the log stream, the cache cleaning will
059: // wait for this change.
060: allocPage.preDirty();
061:
062: t.logAndDo(lop);
063: }
064:
065: /**
066: Chain one allocation page to the next.
067:
068: @param t The transaction
069: @param allocPage the allocation page whose next page chain needs
070: to be changed
071: @param pageNumber the next allocation page's number
072: @param pageOffset the next allocation page's page offset
073:
074: @exception StandardException Standard Cloudscape error policy
075: */
076: public void actionChainAllocPage(RawTransaction t,
077: BasePage allocPage, long pageNumber, long pageOffset)
078: throws StandardException {
079: Loggable lop = new ChainAllocPageOperation(
080: (AllocPage) allocPage, pageNumber, pageOffset);
081:
082: // mark the page as pre-dirtied so that if a checkpoint happens after
083: // the log record is sent to the log stream, the cache cleaning will
084: // wait for this change.
085: allocPage.preDirty();
086:
087: t.logAndDo(lop);
088: }
089:
090: /**
091: * Compress free pages.
092: * <p>
093: * Compress the free pages at the end of the range maintained by
094: * this allocation page. All pages being compressed should be FREE.
095: * Only pages in the last allocation page can be compressed.
096: * <p>
097: *
098: * @param t The transaction
099: * @param allocPage the allocation page to do compress on.
100: * @param new_highest_page The new highest page on this allocation
101: * page. The number is the offset of the page
102: * in the array of pages maintained by this
103: * allocation page, for instance a value of 0
104: * indicates all page except the first one are
105: * to be truncated. If all pages are
106: * truncated then the offset is set to -1.
107: * @param num_pages_truncated The number of allocated pages in this
108: * allocation page prior to the truncate.
109: * Note that all pages from NewHighestPage+1
110: * through newHighestPage+num_pages_truncated
111: * should be FREE.
112: *
113: * @exception StandardException Standard exception policy.
114: **/
115: public void actionCompressSpaceOperation(RawTransaction t,
116: BasePage allocPage, int new_highest_page,
117: int num_pages_truncated) throws StandardException {
118: Loggable lop = new CompressSpacePageOperation(
119: (AllocPage) allocPage, new_highest_page,
120: num_pages_truncated);
121: allocPage.preDirty();
122:
123: t.logAndDo(lop);
124: }
125: }
|