Lockable
FileContainer
abstract class BaseContainer extends java.lang.Object implements Lockable
This object implements lockable to provide an object to lock while a page is being
allocated.
MT - Mutable - mutable identity :
Modifier and Type | Field | Description |
---|---|---|
protected ContainerKey |
identity |
Identity of the container.
|
protected boolean |
isCommittedDrop |
Committed Drop state of the container.
|
protected boolean |
isDropped |
Dropped state of the container.
|
protected boolean |
isReusableRecordId |
Is reusable recordId.
|
Constructor | Description |
---|---|
BaseContainer() |
Modifier and Type | Method | Description |
---|---|---|
Page |
addPage(BaseContainerHandle handle,
boolean isOverflow) |
Add a page to this container.
|
protected abstract void |
backupContainer(BaseContainerHandle handle,
java.lang.String backupContainerPath) |
Backup the container to the specified path.
|
protected abstract boolean |
canUpdate() |
Can the container be updated.
|
void |
clearIdentity() |
|
protected abstract void |
clearPreallocThreshold() |
The container will have no pre-allocate threshold, i.e., if the
implementation supports it, page preallocation will happen
the next time a new page is allocated.
|
protected abstract void |
compressContainer(RawTransaction t,
BaseContainerHandle allocHandle) |
|
void |
compressContainer(BaseContainerHandle handle) |
Release free space to the OS.
|
protected abstract void |
deallocatePage(BaseContainerHandle userhandle,
BasePage page) |
Deallocate a page from the container.
|
protected abstract void |
dropContainer(LogInstant instant,
boolean drop) |
Mark the container as drop or not drop depending on the input value.
|
protected abstract void |
encryptOrDecryptContainer(BaseContainerHandle handle,
java.lang.String newFilePath,
boolean doEncrypt) |
Creates encrypted or decrypted version of the container.
|
protected void |
fillInIdentity(ContainerKey key) |
|
protected abstract void |
flushAll() |
Flush all outstanding changes in this container to persistent storage.
|
protected abstract BasePage |
getAllocPage(long pageNumber) |
Return a BasePage that represents the given alloc page number in this container.
|
protected Page |
getAllocPage(BaseContainerHandle handle,
long pageNumber,
boolean wait) |
Get an allocation page and latch it.
|
protected abstract BasePage |
getAnyPage(BaseContainerHandle handle,
long pageNumber) |
Return a BasePage that represents any page - alloc page, valid page, free page,
dealloced page etc.
|
protected Page |
getAnyPage(BaseContainerHandle handle,
long pageNumber,
boolean wait) |
Get any page and latch it .
|
protected boolean |
getCommittedDropState() |
|
long |
getContainerId() |
|
abstract void |
getContainerProperties(java.util.Properties prop) |
Request the system properties associated with a container.
|
int |
getContainerStatus() |
|
protected abstract long |
getContainerVersion() |
Get the logged container version.
|
protected boolean |
getDeallocLock(BaseContainerHandle handle,
RecordHandle deallocLock,
boolean wait,
boolean zeroDuration) |
Get the special dealloc lock on the page - the lock is gotten by the
transaction that owns the container handle
|
protected boolean |
getDroppedState() |
|
abstract long |
getEstimatedPageCount(BaseContainerHandle handle,
int flag) |
|
abstract long |
getEstimatedRowCount(int flag) |
|
protected abstract BasePage |
getFirstHeadPage(BaseContainerHandle handle,
boolean wait) |
Get the first page in the container.
|
protected Page |
getFirstPage(BaseContainerHandle handle) |
Get the first valid page.
|
protected abstract BasePage |
getHeadPage(BaseContainerHandle handle,
long pagenumber,
boolean wait) |
Get only a valid, non-overflow page.
|
java.lang.Object |
getIdentity() |
|
protected abstract BasePage |
getNextHeadPage(BaseContainerHandle handle,
long pageNumber,
boolean wait) |
Get the next page in the container.
|
protected Page |
getNextPage(BaseContainerHandle handle,
long pageNumber) |
Get the next valid page and latch it
|
protected abstract BasePage |
getPage(BaseContainerHandle handle,
long pageNumber,
boolean wait) |
Return a BasePage that represents the given page number in this container.
|
protected abstract BasePage |
getPageForCompress(BaseContainerHandle handle,
int flag,
long pageno) |
|
protected abstract BasePage |
getPageForInsert(BaseContainerHandle handle,
int flag) |
Get a potentially suitable page for insert and latch it.
|
abstract long |
getReusableRecordIdSequenceNumber() |
Get the reusable RecordId sequence number for the
container.
|
long |
getSegmentId() |
|
protected abstract SpaceInfo |
getSpaceInfo(BaseContainerHandle handle) |
Get information about space used by the container.
|
protected abstract void |
incrementReusableRecordIdSequenceNumber() |
Increment the reusable RecordId sequence number.
|
protected boolean |
isReusableRecordId() |
|
protected BasePage |
latchPage(BaseContainerHandle handle,
BasePage foundPage,
boolean wait) |
|
protected void |
letGo(BaseContainerHandle handle) |
Discontinue use of this container.
|
boolean |
lockAttributes(int flag,
java.util.Hashtable attributes) |
If this lockable object wants to participate in a diagnostic virtual
lock table, then put any relevant attributes of this lock into the
attributes list (the attribute must be an immutable object).
|
boolean |
lockerAlwaysCompatible() |
Returns true if any lock request on a Lockable L in a compatibility space CS1 is compatible
with any other lock held on L in CS1.
|
void |
lockEvent(Latch lockInfo) |
Note the fact the object is locked.
|
protected abstract ByteArray |
logCreateContainerInfo() |
Log all information on the container creation necessary to recreate teh
container during a load tran.
|
protected abstract BasePage |
newPage(BaseContainerHandle userhandle,
RawTransaction t,
BaseContainerHandle allocHandle,
boolean isOverflow) |
Create a new page in the container.
|
protected abstract void |
preDirty(boolean preDirtyOn) |
The container is about to be modified.
|
protected abstract void |
prepareForBulkLoad(BaseContainerHandle handle,
int numPage) |
The container will be grown vastly, prepare for it.
|
protected abstract BasePage |
reCreatePageForRedoRecovery(BaseContainerHandle handle,
int pageFormat,
long pageNumber,
long pageOffset) |
ReCreate a page for rollforward recovery.
|
protected abstract void |
removeContainer(LogInstant instant,
boolean leaveStub) |
Remove the container and reclaim its space.
|
protected void |
removePage(BaseContainerHandle handle,
BasePage page) |
Remove a page from this container.
|
boolean |
requestCompatible(java.lang.Object requestedQualifier,
java.lang.Object grantedQualifier) |
Return true if the requested qualifier is compatible with the already granted
qualifier.
|
protected void |
setCommittedDropState(boolean isCommittedDrop) |
|
protected void |
setDroppedState(boolean isDropped) |
Set the container's dropped state
|
abstract void |
setEstimatedRowCount(long count,
int flag) |
|
protected void |
setReusableRecordIdState(boolean isReusableRecordId) |
|
protected void |
truncate(BaseContainerHandle handle) |
|
protected abstract void |
truncatePages(long lastValidPagenum) |
|
void |
unlockEvent(Latch lockInfo) |
Note that the object has been unlocked
|
protected boolean |
use(BaseContainerHandle handle,
boolean forUpdate,
boolean droppedOK) |
Lock the container and mark the container as in-use by this container handle.
|
protected ContainerKey identity
protected boolean isDropped
protected boolean isCommittedDrop
protected boolean isReusableRecordId
protected void fillInIdentity(ContainerKey key)
public void clearIdentity()
public java.lang.Object getIdentity()
public void lockEvent(Latch lockInfo)
Lockable
If the class supports multiple lockers of the object then this method will be called once per locker, each with their own qualifier.
Must only be called by the lock manager. Synchronization will be handled by the lock manager.
public boolean requestCompatible(java.lang.Object requestedQualifier, java.lang.Object grantedQualifier)
Lockable
requestCompatible
in interface Lockable
public boolean lockerAlwaysCompatible()
Lockable
lockerAlwaysCompatible
in interface Lockable
public void unlockEvent(Latch lockInfo)
Lockable
Must only be called by the lock manager. Synchronization will be handled by the lock manager.
unlockEvent
in interface Lockable
public void compressContainer(BaseContainerHandle handle) throws StandardException
As is possible release any free space to the operating system. This will usually mean releasing any free pages located at the end of the file using the java truncate() interface.
StandardException
- Standard Derby error policypublic abstract long getReusableRecordIdSequenceNumber()
protected abstract void incrementReusableRecordIdSequenceNumber()
public Page addPage(BaseContainerHandle handle, boolean isOverflow) throws StandardException
StandardException
- Standard Derby error policypublic abstract void getContainerProperties(java.util.Properties prop) throws StandardException
Request the value of properties that are associated with a container. The following properties can be requested: derby.storage.pageSize derby.storage.pageReservedSpace derby.storage.minimumRecordSize
To get the value of a particular property add it to the property list, and on return the value of the property will be set to it's current value. For example: get_prop(BaseContainer base) { Properties prop = new Properties(); prop.put("derby.storage.pageSize", ""); base.getContainerProperties(prop); System.out.println( "container's page size = " + prop.getProperty("derby.storage.pageSize"); }
prop
- Property list to fill in.StandardException
- Standard exception policy.protected void removePage(BaseContainerHandle handle, BasePage page) throws StandardException
handle
- the container handle that has opened the container and latched the pagepage
- the latched page that is to be deallocatedStandardException
- Standard Derby error policyprotected boolean getDeallocLock(BaseContainerHandle handle, RecordHandle deallocLock, boolean wait, boolean zeroDuration) throws StandardException
StandardException
- Standard Derby error policyprotected Page getAllocPage(BaseContainerHandle handle, long pageNumber, boolean wait) throws StandardException
StandardException
- Standard Derby error policyprotected Page getAnyPage(BaseContainerHandle handle, long pageNumber, boolean wait) throws StandardException
StandardException
- Standard Derby error policyprotected Page getFirstPage(BaseContainerHandle handle) throws StandardException
StandardException
- Standard Derby error policyprotected Page getNextPage(BaseContainerHandle handle, long pageNumber) throws StandardException
StandardException
- Standard Derby error policyprotected BasePage latchPage(BaseContainerHandle handle, BasePage foundPage, boolean wait) throws StandardException
StandardException
protected boolean use(BaseContainerHandle handle, boolean forUpdate, boolean droppedOK) throws StandardException
droppedOK
- if true, use this container even if it is dropped.,StandardException
- I cannot be opened for update.protected void letGo(BaseContainerHandle handle)
protected boolean getDroppedState()
protected boolean getCommittedDropState()
protected boolean isReusableRecordId()
public int getContainerStatus()
public long getContainerId()
public long getSegmentId()
protected abstract SpaceInfo getSpaceInfo(BaseContainerHandle handle) throws StandardException
StandardException
protected abstract boolean canUpdate()
protected abstract void preDirty(boolean preDirtyOn)
protected abstract BasePage getPage(BaseContainerHandle handle, long pageNumber, boolean wait) throws StandardException
StandardException
- Standard Derby error policyprotected abstract BasePage getAllocPage(long pageNumber) throws StandardException
StandardException
- Standard Derby error policyprotected abstract BasePage getAnyPage(BaseContainerHandle handle, long pageNumber) throws StandardException
StandardException
- Derby Standard error policyprotected abstract BasePage reCreatePageForRedoRecovery(BaseContainerHandle handle, int pageFormat, long pageNumber, long pageOffset) throws StandardException
During redo recovery it is possible for the system to try to redo the creation of a page (ie. going from non-existence to version 0). It first trys to read the page from disk, but a few different types of errors can occur: o the page does not exist at all on disk, this can happen during rollforward recovery applied to a backup where the file was copied and the page was added to the file during the time frame of the backup but after the physical file was copied. o space in the file exists, but it was never initalized. This can happen if you happen to crash at just the right moment during the allocation process. Also on some OS's it is possible to read from a part of the file that was not ever written - resulting in garbage from the store's point of view (often the result is all 0's). All these errors are easy to recover from as the system can easily create a version 0 from scratch and write it to disk. Because the system does not sync allocation of data pages, it is also possible at this point that whlie writing the version 0 to disk to create it we may encounter an out of disk space error (caught in this routine as a StandardException from the create() call. We can't recovery from this without help from outside, so the caught exception is nested and a new exception thrown which the recovery system will output to the user asking them to check their disk for space/errors. The arguments passed in need to be sufficient for the page cache to materialize a brand new page and write it to disk.
StandardException
- Standard exception policy.protected abstract ByteArray logCreateContainerInfo() throws StandardException
StandardException
- Derby Standard error policyprotected abstract BasePage getHeadPage(BaseContainerHandle handle, long pagenumber, boolean wait) throws StandardException
StandardException
- Derby Standard error policyprotected abstract BasePage getFirstHeadPage(BaseContainerHandle handle, boolean wait) throws StandardException
StandardException
- Standard Derby error policyprotected abstract BasePage getNextHeadPage(BaseContainerHandle handle, long pageNumber, boolean wait) throws StandardException
StandardException
- Standard Derby error policyprotected abstract BasePage getPageForInsert(BaseContainerHandle handle, int flag) throws StandardException
StandardException
- Standard Derby error policyprotected abstract BasePage getPageForCompress(BaseContainerHandle handle, int flag, long pageno) throws StandardException
StandardException
protected abstract void truncatePages(long lastValidPagenum) throws StandardException
StandardException
protected abstract BasePage newPage(BaseContainerHandle userhandle, RawTransaction t, BaseContainerHandle allocHandle, boolean isOverflow) throws StandardException
StandardException
- Standard Derby error policyprotected abstract void compressContainer(RawTransaction t, BaseContainerHandle allocHandle) throws StandardException
StandardException
protected abstract void deallocatePage(BaseContainerHandle userhandle, BasePage page) throws StandardException
StandardException
- Standard Derby error policyprotected void truncate(BaseContainerHandle handle) throws StandardException
StandardException
protected abstract void dropContainer(LogInstant instant, boolean drop)
protected abstract void removeContainer(LogInstant instant, boolean leaveStub) throws StandardException
leaveStub
- if true, leave a stub. If false, remove everythingStandardException
- Standard Derby error policyRawContainerHandle.removeContainer(org.apache.derby.iapi.store.raw.log.LogInstant)
protected abstract long getContainerVersion() throws StandardException
StandardException
- Standard Derby error policyprotected abstract void flushAll() throws StandardException
StandardException
- Standard Derby error policyprotected abstract void prepareForBulkLoad(BaseContainerHandle handle, int numPage)
protected abstract void clearPreallocThreshold()
public abstract long getEstimatedRowCount(int flag) throws StandardException
StandardException
- Standard Derby error policyContainerHandle.getEstimatedRowCount(int)
public abstract void setEstimatedRowCount(long count, int flag) throws StandardException
StandardException
- Standard Derby error policyContainerHandle.setEstimatedRowCount(long, int)
public abstract long getEstimatedPageCount(BaseContainerHandle handle, int flag) throws StandardException
StandardException
- Standard Derby error policyContainerHandle.getEstimatedPageCount(int)
protected abstract void backupContainer(BaseContainerHandle handle, java.lang.String backupContainerPath) throws StandardException
handle
- the container handle.backupContainerPath
- location of the backup container.StandardException
- Standard Derby error policyprotected abstract void encryptOrDecryptContainer(BaseContainerHandle handle, java.lang.String newFilePath, boolean doEncrypt) throws StandardException
handle
- the container handlenewFilePath
- file to store the new version of the containerdoEncrypt
- tells whether to encrypt or decryptStandardException
- Standard Derby error policyprotected void setDroppedState(boolean isDropped)
protected void setCommittedDropState(boolean isCommittedDrop)
protected void setReusableRecordIdState(boolean isReusableRecordId)
public boolean lockAttributes(int flag, java.util.Hashtable attributes)
Lockable
lockAttributes
in interface Lockable
flag
- use the bits in this int to decide if the user is
interested in this kind of lockable object. The bits are defined in
VirtualLockTable. For instance, the user may only ask
for TABLE_AND_ROWLOCK and if this is not a table or row lock, then
don't participate.attributes
- if this decides to participate, put all relevant
attributes into the Hashtable. The complete list of interesting
attributes is listed in VirtualLockTable.
The following attributes must be present for all participating
lockables:
VirtualLockTable.LOCKNAME,
VirtualLockTable.LOCKTYPE,
either VirtualLockTable.CONTAINERID or VirtualLockTable.CONGLOMID,
MT - this routine must be MP safe, caller will not be single threading the lock manager.
VirtualLockTable
Apache Derby V10.14 Internals - Copyright © 2004,2018 The Apache Software Foundation. All Rights Reserved.