Package org.apache.openjpa.slice
Class DistributedBrokerImpl
- java.lang.Object
-
- org.apache.openjpa.kernel.BrokerImpl
-
- org.apache.openjpa.kernel.FinalizingBrokerImpl
-
- org.apache.openjpa.slice.DistributedBrokerImpl
-
- All Implemented Interfaces:
jakarta.transaction.Synchronization
,java.io.Serializable
,java.lang.Cloneable
,CallbackModes
,AutoClear
,AutoDetach
,Broker
,ConnectionRetainModes
,DetachState
,FindCallbacks
,LockLevels
,RestoreState
,StoreContext
,Closeable
,DistributedBroker
public class DistributedBrokerImpl extends FinalizingBrokerImpl implements DistributedBroker
A specialized Broker to associate slice identifiers with the StateManagers as they are persisted in a cascade. This intervention helps the user to define distribution policy only for root instances i.e. the instances that are explicit argument to persist() call. The cascaded instances are assigned the same slice to honor collocation constraint.- Author:
- Pinaki Poddar
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.openjpa.kernel.BrokerImpl
BrokerImpl.StateManagerId
-
-
Field Summary
-
Fields inherited from class org.apache.openjpa.kernel.BrokerImpl
FLUSH_COMMIT, FLUSH_INC, FLUSH_LOGICAL, FLUSH_ROLLBACK
-
Fields inherited from interface org.apache.openjpa.kernel.AutoClear
CLEAR_ALL, CLEAR_DATASTORE
-
Fields inherited from interface org.apache.openjpa.kernel.AutoDetach
DETACH_CLOSE, DETACH_COMMIT, DETACH_NONE, DETACH_NONTXREAD, DETACH_ROLLBACK, names, values
-
Fields inherited from interface org.apache.openjpa.event.CallbackModes
CALLBACK_FAIL_FAST, CALLBACK_IGNORE, CALLBACK_LOG, CALLBACK_RETHROW, CALLBACK_ROLLBACK
-
Fields inherited from interface org.apache.openjpa.kernel.ConnectionRetainModes
CONN_RETAIN_ALWAYS, CONN_RETAIN_DEMAND, CONN_RETAIN_TRANS
-
Fields inherited from interface org.apache.openjpa.kernel.DetachState
DETACH_ALL, DETACH_FETCH_GROUPS, DETACH_FGS, DETACH_LOADED
-
Fields inherited from interface org.apache.openjpa.kernel.LockLevels
LOCK_NONE, LOCK_READ, LOCK_WRITE
-
Fields inherited from interface org.apache.openjpa.kernel.RestoreState
RESTORE_ALL, RESTORE_IMMUTABLE, RESTORE_NONE
-
Fields inherited from interface org.apache.openjpa.kernel.StoreContext
EXCLUDE_ALL, OID_ALLOW_NEW, OID_COPY, OID_NODELETED, OID_NOVALIDATE
-
-
Constructor Summary
Constructors Constructor Description DistributedBrokerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
beginStore()
A virtual datastore need not be opened.boolean
endOperation()
Mark the operation over.protected void
flush(int reason)
Flush the transactional state to the data store.DistributedConfiguration
getConfiguration()
Return the configuration associated with this context.DistributedStoreManager
getDistributedStoreManager()
Gets the distributed store manager used by this receiver.TargetFetchConfiguration
getFetchConfiguration()
Return the (mutable) fetch configuration for loading objects from this context.void
lock()
Always uses lock irrespective of super's multi-threaded settings.protected QueryImpl
newQueryImpl(java.lang.String lang, StoreQuery sq)
Create a new query.OpenJPAStateManager
persist(java.lang.Object pc, java.lang.Object id, boolean explicit, OpCallbacks call)
Assigns slice identifier to the resultant StateManager as initialized by the super class implementation.java.lang.Object
processArgument(java.lang.Object oid)
Overrides to target specific slices for find() calls.protected void
setStateManager(java.lang.Object id, StateManagerImpl sm, int status)
Set the cached StateManager for the instance that had the given oid.void
unlock()
Releases the internal lock.-
Methods inherited from class org.apache.openjpa.kernel.FinalizingBrokerImpl
finalize
-
Methods inherited from class org.apache.openjpa.kernel.BrokerImpl
addLifecycleListener, addTransactionListener, afterCompletion, assertActiveTransaction, assertNontransactionalRead, assertOpen, assertPersistenceCapable, assertWriteOperation, assignObjectId, attach, attachAll, beforeCompletion, begin, beginOperation, cancelAll, checkForDuplicateId, clearStatusFlag, clone, close, commit, commitAndResume, delete, deleteAll, detach, detachAll, detachAll, detachAll, dirtyType, embed, endTransaction, evict, evictAll, evictAll, evictAll, extentIterator, find, find, find, findAll, findAll, findAll, findCached, flush, free, getAllowReferenceToSiblingContext, getAutoClear, getAutoDetach, getBroker, getBrokerFactory, getCacheFinderQuery, getCachePreparedQuery, getClassLoader, getConnection, getConnectionFactory, getConnectionFactory2, getConnectionFactory2Name, getConnectionFactoryName, getConnectionPassword, getConnectionRetainMode, getConnectionUserName, getDeletedTypes, getDetachState, getDirtyObjects, getDirtyStates, getEvictFromDataCache, getIdentitySequence, getIgnoreChanges, getInverseManager, getLifecycleEventManager, getLifecycleListenerCallbackMode, getLockLevel, getLockManager, getManagedObjects, getManagedRuntime, getManagedStates, getMultithreaded, getNontransactionalRead, getNontransactionalWrite, getObjectId, getObjectIdType, getOperatingSet, getOptimistic, getOrderDirtyObjects, getPendingTransactionalObjects, getPendingTransactionalStates, getPersistedTypes, getPopulateDataCache, getPostLoadOnMerge, getPrintParameters, getProperties, getRestoreState, getRetainState, getRollbackCause, getRollbackOnly, getStateManager, getStateManagerImpl, getStateManagerImplById, getStoreManager, getSupportedProperties, getSuppressBatchOLELogging, getSynchronization, getSyncWithManagedTransactions, getTransactionalObjects, getTransactionalStates, getTransactionListenerCallbackMode, getTransactionListeners, getUpdatedTypes, getUserObject, getValueSequence, getVersion, hasConnection, initialize, initialize, initialize, isActive, isCached, isClosed, isCloseInvoked, isDeleted, isDetached, isDetached, isDetachedNew, isDirty, isFlushing, isFromWriteBehindCallback, isLoading, isManaged, isNew, isPersistent, isStoreActive, isTrackChangesByType, isTransactional, lock, lock, lockAll, lockAll, newExtent, newInstance, newManagedObjectCache, newObjectId, newQuery, newQuery, newStateManagerImpl, nontransactional, nontransactionalAll, persist, persist, persist, persist, persistAll, persistAll, popFetchConfiguration, preFlush, processReturn, pushFetchConfiguration, pushFetchConfiguration, putUserObject, refresh, refreshAll, refreshInternal, refreshInternal, release, releaseAll, releaseSavepoint, releaseSavepoint, removeLifecycleListener, removeTransactionListener, retrieve, retrieveAll, rollback, rollbackAndResume, rollbackToSavepoint, rollbackToSavepoint, setAllowReferenceToSiblingContext, setAuthentication, setAutoClear, setAutoDetach, setAutoDetach, setCacheFinderQuery, setCachePreparedQuery, setConnectionFactory2Name, setConnectionFactoryName, setDetachedNew, setDetachState, setEvictFromDataCache, setIgnoreChanges, setImplicitBehavior, setLifecycleListenerCallbackMode, setMultithreaded, setNontransactionalRead, setNontransactionalWrite, setOptimistic, setOrderDirtyObjects, setPopulateDataCache, setPostLoadOnMerge, setRestoreState, setRetainState, setRollbackOnly, setRollbackOnly, setSavepoint, setStatusFlag, setSuppressBatchOLELogging, setSynchronization, setSyncWithManagedTransactions, setTrackChangesByType, setTransactionListenerCallbackMode, syncWithManagedTransaction, transactional, transactionalAll, validateChanges
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.openjpa.kernel.Broker
addLifecycleListener, addTransactionListener, assertActiveTransaction, assertNontransactionalRead, assertOpen, assertWriteOperation, attach, attachAll, begin, beginOperation, cancelAll, close, commit, commitAndResume, delete, deleteAll, detach, detachAll, detachAll, detachAll, dirtyType, evict, evictAll, evictAll, evictAll, flush, getAutoClear, getAutoDetach, getBrokerFactory, getCachePreparedQuery, getConnectionRetainMode, getEvictFromDataCache, getIdentitySequence, getIgnoreChanges, getInverseManager, getLifecycleEventManager, getLifecycleListenerCallbackMode, getManagedRuntime, getMultithreaded, getNontransactionalRead, getNontransactionalWrite, getOptimistic, getProperties, getRestoreState, getRetainState, getRollbackCause, getRollbackOnly, getSupportedProperties, getSyncWithManagedTransactions, getTransactionListenerCallbackMode, getTransactionListeners, getUserObject, getValueSequence, isClosed, isCloseInvoked, isDetached, isDetachedNew, lock, lock, lockAll, lockAll, newExtent, newInstance, newQuery, newQuery, persist, persist, persistAll, preFlush, putUserObject, refresh, refreshAll, release, releaseAll, releaseSavepoint, releaseSavepoint, removeLifecycleListener, removeTransactionListener, rollback, rollbackAndResume, rollbackToSavepoint, rollbackToSavepoint, setAutoClear, setAutoDetach, setAutoDetach, setCachePreparedQuery, setDetachedNew, setEvictFromDataCache, setIgnoreChanges, setImplicitBehavior, setLifecycleListenerCallbackMode, setMultithreaded, setNontransactionalRead, setNontransactionalWrite, setOptimistic, setRestoreState, setRetainState, setRollbackOnly, setRollbackOnly, setSavepoint, setSyncWithManagedTransactions, setTransactionListenerCallbackMode, syncWithManagedTransaction, validateChanges
-
Methods inherited from interface org.apache.openjpa.kernel.StoreContext
embed, extentIterator, find, find, findAll, findAll, findCached, getAllowReferenceToSiblingContext, getBroker, getClassLoader, getConnection, getConnectionFactory, getConnectionFactory2, getConnectionFactory2Name, getConnectionFactoryName, getConnectionPassword, getConnectionUserName, getDeletedTypes, getDetachState, getDirtyObjects, getLockLevel, getLockManager, getManagedObjects, getObjectId, getObjectIdType, getOrderDirtyObjects, getPendingTransactionalObjects, getPersistedTypes, getPopulateDataCache, getPostLoadOnMerge, getStateManager, getStoreManager, getTransactionalObjects, getUpdatedTypes, getVersion, hasConnection, isActive, isCached, isDeleted, isDirty, isManaged, isNew, isPersistent, isStoreActive, isTrackChangesByType, isTransactional, newObjectId, nontransactional, nontransactionalAll, popFetchConfiguration, pushFetchConfiguration, pushFetchConfiguration, retrieve, retrieveAll, setAllowReferenceToSiblingContext, setConnectionFactory2Name, setConnectionFactoryName, setDetachState, setOrderDirtyObjects, setPopulateDataCache, setPostLoadOnMerge, setTrackChangesByType, transactional, transactionalAll
-
-
-
-
Method Detail
-
getConfiguration
public DistributedConfiguration getConfiguration()
Description copied from interface:StoreContext
Return the configuration associated with this context.- Specified by:
getConfiguration
in interfaceStoreContext
- Overrides:
getConfiguration
in classBrokerImpl
-
getDistributedStoreManager
public DistributedStoreManager getDistributedStoreManager()
Description copied from interface:DistributedBroker
Gets the distributed store manager used by this receiver.- Specified by:
getDistributedStoreManager
in interfaceDistributedBroker
-
getFetchConfiguration
public TargetFetchConfiguration getFetchConfiguration()
Description copied from interface:StoreContext
Return the (mutable) fetch configuration for loading objects from this context.- Specified by:
getFetchConfiguration
in interfaceDistributedBroker
- Specified by:
getFetchConfiguration
in interfaceStoreContext
- Overrides:
getFetchConfiguration
in classBrokerImpl
-
persist
public OpenJPAStateManager persist(java.lang.Object pc, java.lang.Object id, boolean explicit, OpCallbacks call)
Assigns slice identifier to the resultant StateManager as initialized by the super class implementation. The slice identifier is decided byDistributionPolicy
for givenpc
if it is a root instance i.e. the argument of the user application's persist() call. The cascaded instances are detected by non-empty status of the current operating set. The slice is assigned only if a StateManager has never been assigned before.- Overrides:
persist
in classBrokerImpl
-
setStateManager
protected void setStateManager(java.lang.Object id, StateManagerImpl sm, int status)
Description copied from class:BrokerImpl
Set the cached StateManager for the instance that had the given oid. This method must not be called multiple times for new instances.- Overrides:
setStateManager
in classBrokerImpl
- Parameters:
id
- the id previously used by the instancesm
- the state manager for the instance; if the state manager is transient, we'll stop managing the instance; if it has updated its oid, we'll re-cache under the new oidstatus
- one of our STATUS constants describing why we're setting the state manager
-
endOperation
public boolean endOperation()
Description copied from class:BrokerImpl
Mark the operation over. If outermost caller of stack, returns true and will detach managed instances if necessary.- Specified by:
endOperation
in interfaceBroker
- Overrides:
endOperation
in classBrokerImpl
- Returns:
- whether this is the outermost operation on the stack
-
newQueryImpl
protected QueryImpl newQueryImpl(java.lang.String lang, StoreQuery sq)
Create a new query.- Overrides:
newQueryImpl
in classBrokerImpl
-
lock
public void lock()
Always uses lock irrespective of super's multi-threaded settings.- Specified by:
lock
in interfaceStoreContext
- Overrides:
lock
in classBrokerImpl
-
unlock
public void unlock()
Description copied from interface:StoreContext
Releases the internal lock.- Specified by:
unlock
in interfaceStoreContext
- Overrides:
unlock
in classBrokerImpl
-
beginStore
public void beginStore()
A virtual datastore need not be opened.- Specified by:
beginStore
in interfaceStoreContext
- Overrides:
beginStore
in classBrokerImpl
-
flush
protected void flush(int reason)
Description copied from class:BrokerImpl
Flush the transactional state to the data store. Subclasses that customize commit behavior should override this method. The method assumes that the persistence manager is locked, is not closed, and has an active transaction.- Overrides:
flush
in classBrokerImpl
- Parameters:
reason
- one ofBrokerImpl.FLUSH_INC
,BrokerImpl.FLUSH_COMMIT
,BrokerImpl.FLUSH_ROLLBACK
, orBrokerImpl.FLUSH_LOGICAL
-
processArgument
public java.lang.Object processArgument(java.lang.Object oid)
Overrides to target specific slices for find() calls.- Specified by:
processArgument
in interfaceFindCallbacks
- Overrides:
processArgument
in classBrokerImpl
- Returns:
- the id to look up, or null to ignore this argument
-
-