Search in sources :

Example 11 with AsyncResult

use of io.vertx.core.AsyncResult in project vert.x by eclipse.

the class Http2ServerTest method testPushPromise.

private void testPushPromise(Http2Headers requestHeaders, BiConsumer<HttpServerResponse, Handler<AsyncResult<HttpServerResponse>>> pusher, Consumer<Http2Headers> headerChecker) throws Exception {
    Context ctx = vertx.getOrCreateContext();
    server.requestHandler(req -> {
        Handler<AsyncResult<HttpServerResponse>> handler = ar -> {
            assertSame(ctx, Vertx.currentContext());
            assertTrue(ar.succeeded());
            HttpServerResponse response = ar.result();
            response.end("the_content");
            assertIllegalStateException(() -> response.push(HttpMethod.GET, "/wibble2", resp -> {
            }));
        };
        pusher.accept(req.response(), handler);
    });
    startServer(ctx);
    TestClient client = new TestClient();
    ChannelFuture fut = client.connect(DEFAULT_HTTPS_PORT, DEFAULT_HTTPS_HOST, request -> {
        int id = request.nextStreamId();
        Http2ConnectionEncoder encoder = request.encoder;
        encoder.writeHeaders(request.context, id, requestHeaders, 0, true, request.context.newPromise());
        Map<Integer, Http2Headers> pushed = new HashMap<>();
        request.decoder.frameListener(new Http2FrameAdapter() {

            @Override
            public void onPushPromiseRead(ChannelHandlerContext ctx, int streamId, int promisedStreamId, Http2Headers headers, int padding) throws Http2Exception {
                pushed.put(promisedStreamId, headers);
            }

            @Override
            public int onDataRead(ChannelHandlerContext ctx, int streamId, ByteBuf data, int padding, boolean endOfStream) throws Http2Exception {
                int delta = super.onDataRead(ctx, streamId, data, padding, endOfStream);
                String content = data.toString(StandardCharsets.UTF_8);
                vertx.runOnContext(v -> {
                    assertEquals(Collections.singleton(streamId), pushed.keySet());
                    assertEquals("the_content", content);
                    Http2Headers pushedHeaders = pushed.get(streamId);
                    headerChecker.accept(pushedHeaders);
                    testComplete();
                });
                return delta;
            }
        });
    });
    fut.sync();
    await();
}
Also used : Context(io.vertx.core.Context) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) Arrays(java.util.Arrays) GZIPInputStream(java.util.zip.GZIPInputStream) HttpServer(io.vertx.core.http.HttpServer) MultiMap(io.vertx.core.MultiMap) Http2ConnectionEncoder(io.netty.handler.codec.http2.Http2ConnectionEncoder) DefaultHttp2Connection(io.netty.handler.codec.http2.DefaultHttp2Connection) Context(io.vertx.core.Context) Unpooled(io.netty.buffer.Unpooled) Http2ConnectionDecoder(io.netty.handler.codec.http2.Http2ConnectionDecoder) ByteArrayInputStream(java.io.ByteArrayInputStream) HttpVersion(io.vertx.core.http.HttpVersion) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Http2Exception(io.netty.handler.codec.http2.Http2Exception) Map(java.util.Map) ApplicationProtocolNegotiationHandler(io.netty.handler.ssl.ApplicationProtocolNegotiationHandler) ReadStream(io.vertx.core.streams.ReadStream) AbstractHttp2ConnectionHandlerBuilder(io.netty.handler.codec.http2.AbstractHttp2ConnectionHandlerBuilder) Http2FrameAdapter(io.netty.handler.codec.http2.Http2FrameAdapter) StreamResetException(io.vertx.core.http.StreamResetException) ChannelDuplexHandler(io.netty.channel.ChannelDuplexHandler) ChannelInitializer(io.netty.channel.ChannelInitializer) Http2Flags(io.netty.handler.codec.http2.Http2Flags) Set(java.util.Set) ChannelPipeline(io.netty.channel.ChannelPipeline) Http2ConnectionHandler(io.netty.handler.codec.http2.Http2ConnectionHandler) Future(io.vertx.core.Future) InetSocketAddress(java.net.InetSocketAddress) Collectors(java.util.stream.Collectors) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) StandardCharsets(java.nio.charset.StandardCharsets) Base64(java.util.Base64) List(java.util.List) Buffer(io.vertx.core.buffer.Buffer) SslHandler(io.netty.handler.ssl.SslHandler) Http2Headers(io.netty.handler.codec.http2.Http2Headers) HttpServerResponse(io.vertx.core.http.HttpServerResponse) Http2Error(io.netty.handler.codec.http2.Http2Error) HttpClient(io.vertx.core.http.HttpClient) NetSocket(io.vertx.core.net.NetSocket) Trust(io.vertx.test.core.tls.Trust) NioSocketChannel(io.netty.channel.socket.nio.NioSocketChannel) HttpServerRequest(io.vertx.core.http.HttpServerRequest) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Http2EventAdapter(io.netty.handler.codec.http2.Http2EventAdapter) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) HashMap(java.util.HashMap) AtomicReference(java.util.concurrent.atomic.AtomicReference) Function(java.util.function.Function) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) HttpClientRequest(io.vertx.core.http.HttpClientRequest) ByteBuf(io.netty.buffer.ByteBuf) WriteStream(io.vertx.core.streams.WriteStream) Http2Stream(io.netty.handler.codec.http2.Http2Stream) BiConsumer(java.util.function.BiConsumer) AsyncResult(io.vertx.core.AsyncResult) HttpClientOptions(io.vertx.core.http.HttpClientOptions) HttpConnection(io.vertx.core.http.HttpConnection) EventLoopGroup(io.netty.channel.EventLoopGroup) VertxInternal(io.vertx.core.impl.VertxInternal) ClosedChannelException(java.nio.channels.ClosedChannelException) Vertx(io.vertx.core.Vertx) FileOutputStream(java.io.FileOutputStream) ApplicationProtocolNames(io.netty.handler.ssl.ApplicationProtocolNames) Test(org.junit.Test) IOException(java.io.IOException) SSLHelper(io.vertx.core.net.impl.SSLHelper) File(java.io.File) ChannelFuture(io.netty.channel.ChannelFuture) Channel(io.netty.channel.Channel) Http2Settings(io.netty.handler.codec.http2.Http2Settings) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) Bootstrap(io.netty.bootstrap.Bootstrap) AtomicLong(java.util.concurrent.atomic.AtomicLong) Http2Connection(io.netty.handler.codec.http2.Http2Connection) HttpMethod(io.vertx.core.http.HttpMethod) HttpUtils(io.vertx.core.http.impl.HttpUtils) HttpServerOptions(io.vertx.core.http.HttpServerOptions) HttpHeaderNames(io.netty.handler.codec.http.HttpHeaderNames) Handler(io.vertx.core.Handler) Collections(java.util.Collections) TestUtils.assertIllegalStateException(io.vertx.test.core.TestUtils.assertIllegalStateException) DefaultHttp2Headers(io.netty.handler.codec.http2.DefaultHttp2Headers) ChannelFuture(io.netty.channel.ChannelFuture) Http2Exception(io.netty.handler.codec.http2.Http2Exception) Http2FrameAdapter(io.netty.handler.codec.http2.Http2FrameAdapter) HashMap(java.util.HashMap) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) ByteBuf(io.netty.buffer.ByteBuf) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Http2Headers(io.netty.handler.codec.http2.Http2Headers) DefaultHttp2Headers(io.netty.handler.codec.http2.DefaultHttp2Headers) HttpServerResponse(io.vertx.core.http.HttpServerResponse) Http2ConnectionEncoder(io.netty.handler.codec.http2.Http2ConnectionEncoder) AsyncResult(io.vertx.core.AsyncResult)

