blob: 8deefe2e77d1c5acca5e71db98e71cc9de8b5c23 [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
Yuta HIGUCHI8436c4c2014-02-05 16:55:10 -080012 public static final int MAX_MULTI_READS = Math.max(1, Integer
13 .valueOf(System.getProperty("ramcloud.max_multi_reads", "400")));
Yuta HIGUCHI1ef85c42014-01-29 17:23:21 -080014
Yuta HIGUCHI8436c4c2014-02-05 16:55:10 -080015 public static final int MAX_MULTI_WRITES = Math.max(1, Integer
16 .valueOf(System.getProperty("ramcloud.max_multi_writes", "800")));
Yuta HIGUCHIad7dba92014-02-03 16:47:15 -080017
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}