db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1403611 - in /db/derby/code/trunk/java: engine/org/apache/derby/iapi/services/monitor/ engine/org/apache/derby/iapi/store/raw/ engine/org/apache/derby/impl/services/monitor/ engine/org/apache/derby/impl/store/access/ engine/org/apache/derb...
Date Tue, 30 Oct 2012 04:03:45 GMT
Author: mamta
Date: Tue Oct 30 04:03:45 2012
New Revision: 1403611

URL: http://svn.apache.org/viewvc?rev=1403611&view=rev
Log:
DERBY-5232 (Put a stern README file in log and seg0 directories to warn users of corrpution
they will cause if they touch files there)

This will create 3 readme(README_DONT_TOUCH_FILES.txt) files at database creation time, One
at the database level, one in the "log" directory and another in the "seg0" directory. 
a)Content of the readme file at the database level are as follows 
# ************************************************************************* 
# *** Do not touch files in this directory! *** 
# *** FILES IN THIS DIRECTORY AND SUB-DIRECTORIES CONSTITUES DERBY *** 
# *** DATABASE WHICH INCLUDES THE DATA(USER AND SYSTEM) AND THE *** 
# *** NECESSARY FILES FOR DATABASE RECOVERY. *** 
# *** EDITING, ADDITING OR DELETING ANY OF THESE FILES MAY CAUSE DATA *** 
# *** CORRUPTION AND LEAVE THE DATABASE IN NON-RECOVERABLE STATE. *** 
# ************************************************************************* 
b)Content of the readme file at "seg0" directory are as follows 
# ************************************************************************* 
# *** Do not touch files in this directory! *** 
# *** FILES IN THIS DIRECTORY ARE USED BY THE DERBY DATABASE TO STORE *** 
# *** USER AND SYSTEM DATA. EDITING, ADDING, OR DELETING FILES IN THIS *** 
# *** DIRECTORY WILL CORRUPT THE ASSOCIATED DERBY DATABASE, AND WILL *** 
# *** NOT BE RECOVERABLE. *** 
# ************************************************************************* 
c)Content of the readme file at "log" directory are as follows 
# ************************************************************************* 
# *** Do not touch files in this directory! *** 
# *** FILES IN THIS DIRECTORY ARE USED BY THE DERBY DATABASE RECOVERY *** 
# *** SYSTEM. EDITING, ADDING OR DELETING FILES IN THIS DIRECTORY WILL *** 
# *** CAUSE THE DERBY RECOVERY SYSTEM TO FAIL LEADING TO UNRECOVERABLE *** 
# *** CORRUPT DATABASES. *** 
# ************************************************************************* 




Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/monitor/PersistentService.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/RawStoreFactory.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/BaseMonitor.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/StorageFactoryService.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/RAMAccessManager.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/RawStore.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java
    db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml
    db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/MessageId.java
    db/derby/code/trunk/java/storeless/org/apache/derby/impl/storeless/StorelessService.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/monitor/PersistentService.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/monitor/PersistentService.java?rev=1403611&r1=1403610&r2=1403611&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/monitor/PersistentService.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/monitor/PersistentService.java
