Skip to main content

%SYSTEM.ShardWorkMgr

Class %SYSTEM.ShardWorkMgr Extends AbstractWorkMgr

Manage distributing work to other systems in a sharded environment. This is modelled on the %SYSTEM.WorkMgr as closely as possible. To use this you first create an instance of this class, this acts as the container for the units of work you then request. Finally you wait for this work to complete or return errors.

Methods

Broadcast

Method Broadcast(set As %String, work As %String, args... As %String) As %Status

Broadcast a task to be run via the Work Queue Manager on all systems that form part of set of machines. Once the work is broadcast you can Sync to wait for all work to complete or WaitOne to get notifications of individual completions.

The set supports the following values for a sharding system:

  1. DS or data : All shard data nodes
  2. QD or compute : A set of shard compute/query nodes
  3. all : All shard nodes (the default)
  4. instance : All instances that are part of the shard set Note that QD/compute will pick a set of compute/query nodes that cover the entire extent and run the broadcast on these nodes so it will be able to see all the data. If a shard setup has two namespace on a single instance that are part of the shard cluster then 'instance' will only run the logic in one of the namespace on this instance so it is useful for collecting system wide information.

Returns a %Status code if the work was queued correctly, note that to see if the work completed you need to call Sync method and check the returned %Status value for this. Pass the entry point to call in work argument. This can be either '##class(Classname).ClassMethod' or '$$entry^rtn' and it is expected to return a %Status code. If you want to call a function that does not return any value on completion then prepend the class syntax with '=' such as '=##class(Classname).ClassMethod' or for calling a function do not include the '$$' for example 'entry^rtn'. The item being called may also throw exceptions in order to indicate an error happened which is trapped and converted to a %Status value to be returned in the parent process. You can also pass additional arguments including arrays by reference. Note that the size of the data passed in these arguments should be kept relatively small, if there is a large amount of information that needs to be passed then put this in a global. The security context of the caller is recorded when this function is called and is used when the work is executed. Output the work unit makes to the current device will be trapped and relayed to the parent process after this work unit has complted and when the parent process is waiting for work to be completed. If a work unit wishes to flush output before the work unit has completed then then call 'Do $system.WorkMgr.Flush()' Work units may write to the public variable %result which will be relayed to the parent process in the WaitOne call via the byref workresult argument.

Map

Method Map(set As %String, classname As %String, ByRef idlist As %List, work As %String, args... As %String) As %Status

Map the work over a set of id's in a class.

Takes the classname which the id's belong to, a task to be run via the Work Queue Manager on all systems that form part of set of machines. The set supports the following values for a sharding system:

  1. DS or data : All shard data nodes
  2. QD or compute : A set of shard compute/query nodes Note that QD/compute will pick a set of compute/query nodes that cover the entire extent and run the work on these nodes so it will be able to see all the data.

The idlist is a $lb of IDs to process, or a local array subscripted by the ID to process passed in by reference. If idlist="" then we will map the work over all the IDs in the extent. Returns a %Status code if the work was queued correctly, note that to see if the work completed you need to call Sync method and check the returned %Status value for this. Pass the entry point to call in work argument. If this is an instance method indicated by a leading '..' for example '..Method' we will call this method on the instance of the shard local class associated with classname class for this specific id. Also supported is either '##class(Classname).ClassMethod' or '$$entry^rtn' where the first argument being passed in to this class method or function will be the 'id' of the element to process, the second argument will be 'classname' followed by and additional argumented passed in this method. In all these cases the method/function is expected to return a %Status code. If you want to call a function that does not return any value on completion then prepend the class syntax with '=' such as '=##class(Classname).ClassMethod' or for calling a function do not include the '$$' for example 'entry^rtn'. The item being called may also throw exceptions in order to indicate an error happened which is trapped and converted to a %Status value to be returned in the parent process. You can also pass additional arguments including arrays by reference. Note that the size of the data passed in these arguments should be kept relatively small, if there is a large amount of information that needs to be passed then put this in a global. The security context of the caller is recorded when this function is called and is used when the work is executed. Output the work unit makes to the current device will be trapped and relayed to the parent process after this work unit has completed and when the parent process is waiting for work to be completed. If a work unit wishes to flush output before the work unit has completed then then call 'Do $system.WorkMgr.Flush()' Work units may write to the public variable %result which will be relayed to the parent process in the WaitOne call via the byref workresult argument.

QueueShard

Method QueueShard(localSystem As %String, remoteSystem As %String, namespace As %String, work As %String, args... As %String) As %Status [ Internal ]

Internal method for use with sharding only.
localSystem is the reference of this local systems IRISLOCALDATA database from the remote system we will queue work on. Add a task to the Work Queue Manager runqueue on a remote machine. You get a %Status if the work was queued correctly. remoteSystem the namespace or implied reference that maps to the remote systems IRISLOCALDATA database so you can form a valid global reference with '^|remoteSystem|IRIS.WorkQueue' that will write data to the target system. namespace is the remote namespace we wish this work to be done in. The remote work is run in the namespace with the same name as the current namespace when you create the work group. You pass the entry point to call in 'work' argument. This can be either '##class(Classname).ClassMethod' or '$$entry^rtn' and it is expected to return a %Status code on completion. If you want to call a function that does not return any value on completion then prepend the class syntax with '=' such as '=##class(Classname).ClassMethod' or for calling a function do not include the '$$' for example 'entry^rtn'. The item being called may also throw exceptions in order to indicate an error happened which is trapped and converted to a %Status value to be returned in the parent process. You can also pass additional arguments including arrays by reference. Note that the size of the data passed in these arguments should be kept relatively small, if there is a large amount of information that needs to be passed then put this in a global. The security context of the caller is also recorded when this function is called so it can be used when the work is executed.

PostRemoteEvent

ClassMethod PostRemoteEvent(remoteSystem As %String, event As %String) [ Internal ]

Internal method for use with sharding only.
Post a $system.Event to the remote system where remoteSystem the namespace or implied reference that maps to the remote systems IRISLOCALDATA database so you can form a valid global reference with '^|remoteSystem|IRIS.WorkQueue' that will write data to the target system. event is the global name to issue a $system.Event.Signal(event) on.