new scheduling logic made linspector thread senseless - removed
This commit is contained in:
parent
cbb106ee8a
commit
ffc754c608
1 changed files with 31 additions and 14 deletions
|
|
@ -24,18 +24,17 @@ __version__ = "0.11.1"
|
|||
__default_config__ = "./examples/minimal.json"
|
||||
|
||||
import argparse
|
||||
import datetime
|
||||
import logging
|
||||
import logging.handlers
|
||||
import os
|
||||
import os.path as path
|
||||
import Queue
|
||||
import time
|
||||
|
||||
from linspector.linspector import Linspector
|
||||
from linspector.core.interface import LinspectorInterface
|
||||
from linspector.config.parser import FullConfigParser
|
||||
from linspector.core.scheduler import Scheduler
|
||||
from linspector.backends.jsonrpc import JsonrpcBackend
|
||||
from linspector.config.parser import FullConfigParser
|
||||
from linspector.core.interface import LinspectorInterface
|
||||
from linspector.core.job import Job
|
||||
from linspector.core.scheduler import Scheduler
|
||||
from linspector.frontends.lish import LishFrontend
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
|
@ -69,6 +68,10 @@ def parse_args():
|
|||
return parser.parse_args()
|
||||
|
||||
|
||||
def handle_job(jobInfo):
|
||||
jobInfo.handle_call()
|
||||
|
||||
|
||||
def main():
|
||||
args = parse_args()
|
||||
|
||||
|
|
@ -90,15 +93,28 @@ def main():
|
|||
scheduler = Scheduler({"apscheduler.threadpool.max_threads": 1000})
|
||||
scheduler.start()
|
||||
|
||||
q = Queue.Queue()
|
||||
linspector = Linspector(linConf, core, scheduler, q)
|
||||
linspector.daemon = True
|
||||
linspector.start()
|
||||
start_date = datetime.datetime.now()
|
||||
time_delta = 0
|
||||
jobs = []
|
||||
for layout in linConf.get_enabled_layouts():
|
||||
for hostgroup in layout.get_hostgroups():
|
||||
for service in hostgroup.get_services():
|
||||
for host in hostgroup.get_hosts():
|
||||
for period in service.get_periods():
|
||||
time_delta += 2.315379
|
||||
new_start_date = start_date + datetime.timedelta(seconds=time_delta)
|
||||
job = Job(service,
|
||||
host,
|
||||
hostgroup.get_members(),
|
||||
hostgroup.get_processors(),
|
||||
core,
|
||||
hostgroup)
|
||||
schedulerJob = period.createJob(scheduler, job, handle_job, start_date=new_start_date)
|
||||
if schedulerJob is not None:
|
||||
job.set_job(schedulerJob)
|
||||
jobs.append(job)
|
||||
|
||||
while q.qsize() < 1:
|
||||
time.sleep(1)
|
||||
|
||||
interface = LinspectorInterface(q.get(), scheduler, linConf)
|
||||
interface = LinspectorInterface(jobs, scheduler, linConf)
|
||||
|
||||
if "jsonrpc_backend" in core and core["jsonrpc_backend"]:
|
||||
jsonrpc = JsonrpcBackend(interface, core)
|
||||
|
|
@ -106,6 +122,7 @@ def main():
|
|||
jsonrpc.start()
|
||||
|
||||
# Just for debug purposes:
|
||||
#import time
|
||||
#while True:
|
||||
# print "Threads: " + '%d/%d' % (scheduler._threadpool.num_threads, scheduler._threadpool.max_threads)
|
||||
# time.sleep(0.5)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue