org.apache.openjpa.slice.jdbc
Class DistributedStoreManager
java.lang.Object
org.apache.openjpa.jdbc.kernel.JDBCStoreManager
org.apache.openjpa.slice.jdbc.DistributedStoreManager
- All Implemented Interfaces:
- JDBCStore, StoreManager, Closeable
class DistributedStoreManager
- extends JDBCStoreManager
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 |
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 String |
findSliceName(OpenJPAStateManager sm,
Object info)
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)
|
(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)
|
(package private) void |
log(String s)
|
Object |
newDataStoreId(Object oidVal,
ClassMetaData meta)
|
FetchConfiguration |
newFetchConfiguration()
|
StoreQuery |
newQuery(String language)
Construct a distributed query to be executed against all the slices. |
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 |
addToSqlCache, begin, close, commit, createSQLCache, find, getCacheMapFromQuerySQLCache, getConnection, getContext, getDataSource, getDBDictionary, getFetchConfiguration, getLockManager, getQuerySQLCache, getSQLFactory, getType, getVersion, initializeState, isEmptyResult, isQuerySQLCacheOn, load, loadSubclasses, newDataStoreId, newSelect, 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 |
DistributedStoreManager
public DistributedStoreManager(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
findSliceName
protected String findSliceName(OpenJPAStateManager sm,
Object info)
- Decides the index of the StoreManager by first looking at the
implementation data. If not found then
DistributionPolicy determines the target store for new instances and
additional connection info is used to estimate for the existing
instances.
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
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
newFetchConfiguration
public FetchConfiguration newFetchConfiguration()
- Specified by:
newFetchConfiguration in interface StoreManager- Overrides:
newFetchConfiguration 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
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.
log
void log(String s)
Copyright © 2006-2013 Apache Software Foundation. All Rights Reserved.