netty-connection-pool

High-performance non-blocking, multi-endpoint connection pool

License

License

Categories

Categories

Net Netty Networking
GroupId

GroupId

com.github.akurilov
ArtifactId

ArtifactId

netty-connection-pool
Last Version

Last Version

1.2.1
Release Date

Release Date

Type

Type

jar
Description

Description

netty-connection-pool
High-performance non-blocking, multi-endpoint connection pool
Project URL

Project URL

https://github.com/akurilov/netty-connection-pool/wiki
Source Code Management

Source Code Management

https://github.com/akurilov/netty-connection-pool.git

Download netty-connection-pool

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.akurilov/netty-connection-pool/ -->
<dependency>
    <groupId>com.github.akurilov</groupId>
    <artifactId>netty-connection-pool</artifactId>
    <version>1.2.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.akurilov/netty-connection-pool/
implementation 'com.github.akurilov:netty-connection-pool:1.2.1'
// https://jarcasting.com/artifacts/com.github.akurilov/netty-connection-pool/
implementation ("com.github.akurilov:netty-connection-pool:1.2.1")
'com.github.akurilov:netty-connection-pool:jar:1.2.1'
<dependency org="com.github.akurilov" name="netty-connection-pool" rev="1.2.1">
  <artifact name="netty-connection-pool" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.akurilov', module='netty-connection-pool', version='1.2.1')
)
libraryDependencies += "com.github.akurilov" % "netty-connection-pool" % "1.2.1"
[com.github.akurilov/netty-connection-pool "1.2.1"]

Dependencies

compile (2)

Group / Artifact Type Version
io.netty : netty-common jar 4.1.25.Final
io.netty : netty-transport jar 4.1.25.Final

test (2)

Group / Artifact Type Version
junit : junit jar [4,)
io.netty : netty-transport-native-epoll jar 4.1.25.Final

Project Modules

There are no modules declared in this project.

High-performance non-blocking, multi-endpoint connection pool

Introduction

Currently Netty doesn't have a connection pool implementation which would allow to get a connection to any endpoint from the specified set. This connection pool implementation solves the problem using round-robin endpoint selection for each connection leased from the pool.

Also, this connection pool implementation supports the batch mode operation (leasing/releasing many connections at once).

Usage

Gradle

compile group: 'com.github.akurilov', name: 'netty-connection-pool', version: '1.2.1'

Code Example

final Bootstrap bootstrap = new Bootstrap();
// configure the Netty's bootstrap instance here

// your custom channel pool handler
final ChannelPoolHandler cph = ...

final NonBlockingConnPool connPool = new BasicMultiNodeConnPool(
    storageNodeAddrs, bootstrap, cph, storageNodePort, connAttemptsLimit
);

// optional
connPool.preCreateConnections(concurrencyLevel);

// use the pool
final Channel conn = connPool.lease();
...
connPool.release(conn);

// don't forget to clean up
connPool.close();

Batch Mode

...

// try to get up to 4096 connections per time
final int maxConnCount = 0x1000;
final List<Channel> conns = new ArrayList<>(maxConnCount);
final int availConnCount = connPool.lease(conns, maxConnCount);

// use the obtained connections
Channel conn;
for(int i = 0; i < availConnCount; i ++) {
    conn = conns.get(i);
    // use the connection
}

// release all connections back into the pool
connPool.lease(conns);

Versions

Version
1.2.1
1.2.0
1.1.0
1.0.9
1.0.8
1.0.7
1.0.6
1.0.4
1.0.3
1.0.2
1.0.1
1.0.0
0.1.6
0.1.5
0.1.4
0.1.3
0.1.2
0.1.1
0.1.0