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 TypeMethodDescriptionvoidClears all global contexts in case if no unfinished DD computations/tasks are available.voidcloseSession(IContextCollectingSession session) Finishes processing of the session, removing all effective context locks.voidCommits the transaction.voidconfirmOperationComputation(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 pipelinevoiddeactivateContexts(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).booleanisContextExists(IBmObject bmObject, String segmentId) Checks if the DD context exists(supported) for the given object and segmentbooleanisContextExists(org.eclipse.emf.ecore.EClass topObjectEClass, long topObjectId, String segmentId) Checks if the DD context exists(supported) for the given object and segmentvoidmarkAsComputed(IObjectDerivedDataContext context, Object transactionHandle) Marks the context as a computed.voidmarkAsFailed(IObjectDerivedDataContext context, Object transactionHandle) Marks a specified context as failed to compute.popChangedContexts(Object computationCause) Gets updated contexts and removes them from the queuevoidProcesses accumulated contexts (if any), sending corresponding DD context updates to the corresponding consumer (pipeline).voidRegisters the context update listener.registerTransaction(boolean computation, boolean forcedUpdate, Object computationCause, boolean trackWaitingScope) Registers a transaction in the lock manager.voidRolls 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.voidscheduleOperationRemoval(IObjectDerivedDataContext operationHandle, Object transactionHandle) Schedules the operation removalvoidsetScopeTrackerController(IScopeTrackerController scopeTrackerController) Sets the external scope tracker controllervoidRemoves previously registered listener.booleanwaitAccumulatedContextProcessing(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 benullmodalModelAccessor- The modal mode accessor reference. May not benullscheduler- The derived data scheduler reference. May not benullsegments- The collection of all available pipeline segments. May not benullfilteredSegments- The set of filtered segments that must be ommited during the collecting. May not benulldeactivationControllers- The collection ofIContextDeactivationController. Cannot benullexecutionContext- The client-contributed implementation ofIAsyncComputationExecutionContext. Cannot benull
-
-
Method Details
-
clearOnEmptyPipeline
public void clearOnEmptyPipeline()Description copied from interface:IDerivedDataContextManagerClears all global contexts in case if no unfinished DD computations/tasks are available. Removes accumulation global contexts, etc.- Specified by:
clearOnEmptyPipelinein interfaceIDerivedDataContextManager
-
closeSession
Description copied from interface:IDerivedDataContextManagerFinishes processing of the session, removing all effective context locks.- Specified by:
closeSessionin interfaceIDerivedDataContextManager
-
commit
Description copied from interface:IContextTransactionManagerCommits the transaction.- Specified by:
commitin interfaceIContextTransactionManager- Parameters:
transactionHandle- The handle of the context manipulaton transaction. Cannot benull.
-
confirmOperationComputation
public void confirmOperationComputation(OperationContext operationContext, Object transactionHandle) Description copied from interface:IContextTransactionManagerConfirms the computation of the given operation- Specified by:
confirmOperationComputationin interfaceIContextTransactionManager- Parameters:
operationContext- The context of the operation. May not benulltransactionHandle- The handle of the context manipulaton transaction. Cannot benull.
-
deactivateContexts
Description copied from interface:IDerivedDataContextManagerPerform mass deactivation of contexts- Specified by:
deactivateContextsin interfaceIDerivedDataContextManager- Parameters:
segmentId- Target segment of async. processing pipeline for the deactivation
-
createContextCollectingSession
Description copied from interface:IDerivedDataContextManagerCreate synchronous DD context collecting session.- Specified by:
createContextCollectingSessionin 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:IDerivedDataContextManagerCreates 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:
createContextLoadingSessionin interfaceIDerivedDataContextManager- Returns:
- The loading session. Cannot be
null
-
createContextCollectingSession
public IContextCollectingSession createContextCollectingSession(Object computationCause, boolean trackWaitingScope) Description copied from interface:IDerivedDataContextManagerCreate synchronous DD context collecting session.- Specified by:
createContextCollectingSessionin 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:IContextTransactionManagerReturns the existing object context.- Specified by:
getExistingObjectContextin 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:IContextTransactionManagerGathers object context for the given object (if any).- Specified by:
getObjectContextin 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:IContextTransactionManagerGathers object context for the given object (if any).- Specified by:
getObjectContextin interfaceIContextTransactionManager- Parameters:
bmObjectId- The identifier of the object to get the context for for.eClass- TheEClassof the object to get the context for. Cannot benullsegmentId- 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:IContextTransactionManagerGathers object context for the given object (if any).- Specified by:
getObjectContextin interfaceIContextTransactionManager- Parameters:
objectId- Target object, cannot benull.eClass- TheEClassof 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:IContextTransactionManagerChecks if the DD context exists(supported) for the given object and segment- Specified by:
isContextExistsin interfaceIContextTransactionManager- Parameters:
topObjectEClass- Top objectEClass. May not benulltopObjectId- Top object identifier. May not benullsegmentId- The DD segment identifier. May not benull- Returns:
- True if the context exists/may be created
-
isContextExists
Description copied from interface:IContextTransactionManagerChecks if the DD context exists(supported) for the given object and segment- Specified by:
isContextExistsin interfaceIContextTransactionManager- Parameters:
bmObject- The object to get the context for. May not benullsegmentId- The DD segment identifier. May not benull- Returns:
- True if the context exists/may be created
-
markAsComputed
Description copied from interface:IContextTransactionManagerMarks the context as a computed. Will be re-set on a commit.- Specified by:
markAsComputedin interfaceIContextTransactionManager- Parameters:
context- Transaction context. Cannot benull.transactionHandle- The handle of the context manipulaton transaction. Cannot benull.
-
markAsFailed
Description copied from interface:IContextTransactionManagerMarks a specified context as failed to compute.- Specified by:
markAsFailedin 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:IDerivedDataContextManagerProcesses 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:
processAccumulatedContextsin interfaceIDerivedDataContextManager
-
registerContextUpdateListener
Description copied from interface:IDerivedDataContextManagerRegisters the context update listener.- Specified by:
registerContextUpdateListenerin interfaceIDerivedDataContextManager- Parameters:
listener- The listener to register.
-
registerTransaction
public Object registerTransaction(boolean computation, boolean forcedUpdate, Object computationCause, boolean trackWaitingScope) Description copied from interface:IContextTransactionManagerRegisters a transaction in the lock manager. Throws an exception if there are too many concurrent transactions.- Specified by:
registerTransactionin 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:IContextTransactionManagerRolls the transaction back, cancelling all collected context changes.- Specified by:
rollbackin 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:IContextTransactionManagerSchedules a new modal operation- Specified by:
scheduleModalOperationin interfaceIContextTransactionManager- Parameters:
operation- The operation logic to schedule. May not benullmodalOperationController- 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:IContextTransactionManagerSchedules an operation context. Always creates a new one as an operation is non-identifiable- Specified by:
scheduleOperationin interfaceIContextTransactionManager- Parameters:
operation- The operation executable. May not benulloperationType- The operation type. May not benullsegmentId- The target async pipeline operation segment. May not benulltransactionHandle- 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:IContextTransactionManagerSchedules the operation removal- Specified by:
scheduleOperationRemovalin interfaceIContextTransactionManager- Parameters:
operationHandle- The handle of the previously scheduled operation. May not benulltransactionHandle- 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:IDerivedDataContextManagerRemoves previously registered listener.- Specified by:
unregisterContextUpdateListenerin interfaceIDerivedDataContextManager- Parameters:
listener- The listener to remove.
-
waitAccumulatedContextProcessing
public boolean waitAccumulatedContextProcessing(long timeout) Description copied from interface:IDerivedDataContextManagerThe 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:
waitAccumulatedContextProcessingin interfaceIDerivedDataContextManager- Parameters:
timeout- Wait timeout in ms. -1 means no timeout- Returns:
- True if waiting is successfull
-