Java Code Examples for io.netty.channel.Channel#alloc()
The following examples show how to use
io.netty.channel.Channel#alloc() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NettyClientStream.java From grpc-nebula-java with Apache License 2.0 | 6 votes |
NettyClientStream( TransportState state, MethodDescriptor<?, ?> method, Metadata headers, Channel channel, AsciiString authority, AsciiString scheme, AsciiString userAgent, StatsTraceContext statsTraceCtx, TransportTracer transportTracer, CallOptions callOptions) { super( new NettyWritableBufferAllocator(channel.alloc()), statsTraceCtx, transportTracer, headers, callOptions, useGet(method)); this.state = checkNotNull(state, "transportState"); this.writeQueue = state.handler.getWriteQueue(); this.method = checkNotNull(method, "method"); this.channel = checkNotNull(channel, "channel"); this.authority = checkNotNull(authority, "authority"); this.scheme = checkNotNull(scheme, "scheme"); this.userAgent = userAgent; }
Example 2
Source File: NettyClientStream.java From grpc-java with Apache License 2.0 | 6 votes |
NettyClientStream( TransportState state, MethodDescriptor<?, ?> method, Metadata headers, Channel channel, AsciiString authority, AsciiString scheme, AsciiString userAgent, StatsTraceContext statsTraceCtx, TransportTracer transportTracer, CallOptions callOptions, boolean useGetForSafeMethods) { super( new NettyWritableBufferAllocator(channel.alloc()), statsTraceCtx, transportTracer, headers, callOptions, useGetForSafeMethods && method.isSafe()); this.state = checkNotNull(state, "transportState"); this.writeQueue = state.handler.getWriteQueue(); this.method = checkNotNull(method, "method"); this.authority = checkNotNull(authority, "authority"); this.scheme = checkNotNull(scheme, "scheme"); this.userAgent = userAgent; }
Example 3
Source File: NettyServerStream.java From grpc-java with Apache License 2.0 | 6 votes |
public NettyServerStream( Channel channel, TransportState state, Attributes transportAttrs, String authority, StatsTraceContext statsTraceCtx, TransportTracer transportTracer) { super(new NettyWritableBufferAllocator(channel.alloc()), statsTraceCtx); this.state = checkNotNull(state, "transportState"); this.writeQueue = state.handler.getWriteQueue(); this.attributes = checkNotNull(transportAttrs); this.authority = authority; this.transportTracer = checkNotNull(transportTracer, "transportTracer"); // Read the id early to avoid reading transportState later. this.streamId = transportState().id(); }
Example 4
Source File: NettyServerStream.java From grpc-nebula-java with Apache License 2.0 | 5 votes |
public NettyServerStream( Channel channel, TransportState state, Attributes transportAttrs, String authority, StatsTraceContext statsTraceCtx, TransportTracer transportTracer) { super(new NettyWritableBufferAllocator(channel.alloc()), statsTraceCtx); this.state = checkNotNull(state, "transportState"); this.channel = checkNotNull(channel, "channel"); this.writeQueue = state.handler.getWriteQueue(); this.attributes = checkNotNull(transportAttrs); this.authority = authority; this.transportTracer = checkNotNull(transportTracer, "transportTracer"); }
Example 5
Source File: MicronautServerHttpRequest.java From micronaut-spring with Apache License 2.0 | 5 votes |
@SuppressWarnings("SubscriberImplementation") @Override public reactor.core.publisher.Flux<DataBuffer> getBody() { final Optional<Channel> opt = channelResolver.resolveChannel(request); if (opt.isPresent()) { final Channel channel = opt.get(); final NettyDataBufferFactory nettyDataBufferFactory = new NettyDataBufferFactory(channel.alloc()); final Optional<HttpContentProcessor<ByteBufHolder>> httpContentProcessor = channelResolver.resolveContentProcessor(request); if (httpContentProcessor.isPresent()) { final HttpContentProcessor<ByteBufHolder> processor = httpContentProcessor.get(); return Flux.from(subscriber -> processor.subscribe(new Subscriber<ByteBufHolder>() { @Override public void onSubscribe(Subscription s) { subscriber.onSubscribe(s); } @Override public void onNext(ByteBufHolder byteBufHolder) { subscriber.onNext(nettyDataBufferFactory.wrap(byteBufHolder.content())); } @Override public void onError(Throwable t) { subscriber.onError(t); } @Override public void onComplete() { subscriber.onComplete(); } })); } } return Flux.empty(); }
Example 6
Source File: XrpcRequest.java From xrpc with Apache License 2.0 | 5 votes |
public XrpcRequest( FullHttpRequest request, ServerContext connectionContext, Map<String, String> groups, Channel channel) { this.h1Request = request; this.h2Headers = null; this.connectionContext = connectionContext; this.groups = groups; this.upstreamChannel = channel; this.alloc = channel.alloc(); this.eventLoop = channel.eventLoop(); this.h2Data = null; }
Example 7
Source File: XrpcRequest.java From xrpc with Apache License 2.0 | 5 votes |
public XrpcRequest( Http2Headers headers, ServerContext connectionContext, Map<String, String> groups, Channel channel) { this.h1Request = null; this.h2Headers = headers; this.connectionContext = connectionContext; this.groups = groups; this.upstreamChannel = channel; this.alloc = channel.alloc(); this.eventLoop = channel.eventLoop(); this.h2Data = alloc.compositeBuffer(); }
Example 8
Source File: TransportConfig.java From reactor-netty with Apache License 2.0 | 5 votes |
@Override protected void initChannel(Channel channel) { ChannelPipeline pipeline = channel.pipeline(); if (config.metricsRecorder != null) { ChannelOperations.addMetricsHandler(channel, Objects.requireNonNull(config.metricsRecorder.get(), "Metrics recorder supplier returned null"), remoteAddress, onServer); ByteBufAllocator alloc = channel.alloc(); if (alloc instanceof PooledByteBufAllocator) { ByteBufAllocatorMetrics.INSTANCE.registerMetrics("pooled", ((PooledByteBufAllocator) alloc).metric()); } else if (alloc instanceof UnpooledByteBufAllocator) { ByteBufAllocatorMetrics.INSTANCE.registerMetrics("unpooled", ((UnpooledByteBufAllocator) alloc).metric()); } } if (config.loggingHandler != null) { pipeline.addFirst(NettyPipeline.LoggingHandler, config.loggingHandler); } ChannelOperations.addReactiveBridge(channel, config.channelOperationsProvider(), connectionObserver); config.defaultOnChannelInit() .then(config.doOnChannelInit) .onChannelInit(connectionObserver, channel, remoteAddress); pipeline.remove(this); if (log.isDebugEnabled()) { log.debug(format(channel, "Initialized pipeline {}"), pipeline.toString()); } }
Example 9
Source File: DefaultClientRequestContext.java From armeria with Apache License 2.0 | 4 votes |
@Override public ByteBufAllocator alloc() { final Channel channel = channel(); return channel != null ? channel.alloc() : PooledByteBufAllocator.DEFAULT; }