public abstract class ObjectIdFileLoader extends Object implements FileLoader, BackgroundFileLoader, FileStateListener
The object id file loader loads/saves file data to a repository/storage device using an associated object id.
This class relies on a seperate DBObjectIdInterface implementation to provide the methods to load and save the file id/object id mappings to the database table.
Modifier and Type | Field and Description |
---|---|
static String |
DBFileSegmentInfo |
static long |
DEFAULT_FRAGSIZE |
static int |
DefaultWorkerThreads |
static String |
JarFilePrefix |
static long |
MAX_FRAGSIZE |
static long |
MAX_MEMORYBUFFER |
static int |
MaximumWorkerThreads |
static long |
MIN_FRAGSIZE |
static int |
MinimumWorkerThreads |
static long |
RequestProcessedExpire |
static long |
RequestQueuedExpire |
static long |
SequentialFileExpire |
static int |
StsError |
static int |
StsRequeue |
static int |
StsSuccess |
static String |
TempDirPrefix |
static String |
TempFilePrefix |
Constructor and Description |
---|
ObjectIdFileLoader()
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,
String tempPath,
String virtPath,
int sts)
Re-create, or attach, a file request to the file state.
|
void |
deleteFile(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(String virtPath)
Find the file segment for the specified virtual path
|
DBDeviceContext |
getContext()
Return the database device context
|
File |
getCurrentTempDirectory()
Return the current temporry sub-directory
|
DBObjectIdInterface |
getDBObjectIdInterface()
Return the database object id interface
|
int |
getLowQueueSize()
Return the in-memory file request queue low water mark level
|
int |
getMaximumQueueSize()
Return the maximum in-memory file request queue size
|
String |
getName()
Return the worker thread prefix
|
int |
getRequiredDBFeatures()
Return the database features required by this file loader.
|
String |
getShareName()
Return the shared device name that this loader is associated with
|
protected FileStateCache |
getStateCache()
Return the file state cache
|
String |
getTempDirectoryPrefix()
Return the temporary sub-directory prefix
|
String |
getTempFilePrefix()
Return the temporary file prefix
|
File |
getTemporaryDirectory()
Return the temporary directory
|
String |
getTemporaryDirectoryPath()
Return the temporary directory name
|
boolean |
hasDebug()
Check if debug output is enabled
|
boolean |
hasFileProcessors()
Determine if there are any file processors configured
|
protected boolean |
hasRequiredAttributes()
Check if there are any required attributes to be added to file requests
|
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
|
abstract void |
loadFileData(int fileId,
int streamId,
String objectId,
FileSegment fileSeg)
Load the file data
|
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
|
abstract String |
saveFileData(int fileId,
int streamId,
FileSegment fileSeg,
NameValueList attrs)
Save file data
|
void |
setContext(DBDeviceContext dbCtx)
Set the database context
|
protected void |
setName(String name)
Set the worker thread name prefix
|
protected void |
setRequiredAttributes(StringList attrNames)
Set the list of required attributes to be added to file requests
|
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
|
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 String TempDirPrefix
public static final String TempFilePrefix
public static final String JarFilePrefix
public static final String DBFileSegmentInfo
public static final int DefaultWorkerThreads
public static final int MinimumWorkerThreads
public static final int MaximumWorkerThreads
public static final long SequentialFileExpire
public static final long RequestProcessedExpire
public static final long RequestQueuedExpire
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 int getRequiredDBFeatures()
getRequiredDBFeatures
in interface FileLoader
public final DBDeviceContext getContext()
protected final FileStateCache getStateCache()
public final String getTemporaryDirectoryPath()
public final File getTemporaryDirectory()
public final File getCurrentTempDirectory()
public final DBObjectIdInterface getDBObjectIdInterface()
public void addFileProcessor(FileProcessor fileProc) throws FileLoaderException
addFileProcessor
in interface FileLoader
fileProc
- FileProcessorFileLoaderException
public final boolean hasFileProcessors()
public final boolean hasDebug()
public final int getMaximumQueueSize()
public final int getLowQueueSize()
public final String getName()
public final String getShareName()
public final String getTempDirectoryPrefix()
public final String getTempFilePrefix()
protected final void setName(String name)
name
- Stringprotected final void setRequiredAttributes(StringList attrNames)
attrNames
- StringListprotected final boolean hasRequiredAttributes()
public NetworkFile openFile(FileOpenParams params, int fid, int stid, int did, boolean create, boolean dir) throws IOException, FileNotFoundException
openFile
in interface FileLoader
params
- FileOpenParamsfid
- intstid
- intdid
- intcreate
- booleandir
- booleanIOException
FileNotFoundException
public void closeFile(SrvSession sess, NetworkFile netFile) throws IOException
closeFile
in interface FileLoader
sess
- SrvSessionnetFile
- NetworkFileIOException
public void deleteFile(String fname, int fid, int stid) throws IOException
deleteFile
in interface FileLoader
fname
- Stringfid
- intstid
- intIOException
public void queueFileRequest(FileRequest req)
queueFileRequest
in interface FileLoader
req
- FileRequestpublic int loadFile(FileRequest req) throws Exception
loadFile
in interface BackgroundFileLoader
req
- FileRequestException
public int storeFile(FileRequest req) throws Exception
storeFile
in interface BackgroundFileLoader
req
- FileRequestException
public abstract void loadFileData(int fileId, int streamId, String objectId, FileSegment fileSeg) throws IOException
fileId
- intstreamId
- intobjectId
- StringfileSeg
- FileSegmentIOException
public abstract String saveFileData(int fileId, int streamId, FileSegment fileSeg, NameValueList attrs) throws IOException
fileId
- intstreamId
- intfileSeg
- FileSegmentattrs
- NameValueListIOException
public void initializeLoader(org.springframework.extensions.config.ConfigElement params, DeviceContext ctx) throws FileLoaderException, IOException
initializeLoader
in interface FileLoader
params
- ConfigElementctx
- DeviceContextFileLoaderException
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, String tempPath, String virtPath, int sts)
fid
- inttempPath
- StringvirtPath
- Stringsts
- intprotected final FileSegment findFileSegmentForPath(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–2017 Alfresco Software. All rights reserved.