Search in sources :

Example 1 with IOUringEventLoopGroup

use of io.netty.incubator.channel.uring.IOUringEventLoopGroup 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, this.eventLoopType);
                    break;
                }
            case NETTY_EPOLL:
                {
                    EventLoopGroup group = new EpollEventLoopGroup(this.eventLoopSize);
                    eventLoops = new NettyEventLoops(eventPolicy, group, this.eventLoopType);
                    break;
                }
            case NETTY_KQUEUE:
                {
                    EventLoopGroup group = new KQueueEventLoopGroup(this.eventLoopSize);
                    eventLoops = new NettyEventLoops(eventPolicy, group, this.eventLoopType);
                    break;
                }
            case NETTY_IOURING:
                {
                    EventLoopGroup group = new IOUringEventLoopGroup(this.eventLoopSize);
                    eventLoops = new NettyEventLoops(eventPolicy, group, this.eventLoopType);
                    break;
                }
        }
        try {
            clientPolicy.eventLoops = eventLoops;
            if (clientPolicy.asyncMaxConnsPerNode < this.asyncMaxCommands) {
                clientPolicy.asyncMaxConnsPerNode = 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) IOUringEventLoopGroup(io.netty.incubator.channel.uring.IOUringEventLoopGroup) EpollEventLoopGroup(io.netty.channel.epoll.EpollEventLoopGroup) KQueueEventLoopGroup(io.netty.channel.kqueue.KQueueEventLoopGroup) EventLoopGroup(io.netty.channel.EventLoopGroup) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) NettyEventLoops(com.aerospike.client.async.NettyEventLoops) EpollEventLoopGroup(io.netty.channel.epoll.EpollEventLoopGroup) KQueueEventLoopGroup(io.netty.channel.kqueue.KQueueEventLoopGroup) EventPolicy(com.aerospike.client.async.EventPolicy) NioEventLoops(com.aerospike.client.async.NioEventLoops) IOUringEventLoopGroup(io.netty.incubator.channel.uring.IOUringEventLoopGroup) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup)

Example 2 with IOUringEventLoopGroup

use of io.netty.incubator.channel.uring.IOUringEventLoopGroup in project aerospike-client-java by aerospike.

the class AsyncExample method runExamples.

/**
 * Connect and run one or more asynchronous client examples.
 */
public static void runExamples(Console console, Parameters params, List<String> examples) throws Exception {
    EventPolicy eventPolicy = new EventPolicy();
    eventPolicy.maxCommandsInProcess = params.maxCommandsInProcess;
    eventPolicy.maxCommandsInQueue = params.maxCommandsInQueue;
    EventLoops eventLoops;
    switch(params.eventLoopType) {
        default:
        case DIRECT_NIO:
            {
                eventLoops = new NioEventLoops(eventPolicy, 1);
                break;
            }
        case NETTY_NIO:
            {
                EventLoopGroup group = new NioEventLoopGroup(1);
                eventLoops = new NettyEventLoops(eventPolicy, group, params.eventLoopType);
                break;
            }
        case NETTY_EPOLL:
            {
                EventLoopGroup group = new EpollEventLoopGroup(1);
                eventLoops = new NettyEventLoops(eventPolicy, group, params.eventLoopType);
                break;
            }
        case NETTY_KQUEUE:
            {
                EventLoopGroup group = new KQueueEventLoopGroup(1);
                eventLoops = new NettyEventLoops(eventPolicy, group, params.eventLoopType);
                break;
            }
        case NETTY_IOURING:
            {
                EventLoopGroup group = new IOUringEventLoopGroup(1);
                eventLoops = new NettyEventLoops(eventPolicy, group, params.eventLoopType);
                break;
            }
    }
    try {
        ClientPolicy policy = new ClientPolicy();
        policy.eventLoops = eventLoops;
        policy.user = params.user;
        policy.password = params.password;
        policy.authMode = params.authMode;
        policy.tlsPolicy = params.tlsPolicy;
        params.policy = policy.readPolicyDefault;
        params.writePolicy = policy.writePolicyDefault;
        Host[] hosts = Host.parseHosts(params.host, params.port);
        AerospikeClient client = new AerospikeClient(policy, hosts);
        try {
            EventLoop eventLoop = eventLoops.get(0);
            params.setServerSpecific(client);
            for (String exampleName : examples) {
                runExample(exampleName, client, eventLoop, params, console);
            }
        } finally {
            client.close();
        }
    } finally {
        eventLoops.close();
    }
}
Also used : AerospikeClient(com.aerospike.client.AerospikeClient) ClientPolicy(com.aerospike.client.policy.ClientPolicy) NioEventLoops(com.aerospike.client.async.NioEventLoops) EventLoops(com.aerospike.client.async.EventLoops) NettyEventLoops(com.aerospike.client.async.NettyEventLoops) EventPolicy(com.aerospike.client.async.EventPolicy) Host(com.aerospike.client.Host) NioEventLoops(com.aerospike.client.async.NioEventLoops) IOUringEventLoopGroup(io.netty.incubator.channel.uring.IOUringEventLoopGroup) EventLoopGroup(io.netty.channel.EventLoopGroup) IOUringEventLoopGroup(io.netty.incubator.channel.uring.IOUringEventLoopGroup) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) EpollEventLoopGroup(io.netty.channel.epoll.EpollEventLoopGroup) KQueueEventLoopGroup(io.netty.channel.kqueue.KQueueEventLoopGroup) EventLoop(com.aerospike.client.async.EventLoop) NettyEventLoops(com.aerospike.client.async.NettyEventLoops) EpollEventLoopGroup(io.netty.channel.epoll.EpollEventLoopGroup) KQueueEventLoopGroup(io.netty.channel.kqueue.KQueueEventLoopGroup) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup)

