01: /*
02:
03: Derby - Class org.apache.derby.impl.store.raw.data.ContainerHandleActionOnCommit
04:
05: Licensed to the Apache Software Foundation (ASF) under one or more
06: contributor license agreements. See the NOTICE file distributed with
07: this work for additional information regarding copyright ownership.
08: The ASF licenses this file to you under the Apache License, Version 2.0
09: (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.iapi.store.raw.ContainerHandle;
25: import org.apache.derby.iapi.store.raw.ContainerLock;
26: import org.apache.derby.iapi.store.raw.Page;
27: import org.apache.derby.iapi.store.raw.LockingPolicy;
28: import org.apache.derby.iapi.store.raw.RecordHandle;
29: import org.apache.derby.iapi.store.raw.ContainerKey;
30:
31: import org.apache.derby.iapi.store.raw.data.RawContainerHandle;
32: import org.apache.derby.iapi.store.raw.log.LogInstant;
33: import org.apache.derby.iapi.store.raw.xact.RawTransaction;
34:
35: import org.apache.derby.iapi.services.locks.Lockable;
36:
37: import org.apache.derby.catalog.UUID;
38:
39: import org.apache.derby.iapi.error.StandardException;
40:
41: import org.apache.derby.iapi.services.sanity.SanityManager;
42:
43: /**
44: An abstract class that opens the container at commit and delegates
45: the actual work to a sub-class.
46: */
47:
48: public abstract class ContainerHandleActionOnCommit extends
49: ContainerActionOnCommit {
50:
51: public ContainerHandleActionOnCommit(ContainerKey identity) {
52:
53: super (identity);
54: }
55:
56: /*
57: ** Methods of Observer
58: */
59:
60: /**
61: Open the container and call the doIt method
62: */
63: public void openContainerAndDoIt(RawTransaction xact) {
64:
65: BaseContainerHandle handle = null;
66: try {
67: handle = (BaseContainerHandle) xact
68: .openContainer(
69: identity,
70: (LockingPolicy) null,
71: ContainerHandle.MODE_FORUPDATE
72: | ContainerHandle.MODE_NO_ACTIONS_ON_COMMIT);
73:
74: // if the handle is null, the container may have been removed by a previous observer.
75: if (handle != null) {
76: try {
77: doIt(handle);
78: } catch (StandardException se) {
79: xact.setObserverException(se);
80: }
81: }
82:
83: } catch (StandardException se) {
84:
85: // if we get this exception, then the container is readonly.
86: // no problem if we can't open an closed temp container.
87: if (identity.getSegmentId() != ContainerHandle.TEMPORARY_SEGMENT)
88: xact.setObserverException(se);
89: } finally {
90: if (handle != null)
91: handle.close();
92: }
93: }
94:
95: protected abstract void doIt(BaseContainerHandle handle)
96: throws StandardException;
97: }
|