Example 12 with AsyncResult

use of io.vertx.core.AsyncResult in project vert.x by eclipse.

the class VertxImpl method close.

@Override
public synchronized void close(Handler<AsyncResult<Void>> completionHandler) {
    if (closed || eventBus == null) {
        // Just call the handler directly since pools shutdown
        if (completionHandler != null) {
            completionHandler.handle(Future.succeededFuture());
        }
        return;
    }
    closed = true;
    closeHooks.run(ar -> {
        deploymentManager.undeployAll(ar1 -> {
            if (haManager() != null) {
                haManager().stop();
            }
            addressResolver.close(ar2 -> {
                eventBus.close(ar3 -> {
                    closeClusterManager(ar4 -> {
                        Set<HttpServer> httpServers = new HashSet<>(sharedHttpServers.values());
                        Set<NetServerBase> netServers = new HashSet<>(sharedNetServers.values());
                        sharedHttpServers.clear();
                        sharedNetServers.clear();
                        int serverCount = httpServers.size() + netServers.size();
                        AtomicInteger serverCloseCount = new AtomicInteger();
                        Handler<AsyncResult<Void>> serverCloseHandler = res -> {
                            if (res.failed()) {
                                log.error("Failure in shutting down server", res.cause());
                            }
                            if (serverCloseCount.incrementAndGet() == serverCount) {
                                deleteCacheDirAndShutdown(completionHandler);
                            }
                        };
                        for (HttpServer server : httpServers) {
                            server.close(serverCloseHandler);
                        }
                        for (NetServerBase server : netServers) {
                            server.close(serverCloseHandler);
                        }
                        if (serverCount == 0) {
                            deleteCacheDirAndShutdown(completionHandler);
                        }
                    });
                });
            });
        });
    });
}
Also used : HttpServerImpl(io.vertx.core.http.impl.HttpServerImpl) NetServerImpl(io.vertx.core.net.impl.NetServerImpl) HttpClientImpl(io.vertx.core.http.impl.HttpClientImpl) HttpServer(io.vertx.core.http.HttpServer) NetClientImpl(io.vertx.core.net.impl.NetClientImpl) DummyVertxMetrics(io.vertx.core.metrics.impl.DummyVertxMetrics) Context(io.vertx.core.Context) InetAddress(java.net.InetAddress) EventBus(io.vertx.core.eventbus.EventBus) WindowsFileSystem(io.vertx.core.file.impl.WindowsFileSystem) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) JsonObject(io.vertx.core.json.JsonObject) DatagramSocketOptions(io.vertx.core.datagram.DatagramSocketOptions) Logger(io.vertx.core.logging.Logger) ThreadFactory(java.util.concurrent.ThreadFactory) ClusterManager(io.vertx.core.spi.cluster.ClusterManager) VertxMetricsFactory(io.vertx.core.spi.VertxMetricsFactory) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) VertxOptions(io.vertx.core.VertxOptions) Set(java.util.Set) MetricsProvider(io.vertx.core.spi.metrics.MetricsProvider) EventLoop(io.netty.channel.EventLoop) ResourceLeakDetector(io.netty.util.ResourceLeakDetector) Future(io.vertx.core.Future) ServerID(io.vertx.core.net.impl.ServerID) InetSocketAddress(java.net.InetSocketAddress) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) Executors(java.util.concurrent.Executors) NetClientOptions(io.vertx.core.net.NetClientOptions) DnsClient(io.vertx.core.dns.DnsClient) Objects(java.util.Objects) AddressResolverGroup(io.netty.resolver.AddressResolverGroup) NetServerOptions(io.vertx.core.net.NetServerOptions) PoolMetrics(io.vertx.core.spi.metrics.PoolMetrics) FileSystem(io.vertx.core.file.FileSystem) HttpClient(io.vertx.core.http.HttpClient) DatagramSocketImpl(io.vertx.core.datagram.impl.DatagramSocketImpl) VerticleFactory(io.vertx.core.spi.VerticleFactory) DatagramSocket(io.vertx.core.datagram.DatagramSocket) DnsClientImpl(io.vertx.core.dns.impl.DnsClientImpl) NetServerBase(io.vertx.core.net.impl.NetServerBase) HashMap(java.util.HashMap) LoggerFactory(io.vertx.core.logging.LoggerFactory) SharedData(io.vertx.core.shareddata.SharedData) VertxMetrics(io.vertx.core.spi.metrics.VertxMetrics) ArrayList(java.util.ArrayList) ConcurrentMap(java.util.concurrent.ConcurrentMap) TimeoutStream(io.vertx.core.TimeoutStream) HashSet(java.util.HashSet) ServiceHelper(io.vertx.core.ServiceHelper) SharedDataImpl(io.vertx.core.shareddata.impl.SharedDataImpl) AsyncResult(io.vertx.core.AsyncResult) HttpClientOptions(io.vertx.core.http.HttpClientOptions) NetClient(io.vertx.core.net.NetClient) Metrics(io.vertx.core.spi.metrics.Metrics) ExecutorService(java.util.concurrent.ExecutorService) EventBusImpl(io.vertx.core.eventbus.impl.EventBusImpl) Closeable(io.vertx.core.Closeable) EventLoopGroup(io.netty.channel.EventLoopGroup) Vertx(io.vertx.core.Vertx) GenericFutureListener(io.netty.util.concurrent.GenericFutureListener) Verticle(io.vertx.core.Verticle) File(java.io.File) FileSystemImpl(io.vertx.core.file.impl.FileSystemImpl) TimeUnit(java.util.concurrent.TimeUnit) AtomicLong(java.util.concurrent.atomic.AtomicLong) DeploymentOptions(io.vertx.core.DeploymentOptions) NetServer(io.vertx.core.net.NetServer) HttpServerOptions(io.vertx.core.http.HttpServerOptions) ClusteredEventBus(io.vertx.core.eventbus.impl.clustered.ClusteredEventBus) Handler(io.vertx.core.Handler) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) NetServerBase(io.vertx.core.net.impl.NetServerBase) HttpServer(io.vertx.core.http.HttpServer) AsyncResult(io.vertx.core.AsyncResult) HashSet(java.util.HashSet)

