Adding JMCR-Stable version
[Benchmarks_CSolver.git] / JMCR-Stable / real-world application / MyDerby-10.3 / java / engine / org / apache / derby / iapi / store / raw / data / DataFactory.java
diff --git a/JMCR-Stable/real-world application/MyDerby-10.3/java/engine/org/apache/derby/iapi/store/raw/data/DataFactory.java b/JMCR-Stable/real-world application/MyDerby-10.3/java/engine/org/apache/derby/iapi/store/raw/data/DataFactory.java
new file mode 100644 (file)
index 0000000..f653503
--- /dev/null
@@ -0,0 +1,382 @@
+/*\r
+\r
+   Derby - Class org.apache.derby.iapi.store.raw.data.DataFactory\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.iapi.store.raw.data;\r
+\r
+import org.apache.derby.iapi.store.raw.ContainerKey;\r
+\r
+import org.apache.derby.iapi.services.daemon.Serviceable;\r
+import org.apache.derby.iapi.services.context.ContextManager;\r
+\r
+import org.apache.derby.iapi.error.StandardException;\r
+import org.apache.derby.iapi.store.raw.ContainerHandle;\r
+import org.apache.derby.iapi.store.raw.Corruptable;\r
+import org.apache.derby.iapi.store.raw.LockingPolicy;\r
+import org.apache.derby.iapi.store.raw.RawStoreFactory;\r
+import org.apache.derby.iapi.store.raw.RecordHandle;\r
+import org.apache.derby.iapi.store.raw.StreamContainerHandle;\r
+import org.apache.derby.iapi.store.raw.xact.RawTransaction;\r
+import org.apache.derby.iapi.store.raw.Transaction;\r
+import org.apache.derby.io.StorageFactory;\r
+import org.apache.derby.iapi.store.access.FileResource;\r
+import org.apache.derby.iapi.store.access.RowSource;\r
+import org.apache.derby.iapi.store.raw.log.LogInstant;\r
+import org.apache.derby.iapi.util.ByteArray;\r
+import org.apache.derby.catalog.UUID;\r
+\r
+import java.util.Properties;\r
+import java.io.File;\r
+\r
+public interface DataFactory extends Corruptable {\r
+\r
+       public static final String MODULE = "org.apache.derby.iapi.store.raw.data.DataFactory";\r
+\r
+       /**\r
+               The temporary segment is called "tmp"\r
+        */\r
+       public static final String TEMP_SEGMENT_NAME = "tmp";\r
+\r
+       /**\r
+               The database lock\r
+        */\r
+       public static final String DB_LOCKFILE_NAME = "db.lck";\r
+\r
+       /**\r
+       ** file name that is used to acquire exclusive lock on DB.\r
+       **/\r
+       public static final String DB_EX_LOCKFILE_NAME = "dbex.lck";\r
+\r
+       /**\r
+               Is the store read-only.\r
+       */\r
+       public boolean isReadOnly();\r
+\r
+\r
+       /**\r
+               Open a container that is not droped.\r
+\r
+               @param t the raw transaction that is opening the container\r
+               @param containerId the container's identity\r
+               @param locking the locking policy\r
+               @param mode see the different mode in @see ContainerHandle\r
+               then will return a null handle if the container is dropped.\r
+\r
+               @return the handle to the opened container\r
+               @exception StandardException Standard Derby error policy\r
+\r
+        */\r
+       public ContainerHandle openContainer(RawTransaction t,\r
+                                                                                ContainerKey containerId,\r
+                                                                                LockingPolicy locking,\r
+                                                                                int mode)\r
+                throws StandardException;\r
+\r
+       /**\r
+               Open a container that may have been dropped.\r
+               Only internal raw store code should call this, e.g. recovery.\r
+\r
+               @see #openContainer\r
+               @exception StandardException Standard Derby error policy\r
+       */\r
+       public RawContainerHandle openDroppedContainer(RawTransaction t,\r
+                                                                                                  ContainerKey containerId,\r
+                                                                                                  LockingPolicy locking,\r
+                                                                                                  int mode)\r
+               throws StandardException;\r
+\r
+       /**\r
+               Add a container.\r
+\r
+               @param t the transaction that is creating the container\r
+               @param segmentId the segment where the container is to go\r
+               @param mode whether or not to LOGGED or not.  The effect of this mode\r
+                               is only for this addContainer call, not persisently stored\r
+                               throughout the lifetime of the container\r
+               @param tableProperties properties of the container that is persistently\r
+                               stored throughout the lifetime of the container\r
+\r
+               @return the containerId of the newly created container\r
+\r
+               @exception StandardException Standard Derby Error policy\r
+\r
+        */\r
+       public long addContainer(\r
+    RawTransaction  t,\r
+    long            segmentId,\r
+    long            containerid,\r
+    int             mode,\r
+    Properties      tableProperties,\r
+    int             temporaryFlag)\r
+               throws StandardException;\r
+\r
+       /**\r
+               Create and load a stream container.\r
+\r
+               @param t the transaction that is creating the container\r
+               @param segmentId the segment where the container is to go\r
+               @param tableProperties properties of the container that is persistently\r
+                               stored throughout the lifetime of the container\r
+               @param rowSource the data to load the container with\r
+\r
+               @return the containerId of the newly created stream container\r
+\r
+               @exception StandardException Standard Derby Error policy\r
+\r
+        */\r
+       public long addAndLoadStreamContainer(RawTransaction t, long segmentId,\r
+                       Properties tableProperties, RowSource rowSource)\r
+                throws StandardException;\r
+\r
+       /**\r
+               Open a stream container.\r
+\r
+               @return a valid StreamContainerHandle or null if the container does not exist.\r
+\r
+               @exception StandardException  Standard Derby exception policy\r
+\r
+       */\r
+       public StreamContainerHandle openStreamContainer(\r
+    RawTransaction  t,\r
+    long            segmentId,\r
+    long            containerId,\r
+    boolean         hold)\r
+               throws StandardException;\r
+\r
+       /**\r
+               Drop and remove a stream container.\r
+\r
+               @exception StandardException  Standard Derby exception policy\r
+       */\r
+       public void dropStreamContainer(RawTransaction t, long segmentId, long containerId)\r
+               throws StandardException;\r
+\r
+       /**\r
+               re-Create a container during redo recovery.\r
+\r
+        Used if container is found to not exist during redo recovery of\r
+        log records creating the container.\r
+\r
+               @exception StandardException Standard Derby Error policy\r
+        */\r
+       public void reCreateContainerForRedoRecovery(RawTransaction t,\r
+                       long segmentId, long containerId, ByteArray containerInfo)\r
+                throws StandardException;\r
+\r
+\r
+       public void dropContainer(RawTransaction t, ContainerKey containerId)\r
+               throws StandardException;\r
+\r
+       public void checkpoint() throws StandardException;\r
+\r
+       public void idle() throws StandardException;\r
+\r
+       /**\r
+               Return the identifier that uniquely identifies this raw store at runtime.\r
+               This identifier is to be used as part of the lokcing key for objects\r
+               locked in the raw store by value (e.g. Containers).\r
+       */\r
+       public UUID getIdentifier();\r
+\r
+       /**\r
+               make data factory aware of which raw store factory it belongs to\r
+               Also need to boot the LogFactory\r
+\r
+               @exception StandardException cannot boot the log factory\r
+       */\r
+       public void setRawStoreFactory(RawStoreFactory rsf, boolean create,\r
+                                                                  Properties properties)\r
+                throws StandardException ;\r
+\r
+       /**\r
+               Return a record handle that is initialized to the given page number and\r
+        record id.\r
+\r
+               @exception StandardException Standard Derby exception policy.\r
+\r
+               @param segmentId    segment where the RecordHandle belongs.\r
+               @param containerId  container where the RecordHandle belongs.\r
+               @param pageNumber   the page number of the RecordHandle.\r
+               @param recordId     the record id of the RecordHandle.\r
+\r
+               @see RecordHandle\r
+       */\r
+//     public RecordHandle makeRecordHandle(long segmentId, long containerId, long pageNumber, int recordId)\r
+//              throws StandardException;\r
+\r
+       /**\r
+               Database creation finished\r
+\r
+               @exception StandardException Standard Derby exception policy.\r
+       */\r
+       public void createFinished() throws StandardException;\r
+\r
+       /**\r
+               Get an object to handle non-transactional files.\r
+       */\r
+       public FileResource getFileHandler();\r
+\r
+       /**\r
+               Tell the data factory it is OK to remove committed deleted containers\r
+               when the data factory shuts down.\r
+        */\r
+       public void removeStubsOK();\r
+\r
+       /**\r
+               Get cache statistics for the specified cache\r
+       */\r
+       public long[] getCacheStats(String cacheName);\r
+\r
+       /**\r
+               Reset the cache statistics for the specified cache\r
+       */\r
+       public void resetCacheStats(String cacheName);\r
+\r
+       /**\r
+               Reclaim space used by this factory.  Called by post commit daemon.\r
+               @exception StandardException  Standard Derby exception policy\r
+       */\r
+       public int reclaimSpace(Serviceable work, ContextManager contextMgr)\r
+                throws StandardException;\r
+\r
+       /**\r
+               Called after recovery is performed.\r
+\r
+               @exception StandardException Standard Derby Error Policy\r
+       */\r
+       public void postRecovery() throws StandardException;\r
+\r
+       /**\r
+               Encrypt cleartext into ciphertext.\r
+\r
+               @see org.apache.derby.iapi.services.crypto.CipherProvider#encrypt\r
+               @exception StandardException Standard Derby Error Policy\r
+        */\r
+       public int encrypt(byte[] cleartext, int offset, int length,\r
+                                          byte[] ciphertext, int outputOffset, \r
+                       boolean newEngine)\r
+                throws StandardException ;\r
+\r
+       /**\r
+               Decrypt cleartext from ciphertext.\r
+\r
+               @see org.apache.derby.iapi.services.crypto.CipherProvider#decrypt\r
+               @exception StandardException Standard Derby Error Policy\r
+        */\r
+       public int decrypt(byte[] ciphertext, int offset, int length,\r
+                                          byte[] cleartext, int outputOffset)\r
+                throws StandardException ;\r
+\r
+    /**\r
+        * Encrypt all the containers in the data segment.\r
+     * @param t the transaction that is encrypting the containers.\r
+     * @exception StandardException Standard Derby Error Policy\r
+        */\r
+       public void encryptAllContainers(RawTransaction t) \r
+        throws StandardException;\r
+\r
+    /**\r
+     * Remove old versions of the containers after (re)encryption \r
+     * of the  database. \r
+     * @param inRecovery  <code> true </code>, if cleanup is \r
+     *                    happening during recovery.\r
+     * @exception StandardException Standard Derby Error Policy\r
+     */\r
+    public void removeOldVersionOfContainers(boolean inRecovery) \r
+        throws StandardException;\r
+\r
+    /**\r
+     * Set that the database is encrypted.\r
+     */\r
+    public void setDatabaseEncrypted();\r
+\r
+       /**\r
+               Return the encryption block size used by the algorithm at time of\r
+               encrypted database creation\r
+        */\r
+       public int getEncryptionBlockSize();\r
+\r
+       /**\r
+        * Backup restore - stop writing dirty pages or container to disk\r
+        * @exception StandardException Standard Derby error policy\r
+        */\r
+       public void freezePersistentStore() throws StandardException;\r
+\r
+       /**\r
+        * Backup restore - start writing dirty pages or container to disk\r
+        */\r
+       public void unfreezePersistentStore();\r
+\r
+       /**\r
+        * Backup restore - don't allow the persistent store to be frozen - or if\r
+        * it is already frozen, block.   A write is about to commence.\r
+        * @exception StandardException Standard Derby error policy\r
+        */\r
+       public void writeInProgress() throws StandardException;\r
+\r
+       /**\r
+        * Backup restore - write finished, if this is the last writer, allow the\r
+        * persistent store to proceed.\r
+        */\r
+       public void writeFinished();\r
+\r
+       /**\r
+        * Back up the data segment of the database.\r
+        */\r
+       public void backupDataFiles(Transaction rt, File backupDir) throws StandardException;\r
+\r
+    /**\r
+     * Return an id which can be used to create a container.\r
+     * <p>\r
+     * Return an id number with is greater than any existing container\r
+     * in the current database.  Caller will use this to allocate future\r
+     * container numbers - most likely caching the value and then incrementing\r
+     * it as it is used.\r
+     * <p>\r
+     *\r
+        * @return The an id which can be used to create a container.\r
+     *\r
+        * @exception  StandardException  Standard exception policy.\r
+     **/\r
+    long getMaxContainerId()\r
+               throws StandardException;\r
+\r
+       /**\r
+        * This function is called after a checkpoint to remove the stub files thar are not required\r
+        * during recovery. Crash recovery  uses these files to identify the dropped\r
+        * containers.   Stub files(d*.dat) gets creates  when a\r
+        * table/index(containers) dropped.\r
+        * @exception StandardException Standard Derby error policy\r
+        **/\r
+    public void removeDroppedContainerFileStubs(LogInstant redoLWM) throws StandardException;\r
+\r
+    /**\r
+     * @return The StorageFactory used by this dataFactory\r
+     */\r
+    public StorageFactory getStorageFactory();\r
+\r
+       public void     stop();\r
+\r
+    /**\r
+     * Returns if data base is in encrypted mode.\r
+     * @return true if database encrypted false otherwise\r
+     */\r
+    public boolean databaseEncrypted();\r
+}\r