/** * Creates a new instance given a configuration and a load balancer. * * @param config The configuration details for this job scheduler. * @param balancer The load balancer to use for distributing jobs. */ public MeandreJobScheduler(MeandreJobSchedulerConfig config, MeandreLoadBalancer balancer) { loadBalancer = balancer; workers = config.getServers(); for (MeandreServerProxy server : workers) { loadBalancer.addServer(server); } }
/** Initializes this instance. */ @PostConstruct public void init() { assert config != null : "No configuration was provided to the job scheduler."; workers = config.getServers(); for (MeandreServerProxy server : workers) { loadBalancer.addServer(server); } }
/** * Add a server to the job scheduler. * * @param server Server to add. */ public void addServer(MeandreServerProxy server) { workersLock.lock(); try { workers.add(server); loadBalancer.addServer(server); } finally { workersLock.unlock(); } }