1 | /* |
2 | |
3 | Derby - Class org.apache.derby.impl.store.raw.log.ReadOnly |
4 | |
5 | Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable. |
6 | |
7 | Licensed under the Apache License, Version 2.0 (the "License"); |
8 | you may not use this file except in compliance with the License. |
9 | You may obtain a copy of the License at |
10 | |
11 | http://www.apache.org/licenses/LICENSE-2.0 |
12 | |
13 | Unless required by applicable law or agreed to in writing, software |
14 | distributed under the License is distributed on an "AS IS" BASIS, |
15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
16 | See the License for the specific language governing permissions and |
17 | limitations under the License. |
18 | |
19 | */ |
20 | |
21 | package org.apache.derby.impl.store.raw.log; |
22 | |
23 | import org.apache.derby.iapi.reference.SQLState; |
24 | |
25 | import org.apache.derby.iapi.services.monitor.ModuleControl; |
26 | import org.apache.derby.iapi.services.monitor.ModuleSupportable; |
27 | import org.apache.derby.iapi.services.sanity.SanityManager; |
28 | import org.apache.derby.iapi.services.io.Formatable; |
29 | |
30 | import org.apache.derby.iapi.services.property.PersistentSet; |
31 | import org.apache.derby.iapi.store.raw.Compensation; |
32 | import org.apache.derby.iapi.store.raw.Loggable; |
33 | import org.apache.derby.iapi.store.raw.RawStoreFactory; |
34 | import org.apache.derby.iapi.store.raw.ScanHandle; |
35 | import org.apache.derby.iapi.store.raw.log.LogFactory; |
36 | import org.apache.derby.iapi.store.raw.log.LogInstant; |
37 | import org.apache.derby.iapi.store.raw.log.Logger; |
38 | import org.apache.derby.iapi.store.raw.log.LogScan; |
39 | |
40 | import org.apache.derby.iapi.store.raw.data.DataFactory; |
41 | import org.apache.derby.iapi.store.raw.xact.TransactionFactory; |
42 | import org.apache.derby.iapi.store.raw.xact.RawTransaction; |
43 | import org.apache.derby.iapi.store.raw.xact.TransactionId; |
44 | |
45 | import org.apache.derby.iapi.error.StandardException; |
46 | |
47 | import org.apache.derby.io.StorageFile; |
48 | import org.apache.derby.iapi.store.access.DatabaseInstant; |
49 | import org.apache.derby.catalog.UUID; |
50 | |
51 | import java.util.Properties; |
52 | import java.io.File; |
53 | |
54 | /** |
55 | A read-only version of the log factory. |
56 | It doesn't do anything, it doesn't check that |
57 | the database needs recovery or not. |
58 | <P> |
59 | It doesn't handle undo. No recovery. |
60 | |
61 | <P>Multithreading considerations:<BR> |
62 | This class must be MT-safe. |
63 | */ |
64 | |
65 | public class ReadOnly implements LogFactory, ModuleSupportable { |
66 | |
67 | private String logArchiveDirectory = null; |
68 | |
69 | /* |
70 | ** Methods of Log Factory |
71 | */ |
72 | |
73 | public Logger getLogger() { |
74 | return null; |
75 | } |
76 | |
77 | /** |
78 | MT - not needed, no work is done |
79 | @exception StandardException Cloudscape Standard Error Policy |
80 | */ |
81 | public void recover(RawStoreFactory rawStoreFactory, |
82 | DataFactory dataFactory, |
83 | TransactionFactory transactionFactory) |
84 | throws StandardException |
85 | { |
86 | if (transactionFactory != null) |
87 | transactionFactory.useTransactionTable((Formatable)null); |
88 | } |
89 | |
90 | /** |
91 | MT - not needed, no work is done |
92 | */ |
93 | public boolean checkpoint(RawStoreFactory rawStoreFactory, |
94 | DataFactory dataFactory, |
95 | TransactionFactory transactionFactory, |
96 | boolean wait) |
97 | { |
98 | return true; |
99 | } |
100 | |
101 | public StandardException markCorrupt(StandardException originalError) { |
102 | return originalError; |
103 | } |
104 | |
105 | public void flush(LogInstant where) throws StandardException { |
106 | } |
107 | |
108 | /* |
109 | ** Methods of ModuleControl |
110 | */ |
111 | |
112 | public boolean canSupport(Properties startParams) { |
113 | |
114 | String runtimeLogAttributes = startParams.getProperty(LogFactory.RUNTIME_ATTRIBUTES); |
115 | if (runtimeLogAttributes == null) |
116 | return false; |
117 | |
118 | return runtimeLogAttributes.equals(LogFactory.RT_READONLY); |
119 | } |
120 | |
121 | /* |
122 | * truncation point support (not supported) |
123 | */ |
124 | |
125 | public LogInstant setTruncationLWM(UUID name, |
126 | LogInstant instant, |
127 | RawStoreFactory rawStoreFactory, |
128 | TransactionFactory transFactory) |
129 | throws StandardException |
130 | { |
131 | if (SanityManager.DEBUG) |
132 | SanityManager.THROWASSERT("functionality not implemented"); |
133 | |
134 | throw StandardException.newException( |
135 | SQLState.STORE_FEATURE_NOT_IMPLEMENTED); |
136 | |
137 | } |
138 | |
139 | /** |
140 | @exception StandardException functionality not implmented |
141 | */ |
142 | public void setTruncationLWM(UUID name, LogInstant instant) throws StandardException |
143 | { |
144 | if (SanityManager.DEBUG) |
145 | SanityManager.THROWASSERT("functionality not implemented"); |
146 | |
147 | throw StandardException.newException( |
148 | SQLState.STORE_FEATURE_NOT_IMPLEMENTED); |
149 | } |
150 | |
151 | |
152 | /** |
153 | @exception StandardException functionality not implmented |
154 | */ |
155 | public void removeTruncationLWM(UUID name, |
156 | RawStoreFactory rawStoreFactory, |
157 | TransactionFactory transFactory) |
158 | throws StandardException |
159 | { |
160 | if (SanityManager.DEBUG) |
161 | SanityManager.THROWASSERT("functionality not implemented"); |
162 | |
163 | throw StandardException.newException( |
164 | SQLState.STORE_FEATURE_NOT_IMPLEMENTED); |
165 | } |
166 | |
167 | |
168 | /** |
169 | @exception StandardException functionality not implmented |
170 | */ |
171 | public LogInstant getTruncationLWM(UUID name) throws StandardException |
172 | { |
173 | if (SanityManager.DEBUG) |
174 | SanityManager.THROWASSERT("functionality not implemented"); |
175 | |
176 | throw StandardException.newException( |
177 | SQLState.STORE_FEATURE_NOT_IMPLEMENTED); |
178 | } |
179 | |
180 | /** |
181 | @exception StandardException functionality not implmented |
182 | */ |
183 | public void removeTruncationLWM(UUID name) throws StandardException |
184 | { |
185 | if (SanityManager.DEBUG) |
186 | SanityManager.THROWASSERT("functionality not implemented"); |
187 | |
188 | throw StandardException.newException( |
189 | SQLState.STORE_FEATURE_NOT_IMPLEMENTED); |
190 | } |
191 | |
192 | /** |
193 | @exception StandardException functionality not implmented |
194 | */ |
195 | public ScanHandle openFlushedScan(DatabaseInstant i, int groupsIWant) |
196 | throws StandardException |
197 | { |
198 | if (SanityManager.DEBUG) |
199 | SanityManager.THROWASSERT("functionality not implemented"); |
200 | |
201 | throw StandardException.newException( |
202 | SQLState.STORE_FEATURE_NOT_IMPLEMENTED); |
203 | } |
204 | |
205 | /** |
206 | @exception StandardException functionality not implmented |
207 | */ |
208 | public LogScan openForwardsScan(LogInstant startAt,LogInstant stopAt) |
209 | throws StandardException |
210 | { |
211 | if (SanityManager.DEBUG) |
212 | SanityManager.THROWASSERT("functionality not implemented"); |
213 | |
214 | throw StandardException.newException( |
215 | SQLState.STORE_FEATURE_NOT_IMPLEMENTED); |
216 | } |
217 | |
218 | /** |
219 | */ |
220 | public LogInstant getFirstUnflushedInstant() |
221 | { |
222 | if (SanityManager.DEBUG) |
223 | SanityManager.THROWASSERT("functionality not implemented"); |
224 | |
225 | return null; |
226 | } |
227 | |
228 | /** |
229 | @exception StandardException functionality not implmented |
230 | */ |
231 | public LogScan openForwardsFlushedScan(LogInstant startAt) |
232 | throws StandardException |
233 | { |
234 | if (SanityManager.DEBUG) |
235 | SanityManager.THROWASSERT("functionality not implemented"); |
236 | |
237 | throw StandardException.newException( |
238 | SQLState.STORE_FEATURE_NOT_IMPLEMENTED); |
239 | } |
240 | |
241 | /** |
242 | * Backup restore - stop sending log record to the log stream |
243 | * @exception StandardException Standard Cloudscape error policy |
244 | */ |
245 | public void freezePersistentStore() throws StandardException |
246 | { |
247 | // read only, do nothing |
248 | } |
249 | |
250 | /** |
251 | * Backup restore - start sending log record to the log stream |
252 | * @exception StandardException Standard Cloudscape error policy |
253 | */ |
254 | public void unfreezePersistentStore() throws StandardException |
255 | { |
256 | // read only, do nothing |
257 | } |
258 | |
259 | /** |
260 | * Backup restore - is the log being archived to some directory? |
261 | * if RawStore.LOG_ARCHIVAL_DIRECTORY is set to some value, that means the |
262 | * log is meant to be archived. Else, log not archived. |
263 | */ |
264 | public boolean logArchived() |
265 | { |
266 | return (logArchiveDirectory != null); |
267 | } |
268 | |
269 | /** |
270 | Get JBMS properties relavent to the log factory |
271 | */ |
272 | public void getLogFactoryProperties(PersistentSet set) |
273 | { |
274 | // do nothing |
275 | } |
276 | |
277 | public StorageFile getLogDirectory() |
278 | { |
279 | return null; |
280 | } |
281 | |
282 | public String getCanonicalLogPath() |
283 | { |
284 | return null; |
285 | } |
286 | |
287 | |
288 | //roll-forward recovery support routines |
289 | //Nothing to be done for read only databases |
290 | public void enableLogArchiveMode() |
291 | { |
292 | //do nothing |
293 | } |
294 | |
295 | public void disableLogArchiveMode() |
296 | { |
297 | //do nothing |
298 | } |
299 | |
300 | //this function is suppose to delete all the logs |
301 | //before this call that are not active logs. |
302 | public void deleteOnlineArchivedLogFiles() |
303 | { |
304 | //do nothing |
305 | } |
306 | |
307 | |
308 | //Is the transaction in rollforward recovery |
309 | public boolean inRFR() |
310 | { |
311 | return false; |
312 | } |
313 | |
314 | /** |
315 | perform a checkpoint during rollforward recovery |
316 | */ |
317 | public void checkpointInRFR(LogInstant cinstant, long redoLWM, |
318 | DataFactory df) throws StandardException |
319 | { |
320 | //do nothing |
321 | } |
322 | |
323 | |
324 | /* |
325 | * There are no log files to backup for read only databases, nothing to be |
326 | * done here. |
327 | * @param toDir - location where the log files should be copied to. |
328 | * @exception StandardException Standard Derby error policy |
329 | */ |
330 | public void startLogBackup(File toDir) throws StandardException |
331 | { |
332 | // nothing to do for read only databases. |
333 | } |
334 | |
335 | |
336 | /* |
337 | * There are no log files to backup for read only databases, |
338 | * nothing to be done here. |
339 | * |
340 | * @param toDir - location where the log files should be copied to. |
341 | * @exception StandardException Standard Derby error policy |
342 | */ |
343 | public void endLogBackup(File toDir) throws StandardException |
344 | { |
345 | // nothing to do for read only databases. |
346 | } |
347 | |
348 | |
349 | /* |
350 | * Log backup is not started for for read only databases, no work to do |
351 | * here. |
352 | **/ |
353 | public void abortLogBackup() |
354 | { |
355 | // nothing to do for read only databases. |
356 | } |
357 | |
358 | /* |
359 | * Set that the database is encrypted. Read-only database can not |
360 | * be reencrypted, nothing to do in this case. |
361 | */ |
362 | public void setDatabaseEncrypted() { |
363 | |
364 | // nothing to do for a read-only database. |
365 | } |
366 | |
367 | /* |
368 | * setup log for encryption. Read-only database can not |
369 | * be reencrypted, nothing to do in this case. |
370 | */ |
371 | public void setupLogEncryption() throws StandardException { |
372 | // nothing to do for a read-only database. |
373 | } |
374 | } |