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

HTTP/3 support for dubbo triple #14033

Merged
merged 5 commits into from
Jun 16, 2024
Merged
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
1 change: 1 addition & 0 deletions .artifacts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ dubbo-registry-zookeeper
dubbo-remoting
dubbo-remoting-api
dubbo-remoting-http12
dubbo-remoting-http3
dubbo-remoting-netty
dubbo-remoting-netty4
dubbo-remoting-zookeeper-curator5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
/**
* Stream utils.
*/
public class StreamUtils {
public final class StreamUtils {

public static final ByteArrayInputStream EMPTY = new ByteArrayInputStream(new byte[0]);

private StreamUtils() {}

public static InputStream limitedInputStream(final InputStream is, final int limit) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.apache.dubbo.config.context;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.context.ApplicationExt;
import org.apache.dubbo.common.extension.DisableInject;
import org.apache.dubbo.common.logger.Logger;
Expand Down Expand Up @@ -72,13 +73,14 @@ public ConfigManager(ApplicationModel applicationModel) {
TracingConfig.class));
}

public static ProtocolConfig getProtocol(URL url) {
return url.getOrDefaultApplicationModel().getApplicationConfigManager().getOrAddProtocol(url.getProtocol());
}

// ApplicationConfig correlative methods

/**
* Set application config
*
* @param application
* @return current application config instance
*/
@DisableInject
public void setApplication(ApplicationConfig application) {
Expand Down Expand Up @@ -147,7 +149,7 @@ public Optional<Collection<ConfigCenterConfig>> getDefaultConfigCenter() {
if (CollectionUtils.isEmpty(defaults)) {
defaults = getConfigCenters();
}
return Optional.ofNullable(defaults);
return ofNullable(defaults);
}

public Optional<ConfigCenterConfig> getConfigCenter(String id) {
Expand Down Expand Up @@ -217,6 +219,7 @@ public List<ProtocolConfig> getDefaultProtocols() {
}

@Override
@SuppressWarnings("RedundantMethodOverride")
public <C extends AbstractConfig> List<C> getDefaultConfigs(Class<C> cls) {
return getDefaultConfigs(getConfigsMap(getTagName(cls)));
}
Expand Down Expand Up @@ -289,7 +292,7 @@ public void loadConfigs() {
// load dubbo.metadata-report.xxx
loadConfigsOfTypeFromProps(MetadataReportConfig.class);

// config centers has bean loaded before starting config center
// config centers has been loaded before starting config center
// loadConfigsOfTypeFromProps(ConfigCenterConfig.class);

refreshAll();
Expand Down Expand Up @@ -319,7 +322,7 @@ private void checkConfigs() {

// check port conflicts
Map<Integer, ProtocolConfig> protocolPortMap = new LinkedHashMap<>();
for (ProtocolConfig protocol : this.getProtocols()) {
for (ProtocolConfig protocol : getProtocols()) {
Integer port = protocol.getPort();
if (port == null || port == -1) {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,99 @@ public class TripleConfig implements Serializable {
*/
private Integer maxHeaderListSize;

/**
* Enable http3 support
* <p>The default value is false.
*/
private Boolean enableHttp3;

/**
* See <a href="https://docs.rs/quiche/0.6.0/quiche/struct.Config.html#method.set_initial_max_data">set_initial_max_data</a>.
* <p>The default value is 8MiB.
*/
private Integer http3InitialMaxData;

/**
* If configured this will enable <a href="https://tools.ietf.org/html/draft-ietf-quic-datagram-01">Datagram support.</a>
*/
private Integer http3RecvQueueLen;

/**
* If configured this will enable <a href="https://tools.ietf.org/html/draft-ietf-quic-datagram-01">Datagram support.</a>
*/
private Integer http3SendQueueLen;

/**
* See
* <a href="https://docs.rs/quiche/0.6.0/quiche/struct.Config.html#method.set_initial_max_stream_data_bidi_local">set_initial_max_stream_data_bidi_local</a>.
* <p>The default value is 1MiB.
*/
private Integer http3InitialMaxStreamDataBidiLocal;

/**
* See
* <a href="https://docs.rs/quiche/0.6.0/quiche/struct.Config.html#method.set_initial_max_stream_data_bidi_remote">set_initial_max_stream_data_bidi_remote</a>.
* <p>The default value is 1MiB.
*/
private Integer http3InitialMaxStreamDataBidiRemote;

/**
* See
* <a href="https://docs.rs/quiche/0.6.0/quiche/struct.Config.html#method.set_initial_max_stream_data_uni">set_initial_max_stream_data_uni</a>.
* <p>The default value is 0.
*/
private Integer http3InitialMaxStreamDataUni;

/**
* See
* <a href="https://docs.rs/quiche/0.6.0/quiche/struct.Config.html#method.set_initial_max_streams_bidi">set_initial_max_streams_bidi</a>.
* <p>The default value is 1B(2^30).
*/
private Long http3InitialMaxStreamsBidi;

/**
* See
* <a href="https://docs.rs/quiche/0.6.0/quiche/struct.Config.html#method.set_initial_max_streams_uni">set_initial_max_streams_uni</a>.
* <p>
* <p>The default value is 1B(2^30).
*/
private Long http3InitialMaxStreamsUni;

/**
* See
* <a href="https://docs.rs/quiche/0.6.0/quiche/struct.Config.html#method.set_ack_delay_exponent">set_ack_delay_exponent</a>.
* <p>The default value is 3.
*/
private Integer http3MaxAckDelayExponent;

/**
* See
* <a href="https://docs.rs/quiche/0.6.0/quiche/struct.Config.html#method.set_max_ack_delay">set_max_ack_delay</a>.
* <p>The default value is 25 milliseconds.
*/
private Integer http3MaxAckDelay;

/**
* See
* <a href="https://docs.rs/quiche/0.6.0/quiche/struct.Config.html#method.set_disable_active_migration">set_disable_active_migration</a>.
* <p>The default value is {@code false}.
*/
private Boolean http3DisableActiveMigration;

/**
* See
* <a href="https://docs.rs/quiche/0.6.0/quiche/struct.Config.html#method.enable_hystart">enable_hystart</a>.
* <p>The default value is {@code true}.
*/
private Boolean http3EnableHystart;

/**
* Sets the congestion control algorithm to use.
* <p>Supported algorithms are {@code "RENO"} or {@code "CUBIC"} or {@code "BBR"}.
* <p>The default value is {@code "CUBIC"}.
*/
private String http3CcAlgorithm;

public Integer getMaxBodySize() {
return maxBodySize;
}
Expand Down Expand Up @@ -196,6 +289,118 @@ public void setMaxHeaderListSize(Integer maxHeaderListSize) {
this.maxHeaderListSize = maxHeaderListSize;
}

public Boolean getEnableHttp3() {
return enableHttp3;
}

public void setEnableHttp3(Boolean enableHttp3) {
this.enableHttp3 = enableHttp3;
}

public Integer getHttp3InitialMaxData() {
return http3InitialMaxData;
}

public void setHttp3InitialMaxData(Integer http3InitialMaxData) {
this.http3InitialMaxData = http3InitialMaxData;
}

public Integer getHttp3RecvQueueLen() {
return http3RecvQueueLen;
}

public void setHttp3RecvQueueLen(Integer http3RecvQueueLen) {
this.http3RecvQueueLen = http3RecvQueueLen;
}

public Integer getHttp3SendQueueLen() {
return http3SendQueueLen;
}

public void setHttp3SendQueueLen(Integer http3SendQueueLen) {
this.http3SendQueueLen = http3SendQueueLen;
}

public Integer getHttp3InitialMaxStreamDataBidiLocal() {
return http3InitialMaxStreamDataBidiLocal;
}

public void setHttp3InitialMaxStreamDataBidiLocal(Integer http3InitialMaxStreamDataBidiLocal) {
this.http3InitialMaxStreamDataBidiLocal = http3InitialMaxStreamDataBidiLocal;
}

public Integer getHttp3InitialMaxStreamDataBidiRemote() {
return http3InitialMaxStreamDataBidiRemote;
}

public void setHttp3InitialMaxStreamDataBidiRemote(Integer http3InitialMaxStreamDataBidiRemote) {
this.http3InitialMaxStreamDataBidiRemote = http3InitialMaxStreamDataBidiRemote;
}

public Integer getHttp3InitialMaxStreamDataUni() {
return http3InitialMaxStreamDataUni;
}

public void setHttp3InitialMaxStreamDataUni(Integer http3InitialMaxStreamDataUni) {
this.http3InitialMaxStreamDataUni = http3InitialMaxStreamDataUni;
}

public Long getHttp3InitialMaxStreamsBidi() {
return http3InitialMaxStreamsBidi;
}

public void setHttp3InitialMaxStreamsBidi(Long http3InitialMaxStreamsBidi) {
this.http3InitialMaxStreamsBidi = http3InitialMaxStreamsBidi;
}

public Long getHttp3InitialMaxStreamsUni() {
return http3InitialMaxStreamsUni;
}

public void setHttp3InitialMaxStreamsUni(Long http3InitialMaxStreamsUni) {
this.http3InitialMaxStreamsUni = http3InitialMaxStreamsUni;
}

public Integer getHttp3MaxAckDelayExponent() {
return http3MaxAckDelayExponent;
}

public void setHttp3MaxAckDelayExponent(Integer http3MaxAckDelayExponent) {
this.http3MaxAckDelayExponent = http3MaxAckDelayExponent;
}

public Integer getHttp3MaxAckDelay() {
return http3MaxAckDelay;
}

public void setHttp3MaxAckDelay(Integer http3MaxAckDelay) {
this.http3MaxAckDelay = http3MaxAckDelay;
}

public Boolean getHttp3DisableActiveMigration() {
return http3DisableActiveMigration;
}

public void setHttp3DisableActiveMigration(Boolean http3DisableActiveMigration) {
this.http3DisableActiveMigration = http3DisableActiveMigration;
}

public Boolean getHttp3EnableHystart() {
return http3EnableHystart;
}

public void setHttp3EnableHystart(Boolean http3EnableHystart) {
this.http3EnableHystart = http3EnableHystart;
}

public String getHttp3CcAlgorithm() {
return http3CcAlgorithm;
}

public void setHttp3CcAlgorithm(String http3CcAlgorithm) {
this.http3CcAlgorithm = http3CcAlgorithm;
}

public void checkDefault() {
if (maxBodySize == null) {
maxBodySize = 1 << 23;
Expand Down Expand Up @@ -233,5 +438,20 @@ public void checkDefault() {
if (maxHeaderListSize == null) {
maxHeaderListSize = 1 << 15;
}
if (http3InitialMaxData == null) {
http3InitialMaxData = 1 << 23;
}
if (http3InitialMaxStreamDataBidiLocal == null) {
http3InitialMaxStreamDataBidiLocal = 1 << 20;
}
if (http3InitialMaxStreamDataBidiRemote == null) {
http3InitialMaxStreamDataBidiRemote = 1 << 20;
}
if (http3InitialMaxStreamsBidi == null) {
http3InitialMaxStreamsBidi = (long) 1 << 30;
}
if (http3InitialMaxStreamsUni == null) {
http3InitialMaxStreamsUni = (long) 1 << 30;
}
}
}
9 changes: 9 additions & 0 deletions dubbo-demo/dubbo-demo-triple/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15on</artifactId>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-remoting-http3</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.apache.dubbo.demo;

import org.apache.dubbo.common.stream.StreamObserver;
import org.apache.dubbo.demo.hello.HelloReply;
import org.apache.dubbo.demo.hello.HelloRequest;

Expand All @@ -28,5 +29,18 @@ public interface GreeterService {
*/
HelloReply sayHello(HelloRequest request);

/**
* Sends a greeting asynchronously
*/
CompletableFuture<String> sayHelloAsync(String request);

/**
* Sends a greeting with server streaming
*/
void sayHelloServerStream(HelloRequest request, StreamObserver<HelloReply> responseObserver);

/**
* Sends greetings with bi streaming
*/
StreamObserver<HelloRequest> sayHelloBiStream(StreamObserver<HelloReply> responseObserver);
}
Loading
Loading