@NotStorableClass public class HeapElementManager extends Object implements IHeapElementManager
IHeapElementManager for role descriptionheapRecordToWriteMap and in
readHeapRecordMap#readHeapFileDataRecord(long, boolean) check if record already in
cache, if not read it from file and put it in cache ( the record is marked
not modified )#newHeapFileRecord(long, long, long, boolean, boolean, int, int),
create a new record and put it in the cachedelete(long) delete record from the cachecloseTransaction() write record marked changed from the cache to the
files ( see crash safe mechanisms )closeTransaction() is
call, that close the file to be sure all is on disk before reopen file for
readingwasBadFileStableState() must be call before use files to restore
stable file state if needed| Constructor and Description |
|---|
HeapElementManager(FileForStorable fileForStorable,
File stateOkFlagFile,
FileForStorable fileForStorableBackup,
File stateBackupOkFlagFile,
File globalStateFlagFile,
boolean deleteRenaming,
boolean clearResizeFile,
int maxFileOperationRetry,
int fileOperationRetryMsDelay,
File openFileTraceFile)
construction for crash safe mode enabled
|
HeapElementManager(IFileForStorable fileForStorable,
boolean deleteRenaming,
boolean clearResizeFile,
int maxFileOperationRetry,
int fileOperationRetryMsDelay,
File openFileTraceFile)
construction for crash safe mode disabled
|
| Modifier and Type | Method and Description |
|---|---|
void |
appendHeapFileRecord(IFileStorable heapRecord)
append an heap file record that will be to write in file
|
String |
backup(long identifier,
int maxBackup) |
void |
clear()
clear heap content
service must be started and transaction opened |
void |
clearReadCache() |
void |
closeTransaction()
close the heap file transaction management committing the modifications
to the file before
|
void |
closeTransactionDiscardChange()
close the heap file transaction management without commit modification in
file
|
void |
delete(long positionInFile) |
IDataRecordKeyManager |
getDataRecordKeyManager() |
IFileForStorable |
getFileForStorable() |
long |
getFileSize() |
IFileStorable |
getHeapFileRecordInReadCache(long positionInFile)
FOR TEST ONLY
|
IFileStorable |
getHeapFileRecordInWriteCache(long positionInFile)
FOR TEST ONLY
|
IFileStorable |
getHeapHeader() |
IHeapRecordFactory |
getHeapRecordFactory() |
int |
getNumberOfHeaprecordInMemory() |
boolean |
isCrashSafeMode() |
boolean |
isDataLost()
the returned value is set by
IHeapElementManager.wasBadFileStableState() |
boolean |
isServiceStarted() |
boolean |
isTransactionOpened() |
void |
openTransaction()
open the heap file transaction management
|
IFileStorable |
readHeapFileDataRecord(long positionInFile)
read heap record in file
|
void |
removeFiles()
removes files containing heap data
transaction must be closed and service stopped |
void |
setDataRecordKeyManager(IDataRecordKeyManager dataRecordKeyManager) |
void |
setHeapHeader(IFileStorable heapHeader)
set heap header
|
void |
setHeapRecordFactory(IHeapRecordFactory heapRecordFactory) |
void |
startService()
start heap record management service
|
void |
stopService()
stop heap record management service
|
boolean |
wasBadFileStableState()
check file stable state, restore if possible
service must not be started must be called before heap file access |
public HeapElementManager(IFileForStorable fileForStorable, boolean deleteRenaming, boolean clearResizeFile, int maxFileOperationRetry, int fileOperationRetryMsDelay, File openFileTraceFile)
fileForStorable - data filedeleteRenaming - clearResizeFile - maxFileOperationRetry - fileOperationRetryMsDelay - openFileTraceFile - public HeapElementManager(FileForStorable fileForStorable, File stateOkFlagFile, FileForStorable fileForStorableBackup, File stateBackupOkFlagFile, File globalStateFlagFile, boolean deleteRenaming, boolean clearResizeFile, int maxFileOperationRetry, int fileOperationRetryMsDelay, File openFileTraceFile)
fileForStorable - data filestateOkFlagFile - flag file indicating data file state stablefileForStorableBackup - data backup filestateBackupOkFlagFile - flag file indicating backup data file state stableglobalStateFlagFile - flag file indicating backup and data file stable statedeleteRenaming - clearResizeFile - maxFileOperationRetry - fileOperationRetryMsDelay - openFileTraceFile - HeapException - no files in stable statepublic boolean isCrashSafeMode()
isCrashSafeMode in interface IHeapElementManagerpublic IFileForStorable getFileForStorable()
getFileForStorable in interface IHeapElementManagerpublic long getFileSize()
throws HeapException
getFileSize in interface IHeapElementManagerHeapExceptionpublic boolean wasBadFileStableState()
throws HeapException
IHeapElementManagerwasBadFileStableState in interface IHeapElementManagerHeapException - no file in stable state, no files in stable statepublic boolean isDataLost()
IHeapElementManagerIHeapElementManager.wasBadFileStableState()isDataLost in interface IHeapElementManagerIHeapElementManager.wasBadFileStableState()public void removeFiles()
throws HeapException
IHeapElementManagerremoveFiles in interface IHeapElementManagerHeapExceptionpublic void clear()
throws HeapException
IHeapElementManagerclear in interface IHeapElementManagerHeapExceptionpublic void startService()
throws HeapException
IHeapElementManagerstartService in interface IHeapElementManagerHeapException - file access error
file data corruptedpublic void stopService()
throws HeapException
IHeapElementManagerstopService in interface IHeapElementManagerHeapExceptionpublic boolean isServiceStarted()
isServiceStarted in interface IHeapElementManagerpublic void openTransaction()
throws HeapException
IHeapElementManageropenTransaction in interface IHeapElementManagerHeapExceptionpublic void closeTransaction()
throws HeapException
IHeapElementManagercloseTransaction in interface IHeapElementManagerHeapExceptionpublic void closeTransactionDiscardChange()
throws HeapException
IHeapElementManagercloseTransactionDiscardChange in interface IHeapElementManagerHeapExceptionpublic void clearReadCache()
clearReadCache in interface IHeapElementManagerpublic boolean isTransactionOpened()
isTransactionOpened in interface IHeapElementManagerpublic void setHeapHeader(IFileStorable heapHeader) throws HeapException
IHeapElementManagersetHeapHeader in interface IHeapElementManagerHeapExceptionpublic IFileStorable getHeapHeader() throws HeapException
getHeapHeader in interface IHeapElementManagerHeapExceptionpublic IFileStorable readHeapFileDataRecord(long positionInFile) throws HeapException
IHeapElementManagerreadHeapFileDataRecord in interface IHeapElementManagerpositionInFile - heap record position in fileHeapExceptionpublic void appendHeapFileRecord(IFileStorable heapRecord) throws HeapException
IHeapElementManagerappendHeapFileRecord in interface IHeapElementManagerheapRecord - the heap file record to appendHeapExceptionpublic void delete(long positionInFile)
throws HeapException
delete in interface IHeapElementManagerHeapExceptionpublic int getNumberOfHeaprecordInMemory()
getNumberOfHeaprecordInMemory in interface IHeapElementManagerpublic void setHeapRecordFactory(IHeapRecordFactory heapRecordFactory)
setHeapRecordFactory in interface IHeapElementManagerpublic IHeapRecordFactory getHeapRecordFactory()
getHeapRecordFactory in interface IHeapElementManagerpublic void setDataRecordKeyManager(IDataRecordKeyManager dataRecordKeyManager)
setDataRecordKeyManager in interface IHeapElementManagerpublic IDataRecordKeyManager getDataRecordKeyManager()
getDataRecordKeyManager in interface IHeapElementManager@Fortest public IFileStorable getHeapFileRecordInReadCache(long positionInFile)
positionInFile - heap record position in file@Fortest public IFileStorable getHeapFileRecordInWriteCache(long positionInFile)
positionInFile - heap record position in fileNULL_FILE_STORABLEpublic String backup(long identifier, int maxBackup) throws HeapException
backup in interface IHeapElementManagerHeapExceptionCopyright © 2007-2012 Luc Peuvrier. All Rights Reserved.