Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[issue-1287] added io.undertow Http2* replacement classes for io.unde… #1295

Open
wants to merge 4 commits into
base: 2.0.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,5 @@ workflows:
- build:
matrix:
parameters:
jdk-version: ["8.0"] # TODO: Add JDK 11.0 when builds for JDK8 work
category: ["docker"] # TODO: Add builds for kubernetes and openshift
jdk-version: ["11.0"] # TODO: Add JDK 11.0 when builds for JDK8 work
category: ["docker"] # TODO: Add builds for kubernetes and openshift
Binary file modified .mvn/wrapper/maven-wrapper.jar
Binary file not shown.
19 changes: 18 additions & 1 deletion .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1 +1,18 @@
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package io.undertow.protocols.http2;

import io.undertow.connector.ByteBufferPool;
import io.undertow.connector.PooledByteBuffer;
import io.undertow.UndertowLogger;

import java.io.IOException;
import java.util.Collections;
import org.xnio.OptionMap;
import org.xnio.StreamConnection;

public class Http2ChannelWithoutFlowControl extends Http2Channel {

private int initialWindowSize;
private int currentWindowSize;

public Http2ChannelWithoutFlowControl(StreamConnection connectedStreamChannel, ByteBufferPool bufferPool,
PooledByteBuffer data, ByteBufferPool heapBufferPool, boolean clientSide, OptionMap options) {
super(connectedStreamChannel, null, bufferPool, data, clientSide, false,
false, heapBufferPool.allocate().getBuffer(),options);
currentWindowSize = initialWindowSize = getInitialSendWindowSize();
}

@Override
synchronized int grabFlowControlBytes(final int bytesToGrab) {
//Doing by this way the window will always have space so the connection will not hang anymore.
currentWindowSize += bytesToGrab;
updateSettings(
Collections.singletonList(new Http2Setting(Http2Setting.SETTINGS_INITIAL_WINDOW_SIZE, currentWindowSize)));
try {
super.updateReceiveFlowControlWindow(currentWindowSize);
} catch (IOException e) {
UndertowLogger.REQUEST_IO_LOGGER.ioException(e);
}
// no flow control
return super.grabFlowControlBytes(bytesToGrab);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.arquillian.cube.kubernetes.impl.portforward;

import java.nio.ByteBuffer;
import java.io.IOException;
import java.util.Timer;
import java.util.TimerTask;
Expand All @@ -19,7 +20,7 @@
import io.undertow.client.ClientExchange;
import io.undertow.client.ClientRequest;
import io.undertow.connector.ByteBufferPool;
import io.undertow.protocols.spdy.SpdyStreamStreamSinkChannel;
import io.undertow.protocols.http2.Http2StreamSinkChannel;
import io.undertow.server.AbstractServerConnection;
import io.undertow.server.HttpServerExchange;
import io.undertow.server.HttpUpgradeListener;
Expand Down Expand Up @@ -259,7 +260,7 @@ public void failed(IOException e) {
getBufferPool());

// keep alive
timer.scheduleAtFixedRate(new PingSpdyStream((SpdyStreamStreamSinkChannel) result.getRequestChannel()),
timer.scheduleAtFixedRate(new PingHttp2Stream((Http2StreamSinkChannel) result.getRequestChannel()),
15000, 15000); // OSE times out after 30s

// need to wait for the client to close the request channel
Expand Down Expand Up @@ -317,11 +318,11 @@ public void handleEvent(CloseableChannel channel) {
}
}

private final class PingSpdyStream extends TimerTask {
private final class PingHttp2Stream extends TimerTask {

private final SpdyStreamStreamSinkChannel stream;
private final Http2StreamSinkChannel stream;

private PingSpdyStream(SpdyStreamStreamSinkChannel stream) {
private PingHttp2Stream(Http2StreamSinkChannel stream) {
super();
this.stream = stream;
}
Expand All @@ -332,7 +333,7 @@ public void run() {
@Override
public void run() {
if (stream.isOpen()) {
stream.getChannel().sendPing(stream.getStreamId());
stream.getChannel().sendPing(ByteBuffer.allocate(4).putInt(stream.getStreamId()).array());
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
import io.undertow.client.ClientExchange;
import io.undertow.client.ClientRequest;
import io.undertow.client.UndertowClient;
import io.undertow.client.spdy.SpdyClientConnection;
import io.undertow.client.http2.Http2ClientConnection;
import io.undertow.connector.ByteBufferPool;
import io.undertow.protocols.spdy.SpdyChannel;
import io.undertow.protocols.spdy.SpdyChannelWithoutFlowControl;
import io.undertow.protocols.http2.Http2Channel;
import io.undertow.protocols.http2.Http2ChannelWithoutFlowControl;
import io.undertow.server.XnioByteBufferPool;
import io.undertow.util.Headers;
import io.undertow.util.Methods;
Expand Down Expand Up @@ -247,17 +247,17 @@ protected void error(IOException e) {
}
}.setup(result.getResponseChannel());

// Create the upgraded SPDY connection
// Create the upgraded Http2 connection
ByteBufferPool heapBufferPool =
new XnioByteBufferPool(new ByteBufferSlicePool(BufferAllocator.BYTE_BUFFER_ALLOCATOR, 8196, 8196));
SpdyChannel spdyChannel =
new SpdyChannelWithoutFlowControl(connection.performUpgrade(), bufferPool, null, heapBufferPool, true,
Http2Channel http2Channel =
new Http2ChannelWithoutFlowControl(connection.performUpgrade(), bufferPool, null, heapBufferPool, true,
OptionMap.EMPTY);
Integer idleTimeout = DEFAULT_OPTIONS.get(UndertowOptions.IDLE_TIMEOUT);
if (idleTimeout != null && idleTimeout > 0) {
spdyChannel.setIdleTimeout(idleTimeout);
http2Channel.setIdleTimeout(idleTimeout);
}
connection = new SpdyClientConnection(spdyChannel, null);
connection = new Http2ClientConnection(http2Channel, false, this.portForwardURI.getHost(), null);
} else {
throw new IOException("Failed to upgrade connection");
}
Expand Down
Loading