diff --git a/romac4j/src/main/java/com/rakuten/rit/roma/romac4j/AListPluginClient.java b/romac4j/src/main/java/com/rakuten/rit/roma/romac4j/AListPluginClient.java index 0205269..8e2cc21 100644 --- a/romac4j/src/main/java/com/rakuten/rit/roma/romac4j/AListPluginClient.java +++ b/romac4j/src/main/java/com/rakuten/rit/roma/romac4j/AListPluginClient.java @@ -146,7 +146,7 @@ public int index(String key, String value) throws IOException { } public boolean insert(String key, int index, byte[] value) throws IOException { - return sendCmdS("alist_insert", key, "" + index + " " + value.length, value).isStored(); + return sendCmdS("alist_insert", key, index + " " + value.length, value).isStored(); } public boolean insert(String key, int index, String value) throws IOException { @@ -156,7 +156,8 @@ public boolean insert(String key, int index, String value) throws IOException { public boolean sizedInsert(String key, int size, byte[] value) throws IOException { return sendCmdS("alist_sized_insert", - key, "" + size + " " + value.length, value).isStored(); + key, size + " " + value.length, value).isStored(); + } public boolean sizedInsert(String key, int size, String value) @@ -178,7 +179,7 @@ public boolean swapAndInsert(String key, String value) public boolean swapAndSizedInsert(String key, int size, byte[] value) throws IOException { return sendCmdS("alist_swap_and_sized_insert", - key, "" + size + " " + value.length, value).isStored(); + key, size + " " + value.length, value).isStored(); } public boolean swapAndSizedInsert(String key, int size, String value) @@ -211,7 +212,7 @@ public boolean dayExpiredSwapAndInsert(String key, int dexpt, String value) public boolean expiredSwapAndInsert(String key, int expt, byte[] value) throws IOException { return sendCmdS("alist_expired_swap_and_insert", - key, "" + expt + " " + value.length, value).isStored(); + key, expt + " " + value.length, value).isStored(); } public boolean expiredSwapAndInsert(String key, int expt, String value) @@ -244,7 +245,7 @@ public boolean dayExpiredSwapAndSizedInsert( public boolean expiredSwapAndSizedInsert( String key, int expt, int size, byte[] value) throws IOException { return sendCmdS("alist_expired_swap_and_sized_insert", - key, "" + expt + " " + size + " " + value.length, value).isStored(); + key, expt + " " + size + " " + value.length, value).isStored(); } public boolean expiredSwapAndSizedInsert( @@ -310,7 +311,7 @@ public boolean push(String key, String value) throws IOException { public boolean sizedPush(String key, int size, byte[] value) throws IOException { return sendCmdS("alist_sized_push", - key, "" + size + " " + value.length, value).isStored(); + key, size + " " + value.length, value).isStored(); } public boolean sizedPush(String key, int size, String value) @@ -330,7 +331,7 @@ public boolean swapAndPush(String key, String value) throws IOException { public boolean swapAndSizedPush(String key, int size, byte[] value) throws IOException { return sendCmdS("alist_swap_and_sized_push", - key, "" + size + " " + value.length, value).isStored(); + key, size + " " + value.length, value).isStored(); } public boolean swapAndSizedPush(String key, int size, String value) @@ -341,7 +342,7 @@ public boolean swapAndSizedPush(String key, int size, String value) public boolean expiredSwapAndPush(String key, int expt, byte[] value) throws IOException { return sendCmdS("alist_expired_swap_and_push", - key, "" + expt + " " + value.length, value).isStored(); + key, expt + " " + value.length, value).isStored(); } public boolean expiredSwapAndPush(String key, int expt, String value) @@ -352,7 +353,7 @@ public boolean expiredSwapAndPush(String key, int expt, String value) public boolean expiredSwapAndSizedPush( String key, int expt, int size, byte[] value) throws IOException { return sendCmdS("alist_expired_swap_and_sized_push", - key, "" + expt + " " + size + " " + value.length, value).isStored(); + key, expt + " " + size + " " + value.length, value).isStored(); } public boolean expiredSwapAndSizedPush( @@ -362,7 +363,7 @@ public boolean expiredSwapAndSizedPush( public int updateAt(String key, int index, byte[] value) throws IOException { String ret = sendCmdS("alist_update_at", - key, "" + index + " " + value.length, value).toString(); + key, index + " " + value.length, value).toString(); if(ret.equals("STORED")) return 1; else if(ret.equals("NOT_STORED")) return 0; else if(ret.equals("NOT_FOUND")) return -2; diff --git a/romac4j/src/main/java/com/rakuten/rit/roma/romac4j/RomaClient.java b/romac4j/src/main/java/com/rakuten/rit/roma/romac4j/RomaClient.java index d31ea09..32a64c3 100644 --- a/romac4j/src/main/java/com/rakuten/rit/roma/romac4j/RomaClient.java +++ b/romac4j/src/main/java/com/rakuten/rit/roma/romac4j/RomaClient.java @@ -5,7 +5,7 @@ import java.text.ParseException; import java.util.HashMap; import java.util.Map; - +import com.rakuten.rit.roma.romac4j.connection.RomaSocketPool; import org.apache.log4j.Logger; public class RomaClient extends ClientObject { @@ -19,6 +19,11 @@ public RomaClient(String nodeId) { super(nodeId); } + + public void setTimeout(int timeout) { + RomaSocketPool.getInstance().setTimeout(timeout); + } + public byte[] get(String key) throws IOException { return sendCmdV("get", key).getValue(); } diff --git a/romac4j/src/main/java/com/rakuten/rit/roma/romac4j/connection/RomaSocketPool.java b/romac4j/src/main/java/com/rakuten/rit/roma/romac4j/connection/RomaSocketPool.java index 7a96504..7ba4501 100644 --- a/romac4j/src/main/java/com/rakuten/rit/roma/romac4j/connection/RomaSocketPool.java +++ b/romac4j/src/main/java/com/rakuten/rit/roma/romac4j/connection/RomaSocketPool.java @@ -101,4 +101,8 @@ public void returnConnection(Connection con) { log.info("returnConnection() : close connection"); con.forceClose(); } + + public synchronized void setTimeout(int timeout) { + this.timeout = timeout; + } } diff --git a/romac4j/src/main/java/com/rakuten/rit/roma/romac4j/routing/Routing.java b/romac4j/src/main/java/com/rakuten/rit/roma/romac4j/routing/Routing.java index c4732f0..c902fdd 100644 --- a/romac4j/src/main/java/com/rakuten/rit/roma/romac4j/routing/Routing.java +++ b/romac4j/src/main/java/com/rakuten/rit/roma/romac4j/routing/Routing.java @@ -172,7 +172,8 @@ private String getMklHash() { private RoutingData getRoutingDump() { Connection con = null; RoutingData routingData = null; - Receiver rcv = new RoutingReceiver(); + + Receiver rcv = new RoutingReceiver(null); try { con = getConnection(); con.write("routingdump bin"); @@ -194,7 +195,15 @@ private RoutingData getRoutingDump() { private class RoutingReceiver extends Receiver { private byte[] value = null; - + + RoutingReceiver(){ + this.value = null; + } + + RoutingReceiver(RoutingReceiver routingReceiver){ + this(); + } + @Override public void receive(Connection con) throws TimeoutException, IOException, ParseException { int len = 0;