Interface IDerivedDataManager


  • public interface IDerivedDataManager
    Derived data manager is responsible for providing clients with the unified access to the DD management functionality, including status tracking.
    • Method Detail

      • addObjectStatusListener

        void addObjectStatusListener​(IDerivedDataObjectStatusListener listener,
                                     long bmObjectId,
                                     String... segments)
        Adds listener for DD status changes of the given object and set of tracked DD segments.
        Parameters:
        listener - The listener instance. Cannot be null. One can re-use the same instance of the listener to subscribe for different sets of objects and segments, but in this case the call to the removeObjectStatusListener(com._1c.g5.v8.derived.IDerivedDataObjectStatusListener) will remove all subscriptions.
        bmObjectId - The identifier of the object which DD changes are being notified via the supplied listener. Cannot be null or empty due to performance reasons. To track down computation of the entire DD segment use IDerivedDataManager#addStatusListener(IDerivedDataStatusListener) instead}.
        segments - DD segment filter allows to subscribe for specific segments of DD. Cannot be null
      • addObjectStatusListener

        void addObjectStatusListener​(IDerivedDataObjectStatusListener listener,
                                     Map<Long,​Collection<String>> scope)
        Adds listener for DD status changes of the given DD change scope. The scope is defined as a map of BM object identifiers to the respective traked DD segments.
        Parameters:
        listener - The listener instance. Cannot be null. One can re-use the same instance of the listener to subscribe for different sets of objects and segments, but in this case the call to the removeObjectStatusListener(com._1c.g5.v8.derived.IDerivedDataObjectStatusListener) will remove all subscriptions.
        scope - Tracked DD segments mapped to corresponding BM object ids. Cannot be null. Scope entries cannot contain null or empty sets of tracked DD segments.
      • addStatusListener

        void addStatusListener​(IDerivedDataStatusListener listener)
        Adds listener that will be notified about derived data status changes.
        Parameters:
        listener - the listener that should be notified
      • blockAsyncPipeline

        void blockAsyncPipeline​(boolean forcedStop)
        Blocks the async. processing pipeline. This methods waits until all current DD operations are finished before return from the call.
        Parameters:
        forcedStop - Locks pipeline in forced mode. In case if true, could be unlocked only with corresponding value of the flag. Forced lock is being used to prevent file sycnhronization opearions/etc to remove manually defined locks.
      • blockAsyncPipeline

        void blockAsyncPipeline​(boolean forcedStop,
                                boolean wait)
        Blocks the async. processing pipeline
        Parameters:
        forcedStop - Locks pipeline in forced mode. In case if true, could be unlocked only with corresponding value of the flag. Forced lock is being used to prevent file sycnhronization opearions/etc to remove manually defined locks.
        wait - Wait until all running operations in the current pipeline are completed
      • disableImplicitWaiting

        void disableImplicitWaiting()
        Disables implicit waiting of the DD independenly of the current system status. Used during the explicitely managed operations, like merging, etc.
      • enableImplicitWaiting

        void enableImplicitWaiting()
        Enables implicit waiting of the DD independenly of the current system status. Used during the explicitely managed operations, like merging, etc.
      • getDerivedDataStatus

        DerivedDataStatus getDerivedDataStatus()
        Gets the current status of DD for the corresponding BM model.
        Returns:
        The overall status of the DD facility.
      • isAllComputed

        boolean isAllComputed()
        Checks if all derived data parts are computed.
        Returns:
        true if computed, false otherwise
      • isComputed

        boolean isComputed​(Collection<String> segmentIds)
        Checks if the given parts are computed (if applicable) for all the BM objects.
        Parameters:
        partIds - the IDs of the parts to check
        Returns:
        true if computed, false otherwise
      • isComputed

        boolean isComputed​(long bmObjectId,
                           Collection<String> segmentIds)
        Checks if the given parts are computed for the given BM object.
        Parameters:
        bmObjectId - the ID of the BM object to check
        partIds - the IDs of the parts to check
        Returns:
        true if computed, false otherwise
      • isComputed

        boolean isComputed​(long bmObjectId,
                           String segmentId)
        Checks if the given part is computed for the given BM object.
        Parameters:
        bmObjectId - the ID of the BM object to check
        segmentId - the ID of the part to check
        Returns:
        true if computed, false otherwise
      • isComputed

        boolean isComputed​(long bmObjectId,
                           String partId,
                           boolean strict)
        Checks if the given part is computed for the given BM object.
        Parameters:
        bmObjectId - the ID of the BM object to check
        partId - the ID of the part to check
        strict - In strict mode caller expecting, that part must be calculated. In case if part is still not indicated, the method will return false
        Returns:
        true if computed, false otherwise
      • isComputed

        boolean isComputed​(String... segmentIds)
        Checks if the given DD segments are computed (if applicable) for all the BM objects.
        Parameters:
        segmentIds - Array of the DD segment Ids to check
        Returns:
        true if computed, false otherwise
      • recomputeAll

        void recomputeAll()
        Forces the DD mechanism to recompute all the known parts of all the known objects.
      • removeObjectStatusListener

        void removeObjectStatusListener​(IDerivedDataObjectStatusListener listener)
        Removes specific DD object status listener instance from the notification chain. All subscriptions of the given listener instance will be removed as a result.
        Parameters:
        listener - The listener that should be removed. Cannot be null.
      • removeStatusListener

        void removeStatusListener​(IDerivedDataStatusListener listener)
        Removes listener that will be notified about derived data status changes.
        Parameters:
        listener - the listener that should be removed.
      • unblockAsyncPipeline

        void unblockAsyncPipeline​(boolean forcedStop)
        Force unblocking of the async. pipeline. Could stay blocked after the call of this method if async. DD computation prerequisites are not met yet.
        Parameters:
        forcedStop - Unblocks the forced block in case if true. Unblocks usual lock instead.
      • updateDerviedData

        boolean updateDerviedData​(IDerivedDataUpdate update,
                                  long waitTimeout)
        Updates derivided data using the provided IDerivedDataUpdate update
        Parameters:
        update - The update to perform
        waitTimeout - Waiting time (in milliseconds) for the updated DD to be re-computed; 0 means no wait
        Returns:
        True if the requested DD were computed until the end of the waiting period; false otherwise
      • supplyImplicitOperationContextIfApplicable

        void supplyImplicitOperationContextIfApplicable​(Object computationCause,
                                                        Runnable asyncEventScheduler)
                                                 throws InterruptedException
        Computes synchronous derived data pending for the current session (if any). The computation is synchronous.
        Parameters:
        computationCause - The object bound to the computation context and used to track computations. Can be null
        asyncEventScheduler -
        Throws:
        InterruptedException
      • waitAllComputations

        boolean waitAllComputations​(long timeout)
                             throws InterruptedException
        Wait till all computations are finished or waiting time exceeds the specified value.
        Parameters:
        timeout - the maximum time to wait in milliseconds
        Returns:
        true if all derived data has been computed by the time this method returns, false otherwise
        Throws:
        InterruptedException - if any thread interrupted the current thread before or while the current thread was waiting for the computations.
      • waitComputation

        boolean waitComputation​(long timeout,
                                boolean priority,
                                String... scope)
                         throws InterruptedException
        Waits completion of the given scope
        Parameters:
        timeout - The wait timeout
        priority - The data that is being waited are priority computations
        scope - The scope (parts) to wait
        Returns:
        True if the wait was successful; false if it was timed out
        Throws:
        InterruptedException
      • waitComputation

        void waitComputation​(Map<Long,​Collection<String>> scope)
                      throws InterruptedException
        Waits till the given scope of computations is finished.
        Parameters:
        scope - the scope of computations to wait for. The scope is a map, where the keys are BM objects whose derived data parts must be computed and the values are collections of the part IDs
        Throws:
        InterruptedException - if any thread interrupted the current thread before or while the current thread was waiting for the computation
      • waitComputation

        boolean waitComputation​(Map<Long,​Collection<String>> scope,
                                long timeout)
                         throws InterruptedException
        Waits till the given scope of computations is finished or waiting time exceeds the specified value.
        Parameters:
        scope - the scope of computations to wait for. The scope is a map, where the keys are BM objects whose derived data parts must be computed and the values are collections of the part IDs
        timeout - the maximum time to wait in milliseconds
        Returns:
        true if the given scope has been computed by the time this method returns, false otherwise
        Throws:
        InterruptedException - if any thread interrupted the current thread before or while the current thread was waiting for the computation.
      • waitOperationComputation

        boolean waitOperationComputation​(Object handle,
                                         long timeout)
                                  throws InterruptedException
        Waits the given operation computation
        Parameters:
        handle - The operation computation handle. May not be NullPointerException
        timeout - the maximum time to wait in milliseconds
        Returns:
        true if the given scope has been computed by the time this method returns, false otherwise
        Throws:
        InterruptedException - if any thread interrupted the current thread before or while the current thread was waiting for the computation.
      • waitComputationExt

        boolean waitComputationExt​(Map<Object,​Collection<String>> scope,
                                   long timeout)
                            throws InterruptedException
        Waits till the given scope of computations is finished or waiting time exceeds the specified value.
        Parameters:
        scope - the scope of computations to wait for. The scope is a map, where the keys are BM objects whose derived data parts must be computed and the values are collections of the part IDs
        timeout - the maximum time to wait in milliseconds
        Returns:
        true if the given scope has been computed by the time this method returns, false otherwise
        Throws:
        InterruptedException - if any thread interrupted the current thread before or while the current thread was waiting for the computation.
      • startMassiveComputing

        void startMassiveComputing()
        Enables the massive computing mode for the DD pipeline. The mode is being desingaged after computing of all registered important tasks
      • scheduleModalOperation

        Object scheduleModalOperation​(Consumer<org.eclipse.core.runtime.IProgressMonitor> operation,
                                      DerivedDataSegmentBucket stage,
                                      IModalOperationController modalOperationController)
        Schedules the orchestrated modal operation. See OperationType.MODAL for details
        Parameters:
        operation - The operation logic to schedule. May not be null
        stage - The target stage for the scheduling. May not be null
        modalOperationController - The modal operation controller. May not be null
        Returns:
        The operation handle for external operation referencing, may not be null
      • scheduleOperation

        Object scheduleOperation​(Consumer<org.eclipse.core.runtime.IProgressMonitor> operation,
                                 OperationType operationType,
                                 boolean important,
                                 DerivedDataSegmentBucket stage)
        Schedules the orchestrated operation.
        Parameters:
        operation - The operation logic to schedule. May not be null
        operationType - The type of the operation. May not be null
        important - The designator of an important operation. The system waits for important operations computation during closing of projects, etc
        stage - The target stage for the scheduling. May not be null
        Returns:
        The operation handle for external operation referencing, may not be null
      • setStageLock

        StageLockRequestResult setStageLock​(DerivedDataSegmentBucket stage,
                                            boolean allowDataComputing)
        Locks the async. pipeline stage (to support manual operations with external pipeline state control). Locked bucket tasks are being computed yet the pipeline can't switch to the next stage. The pre-set lock is being activated only after switching of the pipeline to the target stage. Before the activation the lock doesn't affect the computation.
        Parameters:
        stage - The stage to lock. May not be null
        Returns:
        The status of a target stage at the moment of a lock call. May not be null
      • resetStageLock

        void resetStageLock​(DerivedDataSegmentBucket stage)
        Resets the lock being set earlier
        Parameters:
        stage - The stage to re-set the bucket. May not be null. If block isn't set - does nothing.
      • isIdle

        boolean isIdle()
        Checks if the computation pipeline is idle
        Returns:
        True if no computations are done/possible at the moment
      • removeOperation

        void removeOperation​(Object handle)
        Removes the previously scheduled operation. Does nothing if the operation is already removed/computed
        Parameters:
        handle - The operation handle taken from the IDerivedDataManager#scheduleOperation(Consumer, OperationType, DerivedDataSegmentBucket) call. May not be null.
      • markAsModalOperationParticipant

        void markAsModalOperationParticipant()
        Marks a current thread as a current modal operation participant. The mark is removed automatically on the completion of the corresponding modal operation
      • prepareForClose

        void prepareForClose()
        Prepares the async. computation facility for closing. Blocks all unnecessary data computations and scheduled operations and waits until all required computations are done
      • startWrappingOperationIfNesessary

        void startWrappingOperationIfNesessary​(Object bmOperationHandle)
        Starts implicit wrapping operation for the specified IBmTask in this thread in case if no operation is manually started already
        Parameters:
        bmOperationHandle - The BM operation handle to wrap with the orchestrated operation. May not be null
      • completeWrappingOperationIfApplicable

        void completeWrappingOperationIfApplicable​(Object bmOperationHandle)
        Complete implicit wrapping operation if the implicit wrapping operation were started earlier in this thread
        Parameters:
        bmOperationHandle - The BM operation handle to wrap with the orchestrated operation. May not be null
      • implicitDerivedDataWait

        void implicitDerivedDataWait​(Object computationCause)
                              throws InterruptedException
        Waits for the derived data computation from the BM task that is wrapped by the implicit/explicit orchestrated operation
        Parameters:
        computationCause - The cause of the computation. May not be NullPointerException
        Throws:
        InterruptedException
      • resetActiveWrappingOperationContext

        void resetActiveWrappingOperationContext​(OperationContext operationContext)
        Resets the active wrapping operation context associated with the current thread.
        Parameters:
        operationContext - The context to reset. May not be null
      • getEventConsumer

        BiConsumer<BmEvent,​Boolean> getEventConsumer()
        Gets the sync event consumer for the integration with the event processing flow of IBmModel. Also it's possible to supply BM events directly to the consumer in complex scenarios of managed data updates
        Returns:
        The DD BmEvent consumer. May not be null
      • disableAutoWrapping

        void disableAutoWrapping()
        Disables auto-wrapping of BM tasks with orchestrator operations for the current thread. Used for async data computations being controlled directly by the async pipeline. The disablement stays on during the whole thread lifecycle
      • enableAutoWrapping

        void enableAutoWrapping()
        Enables an auto-wrapping of BM tasks with orchestrator operations for the current thread. Used to restore an auto-wrapping being disabled previously