Skip to main content

%DeepSee.WorkMgr

Class %DeepSee.WorkMgr Extends %RegisteredObject [ System = 3 ]

Utility class that provides an API for managing DeepSee tasks.
This is an internal utility used by DeepSee.

Parameters

EVENTNAME

Parameter EVENTNAME = "^DeepSee.Tasks.";

Name of system used to talk to agents.

TIMEOUT

Parameter TIMEOUT = 0;

Timeout value (seconds) for events. If no events are received, then the agent will shut itself down.

Methods

%SetLoggingOptions

ClassMethod %SetLoggingOptions(pUseArchive = 0, pLogSize = 100, pLogAll = 0)

Turn on logging for the DeepSee background agents. These will be reset during a call to %KillLog.

%Reset

ClassMethod %Reset() As %Status

Reset the WorkMgr.
This stops all running agents, clears out all tasks, and clears the logs.

%IsActive

ClassMethod %IsActive() As %Boolean

WorkQ agents will be made available as needed. This test always returns True

%WaitForTaskGroup

ClassMethod %WaitForTaskGroup(ByRef pTaskGroup As %String = "", Output pCompleted As %Boolean, pTimeOut As %Integer = 0, ByRef pWorkMgr As %SYSTEM.WorkMgr = {$$$NULLOREF}, Output pMaxTaskGroupWorkers As %Integer, Output pMaxWorkersOverallSoFar As %Integer) As %Status

Wrapper for the WorkMgr:Sync() that parallels the original %DeepSee.TaskMaster version. The caller may optionally supply an object reference to a pWorkMgr for custom use.

%CreateTaskGroup

ClassMethod %CreateTaskGroup(Output pTaskGroup As %String, pWait As %Boolean = 0, pName As %String = "", pRequestWorkMgr = 0, Output pWorkMgr = {$$$NULLOREF}) As %Status

Create a unique idenitfier for a task group. The caller may optionally request an object reference with pRequestWorkMgr=1 which will be returned via pWorkMgr for customized use.

%DestroyTaskGroup

ClassMethod %DestroyTaskGroup(pTaskGroup As %String = "", pPurgeTasks As %Boolean = 1) As %Status

Close down all work being done by this task group

%CreateAgents

ClassMethod %CreateAgents(pNumAgents As %Integer = "") As %Status

- NOT IMPLEMENTED - This is handled by the WorkQMgr as part of task queueing operations

%AttachToQueue

ClassMethod %AttachToQueue(pQueueName As %String = "", Output pStatus As %Status = {$$$OK}) As %SYSTEM.WorkMgr

Look up a token to reattach to a given WorkMgr queue. After successfully serializing a WorkMgr instance, through either attachment to a pre-existing queue or initialization of a new queue, the storage location for the provided pQueueName is marked with the null string to provide an indication the queue is currently open and working.

%DetachFromQueue

ClassMethod %DetachFromQueue(pQueueName As %String = "", ByRef pWorkMgr As %SYSTEM.WorkMgr = {$$$NULLOREF}) As %Status

Detach from a given WorkMgr queue and store the current token needed to reattach. If the storage location has been deleted before detaching from the queue (eg: by a cancellation operation), then the token is discarded.

%KillAgents

ClassMethod %KillAgents(pPurgeTasks As %Boolean = 0) As %Status

Find all open WorkQ manager instances and shut them down

%KillTasksForGroup

ClassMethod %KillTasksForGroup(pTaskGroup As %String) As %Status

This performs the actual cleanup work to remove all tasks assigned to a particular logical work group.

%QueueTask

ClassMethod %QueueTask(pTaskGroup As %String = "", pTaskType As %String, pCubeName As %String, pQueryKey As %String = "", pData As %String = "", pData2 As %String = "", pData3 As %String = "", pSQLParams As %String = "", pSuppressArchive As %Boolean = 0, ByRef pWorkMgr As %SYSTEM.WorkMgr = {$$$NULLOREF}) As %Status

This is called from the foreground to add a task to the queue of background tasks.
pTaskGroup must be defined in order to properly assign individual tasks to a particular work queue. The caller may optionally supply an object reference to a pWorkMgr to add the task to that custom work queue.

%StartAgent

ClassMethod %StartAgent(pAgentId As %String, pPriority As %String) [ Internal ]

- NOT IMPLEMENTED - This is handled by the WorkQMgr.

%DequeueTask

ClassMethod %DequeueTask(pTaskGroup As %String, pParameters As %List, pSuppressArchive As %Boolean = 0) As %Status

This is called in %ExecuteTask to mark the task "active" in the process logging.

%CloseTask

ClassMethod %CloseTask(pTaskGroup As %String, pParameters As %List) As %Status

