当前位置: 首页>>代码示例>>Java>>正文


Java EventLoop.shutdownGracefully方法代码示例

本文整理汇总了Java中io.netty.channel.EventLoop.shutdownGracefully方法的典型用法代码示例。如果您正苦于以下问题:Java EventLoop.shutdownGracefully方法的具体用法?Java EventLoop.shutdownGracefully怎么用?Java EventLoop.shutdownGracefully使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.netty.channel.EventLoop的用法示例。


在下文中一共展示了EventLoop.shutdownGracefully方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: stop

import io.netty.channel.EventLoop; //导入方法依赖的package包/类
@PreDestroy
public void stop() throws IOException, InterruptedException {
    EventLoop loop = channel.eventLoop();
    channel.close().sync();
    channel = null;
    loop.shutdownGracefully();

    super.stop();
}
 
开发者ID:shevek,项目名称:dhcp4j,代码行数:10,代码来源:DhcpServer.java

示例2: stop

import io.netty.channel.EventLoop; //导入方法依赖的package包/类
@PreDestroy
public void stop() throws IOException, InterruptedException {
    EventLoop loop = channel.eventLoop();
    channel.close().sync();
    channel = null;
    loop.shutdownGracefully();
}
 
开发者ID:shevek,项目名称:dhcp4j,代码行数:8,代码来源:Dhcp6Server.java

示例3: testProjectAccessController

import io.netty.channel.EventLoop; //导入方法依赖的package包/类
@Test
public void testProjectAccessController() throws Exception {
    final EventLoop ev = new DefaultEventLoop();

    try {
        final ServiceRequestContext ctx = spy(mock(ServiceRequestContext.class));
        when(ctx.eventLoop()).thenReturn(ev);

        final DefaultAttributeMap attrs = new DefaultAttributeMap();
        attrs.attr(ROLE_MAP).set(roleMap::get);
        when(ctx.attr(CURRENT_USER_KEY)).thenReturn(attrs.attr(CURRENT_USER_KEY));
        when(ctx.attr(ROLE_MAP)).thenReturn(attrs.attr(ROLE_MAP));

        try (SafeCloseable ignore = RequestContext.push(ctx)) {

            attrs.attr(CURRENT_USER_KEY).set(User.DEFAULT);

            when(ctx.pathParam("projectName")).thenReturn("A");
            assertThat(new ProjectMembersOnly().serve(delegate, ctx, null).aggregate().join().status())
                    .isEqualTo(HttpStatus.OK);
            assertThat(new ProjectOwnersOnly().serve(delegate, ctx, null).aggregate().join().status())
                    .isEqualTo(HttpStatus.OK);

            when(ctx.pathParam("projectName")).thenReturn("B");
            assertThat(new ProjectMembersOnly().serve(delegate, ctx, null).aggregate().join().status())
                    .isEqualTo(HttpStatus.OK);
            assertThatThrownBy(() -> new ProjectOwnersOnly().serve(delegate, ctx, null))
                    .isInstanceOf(HttpStatusException.class)
                    .satisfies(cause -> {
                        assertThat(((HttpStatusException) cause).httpStatus())
                                .isEqualTo(HttpStatus.UNAUTHORIZED);
                    });

            attrs.attr(CURRENT_USER_KEY).set(User.ADMIN);

            assertThat(new AdministratorsOnly().serve(delegate, ctx, null).aggregate().join().status())
                    .isEqualTo(HttpStatus.OK);
            assertThat(new ProjectMembersOnly().serve(delegate, ctx, null).aggregate().join().status())
                    .isEqualTo(HttpStatus.OK);
            assertThat(new ProjectOwnersOnly().serve(delegate, ctx, null).aggregate().join().status())
                    .isEqualTo(HttpStatus.OK);
        }
    } finally {
        ev.shutdownGracefully();
    }
}
 
开发者ID:line,项目名称:centraldogma,代码行数:47,代码来源:DecoratorTest.java

示例4: stop

import io.netty.channel.EventLoop; //导入方法依赖的package包/类
@Override
public void stop() throws IOException, InterruptedException {
    EventLoop loop = channel.eventLoop();
    channel.close().sync();
    loop.shutdownGracefully();
}
 
开发者ID:shevek,项目名称:tftp4j,代码行数:7,代码来源:TftpServer.java


注:本文中的io.netty.channel.EventLoop.shutdownGracefully方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。