Java Doc for BaseDataFileFactory.java in  » Database-DBMS » db-derby-10.2 » org » apache » derby » impl » store » raw » data » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database DBMS » db derby 10.2 » org.apache.derby.impl.store.raw.data 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.derby.impl.store.raw.data.BaseDataFileFactory

BaseDataFileFactory
final public class BaseDataFileFactory implements DataFactory,CacheableFactory,ModuleControl,ModuleSupportable,PrivilegedExceptionAction(Code)
Provides the abstract class with most of the implementation of DataFactory and ModuleControl shared by all the different filesystem implementations.

RESOLVE (mikem - 2/19/98) - Currently only getContainerClass() is abstract, there are probably more routines which should be abstract. Also the other implementations should probably inherit from the abstract class, rather than from the DataFileFactory class. Also there probably should be a generic directory and the rest of the filesystem implementations parallel to it. I wanted to limit the changes going into the branch and then fix inheritance stuff in main.

The code in this class was moved over from DataFileFactory.java and then that file was made to inherit from this one.



Field Summary
 booleandataNotSyncedAtAllocation
    
 booleandataNotSyncedAtCheckpoint
    
 StorageFactorystorageFactory
    
 WritableStorageFactorywritableStorageFactory
    

Constructor Summary
public  BaseDataFileFactory()
    

Method Summary
public  longaddAndLoadStreamContainer(RawTransaction t, long segmentId, Properties tableProperties, RowSource rowSource)
    
public  longaddContainer(RawTransaction t, long segmentId, long input_containerid, int mode, Properties tableProperties, int temporaryFlag)
     Add a container with a specified page size to a segment.
public  voidbackupDataFiles(Transaction rt, File backupDir)
    
public  voidboot(boolean create, Properties startParams)
    
public  booleancanSupport(Properties startParams)
    
public  voidcheckpoint()
     Implement checkpoint operation, write/sync all pages in cache.

The derby write ahead log algorithm uses checkpoint of the data cache to determine points of the log no longer required by restart recovery.

public  voidcreateFinished()
    
final public  booleandatabaseEncrypted()
    
public  intdecrypt(byte[] ciphertext, int offset, int length, byte[] cleartext, int outputOffset)
    
public  voiddropContainer(RawTransaction t, ContainerKey ckey)
     Drop a container.

Synchronisation

This call will mark the container as dropped and then obtain an CX lock (table level exclusive lock) on the container.

public  voiddropStreamContainer(RawTransaction t, long segmentId, long containerId)
     Drop a stream container.
public  intencrypt(byte[] cleartext, int offset, int length, byte[] ciphertext, int outputOffset, boolean newEngine)
    
public  voidencryptAllContainers(RawTransaction t)
    
 voidfileToRemove(StorageFile file, boolean remove)
     Add a file to the list of files to be removed post recovery.
 voidflush(LogInstant instant)
     Ask the log factory to flush up to this log instant.
public  voidfreezePersistentStore()
    
public  StorageFilegetAlternateContainerPath(ContainerKey containerId, boolean stub)
     Return an alternate path to container file relative to the root directory.
public  long[]getCacheStats(String cacheName)
    
 CacheManagergetContainerCache()
    
synchronized  String[]getContainerNames()
     get all the names of the files in seg 0.
public  StorageFilegetContainerPath(ContainerKey containerId, boolean stub)
     Return the path to a container file.
public  intgetEncryptionBlockSize()
    
public  FileResourcegetFileHandler()
    
public  UUIDgetIdentifier()
    
public  intgetIntParameter(String parameterName, Properties properties, int defaultValue, int minimumValue, int maximumValue)
    
 LogFactorygetLogFactory()
    
public  longgetMaxContainerId()
     Return an id which can be used to create a container.

Return an id number with is greater than any existing container in the current database.

synchronized  longgetNextId()
    
 CacheManagergetPageCache()
    
 RawStoreFactorygetRawStoreFactory()
    
public  StringgetRootDirectory()
     Get the root directory of the data storage area.
public  StorageFactorygetStorageFactory()
    
synchronized  StorageFilegetTempDirectory()
    
public  StringgetVersionedName(String name, long generationId)
    
public  voididle()
    
public  booleanisReadOnly()
     Is the store read-only.
public  StandardExceptionmarkCorrupt(StandardException originalError)
     Really this is just a convience routine for callers that might not have access to a log factory.
