public class DBFileLoader extends java.lang.Object implements FileLoader, BackgroundFileLoader, FileStateListener
The database file data loader loads/saves file data to a BLOB field in a seperate database table to the main filesystem structure. The file data is indexed using the file id generated by the main database disk driver.
The file data may be split up into several BLOB fields.
This class relies on a seperate DBDataInterface implementation to provide the methods to load and save the file data to the database table.
Modifier and Type | Class and Description |
---|---|
protected class |
DBFileLoader.TransactionTimer
Transaction Timer Thread Inner Class
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DBFileSegmentInfo |
static long |
DEFAULT_FRAGSIZE |
static int |
DefaultFilesPerJar |
static int |
DefaultSizePerJar |
static long |
DefaultTransactionTimeout |
static int |
DefaultWorkerThreads |
static int |
JarDefaultCompression |
static java.lang.String |
JarFilePrefix |
static java.lang.String |
JarStatePrefix |
static long |
JarStateTimeout |
static long |
MAX_FRAGSIZE |
static long |
MAX_MEMORYBUFFER |
static long |
MaximumTransactionTimeout |
static int |
MaximumWorkerThreads |
static long |
MIN_FRAGSIZE |
static int |
MinimumFilesPerJar |
static int |
MinimumSizePerJar |
static long |
MinimumTransactionTimeout |
static int |
MinimumWorkerThreads |
static long |
RequestProcessedExpire |
static long |
RequestQueuedExpire |
static long |
SequentialFileExpire |
static int |
StsError |
static int |
StsRequeue |
static int |
StsSuccess |
static java.lang.String |
TempDirPrefix |
static java.lang.String |
TempFilePrefix |
static int |
TransactionMinimumFileSize |
Constructor and Description |
---|
DBFileLoader()
Class constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addFileProcessor(FileProcessor fileProc)
Add a file processor to process files before storing and after loading.
|
void |
closeFile(SrvSession sess,
NetworkFile netFile)
Close the network file
|
protected FileState |
createFileStateForRequest(int fid,
java.lang.String tempPath,
java.lang.String virtPath,
int sts)
Re-create, or attach, a file request to the file state.
|
void |
deleteFile(java.lang.String fname,
int fid,
int stid)
Delete the specified file data
|
void |
fileStateClosed(FileState state)
File state cache is closing down, any resources attached to the file state must be released.
|
boolean |
fileStateExpired(FileState state)
File state has expired.
|
protected FileSegment |
findFileSegmentForPath(java.lang.String virtPath)
Find the file segment for the specified virtual path
|
DBDeviceContext |
getContext()
Return the database device context
|
java.io.File |
getCurrentTempDirectory()
Return the current temporry sub-directory
|
DBDataInterface |
getDBDataInterface()
Return the database data interface
|
int |
getFilesPerJar()
Get the number of files per Jar
|
int |
getJarCompressionLevel()
Return the Jar compression level
|
int |
getJarFileSize()
Get the file size limit for packing into Jars
|
int |
getLowQueueSize()
Return the in-memory file request queue low water mark level
|
int |
getMaximumQueueSize()
Return the maximum in-memory file request queue size
|
java.lang.String |
getName()
Return the worker thread prefix
|
int |
getRequiredDBFeatures()
Return the database features required by this file loader.
|
long |
getSmallFileSize()
Get the small file threshold size
|
protected FileStateCache |
getStateCache()
Return the file state cache
|
java.lang.String |
getTempDirectoryPrefix()
Return the temporary sub-directory prefix
|
java.lang.String |
getTempFilePrefix()
Return the temporary file prefix
|
java.io.File |
getTemporaryDirectory()
Return the temporary directory
|
java.lang.String |
getTemporaryDirectoryPath()
Return the temporary directory name
|
long |
getTransactionTimeout()
Get the transaction timeout value, in milliseconds
|
boolean |
hasDebug()
Check if debug output is enabled
|
boolean |
hasFileProcessors()
Determine if there are any file processors configured
|
boolean |
hasKeepJars()
Check if Jars files should be kept in the temporary area
|
void |
initializeLoader(org.springframework.extensions.config.ConfigElement params,
DeviceContext ctx)
Initialize the file loader using the specified parameters
|
int |
loadFile(FileRequest req)
Load a file
|
protected int |
loadFileFromJar(SingleFileRequest loadReq,
java.io.File tempFile,
DBDataDetails dataDetails)
Load the requested file from a Jar file.
|
NetworkFile |
openFile(FileOpenParams params,
int fid,
int stid,
int did,
boolean create,
boolean dir)
Create a network file for the specified file
|
void |
queueFileRequest(FileRequest req)
Request file data to be loaded/saved
|
protected void |
runFileLoadedProcessors(DiskDeviceContext context,
FileState state,
FileSegment segment)
Run the file load file processors
|
protected void |
runFileStoreProcessors(DiskDeviceContext context,
FileState state,
FileSegment segment)
Run the file store file processors
|
void |
setContext(DBDeviceContext dbCtx)
Set the database context
|
protected void |
setName(java.lang.String name)
Set the worker thread name prefix
|
void |
shutdownLoader(boolean immediate)
Shutdown the file loader and release all resources
|
void |
startLoader(DeviceContext ctx)
Start the file loader
|
int |
storeFile(FileRequest req)
Store a file
|
protected int |
storeMultipleFile(MultipleFileRequest saveReq)
Process a store multiple file request
|
protected int |
storeSingleFile(SingleFileRequest saveReq)
Process a store single file request
|
boolean |
supportsStreams()
Determine if the loader supports NTFS streams
|
public static final int StsSuccess
public static final int StsRequeue
public static final int StsError
public static final java.lang.String TempDirPrefix
public static final java.lang.String TempFilePrefix
public static final java.lang.String JarFilePrefix
public static final java.lang.String DBFileSegmentInfo
public static final int DefaultWorkerThreads
public static final int MinimumWorkerThreads
public static final int MaximumWorkerThreads
public static final int DefaultFilesPerJar
public static final int MinimumFilesPerJar
public static final int DefaultSizePerJar
public static final int MinimumSizePerJar
public static final long SequentialFileExpire
public static final long RequestProcessedExpire
public static final long RequestQueuedExpire
public static final int TransactionMinimumFileSize
public static final long DefaultTransactionTimeout
public static final long MinimumTransactionTimeout
public static final long MaximumTransactionTimeout
public static final long DEFAULT_FRAGSIZE
public static final long MIN_FRAGSIZE
public static final long MAX_FRAGSIZE
public static final long MAX_MEMORYBUFFER
public static final java.lang.String JarStatePrefix
public static final long JarStateTimeout
public static final int JarDefaultCompression
public int getRequiredDBFeatures()
getRequiredDBFeatures
in interface FileLoader
public final DBDeviceContext getContext()
public final int getJarCompressionLevel()
protected final FileStateCache getStateCache()
public final java.lang.String getTemporaryDirectoryPath()
public final java.io.File getTemporaryDirectory()
public final java.io.File getCurrentTempDirectory()
public final boolean hasKeepJars()
public final DBDataInterface getDBDataInterface()
public void addFileProcessor(FileProcessor fileProc) throws FileLoaderException
addFileProcessor
in interface FileLoader
fileProc
- FileLoaderException
public final boolean hasFileProcessors()
public final boolean hasDebug()
public final int getMaximumQueueSize()
public final int getLowQueueSize()
public final java.lang.String getName()
public final long getSmallFileSize()
public final int getFilesPerJar()
public final int getJarFileSize()
public final long getTransactionTimeout()
public final java.lang.String getTempDirectoryPrefix()
public final java.lang.String getTempFilePrefix()
protected final void setName(java.lang.String name)
name
- Stringpublic NetworkFile openFile(FileOpenParams params, int fid, int stid, int did, boolean create, boolean dir) throws java.io.IOException, java.io.FileNotFoundException
openFile
in interface FileLoader
params
- FileOpenParamsfid
- intstid
- intdid
- intcreate
- booleandir
- booleanjava.io.IOException
java.io.FileNotFoundException
public void closeFile(SrvSession sess, NetworkFile netFile) throws java.io.IOException
closeFile
in interface FileLoader
sess
- SrvSessionnetFile
- NetworkFilejava.io.IOException
public void deleteFile(java.lang.String fname, int fid, int stid) throws java.io.IOException
deleteFile
in interface FileLoader
fname
- Stringfid
- intstid
- intjava.io.IOException
public void queueFileRequest(FileRequest req)
queueFileRequest
in interface FileLoader
req
- FileRequestpublic int loadFile(FileRequest req) throws java.lang.Exception
loadFile
in interface BackgroundFileLoader
req
- FileRequest2java.lang.Exception
protected final int loadFileFromJar(SingleFileRequest loadReq, java.io.File tempFile, DBDataDetails dataDetails)
loadReq
- SingleFileRequesttempFile
- FiledataDetails
- DBDataDetailspublic int storeFile(FileRequest req) throws java.lang.Exception
storeFile
in interface BackgroundFileLoader
req
- FileRequestjava.lang.Exception
protected final int storeSingleFile(SingleFileRequest saveReq) throws java.lang.Exception
saveReq
- SingleFileRequestjava.lang.Exception
protected final int storeMultipleFile(MultipleFileRequest saveReq) throws java.lang.Exception
saveReq
- MultipleFileRequestjava.lang.Exception
public void initializeLoader(org.springframework.extensions.config.ConfigElement params, DeviceContext ctx) throws FileLoaderException, java.io.IOException
initializeLoader
in interface FileLoader
params
- ConfigElementctx
- DeviceContextFileLoaderException
java.io.IOException
public void startLoader(DeviceContext ctx)
startLoader
in interface FileLoader
ctx
- DeviceContextpublic void shutdownLoader(boolean immediate)
shutdownLoader
in interface FileLoader
immediate
- booleanprotected final void runFileStoreProcessors(DiskDeviceContext context, FileState state, FileSegment segment)
context
- DiskDeviceContextstate
- FileStatesegment
- FileSegmentprotected final void runFileLoadedProcessors(DiskDeviceContext context, FileState state, FileSegment segment)
context
- DiskDeviceContextstate
- FileStatesegment
- FileSegmentprotected final FileState createFileStateForRequest(int fid, java.lang.String tempPath, java.lang.String virtPath, int sts)
fid
- inttempPath
- StringvirtPath
- Stringsts
- intprotected final FileSegment findFileSegmentForPath(java.lang.String virtPath)
virtPath
- Stringpublic boolean supportsStreams()
supportsStreams
in interface FileLoader
public boolean fileStateExpired(FileState state)
fileStateExpired
in interface FileStateListener
state
- FileStatepublic void fileStateClosed(FileState state)
fileStateClosed
in interface FileStateListener
state
- FileStatepublic final void setContext(DBDeviceContext dbCtx)
setContext
in interface FileLoader
dbCtx
- DBDeviceContextCopyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.