Package ganeti :: Module jqueue
[hide private]
[frames] | no frames]

Module jqueue

source code

Module implementing the job queue handling.

Locking: there's a single, large lock in the JobQueue class. It's used by all other classes in this module.

Classes [hide private]
  CancelJob
Special exception to cancel a job.
  QueueShutdown
Special exception to abort a job when the job queue is shutting down.
  _SimpleJobQuery
Wrapper for job queries.
  _QueuedOpCode
Encapsulates an opcode object.
  _QueuedJob
In-memory job representation.
  _OpExecCallbacks
  _JobChangesChecker
  _JobFileChangesWaiter
  _JobChangesWaiter
  _WaitForJobChangesHelper
Helper class using inotify to wait for changes in a job file.
  _TimeoutStrategyWrapper
  _OpExecContext
  _JobProcessor
  _JobQueueWorker
The actual job workers.
  _JobQueueWorkerPool
Simple class implementing a job-processing workerpool.
  _JobDependencyManager
Keeps track of job dependencies.
  JobQueue
Queue used to manage the jobs.
Functions [hide private]
tuple
TimeStampNow()
Returns the current timestamp.
source code
 
_CallJqUpdate(runner, names, file_name, content)
Updates job queue file after virtualizing filename.
source code
 
_EncodeOpError(err)
Encodes an error which occurred while processing an opcode.
source code
 
_EvaluateJobProcessorResult(depmgr, job, result)
Looks at a result from _JobProcessor for a job.
source code
 
_RequireOpenQueue(fn)
Decorator for "public" functions.
source code
 
_RequireNonDrainedQueue(fn)
Decorator checking for a non-drained queue.
source code
Variables [hide private]
  JOBQUEUE_THREADS = 25
the number of worker threads we start for processing jobs
  _LOCK = "_lock"
  _QUEUE = "_queue"
  _GetIdAttr = operator.attrgetter("id")
Retrieves "id" attribute

Imports: logging, errno, time, weakref, threading, itertools, operator, pyinotify, asyncnotifier, constants, serializer, workerpool, locking, luxi, opcodes, opcodes_base, errors, mcpu, utils, jstore, rpc, runtime, netutils, compat, ht, query, qlang, pathutils, vcluster


Function Details [hide private]

TimeStampNow()

source code 

Returns the current timestamp.

Returns: tuple
the current time in the (seconds, microseconds) format

_EvaluateJobProcessorResult(depmgr, job, result)

source code 

Looks at a result from _JobProcessor for a job.

To be used in a _JobQueueWorker.

_RequireOpenQueue(fn)

source code 

Decorator for "public" functions.

This function should be used for all 'public' functions. That is, functions usually called from other classes. Note that this should be applied only to methods (not plain functions), since it expects that the decorated function is called with a first argument that has a '_queue_filelock' argument.

Warning: Use this decorator only after locking.ssynchronized

Example:

 @locking.ssynchronized(_LOCK)
 @_RequireOpenQueue
 def Example(self):
   pass

_RequireNonDrainedQueue(fn)

source code 

Decorator checking for a non-drained queue.

To be used with functions submitting new jobs.