public  CacheablenewCacheable(CacheManager cm)
    
 CacheablenewContainerObject()
     Return the Class of the Containers to be produced by this factory.

Concrete implementations of a DataFactory must implement this routine to indicate what kind of containers are produced.

public  ContainerHandleopenContainer(RawTransaction t, ContainerKey containerId, LockingPolicy locking, int mode)
    
public  RawContainerHandleopenDroppedContainer(RawTransaction t, ContainerKey containerId, LockingPolicy locking, int mode)
    
public  StreamContainerHandleopenStreamContainer(RawTransaction t, long segmentId, long containerId, boolean hold)
    
public  voidpostRecovery()
     Called after recovery is performed.
 intrandom()
    
public  voidreCreateContainerForRedoRecovery(RawTransaction t, long segmentId, long containerId, ByteArray containerInfo)
     re-Create a container during redo recovery.
public  intreclaimSpace(Serviceable work, ContextManager contextMgr)
    
public  voidremoveDroppedContainerFileStubs(LogInstant redoLWM)
     Delete the stub files that are not required for recovery.
public  voidremoveOldVersionOfContainers(boolean inRecovery)
    
public  voidremoveStubsOK()
    
public  voidresetCacheStats(String cacheName)
    
final public  Objectrun()
    
public  voidsetDatabaseEncrypted()
    
public  voidsetRawStoreFactory(RawStoreFactory rsf, boolean create, Properties startParams)
    
public  voidstop()
    
public  voidstubFileToRemoveAfterCheckPoint(StorageFile file, LogInstant logInstant, Object identity)
     keeps track of information about the stub files of the committed deleted containers.
public  voidunfreezePersistentStore()
    
public  voidwriteFinished()
    
public  voidwriteInProgress()
    

Field Detail
dataNotSyncedAtAllocation
boolean dataNotSyncedAtAllocation(Code)



dataNotSyncedAtCheckpoint
boolean dataNotSyncedAtCheckpoint(Code)



storageFactory
StorageFactory storageFactory(Code)



writableStorageFactory
WritableStorageFactory writableStorageFactory(Code)




Constructor Detail
BaseDataFileFactory
public BaseDataFileFactory()(Code)




Method Detail
addAndLoadStreamContainer
public long addAndLoadStreamContainer(RawTransaction t, long segmentId, Properties tableProperties, RowSource rowSource) throws StandardException(Code)
Add and load a stream container
exception:
  StandardException - Standard Cloudscape error policy



addContainer
public long addContainer(RawTransaction t, long segmentId, long input_containerid, int mode, Properties tableProperties, int temporaryFlag) throws StandardException(Code)
Add a container with a specified page size to a segment.
exception:
  StandardException - Standard Cloudscape error policy



backupDataFiles
public void backupDataFiles(Transaction rt, File backupDir) throws StandardException(Code)



boot
public void boot(boolean create, Properties startParams) throws StandardException(Code)



canSupport
public boolean canSupport(Properties startParams)(Code)



checkpoint
public void checkpoint() throws StandardException(Code)
Implement checkpoint operation, write/sync all pages in cache.

The derby write ahead log algorithm uses checkpoint of the data cache to determine points of the log no longer required by restart recovery.

This implementation uses the 2 cache interfaces to force all dirty pages to disk: WRITE DIRTY PAGES TO OS: In the first step all pages in the page cache are written, but not synced (pagecache.cleanAll). The cachemanager cleanAll() interface guarantees that every dirty page that exists when this call is first made will have it's clean() method called. The data cache (CachedPage.clean()), will call writePage but not sync the page. By using the java write then sync, the checkpoint is usually doing async I/O, allowing the OS to schedule multiple I/O's to the file as efficiently as it can. Note that it has been observed that checkpoints can flood the I/O system because these writes are not synced, see DERBY-799 - checkpoint should probably somehow restrict the rate it sends out those I/O's - it was observed a simple sleep every N writes fixed most of the problem. FORCE THOSE DIRTY WRITES TO DISK: To force the I/O's to disk, the system calls each open dirty file and uses the java interface to sync any outstanding dirty pages to disk (containerCache.cleanAll()). The open container cache does this work in RAFContainer.clean() by writing it's header out and syncing the file. (Note if any change is made to checkpoint to sync the writes vs. syncing the file, one probably still needs to write the container header out and sync it).
exception:
  StandardException - Standard exception policy.




