noc.core.scheduler.scheduler

Module Contents

class noc.core.scheduler.scheduler.Scheduler(name, pool=None, reset_running=False, max_threads=5, ioloop=None, check_time=1000, submit_threshold=None, max_chunk=None, filter=None, service=None, sample=0)

Bases: object

COLLECTION_BASE = noc.schedules.
SUBMIT_THRESHOLD_FACTOR
MAX_CHUNK_FACTOR
UPDATES_PER_CHECK
CACHE_DEFAULT_TTL
get_cache(self)
run(self)

Run scheduler. Common usage

scheduler.run(ioloop=ioloop) ioloop.run()

get_collection(self)

Returns mongo collection instance

get_executor(self)

Returns threadpool executor

reset_running(self)

Reset all running jobs to waiting status

ensure_indexes(self)

Create all nesessary indexes

get_query(self, q)

Combine filter with query and return resulting query

scheduler_tick(self)

Process single scheduler tick :return:

apply_ops(self)
scheduler_loop(self)

Primary scheduler loop

iter_pending_jobs(self, limit)

Yields pending jobs

run_pending(self)

Read and launch all pending jobs

apply_bulk_ops(self)
remove_job(self, jcls, key=None)

Remove job from schedule

remove_job_by_id(self, jid)

Remove job from schedule

submit(self, jcls, key=None, data=None, ts=None, delta=None, keep_ts=False, max_runs=None)

Submit new job or adjust existing one :param jcls: Job class name :param key: Job key :param data: Job data (will be passed as handler’s arguments) :param ts: Set next run time (datetime) :param delta: Set next run time after delta seconds :param keep_ts: Do not touch timestamp of existing jobs,

set timestamp only for created jobs
Parameters:max_runs – Limit maximum runs attempts
set_next_run(self, jid, status=None, ts=None, delta=None, duration=None, context=None, context_version=None, context_key=None)

Reschedule job and set next run time :param jid: Job id :param status: Register run status :param ts: Set next run time (datetime) :param delta: Set next run time after delta seconds :param duration: Set last run duration (in seconds) :param context_version: Job context format vresion :param context: Stored job context :param context_key: Cache key for context

apply_cache_ops(self)
cache_set(self, key, value, version)
apply_metrics(self, d)

Append scheduler metrics to dictionary d :param d: :return:

shutdown(self, sync=False)