diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/com/orbekk/protobuf/RpcChannel.java | 4 | ||||
-rw-r--r-- | src/test/java/com/orbekk/protobuf/ProtobufFunctionalTest.java | 21 |
2 files changed, 23 insertions, 2 deletions
diff --git a/src/main/java/com/orbekk/protobuf/RpcChannel.java b/src/main/java/com/orbekk/protobuf/RpcChannel.java index a4f1282..2f53349 100644 --- a/src/main/java/com/orbekk/protobuf/RpcChannel.java +++ b/src/main/java/com/orbekk/protobuf/RpcChannel.java @@ -38,8 +38,8 @@ public class RpcChannel extends Thread implements com.google.protobuf.RpcChannel { static final Logger logger = Logger.getLogger(RpcChannel.class.getName()); - private String host; - private int port; + private final String host; + private final int port; private volatile Socket socket = null; private AtomicLong nextId = new AtomicLong(0); private Map<Long, RpcChannel.OngoingRequest> rpcs = diff --git a/src/test/java/com/orbekk/protobuf/ProtobufFunctionalTest.java b/src/test/java/com/orbekk/protobuf/ProtobufFunctionalTest.java index 9e599a4..aa2eea0 100644 --- a/src/test/java/com/orbekk/protobuf/ProtobufFunctionalTest.java +++ b/src/test/java/com/orbekk/protobuf/ProtobufFunctionalTest.java @@ -71,6 +71,27 @@ public class ProtobufFunctionalTest { } } + @org.junit.Test public void testNewRpcChannel() throws Exception { + NewRpcChannel channel = NewRpcChannel.create("localhost", serverport); + Test.Service service = Test.Service.newStub(channel); + Test.Type1 request = Test.Type1.newBuilder().build(); + int count = 1000000; + final Rpc rpc = new Rpc(); + final CountDownLatch stop = new CountDownLatch(count); + long startTime = System.currentTimeMillis(); + for (int i = 0; i < count; i++) { + service.testA(rpc, request, new RpcCallback<Type2>() { + @Override public void run(Type2 result) { + stop.countDown(); + } + }); + } + stop.await(); + long elapsedTime = System.currentTimeMillis() - startTime; + System.out.println("Elapsed time for " + count + " requests: " + + elapsedTime + ". " + count/elapsedTime*1000 + "r/s"); + } + @org.junit.Test public void respondsNormally() throws Exception { Test.Type1 request = Test.Type1.newBuilder().build(); int count = 10; |