KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2
3    Derby - Class org.apache.derby.impl.store.raw.data.LoggableAllocActions
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.AllocationActions;
25 import org.apache.derby.impl.store.raw.data.BasePage;
26
27 import org.apache.derby.iapi.services.sanity.SanityManager;
28 import org.apache.derby.iapi.services.io.FormatIdUtil;
29
30 import org.apache.derby.iapi.store.raw.Loggable;
31 import org.apache.derby.iapi.store.raw.xact.RawTransaction;
32 import org.apache.derby.iapi.store.raw.log.LogInstant;
33
34 import org.apache.derby.iapi.error.StandardException;
35
36 public class LoggableAllocActions implements AllocationActions {
37
38     /**
39         Set the allocation status of pageNumber to doStatus. To undo this
40         operation, set the allocation status of pageNumber to undoStatus
41         
42         @param t The transaction
43         @param allocPage the allocation page
44         @param pageNumber the page to allocation or deallocation
45         @param doStatus set the allocation status of the page this value
46         @param undoStatus on undo, set the allocation status of the page
47                                 this value
48
49         @exception StandardException Standard Cloudscape error policy
50     */

51     public void actionAllocatePage(RawTransaction t, BasePage allocPage,
52                                    long pageNumber, int doStatus, int undoStatus)
53          throws StandardException
54     {
55         Loggable lop = new AllocPageOperation((AllocPage)allocPage, pageNumber, doStatus, undoStatus);
56
57         // mark the page as pre-dirtied so that if a checkpoint happens after
58
// the log record is sent to the log stream, the cache cleaning will
59
// wait for this change.
60
allocPage.preDirty();
61
62         t.logAndDo(lop);
63     }
64
65     /**
66         Chain one allocation page to the next.
67
68         @param t The transaction
69         @param allocPage the allocation page whose next page chain needs
70                                 to be changed
71         @param pageNumber the next allocation page's number
72         @param pageOffset the next allocation page's page offset
73
74         @exception StandardException Standard Cloudscape error policy
75     */

76     public void actionChainAllocPage(RawTransaction t, BasePage allocPage,
77                                 long pageNumber, long pageOffset)
78          throws StandardException
79     {
80         Loggable lop = new ChainAllocPageOperation((AllocPage)allocPage, pageNumber, pageOffset);
81
82         // mark the page as pre-dirtied so that if a checkpoint happens after
83
// the log record is sent to the log stream, the cache cleaning will
84
// wait for this change.
85
allocPage.preDirty();
86
87         t.logAndDo(lop);
88     }
89
90     /**
91      * Compress free pages.
92      * <p>
93      * Compress the free pages at the end of the range maintained by
94      * this allocation page. All pages being compressed should be FREE.
95      * Only pages in the last allocation page can be compressed.
96      * <p>
97      *
98      * @param t The transaction
99      * @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(
116     RawTransaction t,
117     BasePage allocPage,
118     int new_highest_page,
119     int num_pages_truncated)
120         throws StandardException
121     {
122         Loggable lop =
123             new CompressSpacePageOperation(
124                 (AllocPage)allocPage, new_highest_page, num_pages_truncated);
125         allocPage.preDirty();
126
127         t.logAndDo(lop);
128     }
129 }
130
Popular Tags