blob: 1abe74c9a42f2d827ea5e5d213b001f78ea37b02 [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
Yuta HIGUCHIad7dba92014-02-03 16:47:15 -08007 // Value taken from RAMCloud's Status.h
8 // FIXME These constants should be defined by JRamCloud
9 public static final int STATUS_OK = 0;
10
Yuta HIGUCHI1ef85c42014-01-29 17:23:21 -080011 // FIXME come up with a proper way to retrieve configuration
12 public static final int MAX_MULTI_READS = Integer.valueOf(System
13 .getProperty("ramcloud.max_multi_reads", "400"));
14
Yuta HIGUCHIad7dba92014-02-03 16:47:15 -080015 public static final int MAX_MULTI_WRITES = Integer.valueOf(System
16 .getProperty("ramcloud.max_multi_writes", "800"));
17
Yuta HIGUCHI1ef85c42014-01-29 17:23:21 -080018 private static final ThreadLocal<JRamCloud> tlsRCClient = new ThreadLocal<JRamCloud>() {
19 @Override
20 protected JRamCloud initialValue() {
21 // FIXME come up with a proper way to retrieve configuration
22 return new JRamCloud(System.getProperty("ramcloud.coordinator",
23 "fast+udp:host=127.0.0.1,port=12246"));
24 }
25 };
26
27 /**
28 * @return JRamCloud instance intended to be used only within the
29 * SameThread.
30 * @note Do not store the returned instance in a member variable, etc. which
31 * may be accessed later by another thread.
32 */
33 static JRamCloud getClient() {
34 return tlsRCClient.get();
35 }
36
37}