Search in sources :

Example 1 with DataFactory

use of org.apache.derby.iapi.store.raw.data.DataFactory in project derby by apache.

the class LogToFile method getLogStorageFactory.

// end of boot
private void getLogStorageFactory() throws StandardException {
    if (logDevice == null) {
        DataFactory df = (DataFactory) findServiceModule(this, DataFactory.MODULE);
        logStorageFactory = (WritableStorageFactory) df.getStorageFactory();
    } else {
        try {
            PersistentService ps = getMonitor().getServiceType(this);
            logStorageFactory = (WritableStorageFactory) ps.getStorageFactoryInstance(false, logDevice, null, null);
        } catch (IOException ioe) {
            if (SanityManager.DEBUG)
                SanityManager.NOTREACHED();
            throw StandardException.newException(SQLState.LOG_FILE_NOT_FOUND, ioe, logDevice);
        }
    }
}
Also used : PersistentService(org.apache.derby.iapi.services.monitor.PersistentService) DataFactory(org.apache.derby.iapi.store.raw.data.DataFactory) IOException(java.io.IOException)

Example 2 with DataFactory

use of org.apache.derby.iapi.store.raw.data.DataFactory in project derby by apache.

the class RAMAccessManager method createReadMeFiles.

/**
 * DERBY-5996(Create readme files (cautioning users against modifying
 *  database files) at database hard upgrade time)
 * This gets called during hard upgrade. It will create 3 readme files
 *  one in database directory, one in "seg0" directory and one in log
 *  directory. These readme files warn users against touching any of
 *  files associated with derby database
 */
public void createReadMeFiles() throws StandardException {
    // creating readme in "seg0" directory
    rawstore.createDataWarningFile();
    // creating readme in log directory
    LogFactory logFactory = (LogFactory) findServiceModule(this, rawstore.getLogFactoryModule());
    logFactory.createDataWarningFile();
    // creating readme in root database directory
    DataFactory dataFactory = (DataFactory) findServiceModule(this, rawstore.getDataFactoryModule());
    PersistentService ps = getMonitor().getServiceType(rawstore);
    ps.createDataWarningFile(dataFactory.getStorageFactory());
}
Also used : LogFactory(org.apache.derby.iapi.store.raw.log.LogFactory) PersistentService(org.apache.derby.iapi.services.monitor.PersistentService) DataFactory(org.apache.derby.iapi.store.raw.data.DataFactory)

Example 3 with DataFactory

use of org.apache.derby.iapi.store.raw.data.DataFactory in project derby by apache.

the class GenericLanguageConnectionFactory method boot.

/**
 * Start-up method for this instance of the language connection factory.
 * Note these are expected to be booted relative to a Database.
 *
 * @param startParams	The start-up parameters (ignored in this case)
 *
 * @exception StandardException	Thrown on failure to boot
 */
public void boot(boolean create, Properties startParams) throws StandardException {
    // The following call to Monitor to get DVF is going to get the already
    // booted DVF (DVF got booted by BasicDatabase's boot method.
    // BasicDatabase also set the correct Locale in the DVF. There after,
    // DVF with correct Locale is available to rest of the Derby code.
    dvf = (DataValueFactory) bootServiceModule(create, this, org.apache.derby.shared.common.reference.ClassName.DataValueFactory, startParams);
    javaFactory = (JavaFactory) startSystemModule(org.apache.derby.shared.common.reference.Module.JavaFactory);
    uuidFactory = getMonitor().getUUIDFactory();
    classFactory = (ClassFactory) getServiceModule(this, org.apache.derby.shared.common.reference.Module.ClassFactory);
    if (classFactory == null)
        classFactory = (ClassFactory) findSystemModule(org.apache.derby.shared.common.reference.Module.ClassFactory);
    // set the property validation module needed to do propertySetCallBack
    // register and property validation
    setValidation();
    ef = (ExecutionFactory) bootServiceModule(create, this, ExecutionFactory.MODULE, startParams);
    of = (OptimizerFactory) bootServiceModule(create, this, OptimizerFactory.MODULE, startParams);
    tcf = (TypeCompilerFactory) startSystemModule(TypeCompilerFactory.MODULE);
    // If the system supports statement caching boot the CacheFactory module.
    int cacheSize = statementCacheSize(startParams);
    if (cacheSize > 0) {
        CacheFactory cacheFactory = (CacheFactory) startSystemModule(org.apache.derby.shared.common.reference.Module.CacheFactory);
        singleStatementCache = cacheFactory.newCacheManager(this, "StatementCache", cacheSize / 4, cacheSize);
        // Start a management bean for the statement cache to allow
        // monitoring through JMX, if it is available and enabled.
        DataFactory df = (DataFactory) findServiceModule(this, DataFactory.MODULE);
        singleStatementCache.registerMBean(df.getRootDirectory());
    }
}
Also used : ClassFactory(org.apache.derby.iapi.services.loader.ClassFactory) DataFactory(org.apache.derby.iapi.store.raw.data.DataFactory) CacheFactory(org.apache.derby.iapi.services.cache.CacheFactory)

Example 4 with DataFactory

use of org.apache.derby.iapi.store.raw.data.DataFactory in project derby by apache.

the class LOBStreamControl method init.

private void init(byte[] b, long len) throws IOException, StandardException {
    Object monitor = findService(Property.DATABASE_MODULE, conn.getDBName());
    final DataFactory df = (DataFactory) findServiceModule(monitor, DataFactory.MODULE);
    try {
        AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {

            public Object run() throws IOException {
                // create a temporary file
                StorageFile lobFile = df.getStorageFactory().createTemporaryFile("lob", null);
                if (df.databaseEncrypted()) {
                    tmpFile = new EncryptedLOBFile(lobFile, df);
                } else {
                    tmpFile = new LOBFile(lobFile);
                }
                return null;
            }
        });
    } catch (PrivilegedActionException pae) {
        throw (IOException) pae.getCause();
    }
    conn.addLobFile(tmpFile);
    isBytes = false;
    // now this call will write into the file
    if (len != 0)
        write(b, 0, (int) len, 0);
    dataBytes = null;
}
Also used : PrivilegedActionException(java.security.PrivilegedActionException) StorageFile(org.apache.derby.io.StorageFile) DataFactory(org.apache.derby.iapi.store.raw.data.DataFactory) IOException(java.io.IOException)

Aggregations

DataFactory (org.apache.derby.iapi.store.raw.data.DataFactory)4 IOException (java.io.IOException)2 PersistentService (org.apache.derby.iapi.services.monitor.PersistentService)2 PrivilegedActionException (java.security.PrivilegedActionException)1 CacheFactory (org.apache.derby.iapi.services.cache.CacheFactory)1 ClassFactory (org.apache.derby.iapi.services.loader.ClassFactory)1 LogFactory (org.apache.derby.iapi.store.raw.log.LogFactory)1 StorageFile (org.apache.derby.io.StorageFile)1