Tue Oct 30 04:03:45 2012
@@ -82,6 +82,11 @@ public interface PersistentService {
 
     /** Service stored in memory only (not persistent), virtual file memory. */
     public static final String INMEMORY = "memory";
+    /**
+        The readme file cautioning users against touching the files in
+        the database directory 
+    */
+    public static final String DB_README_FILE_NAME = "README_DONT_TOUCH_FILES.txt";
 
 	/**
 		The typical name for the service's properties file.
@@ -116,6 +121,17 @@ public interface PersistentService {
 	*/
 	public Enumeration getBootTimeServices();
 
+    /**
+        Put a readme file in database directory which will caution users
+        against touching any files in the directory. This file will be
+        created at database creation time.
+
+        @param sf StorageFactory will be used to create the file
+
+        @exception StandardException File can't be created
+    */
+    public void createDataWarningFile(StorageFactory sf) throws StandardException;
+
 	/**
 		For a service return its service properties, typically from the service.properties
 		file.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/RawStoreFactory.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/RawStoreFactory.java?rev=1403611&r1=1403610&r2=1403611&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/RawStoreFactory.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/RawStoreFactory.java Tue
Oct 30 04:03:45 2012
@@ -1037,4 +1037,13 @@ public interface RawStoreFactory extends
     int     requiredMinorVersion, 
     String  feature) 
         throws StandardException;
+    
+    /**
+     *  Use the available storage factory handle to create a readme
+     *   file in "seg0" directory warning users to not edit/delete
+     *   any files in the directory to avoid database corruption.
+     * 
+     * @throws StandardException
+     */
+    public void createDataWarningFile() throws StandardException;
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/BaseMonitor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/BaseMonitor.java?rev=1403611&r1=1403610&r2=1403611&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/BaseMonitor.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/BaseMonitor.java
Tue Oct 30 04:03:45 2012
@@ -1824,6 +1824,12 @@ nextModule:
 
 			instance = ts.bootModule(create, null, serviceKey, serviceProperties);
 
+            //Put a readme file in database directory, alerting users to not 
+            // touch or remove any of the files there 
+            if (create) {
+                provider.createDataWarningFile(usProperties.getStorageFactory());
+            }
+			
 			if (create || inRestore) {
 				// remove all the in-memory properties
 				provider.saveServiceProperties(serviceName, usProperties.getStorageFactory(),

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/StorageFactoryService.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/StorageFactoryService.java?rev=1403611&r1=1403610&r2=1403611&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/StorageFactoryService.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/StorageFactoryService.java
Tue Oct 30 04:03:45 2012
@@ -35,6 +35,7 @@ import org.apache.derby.iapi.error.Stand
 import org.apache.derby.io.StorageFile;
 import org.apache.derby.io.StorageFactory;
 import org.apache.derby.io.WritableStorageFactory;
+import org.apache.derby.io.StorageRandomAccessFile;
 
 import org.apache.derby.iapi.reference.Attribute;
 import org.apache.derby.iapi.reference.Property;
@@ -424,6 +425,53 @@ final class StorageFactoryService implem
         catch( PrivilegedActionException pae) { throw (StandardException) pae.getException();}
 	} // end of saveServiceProperties
 
+	
+    /** @see PersistentService#createDataWarningFile */
+    public void createDataWarningFile(StorageFactory sf) throws StandardException {
+        if( ! (sf instanceof WritableStorageFactory))
+            throw StandardException.newException(SQLState.READ_ONLY_SERVICE);
+        final WritableStorageFactory storageFactory = (WritableStorageFactory) sf;
+        try
+        {
+            AccessController.doPrivileged(
+            	    new PrivilegedExceptionAction()
+            	    {
+            	        public Object run() throws StandardException
+            	        {
+            	            StorageRandomAccessFile fileReadMeDB=null;
+            	            try 
+            	            {
+            	                StorageFile fileReadMe = storageFactory.newStorageFile(
+            	                    PersistentService.DB_README_FILE_NAME);
+                                fileReadMeDB = fileReadMe.getRandomAccessFile( "rw");
+                                fileReadMeDB.writeUTF(MessageService.getTextMessage(
+                                    MessageId.README_AT_DB_LEVEL));
+                                fileReadMeDB.close();
+                            }
+                            catch (IOException ioe)
+                            {
+                            }
+                            finally
+                            {
+                                if (fileReadMeDB != null)
+                                {
+                                    try
+                                    {
+                                        fileReadMeDB.close();
+                                    }
+                                    catch (IOException ioe)
+                                    {
+                                        // Ignore exception on close
+                                    }
+                                }
+                            }
+                            return null;
+                        }
+                    }
+                );
+        }
+        catch( PrivilegedActionException pae) { throw (StandardException) pae.getException();}
+    } // end of createDataWarningFile
 
     /**
      * Save service.properties during backup

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/RAMAccessManager.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/RAMAccessManager.java?rev=1403611&r1=1403610&r2=1403611&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/RAMAccessManager.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/RAMAccessManager.java
Tue Oct 30 04:03:45 2012
@@ -1149,6 +1149,12 @@ public abstract class RAMAccessManager
         // db would fail when trying to create this first file in seg0.
         xactProperties = new PropertyConglomerate(tc, create, startParams, pf);
 
+        //Put a readme file in seg0 directory, alerting users to not 
+        // touch or remove any of the files there 
+        if(create) {
+            rawstore.createDataWarningFile();
+        }
+
         // see if there is any properties that raw store needs to know
         // about
         rawstore.getRawStoreProperties(tc);

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/RawStore.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/RawStore.java?rev=1403611&r1=1403610&r2=1403611&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/RawStore.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/RawStore.java Tue Oct
30 04:03:45 2012
@@ -54,6 +54,7 @@ import org.apache.derby.iapi.store.raw.l
 import org.apache.derby.impl.services.monitor.UpdateServiceProperties;
 
 import org.apache.derby.io.StorageFactory;
+import org.apache.derby.io.StorageRandomAccessFile;
 import org.apache.derby.io.WritableStorageFactory;
 import org.apache.derby.io.StorageFile;
 import org.apache.derby.iapi.store.access.DatabaseInstant;
@@ -2769,4 +2770,35 @@ public final class RawStore implements R
     private static boolean isTrue(Properties p, String attribute) {
         return Boolean.valueOf(p.getProperty(attribute)).booleanValue();
     }
+
+    /** @see RawStoreFactory#createDataWarningFile */
+    public void createDataWarningFile() throws StandardException {
+        StorageFile fileReadMe = storageFactory.newStorageFile(
+            "seg0",
+            PersistentService.DB_README_FILE_NAME);
+        StorageRandomAccessFile fileReadMeDB=null;
+        try {
+            fileReadMeDB = fileReadMe.getRandomAccessFile("rw");
+            fileReadMeDB.writeUTF(MessageService.getTextMessage(
+                MessageId.README_AT_SEG_LEVEL));
+            fileReadMeDB.close();
+        }
+        catch (IOException ioe)
+        {
+        }
+        finally
+        {
+            if (fileReadMeDB != null)
+            {
+                try
+                {
+                    fileReadMeDB.close();
+                }
+                catch (IOException ioe)
+                {
+                    // Ignore exception on close
+                }
+            }
+        }
+    }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java?rev=1403611&r1=1403610&r2=1403611&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java Tue
Oct 30 04:03:45 2012
@@ -2732,8 +2732,38 @@ public final class LogToFile implements 
                 throw StandardException.newException(
                     SQLState.LOG_SEGMENT_NOT_EXIST, logDir.getPath());
             }
+            
+            //Put a readme file in the log directory, alerting users to not 
+            // touch or remove any of the files there 
+            StorageFile fileReadMe = logStorageFactory.newStorageFile(
+                LogFactory.LOG_DIRECTORY_NAME,
+                PersistentService.DB_README_FILE_NAME);
+            StorageRandomAccessFile fileReadMeDB=null;
+            try {
+                fileReadMeDB = fileReadMe.getRandomAccessFile("rw");
+                fileReadMeDB.writeUTF(MessageService.getTextMessage(
+                    MessageId.README_AT_LOG_LEVEL));
+                fileReadMeDB.close();
+            }
+            catch (IOException ioe)
+            {
+            }
+            finally
+            {
+                if (fileReadMeDB != null)
+                {
+                    try
+                    {
+                        fileReadMeDB.close();
+                    }
+                    catch (IOException ioe)
+                    {
+                        // Ignore exception on close
+                    }
+                }
+            }
         }
