Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(452)

Side by Side Diff: scheduler/monitor_db.py

Issue 6246035: Merge remote branch 'cros/upstream' into master (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/autotest.git@master
Patch Set: patch Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/python -u 1 #!/usr/bin/python -u
2 2
3 """ 3 """
4 Autotest scheduler 4 Autotest scheduler
5 """ 5 """
6 6
7 7
8 import common 8 import common
9 import datetime, errno, optparse, os, pwd, Queue, re, shutil, signal 9 import datetime, errno, optparse, os, pwd, Queue, re, shutil, signal
10 import smtplib, socket, stat, subprocess, sys, tempfile, time, traceback, urllib 10 import smtplib, socket, stat, subprocess, sys, tempfile, time, traceback, urllib
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 autoserv_argv += ['--image', job.update_image_path] 255 autoserv_argv += ['--image', job.update_image_path]
256 if verbose: 256 if verbose:
257 autoserv_argv.append('--verbose') 257 autoserv_argv.append('--verbose')
258 return autoserv_argv + extra_args 258 return autoserv_argv + extra_args
259 259
260 260
261 class SchedulerError(Exception): 261 class SchedulerError(Exception):
262 """Raised by HostScheduler when an inconsistent state occurs.""" 262 """Raised by HostScheduler when an inconsistent state occurs."""
263 263
264 264
265 class HostScheduler(metahost_scheduler.HostSchedulingUtility): 265 class BaseHostScheduler(metahost_scheduler.HostSchedulingUtility):
266 """Handles the logic for choosing when to run jobs and on which hosts. 266 """Handles the logic for choosing when to run jobs and on which hosts.
267 267
268 This class makes several queries to the database on each tick, building up 268 This class makes several queries to the database on each tick, building up
269 some auxiliary data structures and using them to determine which hosts are 269 some auxiliary data structures and using them to determine which hosts are
270 eligible to run which jobs, taking into account all the various factors that 270 eligible to run which jobs, taking into account all the various factors that
271 affect that. 271 affect that.
272 272
273 In the past this was done with one or two very large, complex database 273 In the past this was done with one or two very large, complex database
274 queries. It has proven much simpler and faster to build these auxiliary 274 queries. It has proven much simpler and faster to build these auxiliary
275 data structures and perform the logic in Python. 275 data structures and perform the logic in Python.
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 host_list = [] 658 host_list = []
659 for host in eligible_hosts_in_group: 659 for host in eligible_hosts_in_group:
660 hosts_in_label.discard(host.id) 660 hosts_in_label.discard(host.id)
661 self._hosts_available.pop(host.id) 661 self._hosts_available.pop(host.id)
662 host_list.append(host) 662 host_list.append(host)
663 return host_list 663 return host_list
664 664
665 return [] 665 return []
666 666
667 667
668 site_host_scheduler = utils.import_site_class(__file__,
669 "autotest_lib.scheduler.site_host_scheduler",
670 "site_host_scheduler", BaseHostScheduler)
671
672
673 class HostScheduler(site_host_scheduler):
674 pass
675
676
668 class Dispatcher(object): 677 class Dispatcher(object):
669 def __init__(self): 678 def __init__(self):
670 self._agents = [] 679 self._agents = []
671 self._last_clean_time = time.time() 680 self._last_clean_time = time.time()
672 self._host_scheduler = HostScheduler() 681 self._host_scheduler = HostScheduler()
673 user_cleanup_time = scheduler_config.config.clean_interval 682 user_cleanup_time = scheduler_config.config.clean_interval
674 self._periodic_cleanup = monitor_db_cleanup.UserCleanup( 683 self._periodic_cleanup = monitor_db_cleanup.UserCleanup(
675 _db, user_cleanup_time) 684 _db, user_cleanup_time)
676 self._24hr_upkeep = monitor_db_cleanup.TwentyFourHourUpkeep(_db) 685 self._24hr_upkeep = monitor_db_cleanup.TwentyFourHourUpkeep(_db)
677 self._host_agents = {} 686 self._host_agents = {}
(...skipping 1922 matching lines...) Expand 10 before | Expand all | Expand 10 after
2600 paired_process = self._paired_with_monitor().get_process() 2609 paired_process = self._paired_with_monitor().get_process()
2601 _drone_manager.write_lines_to_file( 2610 _drone_manager.write_lines_to_file(
2602 failed_file, ['Archiving failed with exit code %s' 2611 failed_file, ['Archiving failed with exit code %s'
2603 % self.monitor.exit_code()], 2612 % self.monitor.exit_code()],
2604 paired_with_process=paired_process) 2613 paired_with_process=paired_process)
2605 self._set_all_statuses(self._final_status()) 2614 self._set_all_statuses(self._final_status())
2606 2615
2607 2616
2608 if __name__ == '__main__': 2617 if __name__ == '__main__':
2609 main() 2618 main()
OLDNEW
« cli/job.py ('K') | « scheduler/metahost_scheduler.py ('k') | server/autoserv » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698