org.apache.openjpa.slice.jdbc
Class DistributedJDBCStoreManager
java.lang.Object
org.apache.openjpa.jdbc.kernel.JDBCStoreManager
org.apache.openjpa.slice.jdbc.DistributedJDBCStoreManager
- All Implemented Interfaces:
- JDBCStore, StoreManager, Closeable, DistributedStoreManager
class DistributedJDBCStoreManager
- extends JDBCStoreManager
- implements DistributedStoreManager
A Store manager for multiple physical databases referred as slice.
This receiver behaves like a Transaction Manager as it implements two-phase
commit protocol if all the component slices is XA-complaint. The actions are
delegated to the underlying slices. The actions are executed in parallel
threads whenever possible such as flushing or query.
- Author:
- Pinaki Poddar
|
Method Summary |
SliceStoreManager |
addSlice(Slice slice)
Adds the given slice with the given properties. |
boolean |
assignField(OpenJPAStateManager sm,
int field,
boolean preFlush)
|
boolean |
assignObjectId(OpenJPAStateManager sm,
boolean preFlush)
|
void |
beforeStateChange(OpenJPAStateManager sm,
PCState fromState,
PCState toState)
|
void |
beginOptimistic()
|
boolean |
cancelAll()
|
int |
compareVersion(OpenJPAStateManager sm,
Object v1,
Object v2)
|
protected JDBCStoreManager.RefCountConnection |
connectInternal()
|
Object |
copyDataStoreId(Object oid,
ClassMetaData meta)
|
ResultObjectProvider |
executeExtent(ClassMetaData meta,
boolean subclasses,
FetchConfiguration fetch)
|
boolean |
exists(OpenJPAStateManager sm,
Object edata)
|
protected SliceInfo |
findSliceNames(OpenJPAStateManager sm,
Object edata)
Decides the index of the StoreManager by first looking at the
implementation data. |
Collection |
flush(Collection sms)
Flush the given StateManagers after binning them to respective physical
slices. |
Object |
getClientConnection()
|
DistributedJDBCConfiguration |
getConfiguration()
|
Seq |
getDataStoreIdSequence(ClassMetaData forClass)
|
Class<?> |
getDataStoreIdType(ClassMetaData meta)
|
Class<?> |
getManagedType(Object oid)
|
SliceStoreManager |
getSlice(int i)
|
(package private) List<SliceStoreManager> |
getTargets(FetchConfiguration fetch)
Gets the list of slices mentioned as
hint of the given
fetch configuration. |
Seq |
getValueSequence(FieldMetaData forField)
|
boolean |
initialize(OpenJPAStateManager sm,
PCState state,
FetchConfiguration fetch,
Object edata)
|
boolean |
load(OpenJPAStateManager sm,
BitSet fields,
FetchConfiguration fetch,
int lockLevel,
Object edata)
|
Collection |
loadAll(Collection sms,
PCState state,
int load,
FetchConfiguration fetch,
Object edata)
|
Object |
newDataStoreId(Object oidVal,
ClassMetaData meta)
|
FetchConfiguration |
newFetchConfiguration()
|
StoreQuery |
newQuery(String language)
Construct a distributed query to be executed against all the slices. |
(package private) boolean |
occurs(OpenJPAStateManager sm,
Collection<org.apache.openjpa.slice.jdbc.DistributedJDBCStoreManager.StateManagerSet> reminder)
|
void |
setContext(StoreContext ctx)
Sets the context for this receiver and all its underlying slices. |
boolean |
syncVersion(OpenJPAStateManager sm,
Object edata)
|
| Methods inherited from class org.apache.openjpa.jdbc.kernel.JDBCStoreManager |
begin, close, commit, find, getConnection, getContext, getDataSource, getDBDictionary, getFetchConfiguration, getLockManager, getNewConnection, getSQLFactory, getType, getVersion, initializeState, isCached, isEmptyResult, load, loadSubclasses, newDataStoreId, releaseConnection, retainConnection, rollback, rollbackOptimistic, select, setContext, setMappedBy |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DistributedJDBCStoreManager
public DistributedJDBCStoreManager(DistributedJDBCConfiguration conf)
- Constructs a set of child StoreManagers each connected to a physical
DataSource.
The supplied configuration carries multiple URL for underlying physical
slices. The first slice is referred as master and is used to
get Sequence based entity identifiers.
getConfiguration
public DistributedJDBCConfiguration getConfiguration()
- Specified by:
getConfiguration in interface JDBCStore- Overrides:
getConfiguration in class JDBCStoreManager
getSlice
public SliceStoreManager getSlice(int i)
addSlice
public SliceStoreManager addSlice(Slice slice)
- Description copied from interface:
DistributedStoreManager
- Adds the given slice with the given properties. This newly added slice
will participate in the current and subsequent transaction.
- Specified by:
addSlice in interface DistributedStoreManager
- Returns:
- the store manager for the newly added slice.
- See Also:
DistributedBroker#addSlice(String, Map),
DistributedBrokerFactory.addSlice(String, Map)
findSliceNames
protected SliceInfo findSliceNames(OpenJPAStateManager sm,
Object edata)
- Decides the index of the StoreManager by first looking at the
implementation data. If no implementation data is found, then estimates
targets slices by using additional connection info. If no additional
connection info then calls back to user-defined policy.
assignField
public boolean assignField(OpenJPAStateManager sm,
int field,
boolean preFlush)
- Specified by:
assignField in interface StoreManager- Overrides:
assignField in class JDBCStoreManager
assignObjectId
public boolean assignObjectId(OpenJPAStateManager sm,
boolean preFlush)
- Specified by:
assignObjectId in interface StoreManager- Overrides:
assignObjectId in class JDBCStoreManager
beforeStateChange
public void beforeStateChange(OpenJPAStateManager sm,
PCState fromState,
PCState toState)
- Specified by:
beforeStateChange in interface StoreManager- Overrides:
beforeStateChange in class JDBCStoreManager
beginOptimistic
public void beginOptimistic()
- Specified by:
beginOptimistic in interface StoreManager- Overrides:
beginOptimistic in class JDBCStoreManager
cancelAll
public boolean cancelAll()
- Specified by:
cancelAll in interface StoreManager- Overrides:
cancelAll in class JDBCStoreManager
compareVersion
public int compareVersion(OpenJPAStateManager sm,
Object v1,
Object v2)
- Specified by:
compareVersion in interface StoreManager- Overrides:
compareVersion in class JDBCStoreManager
copyDataStoreId
public Object copyDataStoreId(Object oid,
ClassMetaData meta)
- Specified by:
copyDataStoreId in interface StoreManager- Overrides:
copyDataStoreId in class JDBCStoreManager
executeExtent
public ResultObjectProvider executeExtent(ClassMetaData meta,
boolean subclasses,
FetchConfiguration fetch)
- Specified by:
executeExtent in interface StoreManager- Overrides:
executeExtent in class JDBCStoreManager
exists
public boolean exists(OpenJPAStateManager sm,
Object edata)
- Specified by:
exists in interface StoreManager- Overrides:
exists in class JDBCStoreManager
flush
public Collection flush(Collection sms)
- Flush the given StateManagers after binning them to respective physical
slices.
- Specified by:
flush in interface StoreManager- Overrides:
flush in class JDBCStoreManager
occurs
boolean occurs(OpenJPAStateManager sm,
Collection<org.apache.openjpa.slice.jdbc.DistributedJDBCStoreManager.StateManagerSet> reminder)
getClientConnection
public Object getClientConnection()
- Specified by:
getClientConnection in interface StoreManager- Overrides:
getClientConnection in class JDBCStoreManager
getDataStoreIdSequence
public Seq getDataStoreIdSequence(ClassMetaData forClass)
- Specified by:
getDataStoreIdSequence in interface StoreManager- Overrides:
getDataStoreIdSequence in class JDBCStoreManager
getDataStoreIdType
public Class<?> getDataStoreIdType(ClassMetaData meta)
- Specified by:
getDataStoreIdType in interface StoreManager- Overrides:
getDataStoreIdType in class JDBCStoreManager
getManagedType
public Class<?> getManagedType(Object oid)
- Specified by:
getManagedType in interface StoreManager- Overrides:
getManagedType in class JDBCStoreManager
getValueSequence
public Seq getValueSequence(FieldMetaData forField)
- Specified by:
getValueSequence in interface StoreManager- Overrides:
getValueSequence in class JDBCStoreManager
initialize
public boolean initialize(OpenJPAStateManager sm,
PCState state,
FetchConfiguration fetch,
Object edata)
- Specified by:
initialize in interface StoreManager- Overrides:
initialize in class JDBCStoreManager
load
public boolean load(OpenJPAStateManager sm,
BitSet fields,
FetchConfiguration fetch,
int lockLevel,
Object edata)
- Specified by:
load in interface StoreManager- Overrides:
load in class JDBCStoreManager
loadAll
public Collection loadAll(Collection sms,
PCState state,
int load,
FetchConfiguration fetch,
Object edata)
- Specified by:
loadAll in interface StoreManager- Overrides:
loadAll in class JDBCStoreManager
newDataStoreId
public Object newDataStoreId(Object oidVal,
ClassMetaData meta)
- Specified by:
newDataStoreId in interface StoreManager- Overrides:
newDataStoreId in class JDBCStoreManager
newQuery
public StoreQuery newQuery(String language)
- Construct a distributed query to be executed against all the slices.
- Specified by:
newQuery in interface StoreManager- Overrides:
newQuery in class JDBCStoreManager
newFetchConfiguration
public FetchConfiguration newFetchConfiguration()
- Specified by:
newFetchConfiguration in interface StoreManager- Overrides:
newFetchConfiguration in class JDBCStoreManager
setContext
public void setContext(StoreContext ctx)
- Sets the context for this receiver and all its underlying slices.
- Specified by:
setContext in interface StoreManager- Overrides:
setContext in class JDBCStoreManager
syncVersion
public boolean syncVersion(OpenJPAStateManager sm,
Object edata)
- Specified by:
syncVersion in interface StoreManager- Overrides:
syncVersion in class JDBCStoreManager
connectInternal
protected JDBCStoreManager.RefCountConnection connectInternal()
throws SQLException
- Overrides:
connectInternal in class JDBCStoreManager
- Throws:
SQLException
getTargets
List<SliceStoreManager> getTargets(FetchConfiguration fetch)
- Gets the list of slices mentioned as
hint of the given
fetch configuration.
- Returns:
- all active slices if a) the hint is not specified or b) a null
value or c) a non-String or d) matches no active slice.
Copyright © 2006-2013 Apache Software Foundation. All Rights Reserved.