Merge branch 'apache-3.2' into apache-3.3
# Conflicts: # README.md # dubbo-build-tools/pom.xml # dubbo-common/src/main/java/org/apache/dubbo/config/AbstractInterfaceConfig.java # dubbo-common/src/main/java/org/apache/dubbo/config/MetricsConfig.java # dubbo-dependencies-bom/pom.xml # dubbo-dependencies/dubbo-dependencies-zookeeper-curator5/pom.xml # dubbo-dependencies/dubbo-dependencies-zookeeper/pom.xml # dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/api/pu/AbstractPortUnificationServer.java # dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyPortUnificationServerHandler.java # pom.xml
This commit is contained in:
commit
ce570dd932
|
|
@ -1,7 +1,7 @@
|
|||
# Apache Dubbo Project
|
||||
|
||||
[](https://github.com/apache/dubbo/actions/workflows/build-and-test-pr.yml)
|
||||
[](https://codecov.io/gh/apache/dubbo)
|
||||
[](https://codecov.io/gh/apache/dubbo)
|
||||

|
||||

|
||||
[](http://isitmaintained.com/project/apache/dubbo "Average time to resolve an issue")
|
||||
|
|
@ -86,9 +86,9 @@ See [CONTRIBUTING](https://github.com/apache/dubbo/blob/master/CONTRIBUTING.md)
|
|||
* Fix bugs reported on [issues](https://github.com/apache/dubbo/issues), and send us a pull request.
|
||||
* Review the existing [pull request](https://github.com/apache/dubbo/pulls).
|
||||
* Improve the [website](https://github.com/apache/dubbo-website), typically we need
|
||||
* blog post
|
||||
* translation on documentation
|
||||
* use cases around the integration of Dubbo in enterprise systems.
|
||||
* blog post
|
||||
* translation on documentation
|
||||
* use cases around the integration of Dubbo in enterprise systems.
|
||||
* Improve the [dubbo-admin/dubbo-monitor](https://github.com/apache/dubbo-admin).
|
||||
* Contribute to the projects listed in [ecosystem](https://github.com/dubbo).
|
||||
* Other forms of contribution not explicitly enumerated above.
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import org.apache.dubbo.common.compiler.support.AdaptiveCompiler;
|
|||
import org.apache.dubbo.common.config.ConfigurationUtils;
|
||||
import org.apache.dubbo.common.config.Environment;
|
||||
import org.apache.dubbo.common.config.InmemoryConfiguration;
|
||||
import org.apache.dubbo.common.utils.Assert;
|
||||
import org.apache.dubbo.common.utils.ClassUtils;
|
||||
import org.apache.dubbo.common.utils.CollectionUtils;
|
||||
import org.apache.dubbo.common.utils.ConfigUtils;
|
||||
|
|
@ -284,23 +283,6 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated After metrics config is refactored.
|
||||
* This method should no longer use and will be deleted in the future.
|
||||
*/
|
||||
@Deprecated
|
||||
protected void appendMetricsCompatible(Map<String, String> map) {
|
||||
MetricsConfig metricsConfig = getConfigManager().getMetrics().orElse(null);
|
||||
if (metricsConfig != null) {
|
||||
String protocol = Optional.ofNullable(metricsConfig.getProtocol()).orElse(PROTOCOL_PROMETHEUS);
|
||||
if (!StringUtils.isEquals(protocol, PROTOCOL_PROMETHEUS)) {
|
||||
Assert.notEmptyString(metricsConfig.getPort(), "Metrics port cannot be null");
|
||||
map.put("metrics.protocol", protocol);
|
||||
map.put("metrics.port", metricsConfig.getPort());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* To obtain the method list in the port, use reflection when in native mode and javassist otherwise.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -84,12 +84,6 @@ public class MetricsConfig extends AbstractConfig {
|
|||
*/
|
||||
private Integer collectorSyncPeriod;
|
||||
|
||||
/**
|
||||
* Deprecated: This parameter should no longer be used and will be removed in the future.
|
||||
*/
|
||||
@Deprecated
|
||||
private String port;
|
||||
|
||||
/**
|
||||
* Configuration for Prometheus metrics collection.
|
||||
*/
|
||||
|
|
@ -182,14 +176,6 @@ public class MetricsConfig extends AbstractConfig {
|
|||
this.enableRegistry = enableRegistry;
|
||||
}
|
||||
|
||||
public String getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setPort(String port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public PrometheusConfig getPrometheus() {
|
||||
return prometheus;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,15 +32,18 @@ import java.util.Map;
|
|||
public final class DefaultTypeBuilder {
|
||||
|
||||
public static TypeDefinition build(Class<?> clazz, Map<String, TypeDefinition> typeCache) {
|
||||
final String canonicalName = clazz.getCanonicalName();
|
||||
String className = clazz.getCanonicalName();
|
||||
if (className == null) {
|
||||
className = clazz.getName();
|
||||
}
|
||||
|
||||
// Try to get a cached definition
|
||||
TypeDefinition td = typeCache.get(canonicalName);
|
||||
TypeDefinition td = typeCache.get(className);
|
||||
if (td != null) {
|
||||
return td;
|
||||
}
|
||||
td = new TypeDefinition(canonicalName);
|
||||
typeCache.put(canonicalName, td);
|
||||
td = new TypeDefinition(className);
|
||||
typeCache.put(className, td);
|
||||
|
||||
// Primitive type
|
||||
if (!JaketConfigurationUtils.needAnalyzing(clazz)) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.apache.dubbo.metadata.definition;
|
||||
|
||||
import org.apache.dubbo.metadata.definition.builder.DefaultTypeBuilder;
|
||||
import org.apache.dubbo.rpc.model.FrameworkModel;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class DefaultTypeBuilderTest {
|
||||
@Test
|
||||
void testInnerClass() {
|
||||
TypeDefinitionBuilder.initBuilders(FrameworkModel.defaultModel());
|
||||
|
||||
Assertions.assertEquals(
|
||||
String.class.getName(),
|
||||
DefaultTypeBuilder.build(String.class, new HashMap<>()).getType());
|
||||
|
||||
DefaultTypeBuilderTest innerObject = new DefaultTypeBuilderTest() {};
|
||||
Assertions.assertEquals(
|
||||
DefaultTypeBuilderTest.class.getName() + "$1",
|
||||
DefaultTypeBuilder.build(innerObject.getClass(), new HashMap<>())
|
||||
.getType());
|
||||
|
||||
TypeDefinitionBuilder.BUILDERS = null;
|
||||
}
|
||||
}
|
||||
|
|
@ -242,7 +242,7 @@
|
|||
<dependency>
|
||||
<groupId>org.testcontainers</groupId>
|
||||
<artifactId>testcontainers</artifactId>
|
||||
<version>1.19.3</version>
|
||||
<version>1.19.4</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
|
|
|||
|
|
@ -445,7 +445,6 @@ public class ReferenceConfig<T> extends ReferenceConfigBase<T> {
|
|||
AbstractConfig.appendParameters(map, getModule());
|
||||
AbstractConfig.appendParameters(map, consumer);
|
||||
AbstractConfig.appendParameters(map, this);
|
||||
appendMetricsCompatible(map);
|
||||
|
||||
String hostToRegistry = ConfigUtils.getSystemProperty(DUBBO_IP_TO_REGISTRY);
|
||||
if (StringUtils.isEmpty(hostToRegistry)) {
|
||||
|
|
|
|||
|
|
@ -683,7 +683,6 @@ public class ServiceConfig<T> extends ServiceConfigBase<T> {
|
|||
AbstractConfig.appendParameters(map, provider);
|
||||
AbstractConfig.appendParameters(map, protocolConfig);
|
||||
AbstractConfig.appendParameters(map, this);
|
||||
appendMetricsCompatible(map);
|
||||
|
||||
// append params with method configs,
|
||||
if (CollectionUtils.isNotEmpty(getMethods())) {
|
||||
|
|
|
|||
|
|
@ -1109,12 +1109,6 @@
|
|||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
|
||||
<xsd:attribute name="port" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[ Deprecated. No longer use. ]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
|
||||
<xsd:attribute name="enable-rpc" type="xsd:boolean" default="true">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[ Enable record rpc metrics. ]]></xsd:documentation>
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@
|
|||
<javassist_version>3.30.2-GA</javassist_version>
|
||||
<byte-buddy_version>1.14.11</byte-buddy_version>
|
||||
<netty_version>3.2.10.Final</netty_version>
|
||||
<netty4_version>4.1.104.Final</netty4_version>
|
||||
<netty4_version>4.1.106.Final</netty4_version>
|
||||
<httpclient_version>4.5.14</httpclient_version>
|
||||
<httpcore_version>4.4.16</httpcore_version>
|
||||
<fastjson_version>1.2.83</fastjson_version>
|
||||
|
|
@ -166,9 +166,9 @@
|
|||
|
||||
<jaxb_version>2.2.7</jaxb_version>
|
||||
<activation_version>1.2.0</activation_version>
|
||||
<test_container_version>1.19.3</test_container_version>
|
||||
<test_container_version>1.19.4</test_container_version>
|
||||
<hessian_lite_version>3.2.13</hessian_lite_version>
|
||||
<swagger_version>1.6.12</swagger_version>
|
||||
<swagger_version>1.6.13</swagger_version>
|
||||
|
||||
<snappy_java_version>1.1.10.5</snappy_java_version>
|
||||
<bouncycastle-bcprov_version>1.70</bouncycastle-bcprov_version>
|
||||
|
|
@ -180,7 +180,7 @@
|
|||
<portlet_version>2.0</portlet_version>
|
||||
<maven_flatten_version>1.6.0</maven_flatten_version>
|
||||
<commons_compress_version>1.25.0</commons_compress_version>
|
||||
<spotless-maven-plugin.version>2.42.0</spotless-maven-plugin.version>
|
||||
<spotless-maven-plugin.version>2.43.0</spotless-maven-plugin.version>
|
||||
<spotless.action>check</spotless.action>
|
||||
<dubbo-shared-resources.version>1.0.0</dubbo-shared-resources.version>
|
||||
<palantirJavaFormat.version>2.38.0</palantirJavaFormat.version>
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
<slf4j_version>1.7.36</slf4j_version>
|
||||
<curator5_version>5.1.0</curator5_version>
|
||||
<zookeeper_version>3.8.3</zookeeper_version>
|
||||
<spotless-maven-plugin.version>2.42.0</spotless-maven-plugin.version>
|
||||
<spotless-maven-plugin.version>2.43.0</spotless-maven-plugin.version>
|
||||
<spotless.action>check</spotless.action>
|
||||
<dubbo-shared-resources.version>1.0.0</dubbo-shared-resources.version>
|
||||
<palantirJavaFormat.version>2.38.0</palantirJavaFormat.version>
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
<slf4j_version>1.7.36</slf4j_version>
|
||||
<curator_version>4.3.0</curator_version>
|
||||
<zookeeper_version>3.4.14</zookeeper_version>
|
||||
<spotless-maven-plugin.version>2.42.0</spotless-maven-plugin.version>
|
||||
<spotless-maven-plugin.version>2.43.0</spotless-maven-plugin.version>
|
||||
<spotless.action>check</spotless.action>
|
||||
<dubbo-shared-resources.version>1.0.0</dubbo-shared-resources.version>
|
||||
<palantirJavaFormat.version>2.38.0</palantirJavaFormat.version>
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
</modules>
|
||||
|
||||
<properties>
|
||||
<spotless-maven-plugin.version>2.42.0</spotless-maven-plugin.version>
|
||||
<spotless-maven-plugin.version>2.43.0</spotless-maven-plugin.version>
|
||||
<spotless.action>check</spotless.action>
|
||||
<dubbo-shared-resources.version>1.0.0</dubbo-shared-resources.version>
|
||||
<palantirJavaFormat.version>2.38.0</palantirJavaFormat.version>
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
<packaging>pom</packaging>
|
||||
|
||||
<properties>
|
||||
<spotless-maven-plugin.version>2.42.0</spotless-maven-plugin.version>
|
||||
<spotless-maven-plugin.version>2.43.0</spotless-maven-plugin.version>
|
||||
<spotless.action>check</spotless.action>
|
||||
<dubbo-shared-resources.version>1.0.0</dubbo-shared-resources.version>
|
||||
<palantirJavaFormat.version>2.38.0</palantirJavaFormat.version>
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ package org.apache.dubbo.remoting.api.pu;
|
|||
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.extension.ExtensionLoader;
|
||||
import org.apache.dubbo.common.utils.StringUtils;
|
||||
import org.apache.dubbo.remoting.ChannelHandler;
|
||||
import org.apache.dubbo.remoting.RemotingException;
|
||||
import org.apache.dubbo.remoting.api.WireProtocol;
|
||||
|
|
@ -29,12 +28,18 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.COMMA_SEPARATOR;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.EXT_PROTOCOL;
|
||||
|
||||
public abstract class AbstractPortUnificationServer extends AbstractServer {
|
||||
private final List<WireProtocol> protocols;
|
||||
|
||||
/**
|
||||
* extension name -> activate WireProtocol
|
||||
*/
|
||||
private final Map<String, WireProtocol> protocols;
|
||||
|
||||
/*
|
||||
protocol name --> URL object
|
||||
|
|
@ -52,20 +57,19 @@ public abstract class AbstractPortUnificationServer extends AbstractServer {
|
|||
public AbstractPortUnificationServer(URL url, ChannelHandler handler) throws RemotingException {
|
||||
super(url, handler);
|
||||
ExtensionLoader<WireProtocol> loader = url.getOrDefaultFrameworkModel().getExtensionLoader(WireProtocol.class);
|
||||
List<WireProtocol> extProtocols = new ArrayList<>();
|
||||
// load main protocol
|
||||
extProtocols.add(loader.getExtension(url.getProtocol()));
|
||||
Map<String, WireProtocol> protocols = extensionLoader.getActivateExtension(url, new String[0]).stream()
|
||||
.collect(Collectors.toConcurrentMap(extensionLoader::getExtensionName, Function.identity()))
|
||||
// load extra protocols
|
||||
String extraProtocols = url.getParameter(EXT_PROTOCOL);
|
||||
if (StringUtils.isNotEmpty(extraProtocols)) {
|
||||
Arrays.stream(extraProtocols.split(COMMA_SEPARATOR)).forEach(p -> {
|
||||
extProtocols.add(loader.getExtension(p));
|
||||
protocols.put(p, loader.getExtension(p));
|
||||
});
|
||||
}
|
||||
this.protocols = extProtocols;
|
||||
this.protocols = protocols;
|
||||
}
|
||||
|
||||
public List<WireProtocol> getProtocols() {
|
||||
public Map<String, WireProtocol> getProtocols() {
|
||||
return protocols;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ public class NettyPortUnificationServer extends AbstractPortUnificationServer {
|
|||
} catch (Throwable e) {
|
||||
logger.warn(TRANSPORT_FAILED_CLOSE, "", "", e.getMessage(), e);
|
||||
}
|
||||
for (WireProtocol protocol : getProtocols()) {
|
||||
for (WireProtocol protocol : getProtocols().values()) {
|
||||
protocol.close();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -131,7 +131,8 @@ public class NettyConnectionClient extends AbstractConnectionClient {
|
|||
|
||||
NettyConfigOperator operator = new NettyConfigOperator(nettyChannel, getChannelHandler());
|
||||
protocol.configClientPipeline(getUrl(), operator, nettySslContextOperator);
|
||||
ch.closeFuture().addListener(channelFuture -> doClose());
|
||||
// set null but do not close this client, it will be reconnect in the future
|
||||
ch.closeFuture().addListener(channelFuture -> channel.set(null));
|
||||
// TODO support Socks5
|
||||
}
|
||||
});
|
||||
|
|
@ -150,9 +151,7 @@ public class NettyConnectionClient extends AbstractConnectionClient {
|
|||
current.close();
|
||||
}
|
||||
this.channel.set(null);
|
||||
if (!closePromise.isDone()) {
|
||||
closePromise.setSuccess(null);
|
||||
}
|
||||
closePromise.setSuccess(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ public class NettyPortUnificationServer extends AbstractPortUnificationServer {
|
|||
logger.warn(TRANSPORT_FAILED_CLOSE, "", "", e.getMessage(), e);
|
||||
}
|
||||
|
||||
for (WireProtocol protocol : getProtocols()) {
|
||||
for (WireProtocol protocol : getProtocols().values()) {
|
||||
protocol.close();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import org.apache.dubbo.remoting.transport.netty4.ssl.SslContexts;
|
|||
|
||||
import javax.net.ssl.SSLSession;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
|
@ -51,14 +52,14 @@ public class NettyPortUnificationServerHandler extends ByteToMessageDecoder {
|
|||
private final URL url;
|
||||
private final ChannelHandler handler;
|
||||
private final boolean detectSsl;
|
||||
private final List<WireProtocol> protocols;
|
||||
private final Map<String, WireProtocol> protocols;
|
||||
private final Map<String, URL> urlMapper;
|
||||
private final Map<String, ChannelHandler> handlerMapper;
|
||||
|
||||
public NettyPortUnificationServerHandler(
|
||||
URL url,
|
||||
boolean detectSsl,
|
||||
List<WireProtocol> protocols,
|
||||
Map<String, WireProtocol> protocols,
|
||||
ChannelHandler handler,
|
||||
Map<String, URL> urlMapper,
|
||||
Map<String, ChannelHandler> handlerMapper) {
|
||||
|
|
@ -118,8 +119,11 @@ public class NettyPortUnificationServerHandler extends ByteToMessageDecoder {
|
|||
if (providerConnectionConfig != null && isSsl(in)) {
|
||||
enableSsl(ctx, providerConnectionConfig);
|
||||
} else {
|
||||
for (final WireProtocol protocol : protocols) {
|
||||
Set<String> supportedProtocolNames = new HashSet<>(protocols.keySet());
|
||||
supportedProtocolNames.retainAll(urlMapper.keySet());
|
||||
|
||||
for (final String name : supportedProtocolNames) {
|
||||
WireProtocol protocol = protocols.get(name);
|
||||
in.markReaderIndex();
|
||||
ChannelBuffer buf = new NettyBackedChannelBuffer(in);
|
||||
final ProtocolDetector.Result result = protocol.detector().detect(buf);
|
||||
|
|
@ -128,11 +132,8 @@ public class NettyPortUnificationServerHandler extends ByteToMessageDecoder {
|
|||
case UNRECOGNIZED:
|
||||
continue;
|
||||
case RECOGNIZED:
|
||||
String protocolName = url.getOrDefaultFrameworkModel()
|
||||
.getExtensionLoader(WireProtocol.class)
|
||||
.getExtensionName(protocol);
|
||||
ChannelHandler localHandler = this.handlerMapper.getOrDefault(protocolName, handler);
|
||||
URL localURL = this.urlMapper.getOrDefault(protocolName, url);
|
||||
ChannelHandler localHandler = this.handlerMapper.getOrDefault(name, handler);
|
||||
URL localURL = this.urlMapper.getOrDefault(name, url);
|
||||
channel.setUrl(localURL);
|
||||
NettyConfigOperator operator = new NettyConfigOperator(channel, localHandler);
|
||||
operator.setDetectResult(result);
|
||||
|
|
|
|||
|
|
@ -70,7 +70,9 @@ public class TriplePingPongHandler extends ChannelDuplexHandler {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
ctx.close();
|
||||
if (ctx.channel().isActive()) {
|
||||
ctx.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
4
pom.xml
4
pom.xml
|
|
@ -147,7 +147,7 @@
|
|||
|
||||
<protobuf-protoc_version>3.22.3</protobuf-protoc_version>
|
||||
<grpc_version>1.54.0</grpc_version>
|
||||
<spotless-maven-plugin.version>2.42.0</spotless-maven-plugin.version>
|
||||
<spotless-maven-plugin.version>2.43.0</spotless-maven-plugin.version>
|
||||
<spotless.action>check</spotless.action>
|
||||
<dubbo-shared-resources.version>1.0.0</dubbo-shared-resources.version>
|
||||
<palantirJavaFormat.version>2.38.0</palantirJavaFormat.version>
|
||||
|
|
@ -714,7 +714,7 @@
|
|||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>license-maven-plugin</artifactId>
|
||||
<version>2.3.0</version>
|
||||
<version>2.4.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>license-check</id>
|
||||
|
|
|
|||
Loading…
Reference in New Issue