createFinished
public void createFinished() throws StandardException(Code)
Database creation finished
exception:
  StandardException - Standard cloudscape exception policy.



databaseEncrypted
final public boolean databaseEncrypted()(Code)



decrypt
public int decrypt(byte[] ciphertext, int offset, int length, byte[] cleartext, int outputOffset) throws StandardException(Code)



dropContainer
public void dropContainer(RawTransaction t, ContainerKey ckey) throws StandardException(Code)
Drop a container.

Synchronisation

This call will mark the container as dropped and then obtain an CX lock (table level exclusive lock) on the container. Once a container has been marked as dropped it cannot be retrieved by an openContainer() call unless explicitly with droppedOK.

Once the exclusive lock has been obtained the container is removed and all its pages deallocated. The container will be fully removed at the commit time of the transaction.
exception:
  StandardException - Standard Cloudscape error policy




dropStreamContainer
public void dropStreamContainer(RawTransaction t, long segmentId, long containerId) throws StandardException(Code)
Drop a stream container.

Synchronisation

This call will remove the container.
exception:
  StandardException - Standard Cloudscape error policy




encrypt
public int encrypt(byte[] cleartext, int offset, int length, byte[] ciphertext, int outputOffset, boolean newEngine) throws StandardException(Code)



encryptAllContainers
public void encryptAllContainers(RawTransaction t) throws StandardException(Code)



fileToRemove
void fileToRemove(StorageFile file, boolean remove)(Code)
Add a file to the list of files to be removed post recovery.



flush
void flush(LogInstant instant) throws StandardException(Code)
Ask the log factory to flush up to this log instant.
exception:
  StandardException - cannot sync log file



freezePersistentStore
public void freezePersistentStore() throws StandardException(Code)



getAlternateContainerPath
public StorageFile getAlternateContainerPath(ContainerKey containerId, boolean stub)(Code)
Return an alternate path to container file relative to the root directory. The alternate path uses upper case 'C','D', and 'DAT' instead of lower case - there have been cases of people copying the database and somehow upper casing all the file names. The intended use is as a bug fix for track 3444.
Parameters:
  containerId - The container being opened/created
Parameters:
  stub - True if the file name for the stub is requested, otherwise the file name for the data file



getCacheStats
public long[] getCacheStats(String cacheName)(Code)



getContainerCache
CacheManager getContainerCache()(Code)



getContainerNames
synchronized String[] getContainerNames()(Code)
get all the names of the files in seg 0. MT - This method needs to be synchronized to avoid conflicts with other privileged actions execution in this class. An array of all the file names in seg0.



getContainerPath
public StorageFile getContainerPath(ContainerKey containerId, boolean stub)(Code)
Return the path to a container file.

Return the path to a container file that is relative to the root directory.

The format of the name of an existing container file is: segNNN/cXXX.dat The format of the name of a stub describing a dropped container file is: segNNN/dXXX.dat NNN = segment number, currently 0 is where normal db files are found. XXX = The hex representation of the container number The store will always create containers with this format name, but the store will also recognize the following two formats when attempting to open files - as some copy tools have uppercased our filesnames when moving across operating systems: The format of the name of an existing container file is: segNNN/CXXX.DAT The format of the name of a stub describing a dropped container file is: segNNN/DXXX.DAT


Parameters:
  containerId - The container being opened/created
Parameters:
  stub - True if the file name for the stub is requested, otherwise the file name for the data file The StorageFile representing path to container relative to root.




getEncryptionBlockSize
public int getEncryptionBlockSize()(Code)
Returns the encryption block size used by the algorithm at time of creation of an encrypted database



getFileHandler
public FileResource getFileHandler()(Code)



getIdentifier
public UUID getIdentifier()(Code)
Return my unique identifier
See Also:   DataFactory.getIdentifier



getIntParameter
public int getIntParameter(String parameterName, Properties properties, int defaultValue, int minimumValue, int maximumValue)(Code)



getLogFactory
LogFactory getLogFactory()(Code)



getMaxContainerId
public long getMaxContainerId() throws StandardException(Code)
Return an id which can be used to create a container.

Return an id number with is greater than any existing container in the current database. Caller will use this to allocate future container numbers - most likely caching the value and then incrementing it as it is used.

The an id which can be used to create a container.
exception:
  StandardException - Standard exception policy.




getNextId
synchronized long getNextId()(Code)



getPageCache
CacheManager getPageCache()(Code)



