Package starcluster :: Package commands :: Module loadbalance
[hide private]
[frames] | no frames]

Source Code for Module starcluster.commands.loadbalance

 1  from starcluster import exception 
 2  from starcluster.balancers import sge 
 3   
 4  from completers import ClusterCompleter 
 5   
 6   
7 -class CmdLoadBalance(ClusterCompleter):
8 """ 9 loadbalance <cluster_tag> 10 11 Start the SGE Load Balancer. 12 13 Example: 14 15 $ starcluster loadbalance mycluster 16 17 This command will endlessly attempt to monitor and load balance 'mycluster' 18 based on the current SGE load. You can also have the load balancer plot the 19 various stats it's monitoring over time using the --plot-stats option: 20 21 $ starcluster loadbalance -p mycluster 22 23 If you just want the stats data and not the plots use the --dump-stats 24 option instead: 25 26 $ starcluster loadbalance -d mycluster 27 28 See "starcluster loadbalance --help" for more details on the '-p' and '-d' 29 options as well as other options for tuning the SGE load balancer 30 algorithm. 31 """ 32 33 names = ['loadbalance', 'bal'] 34
35 - def addopts(self, parser):
36 parser.add_option("-d", "--dump-stats", dest="dump_stats", 37 action="store_true", default=False, 38 help="Output stats to a csv file at each iteration") 39 parser.add_option("-D", "--dump-stats-file", dest="stats_file", 40 action="store", default=None, 41 help="File to dump stats to (default: %s)" % 42 sge.DEFAULT_STATS_FILE % "<cluster_tag>") 43 parser.add_option("-p", "--plot-stats", dest="plot_stats", 44 action="store_true", default=False, 45 help="Plot usage stats at each iteration") 46 parser.add_option("-P", "--plot-output-dir", dest="plot_output_dir", 47 action="store", default=None, 48 help="Output directory for stats plots " 49 "(default: %s)" % sge.DEFAULT_STATS_DIR % 50 "<cluster_tag>") 51 parser.add_option("-i", "--interval", dest="interval", 52 action="store", type="int", default=None, 53 help="Polling interval for load balancer") 54 parser.add_option("-m", "--max_nodes", dest="max_nodes", 55 action="store", type="int", default=None, 56 help="Maximum # of nodes in cluster") 57 parser.add_option("-w", "--job_wait_time", dest="wait_time", 58 action="store", type="int", default=None, 59 help=("Maximum wait time for a job before " 60 "adding nodes, seconds")) 61 parser.add_option("-a", "--add_nodes_per_iter", dest="add_pi", 62 action="store", type="int", default=None, 63 help="Number of nodes to add per iteration") 64 parser.add_option("-k", "--kill_after", dest="kill_after", 65 action="store", type="int", default=None, 66 help="Minutes after which a node can be killed") 67 parser.add_option("-s", "--stabilization_time", dest="stab", 68 action="store", type="int", default=None, 69 help="Seconds to wait before cluster stabilizes") 70 parser.add_option("-l", "--lookback_window", dest="lookback_win", 71 action="store", type="int", default=None, 72 help="Minutes to look back for past job history") 73 parser.add_option("-n", "--min_nodes", dest="min_nodes", 74 action="store", type="int", default=None, 75 help="Minimum number of nodes in cluster") 76 parser.add_option("-K", "--kill-master", dest="allow_master_kill", 77 action="store_true", default=None, 78 help="Allow the master to be killed when " 79 "the queue is empty (EXPERIMENTAL).")
80
81 - def execute(self, args):
82 if not self.cfg.globals.enable_experimental: 83 raise exception.ExperimentalFeature("The 'loadbalance' command") 84 if len(args) != 1: 85 self.parser.error("please specify a <cluster_tag>") 86 cluster_tag = args[0] 87 cluster = self.cm.get_cluster(cluster_tag) 88 lb = sge.SGELoadBalancer(**self.specified_options_dict) 89 lb.run(cluster)
90