public class ServerFileVault extends java.lang.Object implements ServerFileVaultI
TransactionalFileI objects.
It manages all physical storage for BLOBs, ensuring that file operations (like saving, changing, or deleting) are atomic and consistent with database transactions. It utilizes a set of specialized directories (storage, backup, temporary) and a temporary file per BLOB to facilitate this transactional safety.
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
FILEEXTENSION_BLOB |
static java.lang.String |
FILEEXTENSION_LOG |
static org.apache.log4j.Logger |
log |
| Constructor and Description |
|---|
ServerFileVault(java.io.File _newFilesDir,
java.io.File _storageDir,
java.io.File _backupDir,
java.io.File _lostAndFoundDir,
java.io.File _atticDir)
Private constructor for the ServerFileVault singleton.
|
ServerFileVault(java.io.File _newFilesDir,
java.io.File _storageDir,
java.io.File _backupDir,
java.io.File _lostAndFoundDir,
java.io.File _atticDir,
DBManLocalI _dbm) |
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getBackupFileName(java.lang.Long boid,
java.lang.Long bpid) |
java.lang.String |
getBackupFileNameTemp(java.lang.Long boid,
java.lang.Long bpid) |
java.io.File |
getBLOB(java.lang.Long boid)
get the BLOB belonging to BO[id].
|
java.io.File |
getBLOB(java.lang.Long boid,
java.lang.Long backuppingBPId)
get the BLOB belonging to BO[id].
|
InitialBLOBTransferMetaDataContainer |
getBLOBBOIdsForIntitialBLOBCopy(java.util.Map idsAndVFilesOnSyncNode,
java.util.List pendingBLOBChangeBOIdsOnSyncNode,
java.util.List pendingBLOBChangeBOIdsOnAuthNode)
Returns the Ids of all local BLOBs, unless they are older or have the same hash as listed in the passed Map
|
VFile |
getBLOBInfo(java.lang.Long id)
gathers information about the BLOB belonging to BO[i].
|
VFile |
getBLOBInfo(java.lang.Long id,
java.lang.Long backuppingBPId)
gathers information about the BLOB belonging to BO[i].
|
java.util.Iterator<java.lang.Long> |
getExistingBLOBsIdIterator() |
java.util.Iterator<java.lang.Long> |
getExistingBLOBsIdIterator(java.util.Set<java.lang.Long> pendingBLOBChangeBOIdsLocal) |
java.util.Iterator<VFile> |
getExistingBLOBsVFileIterator(java.util.Set<java.lang.Long> pendingBLOBChangeBOIdsLocal)
Traverses the storageDir and creates a Map
|
ManagedFileI |
getHandle(java.io.InputStream is,
java.lang.Long id)
Returns a ManagedFileI for reading binary data from the given InputStream and storing it as BLOB of the BO with the passed Id
|
ManagedFileI |
getHandle(java.io.InputStream is,
java.lang.Long id,
boolean noHistory) |
ManagedFileI |
getHandleForPullDuringSync(BLOBLoaderI blobLoader,
long len,
java.lang.String blobHash,
java.lang.Long boid,
java.lang.Long backuppingBPId,
boolean noHistory) |
ManagedFileI |
getHandleForPushDuringSync(java.lang.Long id,
boolean deletion,
java.lang.Long backuppingBPId,
java.lang.String blobHash) |
ManagedFileI |
getHandleForReceivingBLOBOnServerSide(java.io.ObjectInput in,
long len,
java.lang.String blobHash,
java.lang.Long id,
boolean syncMode,
boolean noHistory) |
ManagedFileI |
getHandleForRemoveBLOB(java.lang.String oldHash,
java.lang.Long id) |
ManagedFileI |
getHandleForRemoveBLOB(java.lang.String oldHash,
java.lang.Long id,
boolean noHistory) |
ManagedFileI |
getHandleForUndoBLOBChangeOnServerSide(java.lang.String oldHash,
java.lang.String newHash,
java.lang.Long undoBPId,
java.lang.Long id,
boolean noHistory) |
static ServerFileVault |
getInstance(DBManLocalI _dbm,
netrexx.lang.Rexx _section)
Returns the singleton instance of ServerFileVault, configuring it via a database manager's configuration.
|
static ServerFileVault |
getInstance(DBManLocalI _dbm,
netrexx.lang.Rexx _section,
java.lang.String _legacyFilesRootName) |
static ServerFileVault |
getInstance(java.io.File _newFilesDir,
java.io.File _storageDir,
java.io.File _backupDir,
java.io.File _lostAndFoundDir,
java.io.File _atticDir)
Deprecated.
use the configuration-based factory method
getInstance(DBManLocalI, Rexx, String) instead |
InputStreamWrapper |
getStream(java.lang.Long id)
get the BLOB belonging to BO[id].
|
InputStreamWrapper |
getStream(java.lang.Long id,
java.lang.Long backuppingBPId)
get the BLOB belonging to BO[id].
|
void |
recover()
Executes the recovery process for transactional file changes.
|
void |
retireOrphanedBLOBsEventually(java.util.Set<java.lang.Long> blobIds)
Initiates the eventual retirement (deletion) of BLOBs that are no longer referenced by the database.
|
VFile |
storeRemoteBLOB(BLOBInputI in,
java.lang.String newBLOBIdString,
VFile rvfile,
int current,
int totalBLOBs) |
long |
toDataOutput(java.lang.Long boid,
java.io.DataOutput oo,
boolean closeOS,
java.lang.Long backuppingBPId)
Writes the BLOB belonging to BO[id] to the passed DataOutput.
|
long |
toStream(java.lang.Long boid,
java.io.OutputStream os,
boolean closeOS,
java.lang.Long backuppingBPId)
Writes the BLOB belonging to BO[id] to the passed OutputStream.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitexists, existspublic static final org.apache.log4j.Logger log
public static final java.lang.String FILEEXTENSION_LOG
public static final java.lang.String FILEEXTENSION_BLOB
public ServerFileVault(java.io.File _newFilesDir,
java.io.File _storageDir,
java.io.File _backupDir,
java.io.File _lostAndFoundDir,
java.io.File _atticDir)
This constructor initializes the paths for all managed directories and performs critical checks to ensure transactional integrity. Specifically, it verifies that the file system supports atomic move operations between the core directories, which is essential for guaranteeing that file transfers are completed or fully rolled back.
_newFilesDir - The temporary directory for incoming files._storageDir - The directory for live, committed files._backupDir - The directory for files being backed up before being replaced or deleted._lostAndFoundDir - The directory for files that were unassociated upon server start._atticDir - The directory for files moved out of primary storage because they are orphaned._dbm - The associated database manager instance (optional, may be null).java.lang.IllegalArgumentException - If atomic move operations are not supported between critical directories.public ServerFileVault(java.io.File _newFilesDir,
java.io.File _storageDir,
java.io.File _backupDir,
java.io.File _lostAndFoundDir,
java.io.File _atticDir,
DBManLocalI _dbm)
@Deprecated public static ServerFileVault getInstance(java.io.File _newFilesDir, java.io.File _storageDir, java.io.File _backupDir, java.io.File _lostAndFoundDir, java.io.File _atticDir)
getInstance(DBManLocalI, Rexx, String) insteadThis factory method initializes the singleton with explicitly provided directory File objects.
The configuration-based factory method (getInstance(DBManLocalI, Rexx, String)) is the primary path.
_newFilesDir - The directory for new, temporary files before they are committed._storageDir - The main, live storage directory for committed BLOBs._backupDir - The directory used to hold old BLOB versions after they were deleted or replaced by a new file._lostAndFoundDir - The directory for transaction control file remnants that were encountered upon server start._atticDir - The directory for files that are moved out of the main storage because they are orphaned.public static ServerFileVault getInstance(DBManLocalI _dbm, netrexx.lang.Rexx _section)
This is the primary factory method, typically called via reflection from DBMan#initFileVault().
It retrieves directory names from the DBManLocalI's configuration using a specified section
and provides robust fallback logic for directory setup, including legacy support.
_dbm - The local database manager instance to retrieve the configuration from._section - The configuration section (Rexx object) where the directory paths are defined._legacyFilesRootName - An optional fallback directory name for legacy support if 'storageDir' is not configured.
Can be null.java.lang.IllegalArgumentException - If no 'storageDir' is configured and no legacy fallback name is provided.public static ServerFileVault getInstance(DBManLocalI _dbm, netrexx.lang.Rexx _section, java.lang.String _legacyFilesRootName)
public void retireOrphanedBLOBsEventually(java.util.Set<java.lang.Long> blobIds)
This method is typically called as part of a scheduled integrity check or cleanup process (e.g. by the OrphanedBLOBsChecker). It identifies a batch of unreferenced files by their IDs and queues them for safe deletion. The process is "eventual" to decouple the integrity check from the potentially time-consuming file I/O operations.
retireOrphanedBLOBsEventually in interface IntegrityCheckingServerFileVaultIblobIds - A Set of unique Long IDs corresponding to the BLOB files that are confirmed to be orphaned.public void recover()
throws java.io.IOException
This process examines the log files in the ServerFileVault directories to identify transactions that were committed in the database but failed to fully complete their corresponding file system operations (or vice-versa). It then attempts to complete the file system changes to restore transactional consistency.
recover in interface ServerFileVaultIIOException - If a severe I/O error occurs during the recovery process.java.lang.IllegalStateException - If called before the persistence framework is fully initialized,
as it requires querying Business Procedures (BP) and Business Objects (BO).public VFile getBLOBInfo(java.lang.Long id)
ServerFileVaultIgetBLOBInfo in interface ServerFileVaultIid - the id of the BO the BLOB-info belongs to.public VFile getBLOBInfo(java.lang.Long id, java.lang.Long backuppingBPId)
ServerFileVaultIgetBLOBInfo in interface ServerFileVaultIid - the id of the BO the BLOB-info belongs to.backuppingBPId - the information should be taken from the backup-BLOB in the backup-dir using this BP-Idpublic InputStreamWrapper getStream(java.lang.Long id)
ServerFileVaultIgetStream in interface ServerFileVaultIid - the id of the BO the BLOB belongs to.public InputStreamWrapper getStream(java.lang.Long id, java.lang.Long backuppingBPId)
ServerFileVaultIgetStream in interface ServerFileVaultIid - the id of the BO the BLOB belongs to.backuppingBPId - the data should be taken from the backup-BLOB in the backup-dir using this BP-Idpublic long toStream(java.lang.Long boid,
java.io.OutputStream os,
boolean closeOS,
java.lang.Long backuppingBPId)
throws java.io.IOException
ServerFileVaultItoStream in interface ServerFileVaultIboid - the id of the BO the BLOB belongs toos - the OutputStream to write the BLOB-bytes tocloseOS - a boolean designating if the OutputStream shall be closed afterwards or not.backuppingBPId - the data should be taken from the backup-BLOB in the backup-dir using this BP-Idjava.io.IOExceptionpublic long toDataOutput(java.lang.Long boid,
java.io.DataOutput oo,
boolean closeOS,
java.lang.Long backuppingBPId)
throws java.io.IOException
ServerFileVaultItoDataOutput in interface ServerFileVaultIboid - the id of the BO the BLOB belongs tooo - the DataOutput to write the BLOB-bytes tocloseOS - a boolean designating if the DataOutput shall be closed afterwards or not.backuppingBPId - the BLOB should be taken from the backup-dir using this BP-Idjava.io.IOExceptionpublic java.io.File getBLOB(java.lang.Long boid)
ServerFileVaultIgetBLOB in interface ServerFileVaultIboid - the id of the BO the BLOB belongs to.public java.io.File getBLOB(java.lang.Long boid,
java.lang.Long backuppingBPId)
ServerFileVaultIgetBLOB in interface ServerFileVaultIboid - the id of the BO the BLOB belongs to.backuppingBPId - the BLOB should be taken from the backup-dir using this BP-Idpublic java.lang.String getBackupFileName(java.lang.Long boid,
java.lang.Long bpid)
public java.lang.String getBackupFileNameTemp(java.lang.Long boid,
java.lang.Long bpid)
public ManagedFileI getHandleForRemoveBLOB(java.lang.String oldHash, java.lang.Long id)
getHandleForRemoveBLOB in interface FileVaultIpublic ManagedFileI getHandleForRemoveBLOB(java.lang.String oldHash, java.lang.Long id, boolean noHistory)
getHandleForRemoveBLOB in interface ServerFileVaultIpublic ManagedFileI getHandle(java.io.InputStream is, java.lang.Long id) throws java.io.IOException
getHandle in interface FileVaultIjava.io.IOExceptionpublic ManagedFileI getHandle(java.io.InputStream is, java.lang.Long id, boolean noHistory) throws java.io.IOException
getHandle in interface ServerFileVaultIjava.io.IOExceptionpublic ManagedFileI getHandleForReceivingBLOBOnServerSide(java.io.ObjectInput in, long len, java.lang.String blobHash, java.lang.Long id, boolean syncMode, boolean noHistory) throws java.io.IOException
getHandleForReceivingBLOBOnServerSide in interface FileVaultIjava.io.IOExceptionpublic ManagedFileI getHandleForUndoBLOBChangeOnServerSide(java.lang.String oldHash, java.lang.String newHash, java.lang.Long undoBPId, java.lang.Long id, boolean noHistory)
getHandleForUndoBLOBChangeOnServerSide in interface FileVaultIpublic ManagedFileI getHandleForPullDuringSync(BLOBLoaderI blobLoader, long len, java.lang.String blobHash, java.lang.Long boid, java.lang.Long backuppingBPId, boolean noHistory) throws java.io.IOException
getHandleForPullDuringSync in interface ServerFileVaultIjava.io.IOExceptionpublic ManagedFileI getHandleForPushDuringSync(java.lang.Long id, boolean deletion, java.lang.Long backuppingBPId, java.lang.String blobHash)
getHandleForPushDuringSync in interface ServerFileVaultIpublic VFile storeRemoteBLOB(BLOBInputI in, java.lang.String newBLOBIdString, VFile rvfile, int current, int totalBLOBs) throws java.io.FileNotFoundException
storeRemoteBLOB in interface ServerFileVaultIjava.io.FileNotFoundExceptionpublic java.util.Iterator<VFile> getExistingBLOBsVFileIterator(java.util.Set<java.lang.Long> pendingBLOBChangeBOIdsLocal) throws java.io.IOException
getExistingBLOBsVFileIterator in interface ServerFileVaultIjava.io.IOExceptionpublic java.util.Iterator<java.lang.Long> getExistingBLOBsIdIterator(java.util.Set<java.lang.Long> pendingBLOBChangeBOIdsLocal)
throws java.io.IOException
getExistingBLOBsIdIterator in interface ServerFileVaultIjava.io.IOExceptionpublic java.util.Iterator<java.lang.Long> getExistingBLOBsIdIterator()
throws java.io.IOException
getExistingBLOBsIdIterator in interface IntegrityCheckingServerFileVaultIjava.io.IOExceptionpublic InitialBLOBTransferMetaDataContainer getBLOBBOIdsForIntitialBLOBCopy(java.util.Map idsAndVFilesOnSyncNode, java.util.List pendingBLOBChangeBOIdsOnSyncNode, java.util.List pendingBLOBChangeBOIdsOnAuthNode) throws java.io.IOException
getBLOBBOIdsForIntitialBLOBCopy in interface ServerFileVaultIjava.io.IOExceptionCopyright © 2000-2025 OAshi S.à r.l. All Rights Reserved.