IRISLIB database
ShardWorkMgr Class Reference

Manage distributing work to other systems in a sharded environment. More...

Inheritance diagram for ShardWorkMgr:
Collaboration diagram for ShardWorkMgr:

Public Member Functions

_.Library.Status Broadcast (_.Library.String set, _.Library.String work, _.Library.String args)
 Manage distributing work to other systems in a sharded environment. More...
 
_.Library.Status Map (_.Library.String set, _.Library.String classname, _.Library.List idlist, _.Library.String work, _.Library.String args)
 Map the work over a set of id's in a class. More...
 
- Public Member Functions inherited from AbstractWorkMgr
_.Library.Status OnNew (_.Library.String qstruct, _.Library.Integer numberjobs, category, target)
 Initialize the worker jobs so they are ready to start accepting work items. More...
 
_.Library.Status Cleanup (_.Library.String work, _.Library.String args)
 Normally when a work group is deleted the delete/close is synchronous and so waits for all the worker jobs to finish. More...
 
_.Library.Status Clear (_.Library.Integer timeout)
 Clear any existing work from this work queue, it does this by removing the queue and creating a new one. More...
 
_.Library.Status Setup (_.Library.String work, _.Library.String args)
 If you queue a large number of units of work and there is some common setup needed by any process that will. More...
 
_.Library.Status Sync (_.Library.String qspec, _.Library.String errorlog)
 After work has been queued this will wait for all the workers to complete. More...
 
_.Library.Status TearDown (_.Library.String work, _.Library.String args)
 This is a companion method to <method>Setup</method> to restore a workers process to the previous state if. More...
 
_.Library.Status Wait (_.Library.String qspec, _.Library.Boolean atend, _.Library.Integer timeout)
 After work has been queued you can call this to process some work completion events and then return to the caller where the caller. More...
 
_.Library.Status WaitForComplete (_.Library.String qspec, _.Library.String errorlog)
 
_.Library.Boolean WaitOne (_.Library.Integer timeout, _.Library.Status worksc, _.Library.Binary workargs, _.Library.Binary workresult)
 

Additional Inherited Members

- Static Public Member Functions inherited from AbstractWorkMgr
_.Library.String Help (_.Library.String method)
 Write out a list of the methods of this object to the console. More...
 
_.SYSTEM.AbstractWorkMgr Initialize (_.Library.String qspec, _.Library.Status sc, _.Library.Integer numworkers)
 Deprecated method implemented for compatibility with code used to calling 'Initialize' method but new users should call New. More...
 
- Public Attributes inherited from AbstractWorkMgr
 DeleteTimeout
 When the work queue oref is killed or goes out of scope this is the timeout we pass to the call the destructor. More...
 
 NumActiveWorkers
 For local WQM groups number of active workers attached to this group. More...
 
 NumWorkers
 For local WQM group after the work group is created the number of workers allocated to this group. More...
 

Detailed Description

Manage distributing work to other systems in a sharded environment.

This is modelled on the <class>SYSTEM.WorkMgr</class> 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.

Member Function Documentation

◆ Broadcast()

_.Library.Status Broadcast ( _.Library.String  set,
_.Library.String  work,
_.Library.String  args 
)

Manage distributing work to other systems in a sharded environment.

This is modelled on the <class>SYSTEM.WorkMgr</class> 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.

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 <method>Sync</method> to wait for all work to complete or <method>WaitOne</method> 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 <method>Sync</method> 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 <method>WaitOne</method> call via the byref workresult argument.

◆ Map()

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 <method>Sync</method> 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 <method>WaitOne</method> call via the byref workresult argument.