KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > store > raw > log > ReadOnly


1 /*
2
3    Derby - Class org.apache.derby.impl.store.raw.log.ReadOnly
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.log;
23
24 import org.apache.derby.iapi.reference.SQLState;
25
26 import org.apache.derby.iapi.services.monitor.ModuleControl;
27 import org.apache.derby.iapi.services.monitor.ModuleSupportable;
28 import org.apache.derby.iapi.services.sanity.SanityManager;
29 import org.apache.derby.iapi.services.io.Formatable;
30
31 import org.apache.derby.iapi.services.property.PersistentSet;
32 import org.apache.derby.iapi.store.raw.Compensation;
33 import org.apache.derby.iapi.store.raw.Loggable;
34 import org.apache.derby.iapi.store.raw.RawStoreFactory;
35 import org.apache.derby.iapi.store.raw.ScanHandle;
36 import org.apache.derby.iapi.store.raw.log.LogFactory;
37 import org.apache.derby.iapi.store.raw.log.LogInstant;
38 import org.apache.derby.iapi.store.raw.log.Logger;
39 import org.apache.derby.iapi.store.raw.log.LogScan;
40
41 import org.apache.derby.iapi.store.raw.data.DataFactory;
42 import org.apache.derby.iapi.store.raw.xact.TransactionFactory;
43 import org.apache.derby.iapi.store.raw.xact.RawTransaction;
44 import org.apache.derby.iapi.store.raw.xact.TransactionId;
45
46 import org.apache.derby.iapi.error.StandardException;
47
48 import org.apache.derby.io.StorageFile;
49 import org.apache.derby.iapi.store.access.DatabaseInstant;
50 import org.apache.derby.catalog.UUID;
51
52 import java.util.Properties JavaDoc;
53 import java.io.File JavaDoc;
54
55 /**
56     A read-only version of the log factory.
57     It doesn't do anything, it doesn't check that
58     the database needs recovery or not.
59     <P>
60     It doesn't handle undo. No recovery.
61
62     <P>Multithreading considerations:<BR>
63     This class must be MT-safe.
64 */