getRawStoreFactory
RawStoreFactory getRawStoreFactory()(Code)



getRootDirectory
public String getRootDirectory()(Code)
Get the root directory of the data storage area. Is always guaranteed to be an absolute path.



getStorageFactory
public StorageFactory getStorageFactory()(Code)
The StorageFactory used by this dataFactory



getTempDirectory
synchronized StorageFile getTempDirectory()(Code)



getVersionedName
public String getVersionedName(String name, long generationId)(Code)



idle
public void idle() throws StandardException(Code)



isReadOnly
public boolean isReadOnly()(Code)
Is the store read-only.



markCorrupt
public StandardException markCorrupt(StandardException originalError)(Code)
Really this is just a convience routine for callers that might not have access to a log factory.



newCacheable
public Cacheable newCacheable(CacheManager cm)(Code)



newContainerObject
Cacheable newContainerObject()(Code)
Return the Class of the Containers to be produced by this factory.

Concrete implementations of a DataFactory must implement this routine to indicate what kind of containers are produced. For instance the DataFileFactory produce RAFContainer's.

It is expected that this class is called only once, and thus does not worry about the overhead of repeated Class.forName() lookups. The Class object for the Container class.




openContainer
public ContainerHandle openContainer(RawTransaction t, ContainerKey containerId, LockingPolicy locking, int mode) throws StandardException(Code)



openDroppedContainer
public RawContainerHandle openDroppedContainer(RawTransaction t, ContainerKey containerId, LockingPolicy locking, int mode) throws StandardException(Code)

See Also:   DataFactory.openDroppedContainer
exception:
  StandardException - Standard Cloudscape error policy



openStreamContainer
public StreamContainerHandle openStreamContainer(RawTransaction t, long segmentId, long containerId, boolean hold) throws StandardException(Code)
open an exsisting streamContainer
See Also:   DataFactory.openStreamContainer
exception:
  StandardException - Standard Cloudscape error policy



postRecovery
public void postRecovery() throws StandardException(Code)
Called after recovery is performed.
exception:
  StandardException - Standard Cloudscape Error Policy



random
int random()(Code)
return a secure random number



reCreateContainerForRedoRecovery
public void reCreateContainerForRedoRecovery(RawTransaction t, long segmentId, long containerId, ByteArray containerInfo) throws StandardException(Code)
re-Create a container during redo recovery. called ONLY during recovery load tran.
exception:
  StandardException - Standard Cloudscape Error policy



reclaimSpace
public int reclaimSpace(Serviceable work, ContextManager contextMgr) throws StandardException(Code)



removeDroppedContainerFileStubs
public void removeDroppedContainerFileStubs(LogInstant redoLWM) throws StandardException(Code)
Delete the stub files that are not required for recovery. A stub file is not required to be around if the recovery is not going to see any log record that belongs to that container. Since the stub files are created as a post commit operation, they are not necessary during undo operation of the recovery. To remove a stub file we have to be sure that it was created before the redoLWM in the check point record. We can be sure that the stub is not required if the log instant when it was created is less than the redoLWM.



removeOldVersionOfContainers
public void removeOldVersionOfContainers(boolean inRecovery) throws StandardException(Code)



removeStubsOK
public void removeStubsOK()(Code)



resetCacheStats
public void resetCacheStats(String cacheName)(Code)



run
final public Object run() throws Exception(Code)



setDatabaseEncrypted
public void setDatabaseEncrypted()(Code)



setRawStoreFactory
public void setRawStoreFactory(RawStoreFactory rsf, boolean create, Properties startParams) throws StandardException(Code)



stop
public void stop()(Code)



stubFileToRemoveAfterCheckPoint
public void stubFileToRemoveAfterCheckPoint(StorageFile file, LogInstant logInstant, Object identity)(Code)
keeps track of information about the stub files of the committed deleted containers. We use the info to delete them at checkpoints. In addition to the file info , we also keep track of the identity of the container; which helps to remove entry in the cache and the log instant when the stub was created, which helps us to figure out whether we require the stub file for the crash recovery. We maintain the information in a hashtable: key(LOG INSTANT) Values: File handle , and ContainerIdentity.



unfreezePersistentStore
public void unfreezePersistentStore()(Code)



writeFinished
public void writeFinished()(Code)



writeInProgress
public void writeInProgress() throws StandardException(Code)



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

w__w_w___.___j___a__v___a__2___s._co_m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.