-	}
+    }
 
 	/*
 		Return the directory the log should go.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml?rev=1403611&r1=1403610&r2=1403611&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml Tue Oct 30 04:03:45
2012
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE messages SYSTEM "messages.dtd">
 
 <!-- 
@@ -8424,6 +8424,46 @@ Shutting down instance {0} on database d
             </msg>
 
             <msg>
+                <name>M005</name>
+                <text>
+# *************************************************************************
+# ***              Do not touch files in this directory!                ***
+# *** FILES IN THIS DIRECTORY AND SUB-DIRECTORIES CONSTITUES DERBY      ***
+# *** DATABASE WHICH INCLUDES THE DATA(USER AND SYSTEM) AND THE         ***
+# *** NECESSARY FILES FOR DATABASE RECOVERY.                            ***
+# *** EDITING, ADDITING OR DELETING ANY OF THESE FILES MAY CAUSE DATA   ***
+# *** CORRUPTION AND LEAVE THE DATABASE IN NON-RECOVERABLE STATE.       ***
+# *************************************************************************</text>
+                <comment>Translators: Please translate the ALL CAPS words.</comment>
+            </msg>
+
+            <msg>
+                <name>M006</name>
+                <text>
+# *************************************************************************
+# ***              Do not touch files in this directory!                ***
+# *** FILES IN THIS DIRECTORY ARE USED BY THE DERBY DATABASE RECOVERY   ***
+# *** SYSTEM. EDITING, ADDING OR DELETING FILES IN THIS DIRECTORY WILL  ***
+# *** CAUSE THE DERBY RECOVERY SYSTEM TO FAIL LEADING TO UNRECOVERABLE  ***
+# *** CORRUPT DATABASES.                                                ***
+# *************************************************************************</text>
+                <comment>Translators: Please translate the ALL CAPS words.</comment>
+            </msg>
+
+            <msg>
+                <name>M007</name>
+                <text>
+# *************************************************************************
+# ***              Do not touch files in this directory!                ***
+# *** FILES IN THIS DIRECTORY ARE USED BY THE DERBY DATABASE TO STORE   *** 
+# *** USER AND SYSTEM DATA. EDITING, ADDING, OR DELETING FILES IN THIS  ***
+# *** DIRECTORY WILL CORRUPT THE ASSOCIATED DERBY DATABASE, AND WILL    ***
+# *** NOT BE RECOVERABLE.                                               ***
+# *************************************************************************</text>
+                <comment>Translators: Please translate the ALL CAPS words.</comment>
+            </msg>
+
+            <msg>
                 <name>N001</name>
                 <text>This error is caused by the following error.</text>
             </msg>

Modified: db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/MessageId.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/MessageId.java?rev=1403611&r1=1403610&r2=1403611&view=diff
==============================================================================
--- db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/MessageId.java
(original)
+++ db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/MessageId.java
Tue Oct 30 04:03:45 2012
@@ -214,6 +214,12 @@ public interface MessageId {
     String SERVICE_PROPERTIES_BACKUP_DELETED                = "M003";
     /** Informational message, service properties backup deletion failed. */
     String SERVICE_PROPERTIES_BACKUP_DEL_FAILED             = "M004";
