• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java PrematureChannelClosureException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java VerticalLayoutContainer类代码示例发布时间:2022-05-22
下一篇:
Java NonAggregatingLogHandler类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap