本文整理汇总了Java中io.netty.handler.codec.http2.Http2Settings类的典型用法代码示例。如果您正苦于以下问题:Java Http2Settings类的具体用法?Java Http2Settings怎么用?Java Http2Settings使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Http2Settings类属于io.netty.handler.codec.http2包,在下文中一共展示了Http2Settings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newHttp2ConnectionHandler
import io.netty.handler.codec.http2.Http2Settings; //导入依赖的package包/类
private Http2ClientConnectionHandler newHttp2ConnectionHandler(Channel ch) {
final boolean validateHeaders = false;
final Http2Connection conn = new DefaultHttp2Connection(false);
conn.addListener(new Http2GoAwayListener(ch));
Http2FrameReader reader = new DefaultHttp2FrameReader(validateHeaders);
Http2FrameWriter writer = new DefaultHttp2FrameWriter();
Http2ConnectionEncoder encoder = new DefaultHttp2ConnectionEncoder(conn, writer);
Http2ConnectionDecoder decoder = new DefaultHttp2ConnectionDecoder(conn, encoder, reader);
final Http2Settings http2Settings = http2Settings();
final Http2ResponseDecoder listener = new Http2ResponseDecoder(conn, ch, encoder);
final Http2ClientConnectionHandler handler =
new Http2ClientConnectionHandler(decoder, encoder, http2Settings, listener);
// Setup post build options
handler.gracefulShutdownTimeoutMillis(clientFactory.idleTimeoutMillis());
return handler;
}
示例2: channelRead
import io.netty.handler.codec.http2.Http2Settings; //导入依赖的package包/类
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
if (msg instanceof Http2Settings) {
// Expected
} else {
try {
final String typeInfo;
if (msg instanceof ByteBuf) {
typeInfo = msg + " HexDump: " + ByteBufUtil.hexDump((ByteBuf) msg);
} else {
typeInfo = String.valueOf(msg);
}
throw new IllegalStateException("unexpected message type: " + typeInfo);
} finally {
ReferenceCountUtil.release(msg);
}
}
}
示例3: handleHttp2Settings
import io.netty.handler.codec.http2.Http2Settings; //导入依赖的package包/类
private void handleHttp2Settings(ChannelHandlerContext ctx, Http2Settings h2settings) {
if (h2settings.isEmpty()) {
logger.trace("{} HTTP/2 settings: <empty>", ctx.channel());
} else {
logger.debug("{} HTTP/2 settings: {}", ctx.channel(), h2settings);
}
if (protocol == H1) {
protocol = H2;
} else if (protocol == H1C) {
protocol = H2C;
}
final Http2ConnectionHandler handler = ctx.pipeline().get(Http2ConnectionHandler.class);
if (responseEncoder == null) {
responseEncoder = new Http2ObjectEncoder(handler.encoder());
} else if (responseEncoder instanceof Http1ObjectEncoder) {
responseEncoder.close();
responseEncoder = new Http2ObjectEncoder(handler.encoder());
}
}
示例4: newHttp2ConnectionHandler
import io.netty.handler.codec.http2.Http2Settings; //导入依赖的package包/类
private Http2ConnectionHandler newHttp2ConnectionHandler(ChannelPipeline pipeline) {
final Http2Connection conn = new DefaultHttp2Connection(true);
conn.addListener(new Http2GoAwayListener(pipeline.channel()));
Http2FrameReader reader = new DefaultHttp2FrameReader(true);
Http2FrameWriter writer = new DefaultHttp2FrameWriter();
Http2ConnectionEncoder encoder = new DefaultHttp2ConnectionEncoder(conn, writer);
Http2ConnectionDecoder decoder = new DefaultHttp2ConnectionDecoder(conn, encoder, reader);
final Http2ConnectionHandler handler =
new Http2ServerConnectionHandler(decoder, encoder, new Http2Settings());
// Setup post build options
final Http2RequestDecoder listener =
new Http2RequestDecoder(config, pipeline.channel(), handler.encoder());
handler.connection().addListener(listener);
handler.decoder().frameListener(listener);
handler.gracefulShutdownTimeoutMillis(config.idleTimeoutMillis());
return handler;
}
示例5: updateWindow
import io.netty.handler.codec.http2.Http2Settings; //导入依赖的package包/类
public void updateWindow() throws Http2Exception {
if (!autoTuneFlowControlOn) {
return;
}
pingReturn++;
long elapsedTime = (System.nanoTime() - lastPingTime);
if (elapsedTime == 0) {
elapsedTime = 1;
}
long bandwidth = (getDataSincePing() * TimeUnit.SECONDS.toNanos(1)) / elapsedTime;
Http2LocalFlowController fc = decoder().flowController();
// Calculate new window size by doubling the observed BDP, but cap at max window
int targetWindow = Math.min(getDataSincePing() * 2, MAX_WINDOW_SIZE);
setPinging(false);
int currentWindow = fc.initialWindowSize(connection().connectionStream());
if (targetWindow > currentWindow && bandwidth > lastBandwidth) {
lastBandwidth = bandwidth;
int increase = targetWindow - currentWindow;
fc.incrementWindowSize(connection().connectionStream(), increase);
fc.initialWindowSize(targetWindow);
Http2Settings settings = new Http2Settings();
settings.initialWindowSize(targetWindow);
frameWriter().writeSettings(ctx(), settings, ctx().newPromise());
}
}
示例6: manualSetUp
import io.netty.handler.codec.http2.Http2Settings; //导入依赖的package包/类
@Override
protected void manualSetUp() throws Exception {
assertNull("manualSetUp should not run more than once", handler());
initChannel(new GrpcHttp2ServerHeadersDecoder(GrpcUtil.DEFAULT_MAX_HEADER_LIST_SIZE));
// replace the keepAliveManager with spyKeepAliveManager
spyKeepAliveManager =
mock(KeepAliveManager.class, delegatesTo(handler().getKeepAliveManagerForTest()));
handler().setKeepAliveManagerForTest(spyKeepAliveManager);
// Simulate receipt of the connection preface
handler().handleProtocolNegotiationCompleted(Attributes.EMPTY);
channelRead(Http2CodecUtil.connectionPrefaceBuf());
// Simulate receipt of initial remote settings.
ByteBuf serializedSettings = serializeSettings(new Http2Settings());
channelRead(serializedSettings);
}
示例7: build
import io.netty.handler.codec.http2.Http2Settings; //导入依赖的package包/类
@Override
protected Http2TestHandler build(Http2ConnectionDecoder decoder,
Http2ConnectionEncoder encoder, Http2Settings initialSettings) {
Http2TestHandler handler = new Http2TestHandler(decoder, encoder, initialSettings);
frameListener(handler);
return handler;
}
示例8: channelRead0
import io.netty.handler.codec.http2.Http2Settings; //导入依赖的package包/类
@Override
protected void channelRead0(ChannelHandlerContext ctx, Http2Settings msg) throws Exception {
promise.setSuccess();
// Only care about the first settings message
ctx.pipeline().remove(this);
}
示例9: build
import io.netty.handler.codec.http2.Http2Settings; //导入依赖的package包/类
@Override
protected HelloWorldHttp2Handler build(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder,
Http2Settings initialSettings) {
HelloWorldHttp2Handler handler = new HelloWorldHttp2Handler(decoder, encoder, initialSettings);
frameListener(handler);
return handler;
}
示例10: messageReceived
import io.netty.handler.codec.http2.Http2Settings; //导入依赖的package包/类
@Override
protected void messageReceived(ChannelHandlerContext ctx, Http2Settings msg) throws Exception {
promise.setSuccess();
// Only care about the first settings message
ctx.pipeline().remove(this);
}
示例11: frameWriter
import io.netty.handler.codec.http2.Http2Settings; //导入依赖的package包/类
private Http2FrameWriter frameWriter() {
// Set initial SETTINGS
Http2Settings settings = new Http2Settings();
settings.pushEnabled(false);
settings.maxConcurrentStreams(100);
return new Http2OutboundFrameLogger(new CustomHttp2FrameWriter(settings), logger);
}
示例12: writeSettings
import io.netty.handler.codec.http2.Http2Settings; //导入依赖的package包/类
/**
* write customized SETTINGS
*/
@Override
public ChannelFuture writeSettings(ChannelHandlerContext ctx, Http2Settings settings, ChannelPromise promise) {
if(this.settings != null) {
return super.writeSettings(ctx, this.settings, promise);
} else {
return super.writeSettings(ctx, settings, promise);
}
}
示例13: channelRead0
import io.netty.handler.codec.http2.Http2Settings; //导入依赖的package包/类
@Override
protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
if (msg instanceof Http2Settings) {
settingsPromise.setSuccess(null);
return;
}
if (msg instanceof FullHttpResponse) {
FullHttpResponse res = (FullHttpResponse) msg;
Integer streamId = res.headers().getInt(
HttpConversionUtil.ExtensionHeaderNames.STREAM_ID.text());
if (streamId == null) {
responsePromise.tryFailure(new AssertionError("message without stream ID: " + msg));
return;
}
if (streamId == 1) {
// Response to the upgrade request, which is OK to ignore.
return;
}
if (streamId != 3) {
responsePromise.tryFailure(new AssertionError("unexpected stream ID: " + msg));
return;
}
responsePromise.setSuccess(res.content().retain());
return;
}
throw new IllegalStateException("unexpected message type: " + msg.getClass().getName());
}
示例14: Http2ClientConnectionHandler
import io.netty.handler.codec.http2.Http2Settings; //导入依赖的package包/类
Http2ClientConnectionHandler(
Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder,
Http2Settings initialSettings, Http2ResponseDecoder responseDecoder) {
super(decoder, encoder, initialSettings);
this.responseDecoder = responseDecoder;
connection().addListener(responseDecoder);
decoder().frameListener(responseDecoder);
}
示例15: channelRead
import io.netty.handler.codec.http2.Http2Settings; //导入依赖的package包/类
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
isReading = true; // Cleared in channelReadComplete()
if (msg instanceof Http2Settings) {
handleHttp2Settings(ctx, (Http2Settings) msg);
} else {
handleRequest(ctx, (DecodedHttpRequest) msg);
}
}