NAME
Disbatch - a scalable distributed batch processing framework using MongoDB.
VERSION
version 4.103
SUBROUTINES
- new(class => $class, ...)
-
"class" defaults to "Disbatch", and the value is then lowercased.
"node" is the hostname.
Anything else is put into $self.
- logger($type)
-
Parameters: type (string, optional)
Returns a Log::Log4perl object.
- mongo
-
Parameters: none
Returns a MongoDB::Database object.
- nodes
-
Parameters: none
Returns a MongoDB::Collection object for collection "nodes".
- queues
-
Parameters: none
Returns a MongoDB::Collection object for collection "queues".
- tasks
-
Parameters: none
Returns a MongoDB::Collection object for collection "tasks".
- balance
-
Parameters: none
Returns a MongoDB::Collection object for collection "balance".
- load_config
-
Parameters: none
Loads
$self->{config_file}only if$self->{config}is undefined.Anything in the config file at startup is static and cannot be changed without restarting disbatchd.
Returns nothing.
- ensure_indexes
-
Parameters: none
Ensures the proper MongoDB indexes are created for
tasks,tasks.files, andtasks.chunkscollections.Returns nothing.
- validate_plugins
-
Parameters: none
Validates plugins for defined queues.
Returns nothing.
- revalidate_plugins
-
Parameters: none
Clears plugin validation and re-runs
validate_plugins().Returns nothing.
- scheduler_report
-
Parameters: none
Used by the Disbatch Command Interface to get queue information.
Returns an
ARRAYcontainingHASHes of queue information.Throws errors.
- update_node_status
-
Parameters: none
Updates the node document with the current timestamp and queues as returned by
scheduler_report().Returns nothing.
- claim_task($queue)
-
Parameters: queue document
Claims a task (sets status to -1 and sets node to hostname) for the given queue.
Returns a task document, or undef if no queued task found.
- unclaim_task($task_id)
-
Parameters: MongoDB::OID object for a task
Sets the task's node to null, status to -2, and update mtime if it has status -1 and this node's hostname.
Returns a task document, or undef if a matching task is not found.
- orphaned_tasks
-
Parameters: none
Sets status to -6 for all tasks for this node with status -1 and an mtime of more than 300 seconds ago.
Returns nothing.
- start_task($queue, $task)
-
Parameters: queue document, task document
Will fork and exec
$self->{config}{task_runner}to start the given task. If the exec fails, it will set threads to 0 for the given queue and callunclaim_task().Returns nothing.
- count_tasks($queue_id, $status, $node)
-
Parameters: MongoDB::OID object for a queue or a query operator value or
undef, a status or a query operator value orundef, a node orundef.Counts all tasks for the given
$queue_idwith given$statusand$node.Used by the below
count_*subroutines. If any of the parameters areundef, they will not be added to the query.Returns: a non-negative integer, or undef if an error.
- count_queued($queue_id)
- count_running($queue_id)
- count_node_running($queue_id)
- count_completed($queue_id)
- count_total($queue_id)
-
Parameters: MongoDB::OID object for a queue or a query operator value or
undefCounts queued (status <= -2), running (status of 0 or -1), running on this node, completed (status >= 1), or all tasks for the given queue (status <= -2).
Returns: a non-negative integer, or undef if an error.
- is_active_queue($queue_id)
-
Parameters: MongoDB::OID object for a queue
Checks
config.activequeuesif it has entries, and returns 1 if given queue is defined in it or 0 if not. If it does not have entries, checksconfig.ignorequeuesif it has entries, and returns 0 if given queue is defined in it or 1 if not.Returns 1 or 0.
- process_queues
-
Parameters: none
Will claim and start as many tasks for each queue as allowed by the current node's
maxthreadsand each queue'sthreads.Returns nothing.
- put_gfs($content, $filename, $metadata)
-
Parameters: UTF-8 content to store, optional filename to store it as, optional metadata
HASHStores UTF-8 content in a custom GridFS format that stores data as strings instead of as BinData.
Returns a
MongoDB::OIDobject for the ID inserted in thetasks.filescollection. - get_gfs($filename_or_id, $metadata)
-
Parameters: filename or
MongoDB::OIDobject, optional metadataHASHGets UTF-8 content from the custom GridFS format. Metadata is only used if given a filename instead of a
MongoDB::OIDobject.Returns: content string.
SEE ALSO
AUTHORS
Ashley Willis <awillis@synacor.com>
Matt Busigin
COPYRIGHT AND LICENSE
This software is Copyright (c) 2016, 2019 by Ashley Willis.
This is free software, licensed under:
The Apache License, Version 2.0, January 2004