use of com.aerospike.client.async.EventPolicy in project aerospike-client-java by aerospike.
the class Main method runBenchmarks.
public void runBenchmarks() throws Exception {
if (this.asyncEnabled) {
EventPolicy eventPolicy = new EventPolicy();
if (args.readPolicy.socketTimeout > 0 && args.readPolicy.socketTimeout < eventPolicy.minTimeout) {
eventPolicy.minTimeout = args.readPolicy.socketTimeout;
}
if (args.writePolicy.socketTimeout > 0 && args.writePolicy.socketTimeout < eventPolicy.minTimeout) {
eventPolicy.minTimeout = args.writePolicy.socketTimeout;
}
switch(this.eventLoopType) {
default:
case DIRECT_NIO:
{
eventLoops = new NioEventLoops(eventPolicy, this.eventLoopSize);
break;
}
case NETTY_NIO:
{
EventLoopGroup group = new NioEventLoopGroup(this.eventLoopSize);
eventLoops = new NettyEventLoops(eventPolicy, group);
break;
}
case NETTY_EPOLL:
{
EventLoopGroup group = new EpollEventLoopGroup(this.eventLoopSize);
eventLoops = new NettyEventLoops(eventPolicy, group);
break;
}
}
try {
clientPolicy.eventLoops = eventLoops;
if (clientPolicy.maxConnsPerNode < this.asyncMaxCommands) {
clientPolicy.maxConnsPerNode = this.asyncMaxCommands;
}
AerospikeClient client = new AerospikeClient(clientPolicy, hosts);
try {
if (initialize) {
doAsyncInserts(client);
} else {
doAsyncRWTest(client);
}
} finally {
client.close();
}
} finally {
eventLoops.close();
}
} else {
AerospikeClient client = new AerospikeClient(clientPolicy, hosts);
try {
if (initialize) {
doInserts(client);
} else {
doRWTest(client);
}
} finally {
client.close();
}
}
}
Aggregations