class RAFContainer extends FileContainer implements java.security.PrivilegedExceptionAction<java.lang.Object>
Modifier and Type | Field and Description |
---|---|
private int |
actionCode |
private boolean |
actionErrorOK |
private StorageFile |
actionFile |
private ContainerKey |
actionIdentity |
private LogInstant |
actionInstant |
private boolean |
actionStub |
private boolean |
actionTryAlternatePath |
private static int |
CREATE_CONTAINER_ACTION |
protected StorageRandomAccessFile |
fileData |
private java.lang.String |
fileName |
private static int |
GET_FILE_NAME_ACTION |
private static int |
GET_RANDOM_ACCESS_FILE_ACTION |
private boolean |
inBackup |
private boolean |
inRemove |
protected boolean |
needsSync |
private static int |
OPEN_CONTAINER_ACTION |
private static int |
REMOVE_FILE_ACTION |
private static int |
REOPEN_CONTAINER_ACTION |
private static int |
STUBBIFY_ACTION |
allocCache, canUpdate, CHECKSUM_SIZE, CONTAINER_INFO_SIZE, containerCache, containerInfo, containerVersion, dataFactory, estimatedRowCount, FIRST_ALLOC_PAGE_NUMBER, FIRST_ALLOC_PAGE_OFFSET, firstAllocPageNumber, firstAllocPageOffset, formatIdInteger, initialPages, isDirty, lastLogInstant, minimumRecordSize, pageCache, pageSize, preDirty, SPACE_TRACE, spareSpace
identity, isCommittedDrop, isDropped, isReusableRecordId
Constructor and Description |
---|
RAFContainer(BaseDataFileFactory factory) |
Modifier and Type | Method and Description |
---|---|
protected void |
backupContainer(BaseContainerHandle handle,
java.lang.String backupLocation)
Backup the container.
|
void |
clean(boolean forRemove)
Clean the container.
|
private void |
clearDirty() |
(package private) void |
closeContainer() |
private void |
copyFile(StorageFile from,
java.io.File to)
Copy the contents of a
StorageFile to a java.io.File . |
(package private) void |
createContainer(ContainerKey newIdentity)
Create a new container.
|
protected void |
encryptOrDecryptContainer(BaseContainerHandle handle,
java.lang.String newFilePath,
boolean doEncrypt)
Creates encrypted or decrypted version of the container.
|
protected void |
flushAll()
flush the cache to ensure all of my pages are written to disk
|
(package private) StorageFile |
getFileName(ContainerKey identity,
boolean stub,
boolean errorOK,
boolean tryAlternatePath) |
private java.io.RandomAccessFile |
getRandomAccessFile(java.io.File file)
Get a RandomAccessFile for accessing a file in read-write mode.
|
(package private) StorageRandomAccessFile |
getRandomAccessFile(StorageFile file) |
boolean |
isDirty()
We treat this container as dirty if it has the container file open.
|
(package private) boolean |
openContainer(ContainerKey newIdentity)
Open a container.
|
private boolean |
padFile(StorageRandomAccessFile file,
long pageOffset)
Pad the file upto the passed in page offset.
|
protected int |
preAllocate(long lastPreallocPagenum,
int preAllocSize)
Preallocate some pages if need be
|
protected StorageFile |
privGetFileName(ContainerKey identity,
boolean stub,
boolean errorOK,
boolean tryAlternatePath) |
private boolean |
privRemoveFile(StorageFile file) |
protected void |
readPage(long pageNumber,
byte[] pageData)
Read a page into the supplied array.
|
protected void |
removeContainer(LogInstant instant,
boolean leaveStub)
Remove the container
|
private void |
removeFile(java.io.File file)
Remove a file.
|
(package private) boolean |
removeFile(StorageFile file) |
protected void |
reopenContainer(ContainerKey currentIdentity)
Only used by RAFContainer4 (NIO) to reopen RAF when its channel gets
closed due to interrupts.
|
java.lang.Object |
run() |
private void |
stubbify(LogInstant instant) |
protected void |
truncatePages(long lastValidPagenum)
Truncate pages of a container.
|
protected byte[] |
updatePageArray(long pageNumber,
byte[] pageData,
byte[] encryptionBuf,
boolean encryptWithNewEngine)
Updates the page array with container header if the page is a first
allocation page and encrypts the page data if the database is encrypted.
|
protected void |
writePage(long pageNumber,
byte[] pageData,
boolean syncPage)
Write a page from the supplied array.
|
private void |
writeRAFHeader(java.lang.Object identity,
StorageRandomAccessFile file,
boolean create,
boolean syncFile)
Write the header of a random access file and sync it
|
bumpContainerVersion, canUpdate, clearIdentity, clearPreallocThreshold, compressContainer, createIdent, createIdentity, deallocatePage, decryptPage, doPreAllocatePages, dropContainer, encryptPage, getAllocPage, getAnyPage, getContainerProperties, getContainerVersion, getContextService, getEmbryonicPage, getEmbryonicPage, getEncryptionBuffer, getEstimatedPageCount, getEstimatedRowCount, getFirstHeadPage, getHeadPage, getLastPageNumber, getLatchedPage, getMinimumRecordSize, getNextHeadPage, getPage, getPageForCompress, getPageForInsert, getPageSize, getReusableRecordIdSequenceNumber, getSpaceInfo, getSpareSpace, getTypeFormatId, incrementReusableRecordIdSequenceNumber, initPage, latchPage, letGo, logCreateContainerInfo, newPage, preDirty, prepareForBulkLoad, readHeader, reCreatePageForRedoRecovery, setDirty, setEstimatedRowCount, setIdent, setIdentity, trackUnfilledPage, updateEstimatedRowCount, writeAtOffset, writeHeader, writeHeader
addPage, compressContainer, fillInIdentity, getAllocPage, getAnyPage, getCommittedDropState, getContainerId, getContainerStatus, getDeallocLock, getDroppedState, getFirstPage, getIdentity, getNextPage, getSegmentId, isReusableRecordId, lockAttributes, lockerAlwaysCompatible, lockEvent, removePage, requestCompatible, setCommittedDropState, setDroppedState, setReusableRecordIdState, truncate, unlockEvent, use
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getIdentity
protected StorageRandomAccessFile fileData
protected boolean needsSync
private int actionCode
private static final int GET_FILE_NAME_ACTION
private static final int CREATE_CONTAINER_ACTION
private static final int REMOVE_FILE_ACTION
private static final int OPEN_CONTAINER_ACTION
private static final int STUBBIFY_ACTION
private static final int GET_RANDOM_ACCESS_FILE_ACTION
private static final int REOPEN_CONTAINER_ACTION
private ContainerKey actionIdentity
private boolean actionStub
private boolean actionErrorOK
private boolean actionTryAlternatePath
private StorageFile actionFile
private LogInstant actionInstant
private boolean inBackup
private boolean inRemove
private java.lang.String fileName
RAFContainer(BaseDataFileFactory factory)
public boolean isDirty()
FileContainer
isDirty
in interface Cacheable
isDirty
in class FileContainer
Cacheable.isDirty()
protected void removeContainer(LogInstant instant, boolean leaveStub) throws StandardException
removeContainer
in class BaseContainer
leaveStub
- if true, leave a stub. If false, remove everythingStandardException
- Standard Derby error policyRawContainerHandle.removeContainer(org.apache.derby.iapi.store.raw.log.LogInstant)
void closeContainer()
closeContainer
in class FileContainer
protected void readPage(long pageNumber, byte[] pageData) throws java.io.IOException, StandardException
readPage
in class FileContainer
java.io.IOException
- exception reading pageStandardException
- Standard Derby error policyprotected void writePage(long pageNumber, byte[] pageData, boolean syncPage) throws java.io.IOException, StandardException
writePage
in class FileContainer
StandardException
- Standard Derby error policyjava.io.IOException
- IO error accessing pageprotected byte[] updatePageArray(long pageNumber, byte[] pageData, byte[] encryptionBuf, boolean encryptWithNewEngine) throws StandardException, java.io.IOException
pageNumber
- the page number of the pagepageData
- byte array that has the actual page data.encryptionBuf
- buffer that is used to store encrypted version of
the page, or null
if encryption is to be skippedencryptWithNewEngine
- whether to use the new encryption engine for
encryption (only considered if encryptionBuf != null
)StandardException
java.io.IOException
private boolean padFile(StorageRandomAccessFile file, long pageOffset) throws java.io.IOException, StandardException
java.io.IOException
StandardException
public void clean(boolean forRemove) throws StandardException
Write out the container header and sync all dirty pages of this container to disk before returning.
checkpoint calls this interface through callbacks by telling the cache manager to clean all containers in the open container cache. This sync of the file happens as part of writing and then syncing the container header in writeRAFHeader().
clean
in interface Cacheable
forRemove
- Is clean called because container is being removed?StandardException
- Standard exception policy.private void clearDirty()
protected int preAllocate(long lastPreallocPagenum, int preAllocSize)
preAllocate
in class FileContainer
lastPreallocPagenum
- the last preallocated page number as known
by the allocation pagepreAllocSize
- try to preallocate this page number of pages.
Since only the container knows how many pages are actually on
disk, it may determine that certain number of pages that the
allocation page thinks need to be preallocated is already
allocated, in those case, act as if the preallocation is
successful.protected void truncatePages(long lastValidPagenum) throws StandardException
Truncate all pages from lastValidPagenum+1 through the end of the file.
truncatePages
in class BaseContainer
lastValidPagenum
- The page number of the last valid page of the
file. All pages after this one are truncated.StandardException
- Standard exception policy.private void writeRAFHeader(java.lang.Object identity, StorageRandomAccessFile file, boolean create, boolean syncFile) throws java.io.IOException, StandardException
create
- if true, the container is being created
if false, the container already existsyncFile
- if true, sync the filejava.io.IOException
StandardException
protected void flushAll() throws StandardException
flushAll
in class BaseContainer
StandardException
- Standard Derby error policyStorageFile getFileName(ContainerKey identity, boolean stub, boolean errorOK, boolean tryAlternatePath) throws StandardException
StandardException
protected StorageFile privGetFileName(ContainerKey identity, boolean stub, boolean errorOK, boolean tryAlternatePath) throws StandardException
StandardException
void createContainer(ContainerKey newIdentity) throws StandardException
FileContainer
Create a new container, all references to identity must be through the passed in identity, this object will no identity until after this method returns.
createContainer
in class FileContainer
StandardException
- Derby Standard error policyprivate void copyFile(StorageFile from, java.io.File to) throws StandardException
StorageFile
to a java.io.File
.from
- the file to copy fromto
- the file to copy toStandardException
- if the copying failedprivate void removeFile(java.io.File file) throws StandardException
file
- the file to removeStandardException
- if the file could not be removedboolean removeFile(StorageFile file) throws java.lang.SecurityException, StandardException
java.lang.SecurityException
StandardException
private boolean privRemoveFile(StorageFile file) throws StandardException
StandardException
boolean openContainer(ContainerKey newIdentity) throws StandardException
FileContainer
Longer descrption of routine.
Open a container. Open the file that maps to this container, if the
file does not exist then we assume the container was never created.
If the file exists but we have trouble opening it then we throw some
exception.
MT - single thread required - Enforced by cache manager.
openContainer
in class FileContainer
StandardException
- Standard exception policy.protected void reopenContainer(ContainerKey currentIdentity) throws StandardException
currentIdentity
- StandardException
- standard exception policyprivate void stubbify(LogInstant instant) throws StandardException
StandardException
protected void backupContainer(BaseContainerHandle handle, java.lang.String backupLocation) throws StandardException
backupContainer
in class FileContainer
handle
- the container handle.backupLocation
- location of the backup container.StandardException
- Derby Standard error policyprotected void encryptOrDecryptContainer(BaseContainerHandle handle, java.lang.String newFilePath, boolean doEncrypt) throws StandardException
The encryption and decryption engines used to carry out the cryptographic operation(s) are configured through the raw store, and accessed via the data factory. Note that the pages have already been decrypted before being put into the page cache.
encryptOrDecryptContainer
in class BaseContainer
handle
- the container handlenewFilePath
- file to store the new version of the container indoEncrypt
- tells whether to encrypt or notStandardException
- Derby Standard error policyprivate java.io.RandomAccessFile getRandomAccessFile(java.io.File file) throws java.io.IOException
file
- the file to accessjava.io.FileNotFoundException
- if file
cannot be opened in
read-write modejava.io.IOException
- if some other I/O error happensStorageRandomAccessFile getRandomAccessFile(StorageFile file) throws java.lang.SecurityException, StandardException
java.lang.SecurityException
StandardException
public java.lang.Object run() throws StandardException
run
in interface java.security.PrivilegedExceptionAction<java.lang.Object>
StandardException
Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.