summaryrefslogtreecommitdiffstats
path: root/src/main/java/derms/replica2/Hosts.java
blob: 8df77c17fa334b95aecab53adb684f39ede35d09 (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
package derms.replica2;

import derms.City;

import java.net.UnknownHostException;
import java.util.HashMap;
import java.util.Map;

class Hosts {
    private static Map<City, String> hosts = null;

    static String get(City city) throws UnknownHostException {
        if (hosts == null)
            init();

        String host = hosts.get(city);
        if (host == null)
            throw new UnknownHostException("unknown host: "+city);
        return host;
    }

    private static void init() {
        hosts = new HashMap<City, String>();
        hosts.put(new City("MTL"), "alpine1");
        hosts.put(new City("QUE"), "alpine2");
        hosts.put(new City("SHE"), "alpine3");
    }
}