1   package org.daisy.pipeline.tts;
2   
3   import java.util.Collection;
4   
5   public interface LoadBalancer {
6   	static class Host {
7   		public String address;
8   		public int port;
9   
10  		@Override
11  		public String toString() {
12  			return address + ":" + port;
13  		}
14  	}
15  
16  	/**
17  	 * Can be called from different threads.
18  	 * 
19  	 * @return the next host chosen according to the load balancer's strategy.
20  	 */
21  	Host selectHost();
22  
23  	/**
24  	 * 
25  	 * Must not be called from different threads.
26  	 * 
27  	 * @return all the possible hosts that selectHost() can return. It may be
28  	 *         used for checking that all the servers are up. It may not return
29  	 *         the master host as long as it cannot be returned by selectHost().
30  	 */
31  	Collection<Host> getAllHosts();
32  
33  	/**
34  	 * Can be called from different threads.
35  	 * 
36  	 * @return the host that should be used for querying general information
37  	 *         such as the available voices etc.
38  	 */
39  	Host getMaster();
40  
41  	/**
42  	 * Discard the given host. After this call, selectHost() will no longer
43  	 * return @param h. Must not be called from different threads.
44  	 */
45  	void discard(Host h);
46  }