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

Java DefaultEventLoop类代码示例

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

本文整理汇总了Java中io.netty.channel.DefaultEventLoop的典型用法代码示例。如果您正苦于以下问题:Java DefaultEventLoop类的具体用法?Java DefaultEventLoop怎么用?Java DefaultEventLoop使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DefaultEventLoop类属于io.netty.channel包,在下文中一共展示了DefaultEventLoop类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testRemoteInvocation

import io.netty.channel.DefaultEventLoop; //导入依赖的package包/类
private static void testRemoteInvocation(Tracing tracing, String remoteServiceName)
        throws Exception {

    // prepare parameters
    final HttpRequest req = HttpRequest.of(HttpMethod.POST, "/hello/armeria");
    final RpcRequest rpcReq = RpcRequest.of(HelloService.Iface.class, "hello", "Armeria");
    final HttpResponse res = HttpResponse.of(HttpStatus.OK);
    final RpcResponse rpcRes = RpcResponse.of("Hello, Armeria!");
    final ClientRequestContext ctx = new DefaultClientRequestContext(
            new DefaultEventLoop(), NoopMeterRegistry.get(), H2C, Endpoint.of("localhost", 8080),
            HttpMethod.POST, "/hello/armeria", null, null, ClientOptions.DEFAULT, req);

    ctx.logBuilder().startRequest(mock(Channel.class), H2C, "localhost");
    ctx.logBuilder().requestContent(rpcReq, req);
    ctx.logBuilder().endRequest();

    @SuppressWarnings("unchecked")
    Client<HttpRequest, HttpResponse> delegate = mock(Client.class);
    when(delegate.execute(any(), any())).thenReturn(res);

    HttpTracingClient stub = new HttpTracingClient(delegate, tracing, remoteServiceName);

    // do invoke
    HttpResponse actualRes = stub.execute(ctx, req);

    assertThat(actualRes).isEqualTo(res);

    verify(delegate, times(1)).execute(ctx, req);

    ctx.logBuilder().responseHeaders(HttpHeaders.of(HttpStatus.OK));
    ctx.logBuilder().responseContent(rpcRes, res);
    ctx.logBuilder().endResponse();
}
 
开发者ID:line,项目名称:armeria,代码行数:34,代码来源:HttpTracingClientTest.java


示例2: newClientContext

import io.netty.channel.DefaultEventLoop; //导入依赖的package包/类
private static ClientRequestContext newClientContext(RpcRequest req) {
    return spy(new DefaultClientRequestContext(
            new DefaultEventLoop(), NoopMeterRegistry.get(), SessionProtocol.HTTP,
            Endpoint.of("localhost", 8080), HttpMethod.POST, "/cd/thrift/v1",
            null, null, ClientOptions.DEFAULT, req));
}
 
开发者ID:line,项目名称:centraldogma,代码行数:7,代码来源:CentralDogmaTimeoutSchedulerTest.java


示例3: testProjectAccessController

import io.netty.channel.DefaultEventLoop; //导入依赖的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: ServerBootstrap

import io.netty.channel.DefaultEventLoop; //导入依赖的package包/类
public ServerBootstrap(ThriftServerDef serverDef) {
	this(serverDef, new DefaultChannelGroup(new DefaultEventLoop()));
}
 
开发者ID:houkx,项目名称:nettythrift,代码行数:4,代码来源:ServerBootstrap.java


示例5: isCompatible

import io.netty.channel.DefaultEventLoop; //导入依赖的package包/类
@Override
protected boolean isCompatible(EventLoop eventloop) {
	return eventloop instanceof DefaultEventLoop;
}
 
开发者ID:Shevchik,项目名称:UdpServerSocketChannel,代码行数:5,代码来源:UdpChannel.java


示例6: newChild

import io.netty.channel.DefaultEventLoop; //导入依赖的package包/类
@Override
protected EventLoop newChild(Executor executor, Object... args) throws Exception {
    EventLoop eventLoop = new DefaultEventLoop(this, executor);
    eventLoop.submit(() -> CURRENT_EVENT_LOOP.set(eventLoop)).syncUninterruptibly();
    return eventLoop;
}
 
开发者ID:line,项目名称:armeria,代码行数:7,代码来源:EventLoopJmhExecutor.java


示例7: setUpEventLoop

import io.netty.channel.DefaultEventLoop; //导入依赖的package包/类
@BeforeClass
public static void setUpEventLoop() {
    EVENT_LOOP = new DefaultEventLoop(Executors.newSingleThreadExecutor());
}
 
开发者ID:line,项目名称:armeria,代码行数:5,代码来源:DnsServiceEndpointGroupTest.java


示例8: startEventLoop

import io.netty.channel.DefaultEventLoop; //导入依赖的package包/类
@BeforeClass
public static void startEventLoop() {
    eventLoop = new DefaultEventLoop();
}
 
开发者ID:line,项目名称:armeria,代码行数:5,代码来源:EventLoopStreamMessageVerification.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java FailedListener类代码示例发布时间:2022-05-22
下一篇:
Java CastContext类代码示例发布时间: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