|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.sgs.impl.service.data.store.AbstractDataStore
com.sun.sgs.impl.service.data.store.DataStoreImpl
public class DataStoreImpl
Provides an implementation of DataStore based on the database
interface layer defined in the com.sun.sgs.service.store.db package.
Note that, although this class provides support for the TransactionParticipant.prepare method, it
does not provide facilities for resolving prepared transactions after a
crash. Callers can work around this limitation by insuring that the
transaction implementation calls TransactionParticipant.prepareAndCommit to commit transactions on this
class. The current transaction implementation calls
prepareAndCommit on durable participants, such as this class,
so the inability to resolve prepared transactions should have no effect at
present.
The constructor supports these public
properties.
The constructor also passes the properties to the constructor of
the DbEnvironment class chosen at runtime with the
com.sun.sgs.impl.service.data.store.db.environment.class property.
Each implementation of DbEnvironment may support additional
properties.
This class uses the Logger named
com.sun.sgs.impl.service.data.store.DataStoreImpl to log
information at the following logging levels:
SEVERE - Initialization failures
CONFIG - Constructor properties, data store
headers
FINE - Allocating blocks of object IDs
FINER - Transaction operations
FINEST - Name and object operations
In addition, name and object operations that throw TransactionAbortedException will log the failure to the Logger
named com.sun.sgs.impl.service.data.store.DataStoreImpl.abort, to
make it easier to debug concurrency conflicts.
| Nested Class Summary | |
|---|---|
protected static interface |
DataStoreImpl.TxnInfoTable<T>
Records information about all active transactions. |
| Field Summary | |
|---|---|
static String |
DEFAULT_ENVIRONMENT_CLASS
The default environment class. |
static String |
DIRECTORY_PROPERTY
The property that specifies the directory in which to store database files. |
static String |
ENVIRONMENT_CLASS_PROPERTY
The property that specifies the environment class. |
(package private) com.sun.sgs.impl.service.data.store.DataStoreImpl.FreeObjectIds |
freeObjectIds
Information about free object IDs. |
(package private) DbDatabase |
oidsDb
The database that maps object IDs to object bytes. |
(package private) boolean |
useAllocationBlockPlaceholders
Whether object allocations should create a placeholder at the end of each allocation block. |
| Fields inherited from class com.sun.sgs.impl.service.data.store.AbstractDataStore |
|---|
abortLogger, logger, nameAccesses, objectAccesses |
| Constructor Summary | |
|---|---|
DataStoreImpl(Properties properties,
ComponentRegistry systemRegistry,
TransactionProxy txnProxy)
Creates an instance of this class. |
|
| Method Summary | ||
|---|---|---|
protected void |
abortInternal(Transaction txn)
Performs the actual operation for abort. |
|
protected void |
commitInternal(Transaction txn)
Performs the actual operation for commit. |
|
protected long |
createObjectInternal(Transaction txn)
Performs the actual operation for createObject. |
|
protected BindingValue |
getBindingInternal(Transaction txn,
String name)
Performs the actual operation for getBinding. |
|
protected int |
getClassIdInternal(Transaction txn,
byte[] classInfo)
Performs the actual operation for getClassId. |
|
protected byte[] |
getClassInfoInternal(Transaction txn,
int classId)
Performs the actual operation for getClassInfo. |
|
protected long |
getLocalNodeIdInternal()
Performs the actual operation for getLocalNodeId. |
|
protected long |
getNextTxnId(int count,
long timeout)
Returns the next available transaction ID, and reserves the specified number of IDs. |
|
protected byte[] |
getObjectInternal(Transaction txn,
long oid,
boolean forUpdate)
Performs the actual operation for getObject. |
|
(package private) byte[] |
getObjectRaw(Transaction txn,
long oid)
Get raw data for the specified object ID. |
|
protected
|
getTxnInfoTable(Class<T> txnInfoType)
Returns the table that will be used to store transaction information. |
|
protected RuntimeException |
handleException(Transaction txn,
Level level,
RuntimeException e,
String operation)
Performs any operations needed when an exception is going to be thrown, as well as allowing the implementation to replace the exception with a different one. |
|
(package private) static boolean |
isPlaceholderValue(byte[] value)
Checks if an object value read from the database is from a placeholder, meaning there is no object present. |
|
protected void |
joinNewTransaction(Transaction txn)
Explicitly joins a new transaction. |
|
protected void |
markForUpdateInternal(Transaction txn,
long oid)
Performs the actual operation for markForUpdate. |
|
protected long |
newNodeId()
Returns a new node ID, for use with a newly started node. |
|
protected String |
nextBoundNameInternal(Transaction txn,
String name)
Performs the actual operation for nextBoundName. |
|
protected long |
nextObjectIdInternal(Transaction txn,
long oid)
Performs the actual operation for nextObjectId. |
|
(package private) long |
nextObjectIdRaw(Transaction txn,
long oid)
Gets the next object ID after the one specified, or -1 if there are no more objects. |
|
protected void |
prepareAndCommitInternal(Transaction txn)
Performs the actual operation for prepareAndCommit. |
|
protected boolean |
prepareInternal(Transaction txn)
Performs the actual operation for prepare. |
|
protected BindingValue |
removeBindingInternal(Transaction txn,
String name)
Performs the actual operation for removeBinding. |
|
protected void |
removeObjectInternal(Transaction txn,
long oid)
Performs the actual operation for removeObject. |
|
protected BindingValue |
setBindingInternal(Transaction txn,
String name,
long oid)
Performs the actual operation for setBinding. |
|
protected void |
setObjectInternal(Transaction txn,
long oid,
byte[] data)
Performs the actual operation for setObject. |
|
(package private) void |
setObjectRaw(Transaction txn,
long oid,
byte[] data)
Store raw data for the specified object ID. |
|
protected void |
setObjectsInternal(Transaction txn,
long[] oids,
byte[][] dataArray)
Performs the actual operation for setObjects. |
|
protected void |
shutdownInternal()
Performs the actual operation for shutdown. |
|
String |
toString()
Returns a string representation of this object. |
|
| Methods inherited from class com.sun.sgs.impl.service.data.store.AbstractDataStore |
|---|
abort, checkOid, commit, createObject, getBinding, getClassId, getClassInfo, getLocalNodeId, getNameForAccess, getObject, getTypeName, markForUpdate, nextBoundName, nextObjectId, prepare, prepareAndCommit, ready, removeBinding, removeObject, reportNameAccess, reportObjectAccess, setBinding, setBindingDescription, setObject, setObjectDescription, setObjects, shutdown |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String DIRECTORY_PROPERTY
public static final String ENVIRONMENT_CLASS_PROPERTY
public static final String DEFAULT_ENVIRONMENT_CLASS
final DbDatabase oidsDb
final boolean useAllocationBlockPlaceholders
final com.sun.sgs.impl.service.data.store.DataStoreImpl.FreeObjectIds freeObjectIds
| Constructor Detail |
|---|
public DataStoreImpl(Properties properties,
ComponentRegistry systemRegistry,
TransactionProxy txnProxy)
properties - the properties for configuring this instancesystemRegistry - the registry of available system componentstxnProxy - the transaction proxy
DataStoreException - if there is a problem with the database
IllegalArgumentException - if any of the properties are invalid,
as specified in the class documentation| Method Detail |
|---|
protected long getLocalNodeIdInternal()
getLocalNodeId.
getLocalNodeIdInternal in class AbstractDataStoreprotected long createObjectInternal(Transaction txn)
createObject.
createObjectInternal in class AbstractDataStoretxn - the transaction under which the operation should take place
protected void markForUpdateInternal(Transaction txn,
long oid)
markForUpdate.
markForUpdateInternal in class AbstractDataStoretxn - the transaction under which the operation should take placeoid - the object ID
protected byte[] getObjectInternal(Transaction txn,
long oid,
boolean forUpdate)
getObject.
getObjectInternal in class AbstractDataStoretxn - the transaction under which the operation should take placeoid - the object IDforUpdate - whether the caller intends to modify the object
protected void setObjectInternal(Transaction txn,
long oid,
byte[] data)
setObject.
setObjectInternal in class AbstractDataStoretxn - the transaction under which the operation should take placeoid - the object IDdata - the data
protected void setObjectsInternal(Transaction txn,
long[] oids,
byte[][] dataArray)
setObjects.
setObjectsInternal in class AbstractDataStoretxn - the transaction under which the operation should take placeoids - the object IDsdataArray - the associated data values
protected void removeObjectInternal(Transaction txn,
long oid)
removeObject.
removeObjectInternal in class AbstractDataStoretxn - the transaction under which the operation should take placeoid - the object ID
protected BindingValue getBindingInternal(Transaction txn,
String name)
getBinding. If
the name is bound, the return value contains the object ID that the name
is bound to and a next name of null. If the name is not bound,
the return value contains an object ID of -1 and the next name
found, which may be null.
getBindingInternal in class AbstractDataStoretxn - the transaction under which the operation should take placename - the name
protected BindingValue setBindingInternal(Transaction txn,
String name,
long oid)
setBinding. If
the name is bound, the return value contains an arbitrary non-negative
object ID and a next name of null. If the name is not bound,
the return value contains an object ID of -1 and the next name
found, which may be null.
setBindingInternal in class AbstractDataStoretxn - the transaction under which the operation should take placename - the nameoid - the object ID
protected BindingValue removeBindingInternal(Transaction txn,
String name)
removeBinding.
If the name is bound, the return value contains an arbitrary
non-negative object ID, otherwise it contains -1. In all cases,
the return value contains the next name found, which may be null.
removeBindingInternal in class AbstractDataStoretxn - the transaction under which the operation should take placename - the name
protected String nextBoundNameInternal(Transaction txn,
String name)
nextBoundName. This implementation uses a single cursor, so it provides better performance when used to iterate over names in order.
nextBoundNameInternal in class AbstractDataStoretxn - the transaction under which the operation should take placename - the name to search after, or null to start
at the beginning
name, or
null if there are no more bound namesprotected void shutdownInternal()
shutdown.
shutdownInternal in class AbstractDataStore
protected int getClassIdInternal(Transaction txn,
byte[] classInfo)
getClassId.
getClassIdInternal in class AbstractDataStoretxn - the transaction under which the operation should take placeclassInfo - the class information
protected byte[] getClassInfoInternal(Transaction txn,
int classId)
throws ClassInfoNotFoundException
getClassInfo.
getClassInfoInternal in class AbstractDataStoretxn - the transaction under which the operation should take placeclassId - the class ID
ClassInfoNotFoundException - if the ID is not found
protected long nextObjectIdInternal(Transaction txn,
long oid)
nextObjectId.
nextObjectIdInternal in class AbstractDataStoretxn - the transaction under which the operation should take placeoid - the identifier of the object to search after, or
-1 to request the first object
oid, or -1 if there are no more
objectsprotected boolean prepareInternal(Transaction txn)
prepare.
prepareInternal in class AbstractDataStoretxn - the transaction
true if this participant is read-only, otherwise falseprotected void commitInternal(Transaction txn)
commit.
commitInternal in class AbstractDataStoretxn - the transactionprotected void prepareAndCommitInternal(Transaction txn)
prepareAndCommit.
prepareAndCommitInternal in class AbstractDataStoretxn - the transactionprotected void abortInternal(Transaction txn)
abort.
abortInternal in class AbstractDataStoretxn - the transaction
protected RuntimeException handleException(Transaction txn,
Level level,
RuntimeException e,
String operation)
This implementation does logging, and aborts the transaction if it is
not null and the exception is a TransactionAbortedException.
This implementation converts DbDatabaseException to DataStoreException.
handleException in class AbstractDataStoretxn - the transaction or nulllevel - the logging levele - the exceptionoperation - a description of the operation being performed
public String toString()
toString in class Objectprotected <T> DataStoreImpl.TxnInfoTable<T> getTxnInfoTable(Class<T> txnInfoType)
T - the type of the information to be storedtxnInfoType - a class representing the type of the information to
be stored
protected long getNextTxnId(int count,
long timeout)
count - the number of IDs to reservetimeout - the transaction timeout in milliseconds
protected void joinNewTransaction(Transaction txn)
txn - the transaction to joinprotected long newNodeId()
static boolean isPlaceholderValue(byte[] value)
void setObjectRaw(Transaction txn,
long oid,
byte[] data)
txn - the transaction under which the operation should take placeoid - the object IDdata - the data
byte[] getObjectRaw(Transaction txn,
long oid)
txn - the transaction under which the operation should take placeoid - the object ID
long nextObjectIdRaw(Transaction txn,
long oid)
txn - the transaction under which the operation should take placeoid - the object ID or -1
|
RedDwarf, Version 0.10.1 2010-03-14 10:56:12 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||