Example 13 with AsyncResult

use of io.vertx.core.AsyncResult in project vert.x by eclipse.

the class NetServerBase method listen.

public synchronized void listen(Handler<? super C> handler, int port, String host, Handler<AsyncResult<Void>> listenHandler) {
    if (handler == null) {
        throw new IllegalStateException("Set connect handler first");
    }
    if (listening) {
        throw new IllegalStateException("Listen already called");
    }
    listening = true;
    listenContext = vertx.getOrCreateContext();
    registeredHandler = handler;
    synchronized (vertx.sharedNetServers()) {
        // Will be updated on bind for a wildcard port
        this.actualPort = port;
        id = new ServerID(port, host);
        NetServerBase shared = vertx.sharedNetServers().get(id);
        if (shared == null || port == 0) {
            // Wildcard port will imply a new actual server each time
            serverChannelGroup = new DefaultChannelGroup("vertx-acceptor-channels", GlobalEventExecutor.INSTANCE);
            ServerBootstrap bootstrap = new ServerBootstrap();
            bootstrap.group(availableWorkers);
            bootstrap.channel(NioServerSocketChannel.class);
            sslHelper.validate(vertx);
            bootstrap.childHandler(new ChannelInitializer<Channel>() {

                @Override
                protected void initChannel(Channel ch) throws Exception {
                    if (isPaused()) {
                        ch.close();
                        return;
                    }
                    ChannelPipeline pipeline = ch.pipeline();
                    NetServerBase.this.initChannel(ch.pipeline());
                    pipeline.addLast("handler", new ServerHandler(ch));
                }
            });
            applyConnectionOptions(bootstrap);
            handlerManager.addHandler(handler, listenContext);
            try {
                bindFuture = AsyncResolveConnectHelper.doBind(vertx, port, host, bootstrap);
                bindFuture.addListener(res -> {
                    if (res.succeeded()) {
                        Channel ch = res.result();
                        log.trace("Net server listening on " + host + ":" + ch.localAddress());
                        NetServerBase.this.actualPort = ((InetSocketAddress) ch.localAddress()).getPort();
                        NetServerBase.this.id = new ServerID(NetServerBase.this.actualPort, id.host);
                        serverChannelGroup.add(ch);
                        vertx.sharedNetServers().put(id, NetServerBase.this);
                        metrics = vertx.metricsSPI().createMetrics(new SocketAddressImpl(id.port, id.host), options);
                    } else {
                        vertx.sharedNetServers().remove(id);
                    }
                });
            } catch (Throwable t) {
                // Make sure we send the exception back through the handler (if any)
                if (listenHandler != null) {
                    vertx.runOnContext(v -> listenHandler.handle(Future.failedFuture(t)));
                } else {
                    // No handler - log so user can see failure
                    log.error(t);
                }
                listening = false;
                return;
            }
            if (port != 0) {
                vertx.sharedNetServers().put(id, this);
            }
            actualServer = this;
        } else {
            // Server already exists with that host/port - we will use that
            actualServer = shared;
            this.actualPort = shared.actualPort();
            metrics = vertx.metricsSPI().createMetrics(new SocketAddressImpl(id.port, id.host), options);
            actualServer.handlerManager.addHandler(handler, listenContext);
        }
        // just add it to the future so it gets notified once the bind is complete
        actualServer.bindFuture.addListener(res -> {
            if (listenHandler != null) {
                AsyncResult<Void> ares;
                if (res.succeeded()) {
                    ares = Future.succeededFuture();
                } else {
                    listening = false;
                    ares = Future.failedFuture(res.cause());
                }
                listenContext.runOnContext(v -> listenHandler.handle(ares));
            } else if (res.failed()) {
                log.error("Failed to listen", res.cause());
                listening = false;
            }
        });
    }
    return;
}
Also used : DefaultChannelGroup(io.netty.channel.group.DefaultChannelGroup) ChannelOption(io.netty.channel.ChannelOption) ContextImpl(io.vertx.core.impl.ContextImpl) ByteBufAllocator(io.netty.buffer.ByteBufAllocator) DefaultChannelGroup(io.netty.channel.group.DefaultChannelGroup) TCPMetrics(io.vertx.core.spi.metrics.TCPMetrics) LoggerFactory(io.vertx.core.logging.LoggerFactory) GlobalEventExecutor(io.netty.util.concurrent.GlobalEventExecutor) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) FixedRecvByteBufAllocator(io.netty.channel.FixedRecvByteBufAllocator) Map(java.util.Map) AsyncResult(io.vertx.core.AsyncResult) Logger(io.vertx.core.logging.Logger) Metrics(io.vertx.core.spi.metrics.Metrics) Closeable(io.vertx.core.Closeable) ChannelGroup(io.netty.channel.group.ChannelGroup) VertxInternal(io.vertx.core.impl.VertxInternal) ChannelInitializer(io.netty.channel.ChannelInitializer) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) NioServerSocketChannel(io.netty.channel.socket.nio.NioServerSocketChannel) MetricsProvider(io.vertx.core.spi.metrics.MetricsProvider) ChannelPipeline(io.netty.channel.ChannelPipeline) EventLoop(io.netty.channel.EventLoop) Future(io.vertx.core.Future) InetSocketAddress(java.net.InetSocketAddress) Channel(io.netty.channel.Channel) NetServerOptions(io.vertx.core.net.NetServerOptions) SslHandler(io.netty.handler.ssl.SslHandler) ServerBootstrap(io.netty.bootstrap.ServerBootstrap) ChannelGroupFuture(io.netty.channel.group.ChannelGroupFuture) Handler(io.vertx.core.Handler) NioServerSocketChannel(io.netty.channel.socket.nio.NioServerSocketChannel) Channel(io.netty.channel.Channel) ServerBootstrap(io.netty.bootstrap.ServerBootstrap) ChannelPipeline(io.netty.channel.ChannelPipeline)

