Fennel: SegPageBackupRestoreDevice Class Reference (original) (raw)
Device used to backup and restore pages from a data segment. More...
#include <[SegPageBackupRestoreDevice.h](SegPageBackupRestoreDevice%5F8h-source.html)>
Inheritance diagram for SegPageBackupRestoreDevice:

| Public Member Functions | |
|---|---|
| SegPageBackupRestoreDevice (const std::string &backupFilePathname, const char *mode, const std::string &compressionProgram, uint nScratchPages, uint nReservedPages, SegmentAccessor &scratchAccessor, DeviceAccessScheduler &scheduler, SharedRandomAccessDevice pDataDevice) | |
| Opens a device that is used to backup and restore pages from a segment. | |
| PBuffer | getReservedBufferPage () |
| Returns a pointer to one of the reserved buffer pages. | |
| void | writeBackupPage (PConstBuffer pageBuffer) |
| Writes a single page of data to the backup file. | |
| void | backupPage (BlockId blockId) |
| Backs up a data page by scheduling a request to read it, then writing it to the backup file once the read request has been met. | |
| void | notifyReadTransferCompletion (BackupRestorePage &scratchPage, bool bSuccess) |
| Receives notification that a read request has completed and writes the page to the backup file. | |
| void | restorePage (BlockId blockId) |
| Restores a page by reading it from the backup file and then scheduling a request to write it to the data device. | |
| void | notifyWriteTransferCompletion (BackupRestorePage &scratchPage, bool bSuccess) |
| Receives notification that a write request has completed. | |
| void | waitForPendingWrites () |
| Waits for any pending writes to complete. | |
| StrictMutex & | getMutex () |
| **Returns:**the mutex that ensures that only one thread is modifying this object | |
| bool | isClosed () const |
| **Returns:**whether the object has been closed | |
| void | close () |
| Closes this object, releasing any unallocated resources. | |
| Static Public Member Functions | |
| static SharedSegPageBackupRestoreDevice | newSegPageBackupRestoreDevice (const std::string &backupFilePathname, const char *mode, const std::string &compressionProgram, uint nScratchPages, uint nReservedPages, SegmentAccessor &scratchAccessor, DeviceAccessScheduler &scheduler, SharedRandomAccessDevice pDataDevice) |
| Creates a new SegPageBackupRestoreDevice, returning a shared pointer to the object. | |
| Protected Attributes | |
| bool | needsClose |
| Private Types | |
| typedef std::hash_map< BlockNum, BackupRestorePage * > | PendingWriteMap |
| typedef PendingWriteMap::iterator | PendingWriteMapIter |
| Private Member Functions | |
| void | init () |
| Initializes the backup/restore device. | |
| void | setCompressionProgramPathname (const std::string &programName) |
| Determines the full pathname for a compression program by locating the program either in /bin or /usr/bin. | |
| void | initScratchPages (SegPageLock &scratchLock, uint nScratchPages, uint nReservedPages, uint bufferSize) |
| Allocates scratch pages used by backup and restore. | |
| BackupRestorePage * | getFreeScratchPage () |
| Retrieves an available scratch page. | |
| void | freeScratchPage (BackupRestorePage &scratchPage) |
| Puts the scratch page that is no longer being used back into the free scratch page queue, increments counters tracking which page needs to be written next to the backup file, and notifies any threads waiting for a free scratch page. | |
| void | writeBackupPage (PConstBuffer pageBuffer, bool scheduledWrite) |
| Writes a single page of data to the backup file. | |
| void | checkPendingException () |
| Determines if there is a pending I/O exception, and if so, throws the exception. | |
| virtual void | closeImpl () |
| Must be implemented by derived class to release any resources. | |
| Private Attributes | |
| std::string | backupFilePathname |
| Full pathname of the backup file. | |
| uint | nReservedPages |
| Number of reserved scratch pages available. | |
| SegmentAccessor | scratchAccessor |
| Scratch accessor used for temporary buffers. | |
| DeviceAccessScheduler & | scheduler |
| Scheduler for I/O requests. | |
| SharedRandomAccessDevice | pDataDevice |
| Device corresponding to the segment pages that are backed up or restored. | |
| char * | mode |
| String value indicating how the device should be opened. | |
| std::string | compressionProgram |
| uint | nScratchPages |
| bool | isCompressed |
| True if the backup file is compressed. | |
| SegPageLock | scratchLock |
| Scratch lock. | |
| FILE * | backupFile |
| File stream for the backup file. | |
| uint | pageSize |
| Size of each page backed up or restored. | |
| boost::scoped_array< PBuffer > | reservedPages |
| Array of reserved scratch pages. | |
| std::vector< BackupRestorePage * > | freeScratchPageQueue |
| Queue of free scratch pages that can be used to read/write pages during backup and restore. | |
| LocalCondition | freeScratchPageCondition |
| Condition variable used for notification of free scratch page availability. | |
| StrictMutex | mutex |
| Mutex to ensure that only one thread is modifying shared data. | |
| PendingWriteMap | pendingWriteMap |
| A map containing pages waiting to be written to the backup file. | |
| BlockNum | currPageReadCount |
| In the case of a backup, the counter corresponding to the page that needs to be read, for reads that are scheduled. | |
| BlockNum | currPageWriteCount |
| In case of a backup, the counter corresponding to the page that needs to be written to the backup file, for pages for which the reads were scheduled. | |
| boost::scoped_array< BackupRestorePage > | backupRestorePages |
| Array of requests, representing pages being backed up or restored. | |
| boost::scoped_ptr< FennelExcn > | pPendingExcn |
| Pending exception, if there is one. |
Detailed Description
Device used to backup and restore pages from a data segment.
Definition at line 126 of file SegPageBackupRestoreDevice.h.
Member Typedef Documentation
Constructor & Destructor Documentation
Opens a device that is used to backup and restore pages from a segment.
Parameters:
| backupFilePathname | pathname of the backup file |
|---|---|
| mode | string indicating how the device should be opened |
| compressionProgram | if non-empty string, the name of the program to use to compress or decompress the backup file |
| nScratchPages | number of scratch pages to allocate for backing up and restoring data pages |
| nReservedPages | additional scratch pages to allocate for special reserved buffers |
| scratchAccessor | accessor used to allocate temporary scratch buffers |
| scheduler | scheduler used for scheduling I/O requests |
| pDataDevice | the device containing the data segment pages that will be backed up or restored |
Definition at line 115 of file SegPageBackupRestoreDevice.cpp.
References backupFile, currPageReadCount, currPageWriteCount, mode, nScratchPages, and setCompressionProgramPathname().
Referenced by newSegPageBackupRestoreDevice().
Member Function Documentation
| void SegPageBackupRestoreDevice::init | ( | | ) | [private] | | ------------------------------------- | - | | - | ----------- |
Initializes the backup/restore device.
Definition at line 138 of file SegPageBackupRestoreDevice.cpp.
References SegPageLock::accessSegment(), backupFile, backupFilePathname, compressionProgram, initScratchPages(), isCompressed, mode, nReservedPages, nScratchPages, pageSize, SegmentAccessor::pSegment, scratchAccessor, and scratchLock.
| void SegPageBackupRestoreDevice::setCompressionProgramPathname | ( | const std::string & | programName | ) | [private] |
|---|
| void SegPageBackupRestoreDevice::initScratchPages | ( | SegPageLock & | scratchLock, |
|---|---|---|---|
| uint | nScratchPages, | ||
| uint | nReservedPages, | ||
| uint | bufferSize | ||
| ) | [private] |
| void SegPageBackupRestoreDevice::freeScratchPage | ( | BackupRestorePage & | scratchPage | ) | [private] |
|---|
| void SegPageBackupRestoreDevice::writeBackupPage | ( | PConstBuffer | pageBuffer, |
|---|---|---|---|
| bool | scheduledWrite | ||
| ) | [private] |
| void SegPageBackupRestoreDevice::checkPendingException | ( | | ) | [private] | | ------------------------------------------------------ | - | | - | ----------- |
| void SegPageBackupRestoreDevice::closeImpl | ( | | ) | [private, virtual] | | ------------------------------------------ | - | | - | -------------------- |
| PBuffer SegPageBackupRestoreDevice::getReservedBufferPage | ( | | ) | | ------------------------------------------------------------------------------------------------------------- | - | | - |
Returns a pointer to one of the reserved buffer pages.
The number of calls to this method cannot exceed the number of reserved buffers available.
Returns:
pointer to an available reserved buffer; NULL if no more buffers are available
Definition at line 218 of file SegPageBackupRestoreDevice.cpp.
References nReservedPages, and reservedPages.
| void SegPageBackupRestoreDevice::writeBackupPage | ( | PConstBuffer | pageBuffer | ) |
|---|
| void SegPageBackupRestoreDevice::backupPage | ( | BlockId | blockId | ) |
|---|
Backs up a data page by scheduling a request to read it, then writing it to the backup file once the read request has been met.
Parameters:
| blockId | block id of the page that needs to be backed up |
|---|
Definition at line 253 of file SegPageBackupRestoreDevice.cpp.
References RandomAccessRequest::bindingList, RandomAccessRequest::cbOffset, RandomAccessRequest::cbTransfer, currPageReadCount, CompoundId::getBlockNum(), getFreeScratchPage(), pageSize, pDataDevice, RandomAccessRequest::pDevice, RandomAccessRequest::READ, DeviceAccessScheduler::schedule(), scheduler, BackupRestorePage::setPageCounter(), BackupRestorePage::setReadRequest(), and RandomAccessRequest::type.
| void SegPageBackupRestoreDevice::notifyReadTransferCompletion | ( | BackupRestorePage & | scratchPage, |
|---|---|---|---|
| bool | bSuccess | ||
| ) |
| void SegPageBackupRestoreDevice::restorePage | ( | BlockId | blockId | ) |
|---|
Restores a page by reading it from the backup file and then scheduling a request to write it to the data device.
Parameters:
| blockId | block id of the page that needs to be restored |
|---|
Definition at line 349 of file SegPageBackupRestoreDevice.cpp.
References backupFile, backupFilePathname, RandomAccessRequest::bindingList, RandomAccessRequest::cbOffset, RandomAccessRequest::cbTransfer, currPageReadCount, CompoundId::getBlockNum(), BackupRestorePage::getBuffer(), getFreeScratchPage(), pageSize, pDataDevice, RandomAccessRequest::pDevice, DeviceAccessScheduler::schedule(), scheduler, BackupRestorePage::setPageCounter(), BackupRestorePage::setReadRequest(), RandomAccessRequest::type, and RandomAccessRequest::WRITE.
| void SegPageBackupRestoreDevice::notifyWriteTransferCompletion | ( | BackupRestorePage & | scratchPage, |
|---|---|---|---|
| bool | bSuccess | ||
| ) |
Receives notification that a write request has completed.
Frees the scratch buffer associated with the request.
Parameters:
| scratchPage | the scratch page containing the data read |
|---|---|
| bSuccess | whether the request was successful |
Definition at line 374 of file SegPageBackupRestoreDevice.cpp.
References freeScratchPage(), and pPendingExcn.
| void SegPageBackupRestoreDevice::waitForPendingWrites | ( | | ) | | ----------------------------------------------------- | - | | - |
| bool ClosableObject::isClosed | ( | | ) | const [inline, inherited] | | ----------------------------- | - | | - | --------------------------- |
Returns:
whether the object has been closed
Definition at line 58 of file ClosableObject.h.
| void ClosableObject::close | ( | | ) | [inherited] | | -------------------------- | - | | - | ------------- |
Closes this object, releasing any unallocated resources.
Reimplemented in CollectExecStream, CorrelationJoinExecStream, LcsClusterAppendExecStream, and LcsClusterReplaceExecStream.
Definition at line 39 of file ClosableObject.cpp.
References ClosableObject::closeImpl(), and ClosableObject::needsClose.
Referenced by CacheImpl< PageT, VictimPolicyT >::allocatePages(), LcsRowScanBaseExecStream::closeImpl(), ExecStreamGraphImpl::closeImpl(), FlatFileBuffer::open(), ClosableObjectDestructor::operator()(), and Segment::~Segment().
Member Data Documentation
The documentation for this class was generated from the following files:
- /home/pub/open/dev/fennel/segment/SegPageBackupRestoreDevice.h
- /home/pub/open/dev/fennel/segment/SegPageBackupRestoreDevice.cpp
