本文整理汇总了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();
}
示例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();
}
示例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();
}
}
示例4: stop
import io.netty.channel.EventLoop; //导入方法依赖的package包/类
@Override
public void stop() throws IOException, InterruptedException {
EventLoop loop = channel.eventLoop();
channel.close().sync();
loop.shutdownGracefully();
}