// thread pool
final ThreadPoolExecutor executorSend = (ThreadPoolExecutor) Executors.newFixedThreadPool(threadCnt);
// rpcclient
final RPCClient rpcClient = new DefaultRPCClient();
final boolean connectOK =
rpcClient.connect(new InetSocketAddress(remoteHost, remotePort), connectionCnt);
System.out.println("connect server " + remoteHost + (connectOK ? " OK" : " Failed"));
rpcClient.start();
// status
final byte[] message = buildMessage(messageSize);
final AtomicLong callTimesOK = new AtomicLong(0);
final AtomicLong callTimesFailed = new AtomicLong(0);
// multi thread call
for (int i = 0; i < threadCnt; i++) {
executorSend.execute(new Runnable() {
@Override
public void run() {
while (true) {
try {
ByteBuffer repdata = rpcClient.call(message);
if (repdata != null) {
callTimesOK.incrementAndGet();
}
else {
callTimesFailed.incrementAndGet();