001: package com.quadcap.sql.file;
002:
003: /* Copyright 1999 - 2003 Quadcap Software. All rights reserved.
004: *
005: * This software is distributed under the Quadcap Free Software License.
006: * This software may be used or modified for any purpose, personal or
007: * commercial. Open Source redistributions are permitted. Commercial
008: * redistribution of larger works derived from, or works which bundle
009: * this software requires a "Commercial Redistribution License"; see
010: * http://www.quadcap.com/purchase.
011: *
012: * Redistributions qualify as "Open Source" under one of the following terms:
013: *
014: * Redistributions are made at no charge beyond the reasonable cost of
015: * materials and delivery.
016: *
017: * Redistributions are accompanied by a copy of the Source Code or by an
018: * irrevocable offer to provide a copy of the Source Code for up to three
019: * years at the cost of materials and delivery. Such redistributions
020: * must allow further use, modification, and redistribution of the Source
021: * Code under substantially the same terms as this license.
022: *
023: * Redistributions of source code must retain the copyright notices as they
024: * appear in each source code file, these license terms, and the
025: * disclaimer/limitation of liability set forth as paragraph 6 below.
026: *
027: * Redistributions in binary form must reproduce this Copyright Notice,
028: * these license terms, and the disclaimer/limitation of liability set
029: * forth as paragraph 6 below, in the documentation and/or other materials
030: * provided with the distribution.
031: *
032: * The Software is provided on an "AS IS" basis. No warranty is
033: * provided that the Software is free of defects, or fit for a
034: * particular purpose.
035: *
036: * Limitation of Liability. Quadcap Software shall not be liable
037: * for any damages suffered by the Licensee or any third party resulting
038: * from use of the Software.
039: */
040:
041: import java.io.File;
042: import java.io.IOException;
043:
044: import java.util.Properties;
045:
046: import com.quadcap.sql.lock.Transaction;
047:
048: /**
049: * Interface to logging subsystem.
050: *
051: * @author Stan Bailes
052: */
053: public interface Log {
054: /**
055: * Initialize the logging subsystem
056: */
057: public void init(Datafile db, boolean create, Properties props)
058: throws IOException;
059:
060: /**
061: * Start the logging subsystem
062: */
063: public void start();
064:
065: /**
066: * Return the database that we're logging for
067: */
068: public Datafile getDatafile();
069:
070: // /**
071: // * Return the database root directory
072: // */
073: // public File getDbRootDir();
074:
075: /**
076: * Add a transaction's log record to the end of the open log file
077: */
078: public void addEntry(LogEntry entry) throws IOException;
079:
080: /**
081: * XXX why public?
082: */
083: public void reallyAddEntry(LogEntry entry) throws IOException;
084:
085: /**
086: * Flush and close the log file.
087: */
088: public void close() throws IOException;
089:
090: /**
091: * Flush all log records to disk.
092: */
093: public void flushLog() throws IOException;
094:
095: /**
096: * Perform a checkpoint operation.
097: */
098: public void checkpoint() throws IOException;
099:
100: /**
101: * Wait for all queue ops to be processed by the log sync thread
102: */
103: public void sync() throws IOException;
104:
105: /**
106: * Transaction rollback.
107: */
108: public void rollbackTransaction(Transaction trans)
109: throws IOException;
110:
111: /**
112: * Statement rollback.
113: */
114: public void rollbackStatement(Transaction trans, int stmtId)
115: throws IOException;
116:
117: /**
118: * Restart from a previous state
119: */
120: public void restart() throws Exception;
121:
122: /**
123: * Retrieve a row mapping.
124: */
125: public long getRowMap(long rowId);
126:
127: /**
128: * Remember a row mapping {old,new} The old row (logRow) is now stored
129: * in a new place (fileRow), so any stored log entries that refer to
130: * the old row need to be translated to use the new row.
131: *
132: * @param logRow the "old" row
133: * @param fileRow the "new" row
134: */
135: public void putRowMap(long logRow, long fileRow);
136:
137: /**
138: * Discard a row mapping
139: */
140: public void removeRowMap(long row);
141:
142: /**
143: * Are you logging?
144: */
145: public boolean isLogging();
146:
147: /**
148: * Save a "before" image
149: */
150: public void saveBlock(long b) throws IOException;
151:
152: /**
153: * Restore all the "before" images
154: */
155: public void restoreBlocks() throws IOException;
156:
157: /**
158: * Reset the "before" list to be empty
159: */
160: public void resetBlocks() throws IOException;
161:
162: /**
163: * Remove the log
164: */
165: public void remove() throws IOException;
166:
167: /**
168: * Are we currently performing restart log recovery?
169: */
170: public boolean inRecovery() throws IOException;
171: }
|