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 | |
| 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 | } |