summaryrefslogtreecommitdiffstats
path: root/src/main/java/derms/replica2/Hosts.java
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2024-11-28 17:32:28 -0500
committerSam Anthony <sam@samanthony.xyz>2024-11-28 17:32:28 -0500
commitd267dd1dda606f0c56d8afaa7187485e60ebfd86 (patch)
treee1bca5933aa7e5e9793773057fd5616ff65a9eb8 /src/main/java/derms/replica2/Hosts.java
parent6654546671eea9f9becd32b3160a134802659cbc (diff)
downloadsoen423-d267dd1dda606f0c56d8afaa7187485e60ebfd86.zip
move replica2 to top level
Diffstat (limited to 'src/main/java/derms/replica2/Hosts.java')
-rw-r--r--src/main/java/derms/replica2/Hosts.java26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/main/java/derms/replica2/Hosts.java b/src/main/java/derms/replica2/Hosts.java
new file mode 100644
index 0000000..1392b15
--- /dev/null
+++ b/src/main/java/derms/replica2/Hosts.java
@@ -0,0 +1,26 @@
+package derms.replica2;
+
+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");
+ }
+}