package net.onrc.onos.datastore;

import edu.stanford.ramcloud.JRamCloud;

public class RCClient {

    // Value taken from RAMCloud's Status.h
    // FIXME These constants should be defined by JRamCloud
    public static final int STATUS_OK = 0;

    // FIXME come up with a proper way to retrieve configuration
    public static final int MAX_MULTI_READS = Integer.valueOf(System
	    .getProperty("ramcloud.max_multi_reads", "400"));

    public static final int MAX_MULTI_WRITES = Integer.valueOf(System
	    .getProperty("ramcloud.max_multi_writes", "800"));

    private static final ThreadLocal<JRamCloud> tlsRCClient = new ThreadLocal<JRamCloud>() {
	@Override
	protected JRamCloud initialValue() {
	    // FIXME come up with a proper way to retrieve configuration
	    return new JRamCloud(System.getProperty("ramcloud.coordinator",
		    "fast+udp:host=127.0.0.1,port=12246"));
	}
    };

    /**
     * @return JRamCloud instance intended to be used only within the
     *         SameThread.
     * @note Do not store the returned instance in a member variable, etc. which
     *       may be accessed later by another thread.
     */
    static JRamCloud getClient() {
	return tlsRCClient.get();
    }

}

@@ -351,24 +351,36 @@
 _READS =
+ Math.max(1,
  Integer
 .valueOf
@@ -363,32 +363,38 @@
 h.max(1, Integer
+%0A%09    
 .valueOf(System%0A
@@ -384,38 +384,32 @@
  .valueOf(System
-%0A%09    
 .getProperty(%22ra
@@ -436,24 +436,25 @@
 ds%22, %22400%22))
+)
 ;%0A%0A    publi
@@ -490,24 +490,36 @@
 WRITES =
+ Math.max(1,
  Integer
 .valueOf
@@ -510,16 +510,22 @@
  Integer
+%0A%09    
 .valueOf
@@ -531,22 +531,16 @@
 f(System
-%0A%09    
 .getProp
@@ -580,16 +580,17 @@
  %22800%22))
+)
 ;%0A%0A    p

Add simple sanity check