@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 neededConstructor 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 IHeapElementManager
public IFileForStorable getFileForStorable()
getFileForStorable
in interface IHeapElementManager
public long getFileSize() throws HeapException
getFileSize
in interface IHeapElementManager
HeapException
public boolean wasBadFileStableState() throws HeapException
IHeapElementManager
wasBadFileStableState
in interface IHeapElementManager
HeapException
- no file in stable state, no files in stable statepublic boolean isDataLost()
IHeapElementManager
IHeapElementManager.wasBadFileStableState()
isDataLost
in interface IHeapElementManager
IHeapElementManager.wasBadFileStableState()
public void removeFiles() throws HeapException
IHeapElementManager
removeFiles
in interface IHeapElementManager
HeapException
public void clear() throws HeapException
IHeapElementManager
clear
in interface IHeapElementManager
HeapException
public void startService() throws HeapException
IHeapElementManager
startService
in interface IHeapElementManager
HeapException
- file access error
file data corruptedpublic void stopService() throws HeapException
IHeapElementManager
stopService
in interface IHeapElementManager
HeapException
public boolean isServiceStarted()
isServiceStarted
in interface IHeapElementManager
public void openTransaction() throws HeapException
IHeapElementManager
openTransaction
in interface IHeapElementManager
HeapException
public void closeTransaction() throws HeapException
IHeapElementManager
closeTransaction
in interface IHeapElementManager
HeapException
public void closeTransactionDiscardChange() throws HeapException
IHeapElementManager
closeTransactionDiscardChange
in interface IHeapElementManager
HeapException
public void clearReadCache()
clearReadCache
in interface IHeapElementManager
public boolean isTransactionOpened()
isTransactionOpened
in interface IHeapElementManager
public void setHeapHeader(IFileStorable heapHeader) throws HeapException
IHeapElementManager
setHeapHeader
in interface IHeapElementManager
HeapException
public IFileStorable getHeapHeader() throws HeapException
getHeapHeader
in interface IHeapElementManager
HeapException
public IFileStorable readHeapFileDataRecord(long positionInFile) throws HeapException
IHeapElementManager
readHeapFileDataRecord
in interface IHeapElementManager
positionInFile
- heap record position in fileHeapException
public void appendHeapFileRecord(IFileStorable heapRecord) throws HeapException
IHeapElementManager
appendHeapFileRecord
in interface IHeapElementManager
heapRecord
- the heap file record to appendHeapException
public void delete(long positionInFile) throws HeapException
delete
in interface IHeapElementManager
HeapException
public int getNumberOfHeaprecordInMemory()
getNumberOfHeaprecordInMemory
in interface IHeapElementManager
public void setHeapRecordFactory(IHeapRecordFactory heapRecordFactory)
setHeapRecordFactory
in interface IHeapElementManager
public IHeapRecordFactory getHeapRecordFactory()
getHeapRecordFactory
in interface IHeapElementManager
public void setDataRecordKeyManager(IDataRecordKeyManager dataRecordKeyManager)
setDataRecordKeyManager
in interface IHeapElementManager
public 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_STORABLE
public String backup(long identifier, int maxBackup) throws HeapException
backup
in interface IHeapElementManager
HeapException
Copyright © 2007-2012 Luc Peuvrier. All Rights Reserved.