This is called as the callback to %ExecuteTask which cleans up the management global. This method will also close out the WorkQ if the group was created with pWait = 0.

%ExecuteTask

ClassMethod %ExecuteTask(pTaskGroup As %String, pParameters As %List, pSettings As %String = "") As %Status

This is run by the worker and will do the actual work of processing tasks via the work queue manager

%Log

ClassMethod %Log(pMsg As %String)

Log a message to the agent log.

%PrintLog

ClassMethod %PrintLog()

Print contents of the (global-based) agent log to the console.

%PrintTaskGroups

ClassMethod %PrintTaskGroups()

Print current task groups to the console.

%PrintActiveTasks

ClassMethod %PrintActiveTasks()

Print list of active tasks out to the console.

%PrintPendingTasks

ClassMethod %PrintPendingTasks()

Print list of pending (queued) tasks out to the console.

%KillLog

ClassMethod %KillLog(pMsg As %String) As %Status

Kill the agent log.

%RunArchivedTask

ClassMethod %RunArchivedTask(pTaskId As %Integer, pVerbose As %Boolean = 1) As %Status [ Internal ]

Diagnostic method.

%QueueArchivedTask

ClassMethod %QueueArchivedTask(pTaskId As %Integer, pTaskGroup As %String = "", pVerbose As %Boolean = 1, pSuppressArchive As %Boolean = 1) As %Status [ Internal ]

Diagnostic method to dispatch an archived task to a DeepSee background agent. Several tasks can be grouped into a single batch of archived tasks by supplying a pTaskGroup. If pSuppressArchive = 1, the re-execution of an archived task will not get archived.

%RunArchivedTaskGroup

ClassMethod %RunArchivedTaskGroup(pTaskStartId As %Integer = 1, pTaskEndId As %String = 0, pAsync As %Boolean = 1, pSuppressArchive As %Boolean = 1, pWaitTimeout As %Integer = 30, pVerbose As %Boolean = 1) As %Status [ Internal ]

This is a diagnostic utility which will run a group of tasks from the task archive. Siunce the task archive is a ring buffer, pTaskEndId may be set to 0 to indicate that the method should run to the end of the log. By default the method will re-queue the entire task archive beginning at position #1 for processing by DeepSee background agents. When using background processing, if pSuppressArchive = 1, then the re-execution of an archived task will not get archived.
The method can be switched to execute each task sequentially in the foreground by setting pAsync=0.

%CountLiveAgents

ClassMethod %CountLiveAgents(pPriority = "H", Output pStatus, pCleanDeadAgents = 0) As %Integer [ Internal ]

- NOT IMPLEMENTED - There is no longer direct management of agents by this class.

%AgentsAvailable

ClassMethod %AgentsAvailable(pPriority = "H", Output pStatus) As %Integer

- NOT IMPLEMENTED - Agents are always available and created as needed. There is no need to test anymore.

%Test

ClassMethod %Test(pTaskCount = 25, pTimeOut = 0, pClean = 1) As %Status

Perform simple test of DeepSee WorkMgr. This will kill any pending task.

%InitializeWorkMgr

ClassMethod %InitializeWorkMgr(pQueueName, Output pStatus) As %SYSTEM.WorkMgr

Create a new %SYSTEM.WorkMgr instance for use managing this DeepSee task queue.

%SetupQueueContext

ClassMethod %SetupQueueContext(ByRef pCallingContext) As %Status [ Internal ]

Setup procedure to be run by each %SYSTEM.WorkMgr process as it picks up work from a %DeepSee.WorkMgr queue. All environmental setup should occur here. This will execute the user defined setup code if the call is defined in the ^DeepSee.InitCode global.
The pCallingContext is an array to be used as a container for any relevant context established in the calling environment (for example %session information) that needs to be present in the background.

%TearDownQueueContext

ClassMethod %TearDownQueueContext(ByRef pCallingContext) As %Status [ Internal ]

Tear-down procedure to be run by each %SYSTEM.WorkMgr worker process as it completes all work and detaches from a %DeepSee.WorkMgr-managed queue. All environmental tear down should occur here. This will execute the user defined tear-down code if the call is defined in the ^DeepSee.CloseCode global.
The tear-down will receive the same pCallingContext array as was passed to %SetupQueueContext.

%CleanupQueueContext

ClassMethod %CleanupQueueContext(ByRef pCallingContext) As %Status [ Internal ]

This is the worker method that will be executed as cleanup upon final close of the %SYSTEM.WorkMgr queue. At the time this executes there is no further need for any of the indices and metrics filed under the group label that was generated with the original %SYSTEM.WorkMgr, and on exit there should be no trace of the queueID label in the operational globals.