Class FileSystemStore
java.lang.Object
com.arjuna.ats.arjuna.objectstore.ObjectStore
com.arjuna.ats.internal.arjuna.objectstore.FileSystemStore
- All Implemented Interfaces:
BaseStore
,ObjectStoreAPI
,ParticipantStore
,RecoveryStore
,TxLog
- Direct Known Subclasses:
FileLockingStore
,LogStore
,ShadowingStore
The basic class for file system object stores. This is not actually
an object store implementation, since other classes must provide
implementations of the abstract methods. It does provide implementations
of common methods though.
- Since:
- JTS 1.0.
- Version:
- $Id: FileSystemStore.java 2342 2006-03-30 13:06:17Z $
- Author:
- Mark Little (mark@arjuna.com)
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
protected boolean
protected boolean
Fields inherited from class com.arjuna.ats.arjuna.objectstore.ObjectStore
_objectStoreRoot, shareStatus
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected final void
addToCache
(String fname) boolean
allObjUids
(String tName, InputObjectState state, int match) Given a type name initialise thestate
to contains all of the Uids of objects of that typeboolean
allTypes
(InputObjectState foundTypes) Obtain all types of objects stored in the object store.protected boolean
allTypes
(OutputObjectState foundTypes, String root) protected boolean
closeAndUnlock
(File fd, FileInputStream ifile, FileOutputStream ofile) Unlock and close the file.protected final boolean
createHierarchy
(String path) Attempt to build up the object store in the file system dynamically.protected final boolean
If this object store implementation is exclusively working on a set of object states, then this method will check a file cache first.protected String
genPathName
(Uid objUid, String tName, int ostype) protected boolean
Lock the file in the object store.protected File
openAndLock
(String fname, int lmode, boolean create) read_committed
(Uid storeUid, String tName) Read the object's committed state.protected abstract InputObjectState
read_state
(Uid u, String tn, int s) read_uncommitted
(Uid storeUid, String tName) Read the object's shadowed state.boolean
remove_committed
(Uid storeUid, String tName) Remove the object's committed state.protected abstract boolean
remove_state
(Uid u, String tn, int s) boolean
remove_uncommitted
(Uid storeUid, String tName) Remove the object's uncommitted state.protected final void
removeFromCache
(String fname) protected final void
removeFromCache
(String fname, boolean warn) Print a warning if the file to be removed is not in the cache.protected final boolean
renameFromTo
(File from, File to) protected final boolean
renameFromToInternal
(File from, File to) protected boolean
supressEntry
(String name) Suppress directories of the specified type from allTypes etc?protected final boolean
Are synchronous write enabled?protected String
protected boolean
Unlock the file in the object store.boolean
write_committed
(Uid storeUid, String tName, OutputObjectState state) Write a new copy of the object's committed state.protected abstract boolean
write_state
(Uid u, String tn, OutputObjectState buff, int s) boolean
write_uncommitted
(Uid storeUid, String tName, OutputObjectState state) Write a copy of the object's uncommitted state.Methods inherited from class com.arjuna.ats.arjuna.objectstore.ObjectStore
allObjUids, fullCommitNeeded, initialise, isType, locateStore, revealedId, shareState, start, stop, storeDir, storeRoot, sync
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.arjuna.ats.arjuna.objectstore.ParticipantStore
commit_state
Methods inherited from interface com.arjuna.ats.arjuna.objectstore.RecoveryStore
currentState, hide_state, reveal_state
-
Field Details
-
syncWrites
protected boolean syncWrites -
doSync
protected volatile boolean doSync -
scanZeroLengthFiles
protected boolean scanZeroLengthFiles
-
-
Constructor Details
-
FileSystemStore
public FileSystemStore(ObjectStoreEnvironmentBean objectStoreEnvironmentBean) throws ObjectStoreException - Throws:
ObjectStoreException
-
-
Method Details
-
getStoreName
- Returns:
- the "name" of the object store. Where in the hierarchy it appears, e.g., /ObjectStore/MyName/...
-
read_committed
Description copied from interface:ParticipantStore
Read the object's committed state.- Parameters:
storeUid
- The object to work on.tName
- The type of the object to work on.- Returns:
- the state of the object.
- Throws:
ObjectStoreException
-
read_uncommitted
Description copied from interface:ParticipantStore
Read the object's shadowed state.- Parameters:
storeUid
- The object to work on.tName
- The type of the object to work on.- Returns:
- the state of the object.
- Throws:
ObjectStoreException
-
remove_committed
Description copied from interface:TxLog
Remove the object's committed state.- Parameters:
storeUid
- The object to work on.tName
- The type of the object to work on.- Returns:
true
if no errors occurred,false
otherwise.- Throws:
ObjectStoreException
-
remove_uncommitted
Description copied from interface:ParticipantStore
Remove the object's uncommitted state.- Parameters:
storeUid
- The object to work on.tName
- The type of the object to work on.- Returns:
true
if no errors occurred,false
otherwise.- Throws:
ObjectStoreException
-
write_committed
public boolean write_committed(Uid storeUid, String tName, OutputObjectState state) throws ObjectStoreException Description copied from interface:TxLog
Write a new copy of the object's committed state.- Parameters:
storeUid
- The object to work on.tName
- The type of the object to work on.state
- The state to write.- Returns:
true
if no errors occurred,false
otherwise.- Throws:
ObjectStoreException
-
write_uncommitted
public boolean write_uncommitted(Uid storeUid, String tName, OutputObjectState state) throws ObjectStoreException Description copied from interface:ParticipantStore
Write a copy of the object's uncommitted state.- Parameters:
storeUid
- The object to work on.tName
- The type of the object to work on.state
- The state to write.- Returns:
true
if no errors occurred,false
otherwise.- Throws:
ObjectStoreException
-
allObjUids
public boolean allObjUids(String tName, InputObjectState state, int match) throws ObjectStoreException Given a type name initialise thestate
to contains all of the Uids of objects of that type- Parameters:
tName
- The type to scan for.state
- The object state in which to store the Uidsmatch
- The file type to look for (e.g., committed, shadowed). [StateStatus] Note: m=OS_UNKNOWN matches any state.- Returns:
true
if no errors occurred,false
otherwise.- Throws:
ObjectStoreException
-
allTypes
Description copied from interface:RecoveryStore
Obtain all types of objects stored in the object store.- Parameters:
foundTypes
- The state in which to store the types.- Returns:
true
if no errors occurred,false
otherwise.- Throws:
ObjectStoreException
-
read_state
- Throws:
ObjectStoreException
-
remove_state
- Throws:
ObjectStoreException
-
write_state
protected abstract boolean write_state(Uid u, String tn, OutputObjectState buff, int s) throws ObjectStoreException - Throws:
ObjectStoreException
-
synchronousWrites
protected final boolean synchronousWrites()Are synchronous write enabled? -
lock
Lock the file in the object store. -
unlock
Unlock the file in the object store. -
closeAndUnlock
Unlock and close the file. Note that if the unlock fails we set the return value to false to indicate an error but rely on the close to really do the unlock. -
openAndLock
- Throws:
ObjectStoreException
-
renameFromTo
-
renameFromToInternal
-
allTypes
- Throws:
ObjectStoreException
-
genPathName
- Returns:
- the file name for the state of the object identified by the Uid and TypeName. If the StateType argument is OS_SHADOW then the Uid part of the name includes # characters. The magic number SLOP below is the number of extra characters needed to make up the entire path.
- Throws:
ObjectStoreException
-
supressEntry
Description copied from class:ObjectStore
Suppress directories of the specified type from allTypes etc?- Specified by:
supressEntry
in classObjectStore
-
truncate
-
createHierarchy
Attempt to build up the object store in the file system dynamically. This creates directories as required as new types are added to the store. Note that we made sure the root object store was created and writable at construction time. WARNING: on a multi-processor box it is possible that multiple threads may try to create the same hierarchy at the same time. What will tend to happen is that one thread will succeed and the other(s) will fail. However, if a failed thread just assumes that the directory is being created by another thread, then we're in trouble, because although this may be the case, the directory structure may not have actually been created - it may still be in the process of being created. So, we have to err on the side of caution and try to create the directory a few times. (This can happen across processes too.)- Throws:
ObjectStoreException
-
exists
If this object store implementation is exclusively working on a set of object states, then this method will check a file cache first. Otherwise, we must go back to the file system each time to check the status of the file. If we add a FileDescriptor cache a la the C++ version then we would be able to get rid of the state cache and simply check to see if we had a fd for it. -
addToCache
-
removeFromCache
-
removeFromCache
Print a warning if the file to be removed is not in the cache.- Since:
- 2.1.1.
-