+    /** Tell user not to edit/delete any files in the directory. */
+    String README_AT_DB_LEVEL                                = "M005";
+    /** Tell user not to edit/delete any files in the log directory. */
+    String README_AT_LOG_LEVEL                               = "M006";
+    /** Tell user not to edit/delete any files in the seg directory. */
+    String README_AT_SEG_LEVEL                               = "M007";
 
     /*
      * Misc

Modified: db/derby/code/trunk/java/storeless/org/apache/derby/impl/storeless/StorelessService.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/storeless/org/apache/derby/impl/storeless/StorelessService.java?rev=1403611&r1=1403610&r2=1403611&view=diff
==============================================================================
--- db/derby/code/trunk/java/storeless/org/apache/derby/impl/storeless/StorelessService.java
(original)
+++ db/derby/code/trunk/java/storeless/org/apache/derby/impl/storeless/StorelessService.java
Tue Oct 30 04:03:45 2012
@@ -109,4 +109,10 @@ public class StorelessService implements
     protected int getEngineType() {
         return EngineType.STORELESS_ENGINE;
     }
+
+    /** @see PersistentService#createDataWarningFile */
+    public void createDataWarningFile(StorageFactory sf) 
+            throws StandardException {
+        // Auto-generated method stub
+    }
 }



Mime
View raw message