Adding JMCR-Stable version
[Benchmarks_CSolver.git] / JMCR-Stable / real-world application / MyDerby-10.3 / java / engine / org / apache / derby / impl / store / raw / log / ReadOnly.java
diff --git a/JMCR-Stable/real-world application/MyDerby-10.3/java/engine/org/apache/derby/impl/store/raw/log/ReadOnly.java b/JMCR-Stable/real-world application/MyDerby-10.3/java/engine/org/apache/derby/impl/store/raw/log/ReadOnly.java
new file mode 100644 (file)
index 0000000..b84997b
--- /dev/null
@@ -0,0 +1,448 @@
+/*\r
+\r
+   Derby - Class org.apache.derby.impl.store.raw.log.ReadOnly\r
+\r
+   Licensed to the Apache Software Foundation (ASF) under one or more\r
+   contributor license agreements.  See the NOTICE file distributed with\r
+   this work for additional information regarding copyright ownership.\r
+   The ASF licenses this file to you under the Apache License, Version 2.0\r
+   (the "License"); you may not use this file except in compliance with\r
+   the License.  You may obtain a copy of the License at\r
+\r
+      http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
+\r
+ */\r
+\r
+package org.apache.derby.impl.store.raw.log;\r
+\r
+import org.apache.derby.iapi.reference.SQLState;\r
+\r
+import org.apache.derby.iapi.services.monitor.ModuleControl;\r
+import org.apache.derby.iapi.services.monitor.ModuleSupportable;\r
+import org.apache.derby.iapi.services.sanity.SanityManager;\r
+import org.apache.derby.iapi.services.io.Formatable;\r
+\r
+import org.apache.derby.iapi.services.property.PersistentSet;\r
+import org.apache.derby.iapi.store.raw.Compensation;\r
+import org.apache.derby.iapi.store.raw.Loggable;\r
+import org.apache.derby.iapi.store.raw.RawStoreFactory;\r
+import org.apache.derby.iapi.store.raw.ScanHandle;\r
+import org.apache.derby.iapi.store.raw.log.LogFactory;\r
+import org.apache.derby.iapi.store.raw.log.LogInstant;\r
+import org.apache.derby.iapi.store.raw.log.Logger;\r
+import org.apache.derby.iapi.store.raw.log.LogScan;\r
+\r
+import org.apache.derby.iapi.store.raw.data.DataFactory;\r
+import org.apache.derby.iapi.store.raw.xact.TransactionFactory;\r
+import org.apache.derby.iapi.store.raw.xact.RawTransaction;\r
+import org.apache.derby.iapi.store.raw.xact.TransactionId;\r
+\r
+import org.apache.derby.iapi.error.StandardException;\r
+\r
+import org.apache.derby.io.StorageFile;\r
+import org.apache.derby.iapi.store.access.DatabaseInstant;\r
+import org.apache.derby.catalog.UUID;\r
+\r
+import java.util.Properties;\r
+import java.io.File;\r
+\r
+/**\r
+       A read-only version of the log factory.\r
+       It doesn't do anything, it doesn't check that\r
+       the database needs recovery or not.\r
+       <P>\r
+       It doesn't handle undo.  No recovery.\r
+\r
+       <P>Multithreading considerations:<BR>\r
+       This class must be MT-safe.\r
+*/\r
+\r
+public class ReadOnly implements LogFactory, ModuleSupportable {\r
+\r
+       private String logArchiveDirectory = null;\r
+\r
+       /* \r
+       ** Methods of Log Factory\r
+       */\r
+\r
+       public Logger getLogger() {\r
+               return null;\r
+       }\r
+\r
+       /**\r
+         MT - not needed, no work is done\r
+         @exception StandardException Standard Derby Error Policy\r
+       */\r
+       public void recover(RawStoreFactory rawStoreFactory,\r
+                                               DataFactory dataFactory,\r
+                                               TransactionFactory transactionFactory)\r
+                throws StandardException\r
+       {\r
+               if (transactionFactory != null)\r
+                       transactionFactory.useTransactionTable((Formatable)null);\r
+       }\r
+\r
+       /**\r
+         MT - not needed, no work is done\r
+       */\r
+       public boolean checkpoint(RawStoreFactory rawStoreFactory,\r
+                                                         DataFactory dataFactory,\r
+                                                         TransactionFactory transactionFactory,\r
+                                                         boolean wait)\r
+       {\r
+               return true;\r
+       }\r
+\r
+       public StandardException markCorrupt(StandardException originalError) {\r
+               return originalError;\r
+       }\r
+\r
+       public void flush(LogInstant where) throws StandardException {\r
+       }\r
+\r
+       /*\r
+       ** Methods of ModuleControl\r
+       */\r
+\r
+       public boolean canSupport(Properties startParams) {\r
+\r
+               String runtimeLogAttributes = startParams.getProperty(LogFactory.RUNTIME_ATTRIBUTES);\r
+               if (runtimeLogAttributes == null)\r
+                       return false;\r
+\r
+               return runtimeLogAttributes.equals(LogFactory.RT_READONLY);\r
+       }\r
+\r
+       /*\r
+        * truncation point support (not supported)\r
+        */\r
+\r
+       public LogInstant setTruncationLWM(UUID name,\r
+                                                                          LogInstant instant,\r
+                                                                          RawStoreFactory rawStoreFactory, \r
+                                                                         TransactionFactory transFactory)\r
+                throws StandardException\r
+       {\r
+               if (SanityManager.DEBUG)\r
+                       SanityManager.THROWASSERT("functionality not implemented");\r
+\r
+        throw StandardException.newException(\r
+                SQLState.STORE_FEATURE_NOT_IMPLEMENTED);\r
+\r
+       }\r
+\r
+       /**\r
+         @exception StandardException functionality not implmented\r
+       */\r
+       public void setTruncationLWM(UUID name, LogInstant instant) throws StandardException\r
+       {\r
+               if (SanityManager.DEBUG)\r
+                       SanityManager.THROWASSERT("functionality not implemented");\r
+\r
+        throw StandardException.newException(\r
+                SQLState.STORE_FEATURE_NOT_IMPLEMENTED);\r
+       }\r
+\r
+\r
+       /**\r
+         @exception StandardException functionality not implmented\r
+       */\r
+       public void removeTruncationLWM(UUID name,\r
+                                                        RawStoreFactory rawStoreFactory, \r
+                                                        TransactionFactory transFactory)\r
+                throws StandardException\r
+       {\r
+               if (SanityManager.DEBUG)\r
+                       SanityManager.THROWASSERT("functionality not implemented");\r
+\r
+        throw StandardException.newException(\r
+                SQLState.STORE_FEATURE_NOT_IMPLEMENTED);\r
+       }\r
+\r
+\r
+       /**\r
+         @exception StandardException functionality not implmented\r
+       */\r
+       public LogInstant getTruncationLWM(UUID name) throws StandardException\r
+       {\r
+               if (SanityManager.DEBUG)\r
+                       SanityManager.THROWASSERT("functionality not implemented");\r
+\r
+        throw StandardException.newException(\r
+                SQLState.STORE_FEATURE_NOT_IMPLEMENTED);\r
+       }\r
+\r
+       /**\r
+         @exception StandardException functionality not implmented\r
+       */\r
+       public void removeTruncationLWM(UUID name) throws StandardException\r
+       {\r
+               if (SanityManager.DEBUG)\r
+                       SanityManager.THROWASSERT("functionality not implemented");\r
+\r
+        throw StandardException.newException(\r
+                SQLState.STORE_FEATURE_NOT_IMPLEMENTED);\r
+       }\r
+\r
+       /**\r
+         @exception StandardException functionality not implmented\r
+       */\r
+       public ScanHandle openFlushedScan(DatabaseInstant i, int groupsIWant)\r
+                throws StandardException\r
+       {\r
+               if (SanityManager.DEBUG)\r
+                       SanityManager.THROWASSERT("functionality not implemented");\r
+\r
+        throw StandardException.newException(\r
+                SQLState.STORE_FEATURE_NOT_IMPLEMENTED);\r
+       }\r
+\r
+       /**\r
+         @exception StandardException functionality not implmented\r
+       */\r
+       public LogScan openForwardsScan(LogInstant startAt,LogInstant stopAt)\r
+                throws StandardException\r
+       {\r
+               if (SanityManager.DEBUG)\r
+                       SanityManager.THROWASSERT("functionality not implemented");\r
+\r
+        throw StandardException.newException(\r
+                SQLState.STORE_FEATURE_NOT_IMPLEMENTED);\r
+       }\r
+\r
+       /**\r
+         */\r
+    public LogInstant getFirstUnflushedInstant()\r
+       {\r
+               if (SanityManager.DEBUG)\r
+                       SanityManager.THROWASSERT("functionality not implemented");\r
+\r
+               return null;\r
+       }\r
+\r
+       /**\r
+         @exception StandardException functionality not implmented\r
+         */\r
+       public LogScan openForwardsFlushedScan(LogInstant startAt)\r
+                throws StandardException\r
+       {\r
+               if (SanityManager.DEBUG)\r
+                       SanityManager.THROWASSERT("functionality not implemented");\r
+\r
+        throw StandardException.newException(\r
+                SQLState.STORE_FEATURE_NOT_IMPLEMENTED);\r
+       }\r
+\r
+       /**\r
+        * Backup restore - stop sending log record to the log stream\r
+        * @exception StandardException Standard Derby error policy\r
+        */\r
+       public void freezePersistentStore() throws StandardException\r
+       {\r
+               // read only, do nothing\r
+       }\r
+\r
+       /**\r
+        * Backup restore - start sending log record to the log stream\r
+        * @exception StandardException Standard Derby error policy\r
+        */\r
+       public void unfreezePersistentStore() throws StandardException\r
+       {\r
+               // read only, do nothing\r
+       }\r
+\r
+       /**\r
+        * Backup restore - is the log being archived to some directory?\r
+        * if RawStore.LOG_ARCHIVAL_DIRECTORY is set to some value, that means the\r
+        * log is meant to be archived.  Else, log not archived.\r
+        */\r
+       public boolean logArchived()\r
+       {\r
+               return (logArchiveDirectory != null);\r
+       }\r
+\r
+       /**\r
+               Get JBMS properties relavent to the log factory\r
+        */\r
+       public void getLogFactoryProperties(PersistentSet set) \r
+       {\r
+               // do nothing\r
+       }\r
+       \r
+       public StorageFile getLogDirectory()\r
+       {\r
+               return null;\r
+       }\r
+\r
+       public String getCanonicalLogPath()\r
+       {\r
+               return null;\r
+       }\r
+\r
+       \r
+       //roll-forward recovery support routines\r
+       //Nothing to be done for read only databases\r
+       public void enableLogArchiveMode()\r
+       {\r
+               //do nothing\r
+       }\r
+\r
+       public void disableLogArchiveMode()\r
+       {\r
+               //do nothing\r
+       }\r
+\r
+       //this function is suppose to delete all the logs \r
+       //before this call that are not active logs.\r
+       public void deleteOnlineArchivedLogFiles()\r
+       {\r
+               //do nothing\r
+       }\r
+\r
+\r
+       //Is the transaction in rollforward recovery\r
+       public boolean inRFR()\r
+       {\r
+               return false;\r
+       }\r
+\r
+       /**     \r
+               perform a  checkpoint during rollforward recovery\r
+       */\r
+       public void checkpointInRFR(LogInstant cinstant, long redoLWM, \r
+                                                               DataFactory df) throws StandardException\r
+       {\r
+               //do nothing\r
+       }\r
+\r
+               \r
+       /*\r
+        * There are no log files to backup for  read  only databases, nothing to be\r
+     * done here. \r
+     * @param toDir - location where the log files should be copied to.\r
+     * @exception StandardException Standard Derby error policy\r
+       */\r
+       public void startLogBackup(File toDir) throws StandardException\r
+       {\r
+               // nothing to do for read only databases.\r
+       }\r
+\r
+       \r
+       /* \r
+     * There are no log files to backup for read only databases, \r
+     * nothing to be done here. \r
+     *\r
+     * @param toDir - location where the log files should be copied to.\r
+     * @exception StandardException Standard Derby error policy\r
+       */\r
+       public void endLogBackup(File toDir) throws StandardException\r
+       {\r
+               // nothing to do for read only databases.\r
+       }\r
+\r
+       \r
+       /*\r
+     * Log backup is not started for for read only databases, no work to do\r
+     * here.\r
+        **/\r
+       public void abortLogBackup()\r
+       {\r
+               // nothing to do for read only databases.\r
+       }\r
+\r
+    /*\r
+     * Set that the database is encrypted. Read-only database can not \r
+     * be reencrypted, nothing to do in this case. \r
+     */\r
+    public void setDatabaseEncrypted(boolean flushLog)\r
+    {\r
+        // nothing to do for a read-only database.\r
+    }\r
+\r
+\r
+    /*\r
+     * set up a new log file to start writing \r
+     * the log records into the new log file \r
+     * after this call.\r
+     *\r
+     * <P>MT - synchronization provided by caller - RawStore boot,\r
+     * This method is called while re-encrypting the database \r
+     * at databse boot time. \r
+     *\r
+     * Read-only database can not be reencrypted, \r
+     * nothing to do in this case. \r
+     */\r
+    public void startNewLogFile() throws StandardException \r
+    {\r
+        // nothing to do for a read-only database. \r
+    }\r
+\r
+    /*\r
+     * find if the checkpoint is in the last log file. \r
+     *\r
+     * <P>MT - synchronization provided by caller - RawStore boot,\r
+     * This method is called only if a crash occured while \r
+     * re-encrypting the database at boot time. \r
+\r
+     * Read-only database can not be re-encrypted, \r
+     * nothing to do in this case. \r
+     */\r
+    public boolean isCheckpointInLastLogFile() \r
+        throws StandardException \r
+    {\r
+        // nothing to do for a read-only database. \r
+        return false;\r
+    }\r
+    \r
+    /*\r
+     * delete the log file after the checkpoint. \r
+     *\r
+     * <P>MT - synchronization provided by caller - RawStore boot,\r
+     * This method is called only if a crash occured while \r
+     * re-encrypting the database at boot time. \r
+     *\r
+     * Read-only database can not be re-encrypted, \r
+     * nothing to do in this case. \r
+     */\r
+    public void deleteLogFileAfterCheckpointLogFile() \r
+        throws StandardException \r
+    {\r
+        // nothing to do for a read-only database. \r
+    }\r
+\r
+\r
+\r
+    /**\r
+     *  Check to see if a database has been upgraded to the required\r
+     *  level in order to use a store feature.\r
+     *\r
+     * This method is generally used to prevent writes to \r
+     * data/log file by a particular store feature until the \r
+     * database is upgraded to the required version. \r
+     * In read-only database writes are not allowed, so nothing to do\r
+     * for this method in this implementation of the log factory.\r
+     *\r
+     * @param requiredMajorVersion  required database Engine major version\r
+     * @param requiredMinorVersion  required database Engine minor version\r
+     * @param feature Non-null to throw an exception, null to return the \r
+     *                state of the version match.\r
+     *\r
+     * @exception  StandardException \r
+     *             not implemented exception is thrown\r
+     */\r
+       public boolean checkVersion(int requiredMajorVersion, \r
+                                int requiredMinorVersion, \r
+                                String feature) \r
+        throws StandardException\r
+    {\r
+        // nothing to do for read only databases; \r
+        throw StandardException.newException(\r
+                  SQLState.STORE_FEATURE_NOT_IMPLEMENTED);\r
+    }\r
+}\r