...
|
...
|
@@ -22,25 +22,27 @@ public class ConnectionNioTest { |
|
|
Connection connection = new Connection("192.168.157.128", 8000);
|
|
|
Connection connection2 = new Connection("192.168.157.128", 8001);
|
|
|
|
|
|
Operation operation1 = connection.sendNioCommand(Protocol.Command.SET, "myKey".getBytes("UTF-8"), "myKey".getBytes("UTF-8"));
|
|
|
Operation operation12 = connection2.sendNioCommand(Protocol.Command.SET, "myKey".getBytes("UTF-8"), "myKey".getBytes("UTF-8"));
|
|
|
connection.sendNioCommand(Protocol.Command.SET, "myKey".getBytes("UTF-8"), "myKey".getBytes("UTF-8"));
|
|
|
connection2.sendNioCommand(Protocol.Command.SET, "myKey".getBytes("UTF-8"), "myKey".getBytes("UTF-8"));
|
|
|
|
|
|
// connection2.sendNioCommand(Protocol.Command.SET, "myKey".getBytes("UTF-8"), "myKey".getBytes("UTF-8"));
|
|
|
long s1 = System.nanoTime();
|
|
|
Operation operation2 = connection.sendNioCommand(Protocol.Command.GET, "myKey2".getBytes("UTF-8"), "myKey2".getBytes("UTF-8"));
|
|
|
Operation operation3 = connection.sendNioCommand(Protocol.Command.INCR, "myKey3".getBytes("UTF-8"));
|
|
|
Operation operation22 = connection2.sendNioCommand(Protocol.Command.GET, "myKey3".getBytes("UTF-8"));
|
|
|
Operation operation23 = connection2.sendNioCommand(Protocol.Command.GET, "myKey3".getBytes("UTF-8"));
|
|
|
connection.sendNioCommand(Protocol.Command.GET, "myKey2".getBytes("UTF-8"));
|
|
|
connection.sendNioCommand(Protocol.Command.INCR, "myKey3".getBytes("UTF-8"));
|
|
|
connection2.sendNioCommand(Protocol.Command.GET, "myKey3".getBytes("UTF-8"));
|
|
|
connection2.sendNioCommand(Protocol.Command.GET, "myKey3".getBytes("UTF-8"));
|
|
|
|
|
|
// connection2.sendNioCommand(Protocol.Command.GET, "myKey".getBytes("UTF-8"), "myKey".getBytes("UTF-8"));
|
|
|
long s2 = System.nanoTime();
|
|
|
System.out.println(s2 - s1);
|
|
|
|
|
|
System.out.println("result:" + new String((byte[]) operation1.getOperationFuture().get()));
|
|
|
System.out.println("result:" + operation3.getOperationFuture().get());
|
|
|
System.out.println("result:" + operation23.getOperationFuture().get());
|
|
|
System.out.println("result:" + operation22.getOperationFuture().get());
|
|
|
operation2.getOperationFuture().get();
|
|
|
System.out.println("result:" + new String((byte[]) connection.getBinaryBulkReply()));
|
|
|
System.out.println("result:" + connection.getBinaryBulkReply());
|
|
|
System.out.println("result:" + connection.getIntegerReply());
|
|
|
|
|
|
System.out.println("result:" + connection2.getBinaryBulkReply());
|
|
|
System.out.println("result:" + connection2.getBinaryBulkReply());
|
|
|
System.out.println("result:" + connection2.getBinaryBulkReply());
|
|
|
|
|
|
System.out.println(s2 - s1);
|
|
|
try {
|
...
|
...
|
@@ -55,11 +57,11 @@ public class ConnectionNioTest { |
|
|
public void MutiGet() throws IOException, ExecutionException, InterruptedException {
|
|
|
Connection connection = new Connection("192.168.157.128", 8000);
|
|
|
|
|
|
Operation operation1 = connection.sendNioCommand(Protocol.Command.MGET, "myKey".getBytes("UTF-8"), "myKey".getBytes("UTF-8"));
|
|
|
connection.sendNioCommand(Protocol.Command.MGET, "myKey".getBytes("UTF-8"), "myKey".getBytes("UTF-8"));
|
|
|
|
|
|
List list = (List) operation1.getOperationFuture().get();
|
|
|
List list = (List) connection.getBinaryMultiBulkReply();
|
|
|
for (Object o : list) {
|
|
|
System.out.println(new String( (byte[]) o));
|
|
|
System.out.println(new String((byte[]) o));
|
|
|
}
|
|
|
}
|
|
|
} |
...
|
...
|
|