blob: be9fce52700d997686d4bda16dd7e26b212ea2fc [file] [log] [blame]
Jonathan Hart6df90172014-04-03 10:13:11 -07001package net.onrc.onos.core.datastore;
Yuta HIGUCHI66ca1bf2014-03-12 18:34:09 -07002
Jonathan Hart6df90172014-04-03 10:13:11 -07003import net.onrc.onos.core.datastore.hazelcast.HZClient;
4import net.onrc.onos.core.datastore.ramcloud.RCClient;
Yuta HIGUCHI66ca1bf2014-03-12 18:34:09 -07005
Yuta HIGUCHI6a643132014-03-18 22:39:27 -07006// This class probably need to be a service
Yuta HIGUCHI66ca1bf2014-03-12 18:34:09 -07007public class DataStoreClient {
Jonathan Hart6df90172014-04-03 10:13:11 -07008 private static final String BACKEND = System.getProperty("net.onrc.onos.core.datastore.backend", "hazelcast");
Yuta HIGUCHI6a643132014-03-18 22:39:27 -07009
10 // Suppresses default constructor, ensuring non-instantiability.
Ray Milkey269ffb92014-04-03 14:43:30 -070011 private DataStoreClient() {
12 }
Yuta HIGUCHI6a643132014-03-18 22:39:27 -070013
Yuta HIGUCHI66ca1bf2014-03-12 18:34:09 -070014 public static IKVClient getClient() {
Yuta HIGUCHI826b4a42014-03-24 13:10:33 -070015 // TODO read config and return appropriate IKVClient
16 switch (BACKEND) {
Ray Milkey269ffb92014-04-03 14:43:30 -070017 case "ramcloud":
18 return RCClient.getClient();
19 case "hazelcast":
20 return HZClient.getClient();
21 default:
22 return HZClient.getClient();
Yuta HIGUCHI826b4a42014-03-24 13:10:33 -070023 }
Yuta HIGUCHI66ca1bf2014-03-12 18:34:09 -070024 }
Yuta HIGUCHI6a643132014-03-18 22:39:27 -070025
26
Yuta HIGUCHI66ca1bf2014-03-12 18:34:09 -070027}