blob: df6a8ceda6790078088faada4c5137523000226e [file] [log] [blame]
Yuta HIGUCHI1ef85c42014-01-29 17:23:21 -08001package net.onrc.onos.datastore;
2
3import edu.stanford.ramcloud.JRamCloud;
4
5public class RCClient {
6
7 // FIXME come up with a proper way to retrieve configuration
8 public static final int MAX_MULTI_READS = Integer.valueOf(System
9 .getProperty("ramcloud.max_multi_reads", "400"));
10
11 private static final ThreadLocal<JRamCloud> tlsRCClient = new ThreadLocal<JRamCloud>() {
12 @Override
13 protected JRamCloud initialValue() {
14 // FIXME come up with a proper way to retrieve configuration
15 return new JRamCloud(System.getProperty("ramcloud.coordinator",
16 "fast+udp:host=127.0.0.1,port=12246"));
17 }
18 };
19
20 /**
21 * @return JRamCloud instance intended to be used only within the
22 * SameThread.
23 * @note Do not store the returned instance in a member variable, etc. which
24 * may be accessed later by another thread.
25 */
26 static JRamCloud getClient() {
27 return tlsRCClient.get();
28 }
29
30}