Search in sources :

Example 1 with NettyStreamFactory

use of com.mongodb.connection.netty.NettyStreamFactory in project mongo-java-driver by mongodb.

the class NettyMongoClients method create.

static MongoClient create(final MongoClientSettings settings, final MongoDriverInformation mongoDriverInformation) {
    final EventLoopGroup eventLoopGroup = new NioEventLoopGroup();
    StreamFactory streamFactory = new NettyStreamFactory(settings.getSocketSettings(), settings.getSslSettings(), eventLoopGroup);
    StreamFactory heartbeatStreamFactory = new NettyStreamFactory(settings.getHeartbeatSocketSettings(), settings.getSslSettings(), eventLoopGroup);
    return MongoClients.createMongoClient(settings, mongoDriverInformation, streamFactory, heartbeatStreamFactory, new Closeable() {

        @Override
        public void close() throws IOException {
            eventLoopGroup.shutdownGracefully().awaitUninterruptibly();
        }
    });
}
Also used : EventLoopGroup(io.netty.channel.EventLoopGroup) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) NettyStreamFactory(com.mongodb.connection.netty.NettyStreamFactory) StreamFactory(com.mongodb.connection.StreamFactory) NettyStreamFactory(com.mongodb.connection.netty.NettyStreamFactory) Closeable(java.io.Closeable) IOException(java.io.IOException) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup)

Aggregations

StreamFactory (com.mongodb.connection.StreamFactory)1 NettyStreamFactory (com.mongodb.connection.netty.NettyStreamFactory)1 EventLoopGroup (io.netty.channel.EventLoopGroup)1 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)1 Closeable (java.io.Closeable)1 IOException (java.io.IOException)1