65
66 public class ReadOnly implements LogFactory, ModuleSupportable {
67
68     private String JavaDoc logArchiveDirectory = null;
69
70     /*
71     ** Methods of Log Factory
72     */

73
74     public Logger getLogger() {
75         return null;
76     }
77
78     /**
79       MT - not needed, no work is done
80       @exception StandardException Cloudscape Standard Error Policy
81     */

82     public void recover(RawStoreFactory rawStoreFactory,
83                         DataFactory dataFactory,
84                         TransactionFactory transactionFactory)
85          throws StandardException
86     {
87         if (transactionFactory != null)
88             transactionFactory.useTransactionTable((Formatable)null);
89     }
90
91     /**
92       MT - not needed, no work is done
93     */

94     public boolean checkpoint(RawStoreFactory rawStoreFactory,
95                               DataFactory dataFactory,
96                               TransactionFactory transactionFactory,
97                               boolean wait)
98     {
99         return true;
100     }
101
102     public StandardException markCorrupt(StandardException originalError) {
103         return originalError;
104     }
105
106     public void flush(LogInstant where) throws StandardException {
107     }
108
109     /*
110     ** Methods of ModuleControl
111     */

112
113     public boolean canSupport(Properties JavaDoc startParams) {
114
115         String JavaDoc runtimeLogAttributes = startParams.getProperty(LogFactory.RUNTIME_ATTRIBUTES);
116         if (runtimeLogAttributes == null)
117             return false;
118
119         return runtimeLogAttributes.equals(LogFactory.RT_READONLY);
120     }
121
122     /*
123      * truncation point support (not supported)
124      */

125
126     public LogInstant setTruncationLWM(UUID name,
127                                        LogInstant instant,
128                                        RawStoreFactory rawStoreFactory,
129                                       TransactionFactory transFactory)
130          throws StandardException
131     {
132         if (SanityManager.DEBUG)
133             SanityManager.THROWASSERT("functionality not implemented");
134
135         throw StandardException.newException(
136                 SQLState.STORE_FEATURE_NOT_IMPLEMENTED);
137
138     }
139
140     /**
141       @exception StandardException functionality not implmented
142     */

143     public void setTruncationLWM(UUID name, LogInstant instant) throws StandardException
144     {
145         if (SanityManager.DEBUG)
146             SanityManager.THROWASSERT("functionality not implemented");
147
148         throw StandardException.newException(
149                 SQLState.STORE_FEATURE_NOT_IMPLEMENTED);
150     }
151
152
153     /**
154       @exception StandardException functionality not implmented
155     */

156     public void removeTruncationLWM(UUID name,
157                              RawStoreFactory rawStoreFactory,
158                              TransactionFactory transFactory)
159          throws StandardException
160     {
161         if (SanityManager.DEBUG)
162             SanityManager.THROWASSERT("functionality not implemented");
163
164         throw StandardException.newException(
165                 SQLState.STORE_FEATURE_NOT_IMPLEMENTED);
166     }
167
168
169     /**
170       @exception StandardException functionality not implmented
171     */

172     public LogInstant getTruncationLWM(UUID name) throws StandardException
173     {
174         if (SanityManager.DEBUG)
175             SanityManager.THROWASSERT("functionality not implemented");
176
177         throw StandardException.newException(
178                 SQLState.STORE_FEATURE_NOT_IMPLEMENTED);
179     }
180
181     /**
182       @exception StandardException functionality not implmented
183     */

184     public void removeTruncationLWM(UUID name) throws StandardException
185     {
186         if (SanityManager.DEBUG)
187             SanityManager.THROWASSERT("functionality not implemented");
188
189         throw StandardException.newException(
190                 SQLState.STORE_FEATURE_NOT_IMPLEMENTED);
191     }
192
193     /**
194       @exception StandardException functionality not implmented
195     */

196     public ScanHandle openFlushedScan(DatabaseInstant i, int groupsIWant)
197          throws StandardException
198     {
199         if (SanityManager.DEBUG)
200             SanityManager.THROWASSERT("functionality not implemented");
201
202         throw StandardException.newException(
203                 SQLState.STORE_FEATURE_NOT_IMPLEMENTED);
204     }
205
206     /**
207       @exception StandardException functionality not implmented
208     */

209     public LogScan openForwardsScan(LogInstant startAt,LogInstant stopAt)
210          throws StandardException
211     {
212         if (SanityManager.DEBUG)
213             SanityManager.THROWASSERT("functionality not implemented");
214
215         throw StandardException.newException(
216                 SQLState.STORE_FEATURE_NOT_IMPLEMENTED);
217     }
218
219     /**
220       */

221     public LogInstant getFirstUnflushedInstant()
222     {
223         if (SanityManager.DEBUG)
224             SanityManager.THROWASSERT("functionality not implemented");
225
226         return null;
227     }
228
229     /**
230       @exception StandardException functionality not implmented
231       */

232     public LogScan openForwardsFlushedScan(LogInstant startAt)
233          throws StandardException
234     {
235         if (SanityManager.DEBUG)
236             SanityManager.THROWASSERT("functionality not implemented");
237
238         throw StandardException.newException(
239                 SQLState.STORE_FEATURE_NOT_IMPLEMENTED);
240     }
241
242     /**
243      * Backup restore - stop sending log record to the log stream
244      * @exception StandardException Standard Cloudscape error policy
245      */

246     public void freezePersistentStore() throws StandardException
247     {
248         // read only, do nothing
249
}
250
251     /**
252      * Backup restore - start sending log record to the log stream
253      * @exception StandardException Standard Cloudscape error policy
254      */

255     public void unfreezePersistentStore() throws StandardException
256     {
257         // read only, do nothing
258
}
259
260     /**
261      * Backup restore - is the log being archived to some directory?
262      * if RawStore.LOG_ARCHIVAL_DIRECTORY is set to some value, that means the
263      * log is meant to be archived. Else, log not archived.
264      */

265     public boolean logArchived()
266     {
267         return (logArchiveDirectory != null);
268     }
269
270     /**
271         Get JBMS properties relavent to the log factory
272      */

273     public void getLogFactoryProperties(PersistentSet set)
274     {
275         // do nothing
276
}
277     
278     public StorageFile getLogDirectory()
279     {
280         return null;
281     }
282
283     public String JavaDoc getCanonicalLogPath()
284     {
285         return null;
286     }
287
288     
289     //roll-forward recovery support routines
290
//Nothing to be done for read only databases
291
public void enableLogArchiveMode()
292     {
293         //do nothing
294
}
295
296     public void disableLogArchiveMode()
297     {
298         //do nothing
299
}
300
301     //this function is suppose to delete all the logs
302
//before this call that are not active logs.
303
public void deleteOnlineArchivedLogFiles()
304     {
305         //do nothing
306
}
307
308
309     //Is the transaction in rollforward recovery
310
public boolean inRFR()
311     {
312         return false;
313     }
314
315     /**
316         perform a checkpoint during rollforward recovery
317     */

318     public void checkpointInRFR(LogInstant cinstant, long redoLWM,
319                                 DataFactory df) throws StandardException
320     {
321         //do nothing
322
}
323
324         
325     /*
326      * There are no log files to backup for read only databases, nothing to be
327      * done here.
328      * @param toDir - location where the log files should be copied to.
329      * @exception StandardException Standard Derby error policy
330     */

331     public void startLogBackup(File toDir) throws StandardException
332     {
333         // nothing to do for read only databases.
334
}
335
336     
337     /*
338      * There are no log files to backup for read only databases,
339      * nothing to be done here.
340      *
341      * @param toDir - location where the log files should be copied to.
342      * @exception StandardException Standard Derby error policy
343     */

344     public void endLogBackup(File toDir) throws StandardException
345     {
346         // nothing to do for read only databases.
347
}
348
349     
350     /*
351      * Log backup is not started for for read only databases, no work to do
352      * here.
353      **/

354     public void abortLogBackup()
355     {
356         // nothing to do for read only databases.
357
}
358
359     /*
360      * Set that the database is encrypted. Read-only database can not
361      * be reencrypted, nothing to do in this case.
362      */

363     public void setDatabaseEncrypted(boolean flushLog)
364     {
365         // nothing to do for a read-only database.
366
}
367
368
369     /*
370      * set up a new log file to start writing
371      * the log records into the new log file
372      * after this call.
373      *
374      * <P>MT - synchronization provided by caller - RawStore boot,
375      * This method is called while re-encrypting the database
376      * at databse boot time.
377      *
378      * Read-only database can not be reencrypted,
379      * nothing to do in this case.
380      */

381     public void startNewLogFile() throws StandardException
382     {
383         // nothing to do for a read-only database.
384
}
385
386     /*
387      * find if the checkpoint is in the last log file.
388      *
389      * <P>MT - synchronization provided by caller - RawStore boot,
390      * This method is called only if a crash occured while
391      * re-encrypting the database at boot time.
392
393      * Read-only database can not be re-encrypted,
394      * nothing to do in this case.
395      */

396     public boolean isCheckpointInLastLogFile()
397         throws StandardException
398     {
399         // nothing to do for a read-only database.
400
return false;
401     }
402     
403     /*
404      * delete the log file after the checkpoint.
405      *
406      * <P>MT - synchronization provided by caller - RawStore boot,
407      * This method is called only if a crash occured while
408      * re-encrypting the database at boot time.
409      *
410      * Read-only database can not be re-encrypted,
411      * nothing to do in this case.
412      */

413     public void deleteLogFileAfterCheckpointLogFile()
414         throws StandardException
415     {
416         // nothing to do for a read-only database.
417
}
418
419
420
421     /**
422      * Check to see if a database has been upgraded to the required
423      * level in order to use a store feature.
424      *
425      * This method is generally used to prevent writes to
426      * data/log file by a particular store feature until the
427      * database is upgraded to the required version.
428      * In read-only database writes are not allowed, so nothing to do
429      * for this method in this implementation of the log factory.
430      *
431      * @param requiredMajorVersion required database Engine major version
432      * @param requiredMinorVersion required database Engine minor version
433      * @param feature Non-null to throw an exception, null to return the
434      * state of the version match.
435      *
436      * @exception StandardException
437      * not implemented exception is thrown
438      */

439     public boolean checkVersion(int requiredMajorVersion,
440                                 int requiredMinorVersion,
441                                 String JavaDoc feature)
442         throws StandardException
443     {
444         // nothing to do for read only databases;
445
throw StandardException.newException(
446                   SQLState.STORE_FEATURE_NOT_IMPLEMENTED);
447     }
448 }
449
Popular Tags