Class DerivedDataContextManager
java.lang.Object
com._1c.g5.v8.internal.derived.context.DerivedDataContextManager
- All Implemented Interfaces:
IContextTransactionManager
,IDerivedDataContextManager
public class DerivedDataContextManager
extends Object
implements IDerivedDataContextManager, IContextTransactionManager
Implementation of the
IDerivedDataContextManager
.-
Constructor Summary
ConstructorsConstructorDescriptionDerivedDataContextManager
(IObjectContextFactory contextFactory, AsyncPipelineModalModeAccessor modalModelAccessor, IDerivedDataInfoRepository derivedDataInfoRepository, DerivedDataTaskScheduler scheduler, Collection<String> segments, Set<String> filteredSegments, Collection<IContextDeactivationController> deactivationControllers, IAsyncComputationExecutionContext executionContext, int storeSegmentCount, Function<Long, Integer> longSegmentHasher, Function<String, Integer> stringSegmentHasher) Constructs an instance -
Method Summary
Modifier and TypeMethodDescriptionvoid
Clears all global contexts in case if no unfinished DD computations/tasks are available.void
closeSession
(IContextCollectingSession session) Finishes processing of the session, removing all effective context locks.void
Commits the transaction.void
confirmOperationComputation
(OperationContext operationContext, Object transactionHandle) Confirms the computation of the given operationcreateContextCollectingSession
(Object computationCause) Create synchronous DD context collecting session.createContextCollectingSession
(Object computationCause, boolean trackWaitingScope) Create synchronous DD context collecting session.Creates a special context loading session that is used to process unfinished contexts during the start of EDT and schedule them to the DD pipelinevoid
deactivateContexts
(String segmentId) Perform mass deactivation of contextsgetExistingObjectContext
(Object objectId, String segmentId, Object computationCause, Object transactionHandle) Returns the existing object context.getObjectContext
(long bmObjectId, org.eclipse.emf.ecore.EClass eClass, String segmentId, Object object, Object transactionHandle) Gathers object context for the given object (if any).getObjectContext
(IBmObject bmObject, String segmentId, Object computationCause, Object transactionHandle) Gathers object context for the given object (if any).getObjectContext
(Object objectId, org.eclipse.emf.ecore.EClass eClass, String segmentId, Object computationCause, Object transactionHandle) Gathers object context for the given object (if any).boolean
isContextExists
(IBmObject bmObject, String segmentId) Checks if the DD context exists(supported) for the given object and segmentboolean
isContextExists
(org.eclipse.emf.ecore.EClass topObjectEClass, long topObjectId, String segmentId) Checks if the DD context exists(supported) for the given object and segmentvoid
markAsComputed
(IObjectDerivedDataContext context, Object transactionHandle) Marks the context as a computed.void
markAsFailed
(IObjectDerivedDataContext context, Object transactionHandle) Marks a specified context as failed to compute.popChangedContexts
(Object computationCause) Gets updated contexts and removes them from the queuevoid
Processes accumulated contexts (if any), sending corresponding DD context updates to the corresponding consumer (pipeline).void
Registers the context update listener.registerTransaction
(boolean computation, boolean forcedUpdate, Object computationCause, boolean trackWaitingScope) Registers a transaction in the lock manager.void
Rolls the transaction back, cancelling all collected context changes.scheduleModalOperation
(Consumer<org.eclipse.core.runtime.IProgressMonitor> operation, String segmentId, IModalOperationController modalOperationController, Object transactionHandle) Schedules a new modal operationscheduleOperation
(Consumer<org.eclipse.core.runtime.IProgressMonitor> operation, OperationType operationType, boolean important, String segmentId, Object transactionHandle) Schedules an operation context.void
scheduleOperationRemoval
(IObjectDerivedDataContext operationHandle, Object transactionHandle) Schedules the operation removalvoid
setScopeTrackerController
(IScopeTrackerController scopeTrackerController) Sets the external scope tracker controllervoid
Removes previously registered listener.boolean
waitAccumulatedContextProcessing
(long timeout) The caller of this method waits on this method until all accumulated yet not processed DD context updates are being processed.
-
Constructor Details
-
DerivedDataContextManager
public DerivedDataContextManager(IObjectContextFactory contextFactory, AsyncPipelineModalModeAccessor modalModelAccessor, IDerivedDataInfoRepository derivedDataInfoRepository, DerivedDataTaskScheduler scheduler, Collection<String> segments, Set<String> filteredSegments, Collection<IContextDeactivationController> deactivationControllers, IAsyncComputationExecutionContext executionContext, int storeSegmentCount, Function<Long, Integer> longSegmentHasher, Function<String, Integer> stringSegmentHasher) Constructs an instance- Parameters:
contextFactory
- The factory of async computation task contexts. May not benull
modalModelAccessor
- The modal mode accessor reference. May not benull
scheduler
- The derived data scheduler reference. May not benull
segments
- The collection of all available pipeline segments. May not benull
filteredSegments
- The set of filtered segments that must be ommited during the collecting. May not benull
deactivationControllers
- The collection ofIContextDeactivationController
. Cannot benull
executionContext
- The client-contributed implementation ofIAsyncComputationExecutionContext
. Cannot benull
-
-
Method Details
-
clearOnEmptyPipeline
public void clearOnEmptyPipeline()Description copied from interface:IDerivedDataContextManager
Clears all global contexts in case if no unfinished DD computations/tasks are available. Removes accumulation global contexts, etc.- Specified by:
clearOnEmptyPipeline
in interfaceIDerivedDataContextManager
-
closeSession
Description copied from interface:IDerivedDataContextManager
Finishes processing of the session, removing all effective context locks.- Specified by:
closeSession
in interfaceIDerivedDataContextManager
-
commit
Description copied from interface:IContextTransactionManager
Commits the transaction.- Specified by:
commit
in interfaceIContextTransactionManager
- Parameters:
transactionHandle
- The handle of the context manipulaton transaction. Cannot benull
.
-
confirmOperationComputation
public void confirmOperationComputation(OperationContext operationContext, Object transactionHandle) Description copied from interface:IContextTransactionManager
Confirms the computation of the given operation- Specified by:
confirmOperationComputation
in interfaceIContextTransactionManager
- Parameters:
operationContext
- The context of the operation. May not benull
transactionHandle
- The handle of the context manipulaton transaction. Cannot benull
.
-
deactivateContexts
Description copied from interface:IDerivedDataContextManager
Perform mass deactivation of contexts- Specified by:
deactivateContexts
in interfaceIDerivedDataContextManager
- Parameters:
segmentId
- Target segment of async. processing pipeline for the deactivation
-
createContextCollectingSession
Description copied from interface:IDerivedDataContextManager
Create synchronous DD context collecting session.- Specified by:
createContextCollectingSession
in interfaceIDerivedDataContextManager
- Parameters:
computationCause
- The cause of the computation (the context, usually a task, which requires sync. DD computation as a part of performed changes).- Returns:
- The corresponding DD context collecting session.
-
createContextLoadingSession
Description copied from interface:IDerivedDataContextManager
Creates a special context loading session that is used to process unfinished contexts during the start of EDT and schedule them to the DD pipeline- Specified by:
createContextLoadingSession
in interfaceIDerivedDataContextManager
- Returns:
- The loading session. Cannot be
null
-
createContextCollectingSession
public IContextCollectingSession createContextCollectingSession(Object computationCause, boolean trackWaitingScope) Description copied from interface:IDerivedDataContextManager
Create synchronous DD context collecting session.- Specified by:
createContextCollectingSession
in interfaceIDerivedDataContextManager
- Parameters:
computationCause
- The cause of the computation (the context, usually a task, which requires sync. DD computation as a part of performed changes).trackWaitingScope
- Enables tracking of implicit waiting context if true- Returns:
- The corresponding DD context collecting session.
-
getExistingObjectContext
public IObjectDerivedDataContext getExistingObjectContext(Object objectId, String segmentId, Object computationCause, Object transactionHandle) Description copied from interface:IContextTransactionManager
Returns the existing object context.- Specified by:
getExistingObjectContext
in interfaceIContextTransactionManager
- Parameters:
objectId
- Target object, cannot benull
.segmentId
- The identifier of the target DD segment, cannot benull
.computationCause
- The computation cause, cannot benull
.transactionHandle
- The handle of the context manipulaton transaction, cannot benull
.- Returns:
- The target context (if any available or possible for the object), never
null
.
-
getObjectContext
public IObjectDerivedDataContext getObjectContext(IBmObject bmObject, String segmentId, Object computationCause, Object transactionHandle) Description copied from interface:IContextTransactionManager
Gathers object context for the given object (if any).- Specified by:
getObjectContext
in interfaceIContextTransactionManager
- Parameters:
bmObject
- Target BM object. Cannot benull
.segmentId
- The identifier of the target DD segment. Cannot benull
.transactionHandle
- The handle of the context manipulaton transaction. Cannot benull
.- Returns:
- The target context (if any available or possible for the object).
-
getObjectContext
public IObjectDerivedDataContext getObjectContext(long bmObjectId, org.eclipse.emf.ecore.EClass eClass, String segmentId, Object object, Object transactionHandle) Description copied from interface:IContextTransactionManager
Gathers object context for the given object (if any).- Specified by:
getObjectContext
in interfaceIContextTransactionManager
- Parameters:
bmObjectId
- The identifier of the object to get the context for for.eClass
- TheEClass
of the object to get the context for. Cannot benull
segmentId
- The identifier of the target DD segment. Cannot benull
.object
- The object, cannot benull
.transactionHandle
- The handle of the context manipulaton transaction. Cannot benull
.- Returns:
- The target context (if any available or possible for the object).
-
getObjectContext
public IObjectDerivedDataContext getObjectContext(Object objectId, org.eclipse.emf.ecore.EClass eClass, String segmentId, Object computationCause, Object transactionHandle) Description copied from interface:IContextTransactionManager
Gathers object context for the given object (if any).- Specified by:
getObjectContext
in interfaceIContextTransactionManager
- Parameters:
objectId
- Target object, cannot benull
.eClass
- TheEClass
of the object, cannot benull
.segmentId
- The identifier of the target DD segment, cannot benull
.transactionHandle
- The handle of the context manipulaton transaction, cannot benull
.- Returns:
- The target context (if any available or possible for the object), never
null
.
-
isContextExists
public boolean isContextExists(org.eclipse.emf.ecore.EClass topObjectEClass, long topObjectId, String segmentId) Description copied from interface:IContextTransactionManager
Checks if the DD context exists(supported) for the given object and segment- Specified by:
isContextExists
in interfaceIContextTransactionManager
- Parameters:
topObjectEClass
- Top objectEClass
. May not benull
topObjectId
- Top object identifier. May not benull
segmentId
- The DD segment identifier. May not benull
- Returns:
- True if the context exists/may be created
-
isContextExists
Description copied from interface:IContextTransactionManager
Checks if the DD context exists(supported) for the given object and segment- Specified by:
isContextExists
in interfaceIContextTransactionManager
- Parameters:
bmObject
- The object to get the context for. May not benull
segmentId
- The DD segment identifier. May not benull
- Returns:
- True if the context exists/may be created
-
markAsComputed
Description copied from interface:IContextTransactionManager
Marks the context as a computed. Will be re-set on a commit.- Specified by:
markAsComputed
in interfaceIContextTransactionManager
- Parameters:
context
- Transaction context. Cannot benull
.transactionHandle
- The handle of the context manipulaton transaction. Cannot benull
.
-
markAsFailed
Description copied from interface:IContextTransactionManager
Marks a specified context as failed to compute.- Specified by:
markAsFailed
in interfaceIContextTransactionManager
- Parameters:
context
- The context to mark as failed. Cannot benull
.transactionHandle
- The handle of the context manipulaton transaction. Cannot benull
.
-
popChangedContexts
Gets updated contexts and removes them from the queue- Parameters:
computationCause
- The computation cause to get updated contexts for. May not benull
- Returns:
- Changed contexts set. May not be
null
-
processAccumulatedContexts
public void processAccumulatedContexts()Description copied from interface:IDerivedDataContextManager
Processes accumulated contexts (if any), sending corresponding DD context updates to the corresponding consumer (pipeline). This method is not thread safe, the caller should guarantee the calls synchronization to ensure the propert order of accumulated context application- Specified by:
processAccumulatedContexts
in interfaceIDerivedDataContextManager
-
registerContextUpdateListener
Description copied from interface:IDerivedDataContextManager
Registers the context update listener.- Specified by:
registerContextUpdateListener
in interfaceIDerivedDataContextManager
- Parameters:
listener
- The listener to register.
-
registerTransaction
public Object registerTransaction(boolean computation, boolean forcedUpdate, Object computationCause, boolean trackWaitingScope) Description copied from interface:IContextTransactionManager
Registers a transaction in the lock manager. Throws an exception if there are too many concurrent transactions.- Specified by:
registerTransaction
in interfaceIContextTransactionManager
- Parameters:
computation
- True in case if this a DD context computation transaction; false otherwise.forcedUpdate
- Forces update of contexts, even if they aren't changedtrackWaitingScope
- Enables tracking of implicit waiting context if true- Returns:
- the registered transaction handle, never
null
.
-
rollback
Description copied from interface:IContextTransactionManager
Rolls the transaction back, cancelling all collected context changes.- Specified by:
rollback
in interfaceIContextTransactionManager
- Parameters:
transactionHandle
- The handle of the context manipulaton transaction. Cannot benull
.
-
scheduleModalOperation
public IObjectDerivedDataContext scheduleModalOperation(Consumer<org.eclipse.core.runtime.IProgressMonitor> operation, String segmentId, IModalOperationController modalOperationController, Object transactionHandle) Description copied from interface:IContextTransactionManager
Schedules a new modal operation- Specified by:
scheduleModalOperation
in interfaceIContextTransactionManager
- Parameters:
operation
- The operation logic to schedule. May not benull
modalOperationController
- The modal operation controller. May not benull
- Returns:
- The operation handle for external operation referencing, may not be
null
-
scheduleOperation
public IObjectDerivedDataContext scheduleOperation(Consumer<org.eclipse.core.runtime.IProgressMonitor> operation, OperationType operationType, boolean important, String segmentId, Object transactionHandle) Description copied from interface:IContextTransactionManager
Schedules an operation context. Always creates a new one as an operation is non-identifiable- Specified by:
scheduleOperation
in interfaceIContextTransactionManager
- Parameters:
operation
- The operation executable. May not benull
operationType
- The operation type. May not benull
segmentId
- The target async pipeline operation segment. May not benull
transactionHandle
- The handle of the context manipulaton transaction. Cannot benull
.- Returns:
- The operation context. May not be
null
-
scheduleOperationRemoval
public void scheduleOperationRemoval(IObjectDerivedDataContext operationHandle, Object transactionHandle) Description copied from interface:IContextTransactionManager
Schedules the operation removal- Specified by:
scheduleOperationRemoval
in interfaceIContextTransactionManager
- Parameters:
operationHandle
- The handle of the previously scheduled operation. May not benull
transactionHandle
- The handle of the context manipulaton transaction. Cannot benull
.
-
setScopeTrackerController
Sets the external scope tracker controller- Parameters:
scopeTrackerController
- The controller to set. May not benull
-
unregisterContextUpdateListener
Description copied from interface:IDerivedDataContextManager
Removes previously registered listener.- Specified by:
unregisterContextUpdateListener
in interfaceIDerivedDataContextManager
- Parameters:
listener
- The listener to remove.
-
waitAccumulatedContextProcessing
public boolean waitAccumulatedContextProcessing(long timeout) Description copied from interface:IDerivedDataContextManager
The caller of this method waits on this method until all accumulated yet not processed DD context updates are being processed. This allows to be sure that the required scope (e.g. for waiting) is already known/or cleared to the DD after this call- Specified by:
waitAccumulatedContextProcessing
in interfaceIDerivedDataContextManager
- Parameters:
timeout
- Wait timeout in ms. -1 means no timeout- Returns:
- True if waiting is successfull
-