Example 14 with AsyncResult

use of io.vertx.core.AsyncResult in project vert.x by eclipse.

the class NetSocketImpl method sendFile.

@Override
public NetSocket sendFile(String filename, long offset, long length, final Handler<AsyncResult<Void>> resultHandler) {
    File f = vertx.resolveFile(filename);
    if (f.isDirectory()) {
        throw new IllegalArgumentException("filename must point to a file and not to a directory");
    }
    RandomAccessFile raf = null;
    try {
        raf = new RandomAccessFile(f, "r");
        ChannelFuture future = super.sendFile(raf, Math.min(offset, f.length()), Math.min(length, f.length() - offset));
        if (resultHandler != null) {
            future.addListener(fut -> {
                final AsyncResult<Void> res;
                if (future.isSuccess()) {
                    res = Future.succeededFuture();
                } else {
                    res = Future.failedFuture(future.cause());
                }
                vertx.runOnContext(v -> resultHandler.handle(res));
            });
        }
    } catch (IOException e) {
        try {
            if (raf != null) {
                raf.close();
            }
        } catch (IOException ignore) {
        }
        if (resultHandler != null) {
            vertx.runOnContext(v -> resultHandler.handle(Future.failedFuture(e)));
        } else {
            log.error("Failed to send file", e);
        }
    }
    return this;
}
Also used : ChannelFuture(io.netty.channel.ChannelFuture) RandomAccessFile(java.io.RandomAccessFile) ContextImpl(io.vertx.core.impl.ContextImpl) TCPMetrics(io.vertx.core.spi.metrics.TCPMetrics) NetworkMetrics(io.vertx.core.spi.metrics.NetworkMetrics) LoggerFactory(io.vertx.core.logging.LoggerFactory) Unpooled(io.netty.buffer.Unpooled) ByteBuf(io.netty.buffer.ByteBuf) Charset(java.nio.charset.Charset) ChannelFutureListener(io.netty.channel.ChannelFutureListener) CharsetUtil(io.netty.util.CharsetUtil) AsyncResult(io.vertx.core.AsyncResult) Logger(io.vertx.core.logging.Logger) SocketAddress(io.vertx.core.net.SocketAddress) VertxInternal(io.vertx.core.impl.VertxInternal) Message(io.vertx.core.eventbus.Message) IOException(java.io.IOException) UUID(java.util.UUID) X509Certificate(javax.security.cert.X509Certificate) Future(io.vertx.core.Future) File(java.io.File) ChannelFuture(io.netty.channel.ChannelFuture) Channel(io.netty.channel.Channel) Buffer(io.vertx.core.buffer.Buffer) SslHandler(io.netty.handler.ssl.SslHandler) Handler(io.vertx.core.Handler) MessageConsumer(io.vertx.core.eventbus.MessageConsumer) NetSocket(io.vertx.core.net.NetSocket) SSLPeerUnverifiedException(javax.net.ssl.SSLPeerUnverifiedException) RandomAccessFile(java.io.RandomAccessFile) IOException(java.io.IOException) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File)

