use of io.netty.buffer.ByteBufAllocator in project neo4j by neo4j.
the class BoltServer method init.
@Override
public void init() {
Log log = logService.getInternalLog(BoltServer.class);
boltMemoryPool = new BoltMemoryPool(memoryPools, NETTY_BUF_ALLOCATOR.metric());
life.add(new BoltMemoryPoolLifeCycleAdapter(boltMemoryPool));
InternalLoggerFactory.setDefaultFactory(new Netty4LoggerFactory(logService.getInternalLogProvider()));
TransportThrottleGroup throttleGroup = new TransportThrottleGroup(config, clock);
BoltSchedulerProvider boltSchedulerProvider = life.setLast(new ExecutorBoltSchedulerProvider(config, new CachedThreadPoolExecutorFactory(), jobScheduler, logService));
BoltConnectionFactory boltConnectionFactory = createConnectionFactory(config, boltSchedulerProvider, logService, clock);
BoltStateMachineFactory externalBoltStateMachineFactory = createBoltStateMachineFactory(createAuthentication(externalAuthManager), clock);
BoltStateMachineFactory internalBoltStateMachineFactory = createBoltStateMachineFactory(createAuthentication(internalAuthManager), clock);
BoltStateMachineFactory loopbackBoltStateMachineFactory = createBoltStateMachineFactory(createAuthentication(loopbackAuthManager), clock);
BoltProtocolFactory externalBoltProtocolFactory = createBoltProtocolFactory(boltConnectionFactory, externalBoltStateMachineFactory, throttleGroup, clock, config.get(BoltConnectorInternalSettings.connection_keep_alive));
BoltProtocolFactory internalBoltProtocolFactory = createBoltProtocolFactory(boltConnectionFactory, internalBoltStateMachineFactory, throttleGroup, clock, config.get(BoltConnectorInternalSettings.connection_keep_alive));
BoltProtocolFactory loopbackBoltProtocolFactory = createBoltProtocolFactory(boltConnectionFactory, loopbackBoltStateMachineFactory, throttleGroup, clock, config.get(BoltConnectorInternalSettings.connection_keep_alive));
if (config.get(CommonConnectorConfig.ocsp_stapling_enabled)) {
enableOcspStapling();
}
ByteBufAllocator bufferAllocator = getBufferAllocator();
if (config.get(BoltConnector.enabled)) {
jobScheduler.setThreadFactory(Group.BOLT_NETWORK_IO, NettyThreadFactory::new);
NettyServer nettyServer;
var isNotReadReplica = config.get(GraphDatabaseSettings.mode) != GraphDatabaseSettings.Mode.READ_REPLICA;
var loopbackProtocolInitializer = createLoopbackProtocolInitializer(loopbackBoltProtocolFactory, throttleGroup, bufferAllocator);
if (config.get(GraphDatabaseSettings.routing_enabled) && isNotReadReplica) {
nettyServer = new NettyServer(jobScheduler.threadFactory(Group.BOLT_NETWORK_IO), createExternalProtocolInitializer(externalBoltProtocolFactory, throttleGroup, log, bufferAllocator), createInternalProtocolInitializer(internalBoltProtocolFactory, throttleGroup, bufferAllocator), loopbackProtocolInitializer, connectorPortRegister, logService, config);
} else {
nettyServer = new NettyServer(jobScheduler.threadFactory(Group.BOLT_NETWORK_IO), createExternalProtocolInitializer(externalBoltProtocolFactory, throttleGroup, log, bufferAllocator), loopbackProtocolInitializer, connectorPortRegister, logService, config);
}
life.add(nettyServer);
log.info("Bolt server loaded");
}
life.init();
}
use of io.netty.buffer.ByteBufAllocator in project reactor-netty by reactor.
the class WebsocketFinalizer method receive.
@Override
public ByteBufFlux receive() {
ByteBufAllocator alloc = (ByteBufAllocator) configuration().options().get(ChannelOption.ALLOCATOR);
if (alloc == null) {
alloc = ByteBufAllocator.DEFAULT;
}
@SuppressWarnings("unchecked") Mono<ChannelOperations<?, ?>> connector = (Mono<ChannelOperations<?, ?>>) connect();
return ByteBufFlux.fromInbound(connector.flatMapMany(contentReceiver), alloc);
}
use of io.netty.buffer.ByteBufAllocator in project reactor-netty by reactor.
the class HttpClientFinalizer method responseContent.
@Override
public ByteBufFlux responseContent() {
ByteBufAllocator alloc = (ByteBufAllocator) configuration().options().get(ChannelOption.ALLOCATOR);
if (alloc == null) {
alloc = ByteBufAllocator.DEFAULT;
}
@SuppressWarnings("unchecked") Mono<ChannelOperations<?, ?>> connector = (Mono<ChannelOperations<?, ?>>) connect();
return ByteBufFlux.fromInbound(connector.flatMapMany(contentReceiver), alloc);
}
use of io.netty.buffer.ByteBufAllocator in project reactor-netty by reactor.
the class HttpClientTest method testIssue694.
@Test
void testIssue694() {
disposableServer = createServer().handle((req, res) -> {
req.receive().subscribe();
return Mono.empty();
}).bindNow();
HttpClient client = createHttpClientForContextWithPort();
ByteBufAllocator alloc = ByteBufAllocator.DEFAULT;
ByteBuf buffer1 = alloc.buffer().writeInt(1).retain(9);
client.request(HttpMethod.GET).send((req, out) -> out.send(Flux.range(0, 10).map(i -> buffer1))).response().block(Duration.ofSeconds(30));
assertThat(buffer1.refCnt()).isEqualTo(0);
ByteBuf buffer2 = alloc.buffer().writeInt(1).retain(9);
client.request(HttpMethod.GET).send(Flux.range(0, 10).map(i -> buffer2)).response().block(Duration.ofSeconds(30));
assertThat(buffer2.refCnt()).isEqualTo(0);
}
Aggregations