001: /*
002:
003: Derby - Class org.apache.derby.impl.store.raw.log.ReadOnly
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.log;
023:
024: import org.apache.derby.iapi.reference.SQLState;
025:
026: import org.apache.derby.iapi.services.monitor.ModuleControl;
027: import org.apache.derby.iapi.services.monitor.ModuleSupportable;
028: import org.apache.derby.iapi.services.sanity.SanityManager;
029: import org.apache.derby.iapi.services.io.Formatable;
030:
031: import org.apache.derby.iapi.services.property.PersistentSet;
032: import org.apache.derby.iapi.store.raw.Compensation;
033: import org.apache.derby.iapi.store.raw.Loggable;
034: import org.apache.derby.iapi.store.raw.RawStoreFactory;
035: import org.apache.derby.iapi.store.raw.ScanHandle;
036: import org.apache.derby.iapi.store.raw.log.LogFactory;
037: import org.apache.derby.iapi.store.raw.log.LogInstant;
038: import org.apache.derby.iapi.store.raw.log.Logger;
039: import org.apache.derby.iapi.store.raw.log.LogScan;
040:
041: import org.apache.derby.iapi.store.raw.data.DataFactory;
042: import org.apache.derby.iapi.store.raw.xact.TransactionFactory;
043: import org.apache.derby.iapi.store.raw.xact.RawTransaction;
044: import org.apache.derby.iapi.store.raw.xact.TransactionId;
045:
046: import org.apache.derby.iapi.error.StandardException;
047:
048: import org.apache.derby.io.StorageFile;
049: import org.apache.derby.iapi.store.access.DatabaseInstant;
050: import org.apache.derby.catalog.UUID;
051:
052: import java.util.Properties;
053: import java.io.File;
054:
055: /**
056: A read-only version of the log factory.
057: It doesn't do anything, it doesn't check that
058: the database needs recovery or not.
059: <P>
060: It doesn't handle undo. No recovery.
061:
062: <P>Multithreading considerations:<BR>
063: This class must be MT-safe.
064: */
065:
066: public class ReadOnly implements LogFactory, ModuleSupportable {
067:
068: private String logArchiveDirectory = null;
069:
070: /*
071: ** Methods of Log Factory
072: */
073:
074: public Logger getLogger() {
075: return null;
076: }
077:
078: /**
079: MT - not needed, no work is done
080: @exception StandardException Cloudscape Standard Error Policy
081: */
082: public void recover(RawStoreFactory rawStoreFactory,
083: DataFactory dataFactory,
084: TransactionFactory transactionFactory)
085: throws StandardException {
086: if (transactionFactory != null)
087: transactionFactory.useTransactionTable((Formatable) null);
088: }
089:
090: /**
091: MT - not needed, no work is done
092: */
093: public boolean checkpoint(RawStoreFactory rawStoreFactory,
094: DataFactory dataFactory,
095: TransactionFactory transactionFactory, boolean wait) {
096: return true;
097: }
098:
099: public StandardException markCorrupt(StandardException originalError) {
100: return originalError;
101: }
102:
103: public void flush(LogInstant where) throws StandardException {
104: }
105:
106: /*
107: ** Methods of ModuleControl
108: */
109:
110: public boolean canSupport(Properties startParams) {
111:
112: String runtimeLogAttributes = startParams
113: .getProperty(LogFactory.RUNTIME_ATTRIBUTES);
114: if (runtimeLogAttributes == null)
115: return false;
116:
117: return runtimeLogAttributes.equals(LogFactory.RT_READONLY);
118: }
119:
120: /*
121: * truncation point support (not supported)
122: */
123:
124: public LogInstant setTruncationLWM(UUID name, LogInstant instant,
125: RawStoreFactory rawStoreFactory,
126: TransactionFactory transFactory) throws StandardException {
127: if (SanityManager.DEBUG)
128: SanityManager.THROWASSERT("functionality not implemented");
129:
130: throw StandardException
131: .newException(SQLState.STORE_FEATURE_NOT_IMPLEMENTED);
132:
133: }
134:
135: /**
136: @exception StandardException functionality not implmented
137: */
138: public void setTruncationLWM(UUID name, LogInstant instant)
139: throws StandardException {
140: if (SanityManager.DEBUG)
141: SanityManager.THROWASSERT("functionality not implemented");
142:
143: throw StandardException
144: .newException(SQLState.STORE_FEATURE_NOT_IMPLEMENTED);
145: }
146:
147: /**
148: @exception StandardException functionality not implmented
149: */
150: public void removeTruncationLWM(UUID name,
151: RawStoreFactory rawStoreFactory,
152: TransactionFactory transFactory) throws StandardException {
153: if (SanityManager.DEBUG)
154: SanityManager.THROWASSERT("functionality not implemented");
155:
156: throw StandardException
157: .newException(SQLState.STORE_FEATURE_NOT_IMPLEMENTED);
158: }
159:
160: /**
161: @exception StandardException functionality not implmented
162: */
163: public LogInstant getTruncationLWM(UUID name)
164: throws StandardException {
165: if (SanityManager.DEBUG)
166: SanityManager.THROWASSERT("functionality not implemented");
167:
168: throw StandardException
169: .newException(SQLState.STORE_FEATURE_NOT_IMPLEMENTED);
170: }
171:
172: /**
173: @exception StandardException functionality not implmented
174: */
175: public void removeTruncationLWM(UUID name) throws StandardException {
176: if (SanityManager.DEBUG)
177: SanityManager.THROWASSERT("functionality not implemented");
178:
179: throw StandardException
180: .newException(SQLState.STORE_FEATURE_NOT_IMPLEMENTED);
181: }
182:
183: /**
184: @exception StandardException functionality not implmented
185: */
186: public ScanHandle openFlushedScan(DatabaseInstant i, int groupsIWant)
187: throws StandardException {
188: if (SanityManager.DEBUG)
189: SanityManager.THROWASSERT("functionality not implemented");
190:
191: throw StandardException
192: .newException(SQLState.STORE_FEATURE_NOT_IMPLEMENTED);
193: }
194:
195: /**
196: @exception StandardException functionality not implmented
197: */
198: public LogScan openForwardsScan(LogInstant startAt,
199: LogInstant stopAt) throws StandardException {
200: if (SanityManager.DEBUG)
201: SanityManager.THROWASSERT("functionality not implemented");
202:
203: throw StandardException
204: .newException(SQLState.STORE_FEATURE_NOT_IMPLEMENTED);
205: }
206:
207: /**
208: */
209: public LogInstant getFirstUnflushedInstant() {
210: if (SanityManager.DEBUG)
211: SanityManager.THROWASSERT("functionality not implemented");
212:
213: return null;
214: }
215:
216: /**
217: @exception StandardException functionality not implmented
218: */
219: public LogScan openForwardsFlushedScan(LogInstant startAt)
220: throws StandardException {
221: if (SanityManager.DEBUG)
222: SanityManager.THROWASSERT("functionality not implemented");
223:
224: throw StandardException
225: .newException(SQLState.STORE_FEATURE_NOT_IMPLEMENTED);
226: }
227:
228: /**
229: * Backup restore - stop sending log record to the log stream
230: * @exception StandardException Standard Cloudscape error policy
231: */
232: public void freezePersistentStore() throws StandardException {
233: // read only, do nothing
234: }
235:
236: /**
237: * Backup restore - start sending log record to the log stream
238: * @exception StandardException Standard Cloudscape error policy
239: */
240: public void unfreezePersistentStore() throws StandardException {
241: // read only, do nothing
242: }
243:
244: /**
245: * Backup restore - is the log being archived to some directory?
246: * if RawStore.LOG_ARCHIVAL_DIRECTORY is set to some value, that means the
247: * log is meant to be archived. Else, log not archived.
248: */
249: public boolean logArchived() {
250: return (logArchiveDirectory != null);
251: }
252:
253: /**
254: Get JBMS properties relavent to the log factory
255: */
256: public void getLogFactoryProperties(PersistentSet set) {
257: // do nothing
258: }
259:
260: public StorageFile getLogDirectory() {
261: return null;
262: }
263:
264: public String getCanonicalLogPath() {
265: return null;
266: }
267:
268: //roll-forward recovery support routines
269: //Nothing to be done for read only databases
270: public void enableLogArchiveMode() {
271: //do nothing
272: }
273:
274: public void disableLogArchiveMode() {
275: //do nothing
276: }
277:
278: //this function is suppose to delete all the logs
279: //before this call that are not active logs.
280: public void deleteOnlineArchivedLogFiles() {
281: //do nothing
282: }
283:
284: //Is the transaction in rollforward recovery
285: public boolean inRFR() {
286: return false;
287: }
288:
289: /**
290: perform a checkpoint during rollforward recovery
291: */
292: public void checkpointInRFR(LogInstant cinstant, long redoLWM,
293: DataFactory df) throws StandardException {
294: //do nothing
295: }
296:
297: /*
298: * There are no log files to backup for read only databases, nothing to be
299: * done here.
300: * @param toDir - location where the log files should be copied to.
301: * @exception StandardException Standard Derby error policy
302: */
303: public void startLogBackup(File toDir) throws StandardException {
304: // nothing to do for read only databases.
305: }
306:
307: /*
308: * There are no log files to backup for read only databases,
309: * nothing to be done here.
310: *
311: * @param toDir - location where the log files should be copied to.
312: * @exception StandardException Standard Derby error policy
313: */
314: public void endLogBackup(File toDir) throws StandardException {
315: // nothing to do for read only databases.
316: }
317:
318: /*
319: * Log backup is not started for for read only databases, no work to do
320: * here.
321: **/
322: public void abortLogBackup() {
323: // nothing to do for read only databases.
324: }
325:
326: /*
327: * Set that the database is encrypted. Read-only database can not
328: * be reencrypted, nothing to do in this case.
329: */
330: public void setDatabaseEncrypted(boolean flushLog) {
331: // nothing to do for a read-only database.
332: }
333:
334: /*
335: * set up a new log file to start writing
336: * the log records into the new log file
337: * after this call.
338: *
339: * <P>MT - synchronization provided by caller - RawStore boot,
340: * This method is called while re-encrypting the database
341: * at databse boot time.
342: *
343: * Read-only database can not be reencrypted,
344: * nothing to do in this case.
345: */
346: public void startNewLogFile() throws StandardException {
347: // nothing to do for a read-only database.
348: }
349:
350: /*
351: * find if the checkpoint is in the last log file.
352: *
353: * <P>MT - synchronization provided by caller - RawStore boot,
354: * This method is called only if a crash occured while
355: * re-encrypting the database at boot time.
356:
357: * Read-only database can not be re-encrypted,
358: * nothing to do in this case.
359: */
360: public boolean isCheckpointInLastLogFile() throws StandardException {
361: // nothing to do for a read-only database.
362: return false;
363: }
364:
365: /*
366: * delete the log file after the checkpoint.
367: *
368: * <P>MT - synchronization provided by caller - RawStore boot,
369: * This method is called only if a crash occured while
370: * re-encrypting the database at boot time.
371: *
372: * Read-only database can not be re-encrypted,
373: * nothing to do in this case.
374: */
375: public void deleteLogFileAfterCheckpointLogFile()
376: throws StandardException {
377: // nothing to do for a read-only database.
378: }
379:
380: /**
381: * Check to see if a database has been upgraded to the required
382: * level in order to use a store feature.
383: *
384: * This method is generally used to prevent writes to
385: * data/log file by a particular store feature until the
386: * database is upgraded to the required version.
387: * In read-only database writes are not allowed, so nothing to do
388: * for this method in this implementation of the log factory.
389: *
390: * @param requiredMajorVersion required database Engine major version
391: * @param requiredMinorVersion required database Engine minor version
392: * @param feature Non-null to throw an exception, null to return the
393: * state of the version match.
394: *
395: * @exception StandardException
396: * not implemented exception is thrown
397: */
398: public boolean checkVersion(int requiredMajorVersion,
399: int requiredMinorVersion, String feature)
400: throws StandardException {
401: // nothing to do for read only databases;
402: throw StandardException
403: .newException(SQLState.STORE_FEATURE_NOT_IMPLEMENTED);
404: }
405: }
|