Search in sources :

Example 1 with EventPolicy

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();
        }
    }
}
Also used : AerospikeClient(com.aerospike.client.AerospikeClient) EpollEventLoopGroup(io.netty.channel.epoll.EpollEventLoopGroup) EventLoopGroup(io.netty.channel.EventLoopGroup) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) NettyEventLoops(com.aerospike.client.async.NettyEventLoops) EpollEventLoopGroup(io.netty.channel.epoll.EpollEventLoopGroup) EventPolicy(com.aerospike.client.async.EventPolicy) NioEventLoops(com.aerospike.client.async.NioEventLoops) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup)

Aggregations

AerospikeClient (com.aerospike.client.AerospikeClient)1 EventPolicy (com.aerospike.client.async.EventPolicy)1 NettyEventLoops (com.aerospike.client.async.NettyEventLoops)1 NioEventLoops (com.aerospike.client.async.NioEventLoops)1 EventLoopGroup (io.netty.channel.EventLoopGroup)1 EpollEventLoopGroup (io.netty.channel.epoll.EpollEventLoopGroup)1 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)1