Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/upstream/3.3' into servlet
Browse files Browse the repository at this point in the history
# Conflicts:
#	dubbo-common/src/main/java/org/apache/dubbo/config/nested/TripleConfig.java
#	dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleProtocol.java
  • Loading branch information
oxsean committed Jun 16, 2024
2 parents 24923ce + 35adffa commit 3800eb4
Show file tree
Hide file tree
Showing 79 changed files with 3,401 additions and 547 deletions.
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 @@ -81,9 +81,6 @@ public static ProtocolConfig getProtocol(URL url) {

/**
* Set application config
*
* @param application
* @return current application config instance
*/
@DisableInject
public void setApplication(ApplicationConfig application) {
Expand Down Expand Up @@ -152,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 @@ -222,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 @@ -294,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 @@ -324,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;

/**
* Enable servlet support, requests are transport through the servlet container,
* which only supports unary calls due to protocol limitations
Expand Down Expand Up @@ -215,6 +308,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 Boolean getEnableServlet() {
return enableServlet;
}
Expand Down
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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,65 @@
*/
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;

import java.util.concurrent.CompletableFuture;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class GreeterServiceImpl implements GreeterService {

private static final Logger LOG = LoggerFactory.getLogger(GreeterServiceImpl.class);

@Override
public HelloReply sayHello(HelloRequest request) {
return HelloReply.newBuilder().setMessage("Hello " + request.getName()).build();
LOG.info("Received sayHello request: {}", request.getName());
return toReply("Hello " + request.getName());
}

@Override
public CompletableFuture<String> sayHelloAsync(String name) {
return CompletableFuture.supplyAsync(() -> name);
LOG.info("Received sayHelloAsync request: {}", name);
return CompletableFuture.supplyAsync(() -> "Hello " + name);
}

@Override
public void sayHelloServerStream(HelloRequest request, StreamObserver<HelloReply> responseObserver) {
LOG.info("Received sayHelloServerStream request");
for (int i = 1; i < 6; i++) {
LOG.info("sayHelloServerStream onNext: {} {} times", request.getName(), i);
responseObserver.onNext(toReply("Hello " + request.getName() + ' ' + i + " times"));
}
LOG.info("sayHelloServerStream onCompleted");
responseObserver.onCompleted();
}

@Override
public StreamObserver<HelloRequest> sayHelloBiStream(StreamObserver<HelloReply> responseObserver) {
LOG.info("Received sayHelloBiStream request");
return new StreamObserver<HelloRequest>() {
@Override
public void onNext(HelloRequest request) {
LOG.info("sayHelloBiStream onNext: {}", request.getName());
responseObserver.onNext(toReply("Hello " + request.getName()));
}

@Override
public void onError(Throwable throwable) {
LOG.error("sayHelloBiStream onError", throwable);
}

@Override
public void onCompleted() {
LOG.info("sayHelloBiStream onCompleted");
}
};
}

private static HelloReply toReply(String message) {
return HelloReply.newBuilder().setMessage(message).build();
}
}
Loading

0 comments on commit 3800eb4

Please sign in to comment.