Documentation of 'org.apache.derby.impl.io.VFMemoryStorageFactory' Java class
VFMemoryStorageFactory
org.apache.derby.impl.io

Class VFMemoryStorageFactory

  • All Implemented Interfaces:
    StorageFactory, WritableStorageFactory


    public class VFMemoryStorageFactory
    extends java.lang.Object
    implements StorageFactory, WritableStorageFactory
    A storage factory for virtual files, where the contents of the files are stored in main memory.

    Note that data store deletion may happen inside one of two different methods; either in shutdown or in init. This is due to the current implementation and the fact that dropping a database is done through the file IO interface by deleting the service root. As the deletion then becomes a two step process, someone else may boot the database again before the reference to the store has been removed. To avoid this, the init-method will never initialize with a store scheduled for deletion. I have only seen this issue in heavily loaded multithreaded environments (2 CPUs/cores should be enough to reproduce).

    • Constructor Summary

      Constructors 
      Constructor and Description
      VFMemoryStorageFactory()
      Creates a new, uninitialized instance of the storage factory.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      StorageFile createTemporaryFile(java.lang.String prefix, java.lang.String suffix)
      Creates a handle to a temporary file.
      java.lang.String getCanonicalName()
      Get the canonical name of the database.
      char getSeparator()
      Returns the path separator used by this storage factory.
      int getStorageFactoryVersion() 
      StorageFile getTempDir()
      Returns the temporary directory for this storage factory instance.
      void init(java.lang.String home, java.lang.String databaseName, java.lang.String tempDirNameIgnored, java.lang.String uniqueName)
      Initializes the storage factory instance by setting up a temporary directory, the database directory and checking if the database being named already exists.
      boolean isFast()
      The service is fast and supports random access.
      boolean isReadOnlyDatabase()
      The service supports writes.
      StorageFile newStorageFile(StorageFile directoryName, java.lang.String fileName)
      Returns a handle to the specified storage file.
      StorageFile newStorageFile(java.lang.String path)
      Returns a handle to the specific storage file.
      StorageFile newStorageFile(java.lang.String directoryName, java.lang.String fileName)
      Returns a handle to the specified storage file.
      void setCanonicalName(java.lang.String name)
      Set the canonicalName.
      void shutdown()
      Normally does nothing, but if the database is in a state such that it should be deleted this will happen here.
      boolean supportsRandomAccess()
      The service supports random access.
      boolean supportsWriteSync()
      This method tests whether the StorageRandomAccessFile "rws" and "rwd" modes are implemented.
      void sync(java.io.OutputStream stream, boolean metaData)
      The sync method is a no-op for this storage factory.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • init

        public void init(java.lang.String home,
                         java.lang.String databaseName,
                         java.lang.String tempDirNameIgnored,
                         java.lang.String uniqueName)
                  throws java.io.IOException
        Initializes the storage factory instance by setting up a temporary directory, the database directory and checking if the database being named already exists.
        Specified by:
        init in interface StorageFactory
        Parameters:
        home - the value of system.home for this storage factory
        databaseName - the name of the database, all relative pathnames are relative to this name
        tempDirNameIgnored - ignored
        uniqueName - used to determine when the temporary directory can be created, but not to name the temporary directory itself
        Throws:
        java.io.IOException - on an error (unexpected).
      • shutdown

        public void shutdown()
        Normally does nothing, but if the database is in a state such that it should be deleted this will happen here.
        Specified by:
        shutdown in interface StorageFactory
      • getCanonicalName

        public java.lang.String getCanonicalName()
        Description copied from interface: StorageFactory
        Get the canonical name of the database. This is a name that uniquely identifies it. It is system dependent. The normal, disk based implementation uses method java.io.File.getCanonicalPath on the directory holding the database to construct the canonical name.
        Specified by:
        getCanonicalName in interface StorageFactory
        Returns:
        the canonical name
      • setCanonicalName

        public void setCanonicalName(java.lang.String name)
        Set the canonicalName. May need adjustment due to DERBY-5096
        Specified by:
        setCanonicalName in interface StorageFactory
        Parameters:
        name - uniquely identifiable name for this database
      • newStorageFile

        public StorageFile newStorageFile(java.lang.String path)
        Returns a handle to the specific storage file.
        Specified by:
        newStorageFile in interface StorageFactory
        Parameters:
        path - the path of the file or directory
        Returns:
        A path handle.
      • newStorageFile

        public StorageFile newStorageFile(java.lang.String directoryName,
                                          java.lang.String fileName)
        Returns a handle to the specified storage file.
        Specified by:
        newStorageFile in interface StorageFactory
        Parameters:
        directoryName - the name of the parent directory
        fileName - the name of the file
        Returns:
        A path handle.
      • newStorageFile

        public StorageFile newStorageFile(StorageFile directoryName,
                                          java.lang.String fileName)
        Returns a handle to the specified storage file.
        Specified by:
        newStorageFile in interface StorageFactory
        Parameters:
        directoryName - the name of the parent directory
        fileName - the name of the file
        Returns:
        A path handle.
      • getTempDir

        public StorageFile getTempDir()
        Returns the temporary directory for this storage factory instance.
        Specified by:
        getTempDir in interface StorageFactory
        Returns:
        A StorageFile-object representing the temp directory.
      • isFast

        public boolean isFast()
        The service is fast and supports random access.
        Specified by:
        isFast in interface StorageFactory
        Returns:
        true
      • isReadOnlyDatabase

        public boolean isReadOnlyDatabase()
        The service supports writes.
        Specified by:
        isReadOnlyDatabase in interface StorageFactory
        Returns:
        false
      • supportsRandomAccess

        public boolean supportsRandomAccess()
        The service supports random access.
        Specified by:
        supportsRandomAccess in interface StorageFactory
        Returns:
        true
      • getStorageFactoryVersion

        public int getStorageFactoryVersion()
        Specified by:
        getStorageFactoryVersion in interface StorageFactory
        Returns:
        the StorageFactory version supported by this implementation
      • createTemporaryFile

        public StorageFile createTemporaryFile(java.lang.String prefix,
                                               java.lang.String suffix)
        Creates a handle to a temporary file.
        Specified by:
        createTemporaryFile in interface StorageFactory
        Parameters:
        prefix - requested prefix for the file name
        suffix - requested suffix for the file name, if null then .tmp will be used
        Returns:
        A handle to the temporary file.
      • getSeparator

        public char getSeparator()
        Returns the path separator used by this storage factory.
        Specified by:
        getSeparator in interface StorageFactory
        Returns:
        PathUtil.SEP
      • sync

        public void sync(java.io.OutputStream stream,
                         boolean metaData)
        The sync method is a no-op for this storage factory.
        Specified by:
        sync in interface WritableStorageFactory
        Parameters:
        stream - ignored
        metaData - ignored
      • supportsWriteSync

        public boolean supportsWriteSync()
        Description copied from interface: WritableStorageFactory
        This method tests whether the StorageRandomAccessFile "rws" and "rwd" modes are implemented. If the "rws" and "rwd" modes are supported then the database engine will conclude that the write methods of "rws"/"rwd" mode StorageRandomAccessFiles are slow but the sync method is fast and optimize accordingly.
        Specified by:
        supportsWriteSync in interface WritableStorageFactory
        Returns:
        true if an StIRandomAccess file opened with "rws" or "rwd" modes immediately writes data to the underlying storage, false if not.

DataMelt 3.0 © DataMelt by jWork.ORG

Ads help maintain this website.