Yuta HIGUCHI | 1ef85c4 | 2014-01-29 17:23:21 -0800 | [diff] [blame] | 1 | package net.onrc.onos.datastore; |
| 2 | |
| 3 | import edu.stanford.ramcloud.JRamCloud; |
| 4 | |
| 5 | public class RCClient { |
| 6 | |
Yuta HIGUCHI | ad7dba9 | 2014-02-03 16:47:15 -0800 | [diff] [blame] | 7 | // 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 HIGUCHI | 1ef85c4 | 2014-01-29 17:23:21 -0800 | [diff] [blame] | 11 | // 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 HIGUCHI | ad7dba9 | 2014-02-03 16:47:15 -0800 | [diff] [blame] | 15 | public static final int MAX_MULTI_WRITES = Integer.valueOf(System |
| 16 | .getProperty("ramcloud.max_multi_writes", "800")); |
| 17 | |
Yuta HIGUCHI | 1ef85c4 | 2014-01-29 17:23:21 -0800 | [diff] [blame] | 18 | 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 | } |