blob: 4d24745b7d4f3e2c1f43f2e86622bfe56a2b5e27 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
package derms.replica.replica2;
import java.net.InetAddress;
import java.util.Collection;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class Servers {
private Map<City, InetAddress> servers = new ConcurrentHashMap<City, InetAddress>();
/** Returns the address of the server located in the specified city, or null if there is no server in the city. */
public InetAddress get(City city) {
return servers.get(city);
}
/**
* Associates the specified server address with the specified city.
* If there was already a server associated with the city, the old value is replaced.
* @param city the city where the server is located
* @param addr the address of the server
* @return the previous server address, or null if there was no server associated with this city.
*/
public InetAddress put(City city, InetAddress addr) {
return servers.put(city, addr);
}
public Collection<InetAddress> all() {
return servers.values();
}
public int size() {
return servers.size();
}
}
|