Example 15 with AsyncResult

use of io.vertx.core.AsyncResult in project vert.x by eclipse.

the class Http2ServerConnection method sendPush.

synchronized void sendPush(int streamId, String host, HttpMethod method, MultiMap headers, String path, Handler<AsyncResult<HttpServerResponse>> completionHandler) {
    Http2Headers headers_ = new DefaultHttp2Headers();
    if (method == HttpMethod.OTHER) {
        throw new IllegalArgumentException("Cannot push HttpMethod.OTHER");
    } else {
        headers_.method(method.name());
    }
    headers_.path(path);
    headers_.scheme(isSsl() ? "https" : "http");
    if (host != null) {
        headers_.authority(host);
    }
    if (headers != null) {
        headers.forEach(header -> headers_.add(header.getKey(), header.getValue()));
    }
    handler.writePushPromise(streamId, headers_, new Handler<AsyncResult<Integer>>() {

        @Override
        public void handle(AsyncResult<Integer> ar) {
            if (ar.succeeded()) {
                synchronized (Http2ServerConnection.this) {
                    int promisedStreamId = ar.result();
                    String contentEncoding = HttpUtils.determineContentEncoding(headers_);
                    Http2Stream promisedStream = handler.connection().stream(promisedStreamId);
                    boolean writable = handler.encoder().flowController().isWritable(promisedStream);
                    Push push = new Push(promisedStream, contentEncoding, method, path, writable, completionHandler);
                    streams.put(promisedStreamId, push);
                    if (maxConcurrentStreams == null || concurrentStreams < maxConcurrentStreams) {
                        concurrentStreams++;
                        context.executeFromIO(push::complete);
                    } else {
                        pendingPushes.add(push);
                    }
                }
            } else {
                context.executeFromIO(() -> {
                    completionHandler.handle(Future.failedFuture(ar.cause()));
                });
            }
        }
    });
}
Also used : Http2Headers(io.netty.handler.codec.http2.Http2Headers) DefaultHttp2Headers(io.netty.handler.codec.http2.DefaultHttp2Headers) DefaultHttp2Headers(io.netty.handler.codec.http2.DefaultHttp2Headers) Http2Stream(io.netty.handler.codec.http2.Http2Stream) AsyncResult(io.vertx.core.AsyncResult)

Aggregations

AsyncResult (io.vertx.core.AsyncResult)20 Handler (io.vertx.core.Handler)15 Future (io.vertx.core.Future)14 Buffer (io.vertx.core.buffer.Buffer)10 ContextImpl (io.vertx.core.impl.ContextImpl)8 VertxInternal (io.vertx.core.impl.VertxInternal)8 Logger (io.vertx.core.logging.Logger)8 LoggerFactory (io.vertx.core.logging.LoggerFactory)8 ByteBuf (io.netty.buffer.ByteBuf)7 Unpooled (io.netty.buffer.Unpooled)6 Map (java.util.Map)6 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)6 Channel (io.netty.channel.Channel)5 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)5 ChannelPipeline (io.netty.channel.ChannelPipeline)5 SslHandler (io.netty.handler.ssl.SslHandler)5 Context (io.vertx.core.Context)5 MultiMap (io.vertx.core.MultiMap)5 NetSocket (io.vertx.core.net.NetSocket)5 File (java.io.File)5