001: /*
002:
003: Derby - Class org.apache.derby.iapi.store.raw.log.Logger
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.iapi.store.raw.log;
023:
024: import org.apache.derby.iapi.store.raw.RawStoreFactory;
025: import org.apache.derby.iapi.store.raw.Loggable;
026: import org.apache.derby.iapi.store.raw.Compensation;
027:
028: import org.apache.derby.iapi.store.raw.xact.RawTransaction;
029: import org.apache.derby.iapi.store.raw.xact.TransactionFactory;
030: import org.apache.derby.iapi.store.raw.xact.TransactionId;
031:
032: import org.apache.derby.iapi.store.raw.data.DataFactory;
033:
034: import org.apache.derby.iapi.error.StandardException;
035:
036: import org.apache.derby.iapi.services.io.LimitObjectInput;
037:
038: public interface Logger {
039:
040: /**
041: Log the loggable operation under the context of the transaction and then
042: apply the operation to the RawStore.
043:
044: <BR>
045: Before you call this method, make sure that the Loggable's doMe
046: method will succeed. This method will go ahead and send the log record
047: to disk, and once it does that, then doMe cannot fail or the system
048: will be shut down and recovery may fail. So it is <B> very important
049: </B> to make sure that every resource you need for the loggable's doMe
050: method, such as disk space, has be acquired or accounted for before
051: calling logAndDo.
052:
053: @param xact the transaction that is affecting the change
054: @param operation the loggable operation that describes the change
055: @return LogInstant that is the LogInstant of the loggable operation
056:
057: @exception StandardException Standard Cloudscape error policy
058: */
059: public LogInstant logAndDo(RawTransaction xact, Loggable operation)
060: throws StandardException;
061:
062: /**
063: Log the compensation operation under the context of the transaction
064: and then apply the undo to the RawStore.
065:
066: <BR>
067: Before you call this method, make sure that the Compensation's doMe
068: method will succeed. This method will go ahead and send the log record
069: to disk, and once it does that, then doMe cannot fail or the system
070: will be shut down and recovery may fail. So it is <B> very important
071: </B> to make sure that every resource you need for the Compensation's
072: doMe method, such as disk space, has be acquired or accounted for before
073: calling logAndUnDo.
074:
075: @param xact the transaction that is affecting the undo
076: @param operation the compensation operation
077: @param undoInstant the logInstant of the change that is to be undone
078: @param in optional data
079:
080: @return LogInstant that is the LogInstant of the compensation operation
081:
082: @exception StandardException Standard Cloudscape error policy
083: */
084: public LogInstant logAndUndo(RawTransaction xact,
085: Compensation operation, LogInstant undoInstant,
086: LimitObjectInput in) throws StandardException;
087:
088: /**
089: Flush all unwritten log record up to the log instance indicated to disk.
090:
091: @param where flush log up to here
092:
093: @exception StandardException cannot flush due to sync error
094: */
095: public void flush(LogInstant where) throws StandardException;
096:
097: /**
098: Flush all unwritten log to disk
099:
100: @exception StandardException cannot flush due to sync error
101: */
102: public void flushAll() throws StandardException;
103:
104: /**
105: * During recovery re-prepare a transaction.
106: * <p>
107: * After redo() and undo(), this routine is called on all outstanding
108: * in-doubt (prepared) transactions. This routine re-acquires all
109: * logical write locks for operations in the xact, and then modifies
110: * the transaction table entry to make the transaction look as if it
111: * had just been prepared following startup after recovery.
112: * <p>
113: *
114: * @param t is the transaction performing the re-prepare
115: * @param undoId is the transaction ID to be re-prepared
116: * @param undoStopAt is where the log instant (inclusive) where the
117: * re-prepare should stop.
118: * @param undoStartAt is the log instant (inclusive) where re-prepare
119: * should begin, this is normally the log instant of
120: * the last log record of the transaction that is to
121: * be re-prepare. If null, then re-prepare starts
122: * from the end of the log.
123: *
124: * @exception StandardException Standard exception policy.
125: **/
126: public void reprepare(RawTransaction t, TransactionId undoId,
127: LogInstant undoStopAt, LogInstant undoStartAt)
128: throws StandardException;
129:
130: /**
131: Undo transaction.
132:
133: @param t is the transaction performing the rollback
134: @param undoId is the transaction ID to be rolled back
135: @param undoStopAt is where the log instant (inclusive) where
136: the rollback should stop.
137: @param undoStartAt is the log instant (inclusive) where rollback
138: should begin, this is normally the log instant of
139: the last log record of the transaction that is
140: to be rolled back.
141: If null, then rollback starts from the end of the log.
142:
143: @exception StandardException Standard Cloudscape error policy
144: */
145: public void undo(RawTransaction t, TransactionId undoId,
146: LogInstant undoStopAt, LogInstant undoStartAt)
147: throws StandardException;
148: }
|