本文整理汇总了Java中io.netty.handler.codec.PrematureChannelClosureException类的典型用法代码示例。如果您正苦于以下问题:Java PrematureChannelClosureException类的具体用法?Java PrematureChannelClosureException怎么用?Java PrematureChannelClosureException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PrematureChannelClosureException类属于io.netty.handler.codec包,在下文中一共展示了PrematureChannelClosureException类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: exceptionCaught
import io.netty.handler.codec.PrematureChannelClosureException; //导入依赖的package包/类
@Override @SuppressWarnings("unchecked")
public final void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause)
throws IOException {
final Channel channel = ctx.channel();
final O ioTask = (O) channel.attr(NetStorageDriver.ATTR_KEY_IOTASK).get();
if(ioTask != null) {
if(driver.isInterrupted() || driver.isClosed()) {
ioTask.setStatus(INTERRUPTED);
} else if(cause instanceof PrematureChannelClosureException) {
LogUtil.exception(Level.WARN, cause, "Premature channel closure");
ioTask.setStatus(FAIL_IO);
} else {
LogUtil.exception(Level.WARN, cause, "Client handler failure");
ioTask.setStatus(FAIL_UNKNOWN);
}
if(!driver.isInterrupted()) {
try {
driver.complete(channel, ioTask);
} catch(final Exception e) {
LogUtil.exception(Level.DEBUG, e, "Failed to complete the I/O task");
}
}
}
}
开发者ID:emc-mongoose,项目名称:mongoose-base,代码行数:25,代码来源:ResponseHandlerBase.java
示例2: testIdentifyCloseChannelOnFailure
import io.netty.handler.codec.PrematureChannelClosureException; //导入依赖的package包/类
@Test(expected = PrematureChannelClosureException.class)
public void testIdentifyCloseChannelOnFailure() throws Exception {
Channel channel = mock(Channel.class, Answers.RETURNS_SMART_NULLS.get());
mockWriteHandler = mock(ChannelHandler.class);
DefaultChannelPromise completedFuture = new DefaultChannelPromise(channel);
completedFuture.setSuccess();
DefaultChannelPromise failedFuture = new DefaultChannelPromise(channel);
failedFuture.setFailure(new PrematureChannelClosureException("test"));
ChannelPipeline channelPipeline = mock(ChannelPipeline.class);
when(channelPipeline.addLast(anyString(), any(ChannelHandler.class))).thenReturn(channelPipeline);
when(channelPipeline.addLast(any(EventExecutorGroup.class), anyString(), any(ChannelHandler.class))).thenReturn(channelPipeline);
when(channel.pipeline()).thenReturn(channelPipeline);
when(channel.isActive()).thenReturn(true);
when(channel.writeAndFlush(any())).thenReturn(failedFuture);
when(channel.close()).thenReturn(completedFuture);
when(bootstrap.connect(anyString(), anyInt())).thenReturn(completedFuture);
ClientSessionConfiguration configuration = new ClientSessionConfiguration();
jannelClient.identify(configuration, null);
}
开发者ID:spapageo,项目名称:jannel,代码行数:26,代码来源:JannelClientTest.java
示例3: testFailsOnIncompleteChunkedResponse
import io.netty.handler.codec.PrematureChannelClosureException; //导入依赖的package包/类
@Test
public void testFailsOnIncompleteChunkedResponse() {
HttpClientCodec codec = new HttpClientCodec(4096, 8192, 8192, true);
EmbeddedChannel ch = new EmbeddedChannel(codec);
ch.writeOutbound(releaseLater(
new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "http://localhost/")));
assertNotNull(releaseLater(ch.readOutbound()));
assertNull(ch.readInbound());
ch.writeInbound(releaseLater(
Unpooled.copiedBuffer(INCOMPLETE_CHUNKED_RESPONSE, CharsetUtil.ISO_8859_1)));
assertThat(releaseLater(ch.readInbound()), instanceOf(HttpResponse.class));
assertThat(releaseLater(ch.readInbound()), instanceOf(HttpContent.class)); // Chunk 'first'
assertThat(releaseLater(ch.readInbound()), instanceOf(HttpContent.class)); // Chunk 'second'
assertNull(ch.readInbound());
try {
ch.finish();
fail();
} catch (CodecException e) {
assertTrue(e instanceof PrematureChannelClosureException);
}
}
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:24,代码来源:HttpClientCodecTest.java
示例4: channelInactive
import io.netty.handler.codec.PrematureChannelClosureException; //导入依赖的package包/类
@Override
public void channelInactive(ChannelHandlerContext ctx)
throws Exception {
super.channelInactive(ctx);
if (failOnMissingResponse) {
long missingResponses = requestResponseCounter.get();
if (missingResponses > 0) {
ctx.fireExceptionCaught(new PrematureChannelClosureException(
"channel gone inactive with " + missingResponses +
" missing response(s)"));
}
}
}
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:15,代码来源:HttpClientCodec.java
示例5: testFailsOnMissingResponse
import io.netty.handler.codec.PrematureChannelClosureException; //导入依赖的package包/类
@Test
public void testFailsOnMissingResponse() {
HttpClientCodec codec = new HttpClientCodec(4096, 8192, 8192, true);
EmbeddedChannel ch = new EmbeddedChannel(codec);
assertTrue(ch.writeOutbound(new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET,
"http://localhost/")));
assertNotNull(releaseLater(ch.readOutbound()));
try {
ch.finish();
fail();
} catch (CodecException e) {
assertTrue(e instanceof PrematureChannelClosureException);
}
}
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:16,代码来源:HttpClientCodecTest.java
示例6: channelInactive
import io.netty.handler.codec.PrematureChannelClosureException; //导入依赖的package包/类
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
super.channelInactive(ctx);
if (failOnMissingResponse) {
long missingResponses = requestResponseCounter.get();
if (missingResponses > 0) {
ctx.fireExceptionCaught(new PrematureChannelClosureException(
"channel gone inactive with " + missingResponses +
" missing response(s)"));
}
}
}
开发者ID:nathanchen,项目名称:netty-netty-5.0.0.Alpha1,代码行数:14,代码来源:BinaryMemcacheClientCodec.java
示例7: channelInactive
import io.netty.handler.codec.PrematureChannelClosureException; //导入依赖的package包/类
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
super.channelInactive(ctx);
if (failOnMissingResponse) {
long missingResponses = requestResponseCounter.get();
if (missingResponses > 0) {
ctx.fireExceptionCaught(new PrematureChannelClosureException(
"channel gone inactive with " + missingResponses
+ " missing response(s)"));
}
}
}
开发者ID:couchbase,项目名称:couchbase-jvm-core,代码行数:14,代码来源:BinaryMemcacheClientCodec.java
示例8: onUncaughtException
import io.netty.handler.codec.PrematureChannelClosureException; //导入依赖的package包/类
@Override
public void onUncaughtException(Throwable t) {
callWithLock(() -> {
if (t instanceof PrematureChannelClosureException) {
LOG.error("Lost connection to the mesos master, aborting", t);
notifyStopping();
abort.abort(AbortReason.LOST_MESOS_CONNECTION, Optional.absent());
} else {
LOG.error("Aborting due to error: {}", t.getMessage(), t);
notifyStopping();
abort.abort(AbortReason.MESOS_ERROR, Optional.absent());
}
}, "errorUncaughtException");
}
开发者ID:HubSpot,项目名称:Singularity,代码行数:15,代码来源:SingularityMesosSchedulerImpl.java
注:本文中的io.netty.handler.codec.PrematureChannelClosureException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论