Example 3 with IOUringEventLoopGroup

use of io.netty.incubator.channel.uring.IOUringEventLoopGroup in project aerospike-client-java by aerospike.

the class SuiteAsync method init.

@BeforeClass
public static void init() {
    System.out.println("Begin AerospikeClient");
    Args args = Args.Instance;
    EventPolicy eventPolicy = new EventPolicy();
    switch(args.eventLoopType) {
        default:
        case DIRECT_NIO:
            {
                eventLoops = new NioEventLoops(eventPolicy, 1);
                break;
            }
        case NETTY_NIO:
            {
                EventLoopGroup group = new NioEventLoopGroup(1);
                eventLoops = new NettyEventLoops(eventPolicy, group, args.eventLoopType);
                break;
            }
        case NETTY_EPOLL:
            {
                EventLoopGroup group = new EpollEventLoopGroup(1);
                eventLoops = new NettyEventLoops(eventPolicy, group, args.eventLoopType);
                break;
            }
        case NETTY_KQUEUE:
            {
                EventLoopGroup group = new KQueueEventLoopGroup(1);
                eventLoops = new NettyEventLoops(eventPolicy, group, args.eventLoopType);
                break;
            }
        case NETTY_IOURING:
            {
                EventLoopGroup group = new IOUringEventLoopGroup(1);
                eventLoops = new NettyEventLoops(eventPolicy, group, args.eventLoopType);
                break;
            }
    }
    try {
        ClientPolicy policy = new ClientPolicy();
        policy.eventLoops = eventLoops;
        policy.user = args.user;
        policy.password = args.password;
        policy.authMode = args.authMode;
        policy.tlsPolicy = args.tlsPolicy;
        Host[] hosts = Host.parseHosts(args.host, args.port);
        eventLoop = eventLoops.get(0);
        client = new AerospikeClient(policy, hosts);
        try {
            args.setServerSpecific(client);
        } catch (RuntimeException re) {
            client.close();
            throw re;
        }
    } catch (Exception e) {
        eventLoops.close();
        throw e;
    }
}
Also used : AerospikeClient(com.aerospike.client.AerospikeClient) Args(com.aerospike.test.util.Args) ClientPolicy(com.aerospike.client.policy.ClientPolicy) EventPolicy(com.aerospike.client.async.EventPolicy) Host(com.aerospike.client.Host) NioEventLoops(com.aerospike.client.async.NioEventLoops) IOUringEventLoopGroup(io.netty.incubator.channel.uring.IOUringEventLoopGroup) EventLoopGroup(io.netty.channel.EventLoopGroup) IOUringEventLoopGroup(io.netty.incubator.channel.uring.IOUringEventLoopGroup) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) EpollEventLoopGroup(io.netty.channel.epoll.EpollEventLoopGroup) KQueueEventLoopGroup(io.netty.channel.kqueue.KQueueEventLoopGroup) NettyEventLoops(com.aerospike.client.async.NettyEventLoops) EpollEventLoopGroup(io.netty.channel.epoll.EpollEventLoopGroup) KQueueEventLoopGroup(io.netty.channel.kqueue.KQueueEventLoopGroup) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) BeforeClass(org.junit.BeforeClass)

Aggregations

AerospikeClient (com.aerospike.client.AerospikeClient)3 EventPolicy (com.aerospike.client.async.EventPolicy)3 NettyEventLoops (com.aerospike.client.async.NettyEventLoops)3 NioEventLoops (com.aerospike.client.async.NioEventLoops)3 EventLoopGroup (io.netty.channel.EventLoopGroup)3 EpollEventLoopGroup (io.netty.channel.epoll.EpollEventLoopGroup)3 KQueueEventLoopGroup (io.netty.channel.kqueue.KQueueEventLoopGroup)3 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)3 IOUringEventLoopGroup (io.netty.incubator.channel.uring.IOUringEventLoopGroup)3 Host (com.aerospike.client.Host)2 ClientPolicy (com.aerospike.client.policy.ClientPolicy)2 EventLoop (com.aerospike.client.async.EventLoop)1 EventLoops (com.aerospike.client.async.EventLoops)1 Args (com.aerospike.test.util.Args)1 BeforeClass (org.junit.BeforeClass)1