⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 corruptdiskstoragefactory.java

📁 derby database source code.good for you.
💻 JAVA
字号:
/*

   Derby - Class org.apache.derbyTesting.functionTests.util.corruptio.CorruptDiskStorageFactory

   Copyright 2004 The Apache Software Foundation or its licensors, as applicable.

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

 */

package org.apache.derbyTesting.functionTests.util.corruptio;
import org.apache.derby.io.WritableStorageFactory;
import org.apache.derby.io.StorageFactory;
import org.apache.derby.iapi.services.info.JVMInfo;

/**
 * This class provides proxy implementation of the StorageFactory
 * interface for testing. 
 *
 * Storage Factory is used by the database engine to access 
 * persistent data and transaction logs. By default all the method calls
 * delegate the work to the real disk storage factory
 * (org.apache.derby.impl.io.DirStorageFactory)
 * based on the classes in the java.io packgs. In some cases this  factory
 * instruments some methods to corrupt the io to simulate disk corruptions for
 * testing. For example to simulate out of order partial writes to disk before
 * the crash. 
 * 
 * Derby by default uses the storage factory implementation in 
 * DirStorageFactory/DirStorageFactory4 when a database is accessed with 
 * "jdbc:derby:<databaseName>". This factory can be specified instead using 
 * derby.subSubProtocol.<sub protocol name>  For example:
 *
 *  derby.subSubProtocol.csf=org.apache.derbyTesting.functionTests.
 *             util.corruptio.CorruptDiskStorageFactory
 *  database need to be accessed by specifying the subporotocol name like
 *  'jdbc:derby:csf:wombat'.
 *
 * Interaction between the tests that requires instrumenting the i/o and 
 * this factory is through the flags in CorruptibleIo class. Tests should not 
 * call the methods in this factory directly. Database engine invokes the 
 * methods in this factory, so they can instrumented to do whatever is 
 * required for testing.
 * 
 * @author <a href="mailto:suresh.thalamati@gmail.com">Suresh Thalamati</a>
 * @version 1.0
 * @see CorruptibleIo
 * @see WritableStorageFactory
 * @see StorageFactory
 * 
 */

public class CorruptDiskStorageFactory extends CorruptBaseStorageFactory
{
	/*
	 * returns the real storage factory to which all the call should be 
	 * delegated from the proxy methods.  
	 */
	WritableStorageFactory getRealStorageFactory()
	{
		String dirStorageFactoryClass;
		if( JVMInfo.JDK_ID >= JVMInfo.J2SE_14)
        {
            dirStorageFactoryClass = 
                "org.apache.derby.impl.io.DirStorageFactory4";
        }
        else
        {
            dirStorageFactoryClass = 
                "org.apache.derby.impl.io.DirStorageFactory";
        }
		
		WritableStorageFactory storageFactory = null;
		try{
			Class storageFactoryClass = Class.forName(dirStorageFactoryClass);
			storageFactory = 
                (WritableStorageFactory) storageFactoryClass.newInstance();
		}catch(Exception e)
		{
			System.out.println(
                "Failed to instantiate the disk storeage classes");
			e.printStackTrace();
		}
		
		return  storageFactory;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -