Merge branch 'apache-3.2' into apache-3.3
# Conflicts: # README.md # dubbo-common/pom.xml # dubbo-common/src/main/java/org/apache/dubbo/config/MetricsConfig.java # dubbo-demo/dubbo-demo-triple/pom.xml # dubbo-dependencies-bom/pom.xml # dubbo-distribution/dubbo-all/pom.xml # dubbo-metadata/dubbo-metadata-processor/pom.xml # dubbo-native-plugin/pom.xml # dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryProtocol.java # dubbo-spring-boot/pom.xml
This commit is contained in:
commit
d018475f73
|
|
@ -2,7 +2,7 @@
|
|||
name: Bug Report
|
||||
about: Report a bug in Dubbo
|
||||
title: ''
|
||||
labels: type/bug
|
||||
labels: status/need-triage
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ header:
|
|||
- '**/*.fc'
|
||||
- '**/*.javascript'
|
||||
- '**/*.properties'
|
||||
- '**/*.thrift'
|
||||
- '**/*.sh'
|
||||
- '**/*.bat'
|
||||
- '**/*.md'
|
||||
|
|
|
|||
46
README.md
46
README.md
|
|
@ -74,5 +74,51 @@ See [CONTRIBUTING](https://github.com/apache/dubbo/blob/master/CONTRIBUTING.md)
|
|||
* Twitter: [@ApacheDubbo](https://twitter.com/ApacheDubbo)
|
||||
* Security issues: please mail to [us](mailto:security@dubbo.apache.org) privately.
|
||||
|
||||
## Contributing
|
||||
|
||||
See [CONTRIBUTING](https://github.com/apache/dubbo/blob/master/CONTRIBUTING.md) for details on submitting patches and the contribution workflow.
|
||||
|
||||
### How can I contribute?
|
||||
|
||||
* Take a look at issues with tags marked [`Good first issue`](https://github.com/apache/dubbo/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22) or [`Help wanted`](https://github.com/apache/dubbo/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22).
|
||||
* Join the discussion on the mailing list, subscription [guide](https://github.com/apache/dubbo/wiki/Mailing-list-subscription-guide).
|
||||
* Answer questions on [issues](https://github.com/apache/dubbo/issues).
|
||||
* 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.
|
||||
* 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.
|
||||
* If you would like to contribute, please send an email to dev@dubbo.apache.org to let us know!
|
||||
|
||||
## Reporting bugs
|
||||
|
||||
Please follow the [template](https://github.com/apache/dubbo/issues/new?template=dubbo-issue-report-template.md) for reporting any issues.
|
||||
|
||||
## Reporting a security vulnerability
|
||||
|
||||
Please report security vulnerabilities to [us](mailto:security@dubbo.apache.org) privately.
|
||||
|
||||
## Dubbo ecosystem
|
||||
|
||||
* [Dubbo Ecosystem Entry](https://github.com/apache?utf8=%E2%9C%93&q=dubbo&type=&language=) - A GitHub group `dubbo` to gather all Dubbo relevant projects not appropriate in [apache](https://github.com/apache) group yet
|
||||
* [Dubbo Website](https://github.com/apache/dubbo-website) - Apache Dubbo official website
|
||||
* [Dubbo Samples](https://github.com/apache/dubbo-samples) - samples for Apache Dubbo
|
||||
* [Dubbo Spring Boot](https://github.com/apache/dubbo-spring-boot-project) - Spring Boot Project for Dubbo
|
||||
* [Dubbo Admin](https://github.com/apache/dubbo-admin) - The reference implementation for Dubbo admin
|
||||
* [Dubbo Awesome](https://github.com/apache/dubbo-awesome) - Dubbo's slides and video links in Meetup
|
||||
|
||||
#### Language
|
||||
|
||||
* [Go](https://github.com/apache/dubbo-go) (recommended)
|
||||
* [Rust](https://github.com/apache/dubbo-rust)
|
||||
* [Node.js](https://github.com/apache/dubbo-js)
|
||||
* [Python](https://github.com/dubbo/py-client-for-apache-dubbo)
|
||||
* [PHP](https://github.com/apache/dubbo-php-framework)
|
||||
* [Erlang](https://github.com/apache/dubbo-erlang)
|
||||
|
||||
## License
|
||||
Apache Dubbo is licensed under the Apache License Version 2.0. See the [LICENSE](https://github.com/apache/dubbo/blob/master/LICENSE) file for details.
|
||||
|
|
|
|||
|
|
@ -31,4 +31,3 @@ ignore:
|
|||
- "**/dubbo-native/**"
|
||||
- "**/dubbo-common/src/main/java/org/apache/dubbo/common/json/*.java" # internal JSON impl is deprecate, ignore test coverage for them
|
||||
- "**/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/AnnotationBean.java" # Deprecated
|
||||
- "**/dubbo-rpc/dubbo-rpc-thrift/**"
|
||||
|
|
|
|||
|
|
@ -110,5 +110,10 @@
|
|||
<artifactId>log4j-slf4j-impl</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-java</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ import static org.apache.dubbo.common.utils.PathUtils.normalize;
|
|||
* <ul>
|
||||
* <li>{@link org.apache.dubbo.common.config.configcenter.file.FileSystemDynamicConfiguration "file"}</li>
|
||||
* <li>{@link org.apache.dubbo.configcenter.support.zookeeper.ZookeeperDynamicConfiguration "zookeeper"}</li>
|
||||
* <li>{@link org.apache.dubbo.configcenter.consul.ConsulDynamicConfiguration "consul"}</li>
|
||||
* </ul>
|
||||
*
|
||||
* @see DynamicConfiguration
|
||||
|
|
|
|||
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* 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.common.utils;
|
||||
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.PROTOBUF_MESSAGE_CLASS_NAME;
|
||||
|
||||
public class ProtobufUtils {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ProtobufUtils.class);
|
||||
|
||||
private static Class<?> protobufClss;
|
||||
|
||||
private ProtobufUtils() {}
|
||||
|
||||
static {
|
||||
try {
|
||||
protobufClss = ClassUtils.forName(PROTOBUF_MESSAGE_CLASS_NAME, ProtobufUtils.class.getClassLoader());
|
||||
} catch (Throwable t) {
|
||||
logger.info("protobuf's dependency is absent");
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isProtobufClass(Class<?> pojoClazz) {
|
||||
if (protobufClss != null) {
|
||||
return protobufClss.isAssignableFrom(pojoClazz);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -153,6 +153,12 @@ public abstract class AbstractServiceConfig extends AbstractInterfaceConfig {
|
|||
*/
|
||||
private Integer payload;
|
||||
|
||||
/**
|
||||
* Whether to use java_package in IDL as path. Default use package.
|
||||
* This param only available when service using native stub.
|
||||
*/
|
||||
private Boolean useJavaPackageAsPath;
|
||||
|
||||
public AbstractServiceConfig() {}
|
||||
|
||||
public AbstractServiceConfig(ModuleModel moduleModel) {
|
||||
|
|
@ -168,7 +174,9 @@ public abstract class AbstractServiceConfig extends AbstractInterfaceConfig {
|
|||
if (dynamic == null) {
|
||||
dynamic = true;
|
||||
}
|
||||
|
||||
if (useJavaPackageAsPath == null) {
|
||||
useJavaPackageAsPath = false;
|
||||
}
|
||||
if (StringUtils.isBlank(preferSerialization)) {
|
||||
preferSerialization = serialization;
|
||||
}
|
||||
|
|
@ -386,4 +394,13 @@ public abstract class AbstractServiceConfig extends AbstractInterfaceConfig {
|
|||
public void setPayload(Integer payload) {
|
||||
this.payload = payload;
|
||||
}
|
||||
|
||||
public Boolean getUseJavaPackageAsPath() {
|
||||
return useJavaPackageAsPath;
|
||||
}
|
||||
|
||||
@Parameter(excluded = true)
|
||||
public void setUseJavaPackageAsPath(Boolean useJavaPackageAsPath) {
|
||||
this.useJavaPackageAsPath = useJavaPackageAsPath;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -257,7 +257,17 @@ public @interface DubboService {
|
|||
String[] listener() default {};
|
||||
|
||||
/**
|
||||
* Customized parameter key-value pair, for example: {key1, value1, key2, value2}
|
||||
* Customized parameter key-value pair, for example:
|
||||
* <pre>
|
||||
* ["a","b"] ==> {a=b}
|
||||
* [" a "," b "] ==> {a=b}
|
||||
* ["a=b"] ==>{a=b}
|
||||
* ["a:b"] ==>{a=b}
|
||||
* ["a=b","c","d"] ==>{a=b,c=d}
|
||||
* ["a","a:b"] ==>{a="a:b"}
|
||||
* ["a","a,b"] ==>{a="a,b"}
|
||||
* </pre>
|
||||
* @see org.apache.dubbo.config.spring.util.DubboAnnotationUtils#convertParameters(java.lang.String[])
|
||||
*/
|
||||
String[] parameters() default {};
|
||||
|
||||
|
|
@ -327,4 +337,21 @@ public @interface DubboService {
|
|||
* Payload max length.
|
||||
*/
|
||||
String payload() default "";
|
||||
|
||||
/**
|
||||
* The serialization type
|
||||
*/
|
||||
String serialization() default "";
|
||||
|
||||
/**
|
||||
* If the parameter has a value, the consumer will read the parameter first.
|
||||
* If the Dubbo Sdk you are using contains the serialization type, the serialization method specified by the argument is used.
|
||||
* <p>
|
||||
* When this parameter is null or the serialization type specified by this parameter does not exist in the Dubbo SDK, the serialization type specified by serialization is used.
|
||||
* If the Dubbo SDK if still does not exist, the default type of the Dubbo SDK is used.
|
||||
* For Dubbo SDK >= 3.2, <code>preferSerialization</code> takes precedence over <code>serialization</code>
|
||||
* <p>
|
||||
* The configuration supports multiple, which are separated by commas.Such as:<code>fastjson2,fastjson,hessian2</code>
|
||||
*/
|
||||
String preferSerialization() default "";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ import java.util.stream.Stream;
|
|||
|
||||
public class StubMethodDescriptor implements MethodDescriptor, PackableMethod {
|
||||
private static final Logger logger = LoggerFactory.getLogger(StubMethodDescriptor.class);
|
||||
private final ServiceDescriptor serviceDescriptor;
|
||||
private final ConcurrentMap<String, Object> attributeMap = new ConcurrentHashMap<>();
|
||||
private final String methodName;
|
||||
private final String[] compatibleParamSignatures;
|
||||
|
|
@ -46,14 +45,12 @@ public class StubMethodDescriptor implements MethodDescriptor, PackableMethod {
|
|||
String methodName,
|
||||
Class<?> requestClass,
|
||||
Class<?> responseClass,
|
||||
StubServiceDescriptor serviceDescriptor,
|
||||
RpcType rpcType,
|
||||
Pack requestPack,
|
||||
Pack responsePack,
|
||||
UnPack requestUnpack,
|
||||
UnPack responseUnpack) {
|
||||
this.methodName = methodName;
|
||||
this.serviceDescriptor = serviceDescriptor;
|
||||
this.rpcType = rpcType;
|
||||
this.requestPack = requestPack;
|
||||
this.responsePack = responsePack;
|
||||
|
|
@ -65,7 +62,6 @@ public class StubMethodDescriptor implements MethodDescriptor, PackableMethod {
|
|||
this.compatibleParamSignatures =
|
||||
Stream.of(parameterClasses).map(Class::getName).toArray(String[]::new);
|
||||
this.returnTypes = new Type[] {responseClass, responseClass};
|
||||
serviceDescriptor.addMethod(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -130,7 +130,6 @@ org.apache.commons.fileupload
|
|||
org.apache.commons.jelly.
|
||||
org.apache.commons.logging.
|
||||
org.apache.commons.proxy.
|
||||
org.apache.cxf.jaxrs.provider.
|
||||
org.apache.hadoop.shaded.com.zaxxer.hikari.
|
||||
org.apache.http.auth.
|
||||
org.apache.http.conn.
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* 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.common.utils;
|
||||
|
||||
import org.apache.dubbo.common.vo.UserVo;
|
||||
import org.apache.dubbo.rpc.model.HelloReply;
|
||||
import org.apache.dubbo.rpc.model.HelloRequest;
|
||||
import org.apache.dubbo.rpc.model.Person;
|
||||
import org.apache.dubbo.rpc.model.SerializablePerson;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class ProtobufUtilsTest {
|
||||
|
||||
@Test
|
||||
void testIsProtobufClass() {
|
||||
Assertions.assertTrue(ProtobufUtils.isProtobufClass(HelloRequest.class));
|
||||
Assertions.assertTrue(ProtobufUtils.isProtobufClass(HelloReply.class));
|
||||
Assertions.assertFalse(ProtobufUtils.isProtobufClass(Person.class));
|
||||
Assertions.assertFalse(ProtobufUtils.isProtobufClass(SerializablePerson.class));
|
||||
Assertions.assertFalse(ProtobufUtils.isProtobufClass(UserVo.class));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* 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.rpc.model;
|
||||
|
||||
import com.google.protobuf.Message;
|
||||
|
||||
public final class HelloReply extends com.google.protobuf.GeneratedMessageV3 {
|
||||
|
||||
@Override
|
||||
protected FieldAccessorTable internalGetFieldAccessorTable() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Message.Builder newBuilderForType(BuilderParent builderParent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Message.Builder newBuilderForType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Message.Builder toBuilder() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Message getDefaultInstanceForType() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* 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.rpc.model;
|
||||
|
||||
import com.google.protobuf.Message;
|
||||
|
||||
public final class HelloRequest extends com.google.protobuf.GeneratedMessageV3 {
|
||||
|
||||
@Override
|
||||
protected FieldAccessorTable internalGetFieldAccessorTable() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Message.Builder newBuilderForType(BuilderParent builderParent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Message.Builder newBuilderForType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Message.Builder toBuilder() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Message getDefaultInstanceForType() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -31,14 +31,14 @@ import static org.hamcrest.Matchers.not;
|
|||
|
||||
class ProviderConfigTest {
|
||||
@Test
|
||||
void testProtocol() throws Exception {
|
||||
void testProtocol() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setProtocol("protocol");
|
||||
assertThat(provider.getProtocol().getName(), equalTo("protocol"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDefault() throws Exception {
|
||||
void testDefault() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setDefault(true);
|
||||
Map<String, String> parameters = new HashMap<String, String>();
|
||||
|
|
@ -48,7 +48,7 @@ class ProviderConfigTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
void testHost() throws Exception {
|
||||
void testHost() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setHost("demo-host");
|
||||
Map<String, String> parameters = new HashMap<String, String>();
|
||||
|
|
@ -58,7 +58,7 @@ class ProviderConfigTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
void testPort() throws Exception {
|
||||
void testPort() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setPort(8080);
|
||||
Map<String, String> parameters = new HashMap<String, String>();
|
||||
|
|
@ -68,7 +68,7 @@ class ProviderConfigTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
void testPath() throws Exception {
|
||||
void testPath() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setPath("/path");
|
||||
Map<String, String> parameters = new HashMap<String, String>();
|
||||
|
|
@ -79,7 +79,7 @@ class ProviderConfigTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
void testContextPath() throws Exception {
|
||||
void testContextPath() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setContextpath("/context-path");
|
||||
Map<String, String> parameters = new HashMap<String, String>();
|
||||
|
|
@ -89,28 +89,35 @@ class ProviderConfigTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
void testThreads() throws Exception {
|
||||
void testThreads() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setThreads(10);
|
||||
assertThat(provider.getThreads(), is(10));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIothreads() throws Exception {
|
||||
void testIothreads() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setIothreads(10);
|
||||
assertThat(provider.getIothreads(), is(10));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testQueues() throws Exception {
|
||||
void testAlive() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setAlive(10);
|
||||
assertThat(provider.getAlive(), is(10));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testQueues() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setQueues(10);
|
||||
assertThat(provider.getQueues(), is(10));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAccepts() throws Exception {
|
||||
void testAccepts() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setAccepts(10);
|
||||
assertThat(provider.getAccepts(), is(10));
|
||||
|
|
@ -124,35 +131,35 @@ class ProviderConfigTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
void testPayload() throws Exception {
|
||||
void testPayload() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setPayload(10);
|
||||
assertThat(provider.getPayload(), is(10));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBuffer() throws Exception {
|
||||
void testBuffer() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setBuffer(10);
|
||||
assertThat(provider.getBuffer(), is(10));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testServer() throws Exception {
|
||||
void testServer() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setServer("demo-server");
|
||||
assertThat(provider.getServer(), equalTo("demo-server"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testClient() throws Exception {
|
||||
void testClient() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setClient("client");
|
||||
assertThat(provider.getClient(), equalTo("client"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPrompt() throws Exception {
|
||||
void testPrompt() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setPrompt("#");
|
||||
Map<String, String> parameters = new HashMap<String, String>();
|
||||
|
|
@ -162,21 +169,21 @@ class ProviderConfigTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
void testDispatcher() throws Exception {
|
||||
void testDispatcher() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setDispatcher("mockdispatcher");
|
||||
assertThat(provider.getDispatcher(), equalTo("mockdispatcher"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNetworker() throws Exception {
|
||||
void testNetworker() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setNetworker("networker");
|
||||
assertThat(provider.getNetworker(), equalTo("networker"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testWait() throws Exception {
|
||||
void testWait() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setWait(10);
|
||||
assertThat(provider.getWait(), equalTo(10));
|
||||
|
|
|
|||
|
|
@ -115,7 +115,6 @@ class EnableDubboConfigTest {
|
|||
|
||||
configManager.getProtocol("dubbo").get();
|
||||
configManager.getProtocol("rest").get();
|
||||
configManager.getProtocol("thrift").get();
|
||||
|
||||
// asserts aliases
|
||||
// assertTrue(hasAlias(context, "applicationBean2", "dubbo-demo-application2"));
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ dubbo.protocol.name = dubbo
|
|||
dubbo.protocol.port = 20880
|
||||
|
||||
dubbo.protocols.rest.port=8080
|
||||
dubbo.protocols.thrift.port=9090
|
||||
|
||||
## monitor
|
||||
dubbo.monitor.address = zookeeper://127.0.0.1:32770
|
||||
|
|
|
|||
|
|
@ -136,6 +136,13 @@
|
|||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-serialization-jdk</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-registry-multicast</artifactId>
|
||||
|
|
|
|||
|
|
@ -563,6 +563,10 @@ public class ServiceConfig<T> extends ServiceConfigBase<T> {
|
|||
final boolean serverService = ref instanceof ServerService;
|
||||
if (serverService) {
|
||||
serviceDescriptor = ((ServerService) ref).getServiceDescriptor();
|
||||
if (!this.provider.getUseJavaPackageAsPath()) {
|
||||
// for stub service, path always interface name or IDL package name
|
||||
this.path = serviceDescriptor.getInterfaceName();
|
||||
}
|
||||
repository.registerService(serviceDescriptor);
|
||||
} else {
|
||||
serviceDescriptor = repository.registerService(getInterfaceClass());
|
||||
|
|
|
|||
|
|
@ -38,6 +38,10 @@ public class ArgumentBuilder {
|
|||
*/
|
||||
private Boolean callback;
|
||||
|
||||
public static ArgumentBuilder newBuilder() {
|
||||
return new ArgumentBuilder();
|
||||
}
|
||||
|
||||
public ArgumentBuilder index(Integer index) {
|
||||
this.index = index;
|
||||
return this;
|
||||
|
|
|
|||
|
|
@ -43,6 +43,10 @@ public class ConfigCenterBuilder extends AbstractBuilder<ConfigCenterConfig, Con
|
|||
|
||||
private Map<String, String> parameters;
|
||||
|
||||
public static ConfigCenterBuilder newBuilder() {
|
||||
return new ConfigCenterBuilder();
|
||||
}
|
||||
|
||||
public ConfigCenterBuilder protocol(String protocol) {
|
||||
this.protocol = protocol;
|
||||
return getThis();
|
||||
|
|
@ -113,6 +117,7 @@ public class ConfigCenterBuilder extends AbstractBuilder<ConfigCenterConfig, Con
|
|||
return getThis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigCenterConfig build() {
|
||||
ConfigCenterConfig configCenter = new ConfigCenterConfig();
|
||||
super.build(configCenter);
|
||||
|
|
|
|||
|
|
@ -67,6 +67,10 @@ public class ConsumerBuilder extends AbstractReferenceBuilder<ConsumerConfig, Co
|
|||
*/
|
||||
private String urlMergeProcessor;
|
||||
|
||||
public static ConsumerBuilder newBuilder() {
|
||||
return new ConsumerBuilder();
|
||||
}
|
||||
|
||||
public ConsumerBuilder isDefault(Boolean isDefault) {
|
||||
this.isDefault = isDefault;
|
||||
return getThis();
|
||||
|
|
|
|||
|
|
@ -110,6 +110,10 @@ public class MethodBuilder extends AbstractMethodBuilder<MethodConfig, MethodBui
|
|||
|
||||
private String serviceId;
|
||||
|
||||
public static MethodBuilder newBuilder() {
|
||||
return new MethodBuilder();
|
||||
}
|
||||
|
||||
public MethodBuilder name(String name) {
|
||||
this.name = name;
|
||||
return getThis();
|
||||
|
|
@ -206,6 +210,7 @@ public class MethodBuilder extends AbstractMethodBuilder<MethodConfig, MethodBui
|
|||
return getThis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MethodConfig build() {
|
||||
MethodConfig methodConfig = new MethodConfig();
|
||||
super.build(methodConfig);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,220 @@
|
|||
/*
|
||||
* 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.config.bootstrap.builders;
|
||||
|
||||
import org.apache.dubbo.config.MetricsConfig;
|
||||
import org.apache.dubbo.config.nested.AggregationConfig;
|
||||
import org.apache.dubbo.config.nested.HistogramConfig;
|
||||
import org.apache.dubbo.config.nested.PrometheusConfig;
|
||||
|
||||
/**
|
||||
* This is a builder for build {@link MetricsConfig}.
|
||||
*/
|
||||
public class MetricsBuilder extends AbstractBuilder<MetricsConfig, MetricsBuilder> {
|
||||
|
||||
private String protocol;
|
||||
|
||||
/**
|
||||
* Enable jvm metrics when collecting.
|
||||
*/
|
||||
private Boolean enableJvm;
|
||||
|
||||
/**
|
||||
* Enable threadpool metrics when collecting.
|
||||
*/
|
||||
private Boolean enableThreadpool;
|
||||
|
||||
/**
|
||||
* Enable registry metrics.
|
||||
*/
|
||||
private Boolean enableRegistry;
|
||||
|
||||
/**
|
||||
* Enable metadata metrics.
|
||||
*/
|
||||
private Boolean enableMetadata;
|
||||
|
||||
/**
|
||||
* Export metrics service.
|
||||
*/
|
||||
private Boolean exportMetricsService;
|
||||
|
||||
/**
|
||||
* Enable metrics init.
|
||||
*/
|
||||
private Boolean enableMetricsInit;
|
||||
|
||||
/**
|
||||
* Enable collector sync.
|
||||
*/
|
||||
private Boolean enableCollectorSync;
|
||||
|
||||
/**
|
||||
* Collector sync period.
|
||||
*/
|
||||
private Integer collectorSyncPeriod;
|
||||
|
||||
/**
|
||||
* The prometheus metrics config
|
||||
*/
|
||||
private PrometheusConfig prometheus;
|
||||
|
||||
/**
|
||||
* The metrics aggregation config
|
||||
*/
|
||||
private AggregationConfig aggregation;
|
||||
|
||||
private HistogramConfig histogram;
|
||||
|
||||
private String exportServiceProtocol;
|
||||
|
||||
private Integer exportServicePort;
|
||||
|
||||
/**
|
||||
* Decide whether to use the global registry of the micrometer.
|
||||
*/
|
||||
private Boolean useGlobalRegistry;
|
||||
|
||||
/**
|
||||
* Enable rpc metrics.
|
||||
*/
|
||||
private Boolean enableRpc;
|
||||
|
||||
/**
|
||||
* The level of the metrics, the value can be "SERVICE", "METHOD", default is method.
|
||||
*/
|
||||
private String rpcLevel;
|
||||
|
||||
public static MetricsBuilder newBuilder() {
|
||||
return new MetricsBuilder();
|
||||
}
|
||||
|
||||
public MetricsBuilder protocol(String protocol) {
|
||||
this.protocol = protocol;
|
||||
return getThis();
|
||||
}
|
||||
|
||||
public MetricsBuilder enableJvm(Boolean enableJvm) {
|
||||
this.enableJvm = enableJvm;
|
||||
return getThis();
|
||||
}
|
||||
|
||||
public MetricsBuilder enableThreadPool(Boolean enableThreadPool) {
|
||||
this.enableThreadpool = enableThreadPool;
|
||||
return getThis();
|
||||
}
|
||||
|
||||
public MetricsBuilder enableRegistry(Boolean enableRegistry) {
|
||||
this.enableRegistry = enableRegistry;
|
||||
return getThis();
|
||||
}
|
||||
|
||||
public MetricsBuilder enableMetadata(Boolean enableMetadata) {
|
||||
this.enableMetadata = enableMetadata;
|
||||
return getThis();
|
||||
}
|
||||
|
||||
public MetricsBuilder exportMetricsService(Boolean exportMetricsService) {
|
||||
this.exportMetricsService = exportMetricsService;
|
||||
return getThis();
|
||||
}
|
||||
|
||||
public MetricsBuilder enableMetricsInit(Boolean enableMetricsInit) {
|
||||
this.enableMetricsInit = enableMetricsInit;
|
||||
return getThis();
|
||||
}
|
||||
|
||||
public MetricsBuilder enableCollectorSync(Boolean enableCollectorSync) {
|
||||
this.enableCollectorSync = enableCollectorSync;
|
||||
return getThis();
|
||||
}
|
||||
|
||||
public MetricsBuilder collectorSyncPeriod(Integer collectorSyncPeriod) {
|
||||
this.collectorSyncPeriod = collectorSyncPeriod;
|
||||
return getThis();
|
||||
}
|
||||
|
||||
public MetricsBuilder prometheus(PrometheusConfig prometheus) {
|
||||
this.prometheus = prometheus;
|
||||
return getThis();
|
||||
}
|
||||
|
||||
public MetricsBuilder aggregation(AggregationConfig aggregation) {
|
||||
this.aggregation = aggregation;
|
||||
return getThis();
|
||||
}
|
||||
|
||||
public MetricsBuilder histogram(HistogramConfig histogram) {
|
||||
this.histogram = histogram;
|
||||
return getThis();
|
||||
}
|
||||
|
||||
public MetricsBuilder exportServiceProtocol(String exportServiceProtocol) {
|
||||
this.exportServiceProtocol = exportServiceProtocol;
|
||||
return getThis();
|
||||
}
|
||||
|
||||
public MetricsBuilder exportServicePort(Integer exportServicePort) {
|
||||
this.exportServicePort = exportServicePort;
|
||||
return getThis();
|
||||
}
|
||||
|
||||
public MetricsBuilder useGlobalRegistry(Boolean useGlobalRegistry) {
|
||||
this.useGlobalRegistry = useGlobalRegistry;
|
||||
return getThis();
|
||||
}
|
||||
|
||||
public MetricsBuilder enableRpc(Boolean enableRpc) {
|
||||
this.enableRpc = enableRpc;
|
||||
return getThis();
|
||||
}
|
||||
|
||||
public MetricsBuilder rpcLevel(String rpcLevel) {
|
||||
this.rpcLevel = rpcLevel;
|
||||
return getThis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetricsConfig build() {
|
||||
MetricsConfig metrics = new MetricsConfig();
|
||||
super.build(metrics);
|
||||
|
||||
metrics.setProtocol(protocol);
|
||||
metrics.setEnableJvm(enableJvm);
|
||||
metrics.setEnableThreadpool(enableThreadpool);
|
||||
metrics.setEnableRegistry(enableRegistry);
|
||||
metrics.setEnableMetadata(enableMetadata);
|
||||
metrics.setExportMetricsService(exportMetricsService);
|
||||
metrics.setEnableMetricsInit(enableMetricsInit);
|
||||
metrics.setEnableCollectorSync(enableCollectorSync);
|
||||
metrics.setCollectorSyncPeriod(collectorSyncPeriod);
|
||||
metrics.setPrometheus(prometheus);
|
||||
metrics.setAggregation(aggregation);
|
||||
metrics.setHistogram(histogram);
|
||||
metrics.setExportServiceProtocol(exportServiceProtocol);
|
||||
metrics.setExportServicePort(exportServicePort);
|
||||
metrics.setUseGlobalRegistry(useGlobalRegistry);
|
||||
metrics.setEnableRpc(enableRpc);
|
||||
metrics.setRpcLevel(rpcLevel);
|
||||
return metrics;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MetricsBuilder getThis() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
@ -64,6 +64,10 @@ public class ModuleBuilder extends AbstractBuilder<ModuleConfig, ModuleBuilder>
|
|||
*/
|
||||
private Boolean isDefault;
|
||||
|
||||
public static ModuleBuilder newBuilder() {
|
||||
return new ModuleBuilder();
|
||||
}
|
||||
|
||||
public ModuleBuilder name(String name) {
|
||||
this.name = name;
|
||||
return getThis();
|
||||
|
|
@ -110,6 +114,7 @@ public class ModuleBuilder extends AbstractBuilder<ModuleConfig, ModuleBuilder>
|
|||
return getThis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModuleConfig build() {
|
||||
ModuleConfig moduleConfig = new ModuleConfig();
|
||||
super.build(moduleConfig);
|
||||
|
|
|
|||
|
|
@ -63,6 +63,10 @@ public class MonitorBuilder extends AbstractBuilder<MonitorConfig, MonitorBuilde
|
|||
*/
|
||||
private Boolean isDefault;
|
||||
|
||||
public static MonitorBuilder newBuilder() {
|
||||
return new MonitorBuilder();
|
||||
}
|
||||
|
||||
public MonitorBuilder protocol(String protocol) {
|
||||
this.protocol = protocol;
|
||||
return getThis();
|
||||
|
|
@ -113,6 +117,7 @@ public class MonitorBuilder extends AbstractBuilder<MonitorConfig, MonitorBuilde
|
|||
return getThis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MonitorConfig build() {
|
||||
MonitorConfig monitorConfig = new MonitorConfig();
|
||||
super.build(monitorConfig);
|
||||
|
|
|
|||
|
|
@ -180,6 +180,13 @@ public class ProtocolBuilder extends AbstractBuilder<ProtocolConfig, ProtocolBui
|
|||
*/
|
||||
private Map<String, String> parameters;
|
||||
|
||||
private Boolean sslEnabled;
|
||||
|
||||
/*
|
||||
* Extra Protocol for this service, using Port Unification Server
|
||||
*/
|
||||
private String extProtocol;
|
||||
|
||||
/**
|
||||
* If it's default
|
||||
*/
|
||||
|
|
@ -375,11 +382,22 @@ public class ProtocolBuilder extends AbstractBuilder<ProtocolConfig, ProtocolBui
|
|||
return getThis();
|
||||
}
|
||||
|
||||
public ProtocolBuilder isSslEnabled(Boolean sslEnabled) {
|
||||
this.sslEnabled = sslEnabled;
|
||||
return getThis();
|
||||
}
|
||||
|
||||
public ProtocolBuilder extProtocol(String extProtocol) {
|
||||
this.extProtocol = extProtocol;
|
||||
return getThis();
|
||||
}
|
||||
|
||||
public ProtocolBuilder isDefault(Boolean isDefault) {
|
||||
this.isDefault = isDefault;
|
||||
return getThis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProtocolConfig build() {
|
||||
ProtocolConfig protocolConfig = new ProtocolConfig();
|
||||
super.build(protocolConfig);
|
||||
|
|
@ -416,6 +434,8 @@ public class ProtocolBuilder extends AbstractBuilder<ProtocolConfig, ProtocolBui
|
|||
protocolConfig.setThreadpool(threadpool);
|
||||
protocolConfig.setThreads(threads);
|
||||
protocolConfig.setTransporter(transporter);
|
||||
protocolConfig.setSslEnabled(sslEnabled);
|
||||
protocolConfig.setExtProtocol(extProtocol);
|
||||
|
||||
return protocolConfig;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,6 +45,11 @@ public class ProviderBuilder extends AbstractServiceBuilder<ProviderConfig, Prov
|
|||
*/
|
||||
private String threadpool;
|
||||
|
||||
/**
|
||||
* Thread pool name
|
||||
*/
|
||||
private String threadname;
|
||||
|
||||
/**
|
||||
* Thread pool size (fixed size)
|
||||
*/
|
||||
|
|
@ -55,6 +60,11 @@ public class ProviderBuilder extends AbstractServiceBuilder<ProviderConfig, Prov
|
|||
*/
|
||||
private Integer iothreads;
|
||||
|
||||
/**
|
||||
* Thread pool keepAliveTime, default unit TimeUnit.MILLISECONDS
|
||||
*/
|
||||
private Integer alive;
|
||||
|
||||
/**
|
||||
* Thread pool queue length
|
||||
*/
|
||||
|
|
@ -140,6 +150,10 @@ public class ProviderBuilder extends AbstractServiceBuilder<ProviderConfig, Prov
|
|||
*/
|
||||
private Boolean isDefault;
|
||||
|
||||
public static ProviderBuilder newBuilder() {
|
||||
return new ProviderBuilder();
|
||||
}
|
||||
|
||||
public ProviderBuilder host(String host) {
|
||||
this.host = host;
|
||||
return getThis();
|
||||
|
|
@ -160,6 +174,11 @@ public class ProviderBuilder extends AbstractServiceBuilder<ProviderConfig, Prov
|
|||
return getThis();
|
||||
}
|
||||
|
||||
public ProviderBuilder threadName(String threadName) {
|
||||
this.threadname = threadName;
|
||||
return getThis();
|
||||
}
|
||||
|
||||
public ProviderBuilder threads(Integer threads) {
|
||||
this.threads = threads;
|
||||
return getThis();
|
||||
|
|
@ -170,6 +189,11 @@ public class ProviderBuilder extends AbstractServiceBuilder<ProviderConfig, Prov
|
|||
return getThis();
|
||||
}
|
||||
|
||||
public ProviderBuilder alive(Integer alive) {
|
||||
this.alive = alive;
|
||||
return getThis();
|
||||
}
|
||||
|
||||
public ProviderBuilder queues(Integer queues) {
|
||||
this.queues = queues;
|
||||
return getThis();
|
||||
|
|
@ -263,8 +287,10 @@ public class ProviderBuilder extends AbstractServiceBuilder<ProviderConfig, Prov
|
|||
provider.setPort(port);
|
||||
provider.setContextpath(contextpath);
|
||||
provider.setThreadpool(threadpool);
|
||||
provider.setThreadname(threadname);
|
||||
provider.setThreads(threads);
|
||||
provider.setIothreads(iothreads);
|
||||
provider.setAlive(alive);
|
||||
provider.setQueues(queues);
|
||||
provider.setAccepts(accepts);
|
||||
provider.setCodec(codec);
|
||||
|
|
|
|||
|
|
@ -139,6 +139,7 @@ public class ReferenceBuilder<T> extends AbstractReferenceBuilder<ReferenceConfi
|
|||
return getThis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReferenceConfig<T> build() {
|
||||
ReferenceConfig<T> reference = new ReferenceConfig<>();
|
||||
super.build(reference);
|
||||
|
|
|
|||
|
|
@ -340,6 +340,7 @@ public class RegistryBuilder extends AbstractBuilder<RegistryConfig, RegistryBui
|
|||
return getThis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegistryConfig build() {
|
||||
RegistryConfig registry = new RegistryConfig();
|
||||
super.build(registry);
|
||||
|
|
|
|||
|
|
@ -138,6 +138,7 @@ public class ServiceBuilder<U> extends AbstractServiceBuilder<ServiceConfig<U>,
|
|||
// throw new IllegalArgumentException("mock doesn't support on provider side");
|
||||
// }
|
||||
|
||||
@Override
|
||||
public ServiceConfig<U> build() {
|
||||
ServiceConfig<U> serviceConfig = new ServiceConfig<>();
|
||||
super.build(serviceConfig);
|
||||
|
|
|
|||
|
|
@ -133,6 +133,7 @@ import static org.apache.dubbo.remoting.Constants.CLIENT_KEY;
|
|||
import static org.apache.dubbo.remoting.Constants.CODEC_KEY;
|
||||
import static org.apache.dubbo.remoting.Constants.DISPATCHER_KEY;
|
||||
import static org.apache.dubbo.remoting.Constants.EXCHANGER_KEY;
|
||||
import static org.apache.dubbo.remoting.Constants.PREFER_SERIALIZATION_KEY;
|
||||
import static org.apache.dubbo.remoting.Constants.SERIALIZATION_KEY;
|
||||
import static org.apache.dubbo.remoting.Constants.SERVER_KEY;
|
||||
import static org.apache.dubbo.remoting.Constants.TELNET_KEY;
|
||||
|
|
@ -561,6 +562,11 @@ public class ConfigValidationUtils {
|
|||
checkMultiExtension(config.getScopeModel(), Codec2.class, CODEC_KEY, config.getCodec());
|
||||
checkMultiExtension(
|
||||
config.getScopeModel(), Serialization.class, SERIALIZATION_KEY, config.getSerialization());
|
||||
checkMultiExtension(
|
||||
config.getScopeModel(),
|
||||
Serialization.class,
|
||||
PREFER_SERIALIZATION_KEY,
|
||||
config.getPreferSerialization());
|
||||
checkMultiExtension(config.getScopeModel(), Transporter.class, SERVER_KEY, config.getServer());
|
||||
checkMultiExtension(config.getScopeModel(), Transporter.class, CLIENT_KEY, config.getClient());
|
||||
}
|
||||
|
|
@ -582,6 +588,9 @@ public class ConfigValidationUtils {
|
|||
checkMultiExtension(config.getScopeModel(), StatusChecker.class, STATUS_KEY, config.getStatus());
|
||||
checkExtension(config.getScopeModel(), Transporter.class, TRANSPORTER_KEY, config.getTransporter());
|
||||
checkExtension(config.getScopeModel(), Exchanger.class, EXCHANGER_KEY, config.getExchanger());
|
||||
checkMultiExtension(config.getScopeModel(), Serialization.class, SERIALIZATION_KEY, config.getSerialization());
|
||||
checkMultiExtension(
|
||||
config.getScopeModel(), Serialization.class, PREFER_SERIALIZATION_KEY, config.getPreferSerialization());
|
||||
}
|
||||
|
||||
public static void validateConsumerConfig(ConsumerConfig config) {
|
||||
|
|
|
|||
|
|
@ -70,6 +70,31 @@ class AbstractConfigTest {
|
|||
ConfigValidationUtils.validateProtocolConfig(protocolConfig);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testValidateProtocolConfigSerialization() {
|
||||
ProtocolConfig protocolConfig = new ProtocolConfig();
|
||||
protocolConfig.setCodec("exchange");
|
||||
protocolConfig.setName("dubbo");
|
||||
protocolConfig.setHost("host");
|
||||
protocolConfig.setSerialization("fastjson2");
|
||||
protocolConfig.setPreferSerialization("hessian2,java,compactedjava,nativejava");
|
||||
ConfigValidationUtils.validateProtocolConfig(protocolConfig);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testValidateProtocolConfigViolateSerialization() {
|
||||
|
||||
Assertions.assertThrowsExactly(IllegalStateException.class, () -> {
|
||||
ProtocolConfig protocolConfig = new ProtocolConfig();
|
||||
protocolConfig.setCodec("exchange");
|
||||
protocolConfig.setName("dubbo");
|
||||
protocolConfig.setHost("host");
|
||||
protocolConfig.setSerialization("violate");
|
||||
protocolConfig.setPreferSerialization("violate");
|
||||
ConfigValidationUtils.validateProtocolConfig(protocolConfig);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAppendParameters1() {
|
||||
Map<String, String> parameters = new HashMap<String, String>();
|
||||
|
|
|
|||
|
|
@ -32,47 +32,47 @@ import static org.hamcrest.Matchers.not;
|
|||
class ProviderConfigTest {
|
||||
|
||||
@Test
|
||||
void testProtocol() throws Exception {
|
||||
void testProtocol() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setProtocol("protocol");
|
||||
assertThat(provider.getProtocol().getName(), equalTo("protocol"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDefault() throws Exception {
|
||||
void testDefault() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setDefault(true);
|
||||
Map<String, String> parameters = new HashMap<String, String>();
|
||||
Map<String, String> parameters = new HashMap<>();
|
||||
ProviderConfig.appendParameters(parameters, provider);
|
||||
assertThat(provider.isDefault(), is(true));
|
||||
assertThat(parameters, not(hasKey("default")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testHost() throws Exception {
|
||||
void testHost() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setHost("demo-host");
|
||||
Map<String, String> parameters = new HashMap<String, String>();
|
||||
Map<String, String> parameters = new HashMap<>();
|
||||
ProviderConfig.appendParameters(parameters, provider);
|
||||
assertThat(provider.getHost(), equalTo("demo-host"));
|
||||
assertThat(parameters, not(hasKey("host")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPort() throws Exception {
|
||||
void testPort() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setPort(8080);
|
||||
Map<String, String> parameters = new HashMap<String, String>();
|
||||
Map<String, String> parameters = new HashMap<>();
|
||||
ProviderConfig.appendParameters(parameters, provider);
|
||||
assertThat(provider.getPort(), is(8080));
|
||||
assertThat(parameters, not(hasKey("port")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPath() throws Exception {
|
||||
void testPath() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setPath("/path");
|
||||
Map<String, String> parameters = new HashMap<String, String>();
|
||||
Map<String, String> parameters = new HashMap<>();
|
||||
ProviderConfig.appendParameters(parameters, provider);
|
||||
assertThat(provider.getPath(), equalTo("/path"));
|
||||
assertThat(provider.getContextpath(), equalTo("/path"));
|
||||
|
|
@ -80,139 +80,153 @@ class ProviderConfigTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
void testContextPath() throws Exception {
|
||||
void testContextPath() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setContextpath("/context-path");
|
||||
Map<String, String> parameters = new HashMap<String, String>();
|
||||
Map<String, String> parameters = new HashMap<>();
|
||||
ProviderConfig.appendParameters(parameters, provider);
|
||||
assertThat(provider.getContextpath(), equalTo("/context-path"));
|
||||
assertThat(parameters, not(hasKey("/context-path")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testThreadpool() throws Exception {
|
||||
void testThreadpool() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setThreadpool("mockthreadpool");
|
||||
assertThat(provider.getThreadpool(), equalTo("mockthreadpool"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testThreads() throws Exception {
|
||||
void testThreadname() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setThreadname("test-thread-pool");
|
||||
assertThat(provider.getThreadname(), equalTo("test-thread-pool"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testThreads() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setThreads(10);
|
||||
assertThat(provider.getThreads(), is(10));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIothreads() throws Exception {
|
||||
void testIothreads() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setIothreads(10);
|
||||
assertThat(provider.getIothreads(), is(10));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testQueues() throws Exception {
|
||||
void testAlive() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setAlive(10);
|
||||
assertThat(provider.getAlive(), is(10));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testQueues() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setQueues(10);
|
||||
assertThat(provider.getQueues(), is(10));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAccepts() throws Exception {
|
||||
void testAccepts() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setAccepts(10);
|
||||
assertThat(provider.getAccepts(), is(10));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCharset() throws Exception {
|
||||
void testCharset() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setCharset("utf-8");
|
||||
assertThat(provider.getCharset(), equalTo("utf-8"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPayload() throws Exception {
|
||||
void testPayload() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setPayload(10);
|
||||
assertThat(provider.getPayload(), is(10));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBuffer() throws Exception {
|
||||
void testBuffer() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setBuffer(10);
|
||||
assertThat(provider.getBuffer(), is(10));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testServer() throws Exception {
|
||||
void testServer() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setServer("demo-server");
|
||||
assertThat(provider.getServer(), equalTo("demo-server"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testClient() throws Exception {
|
||||
void testClient() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setClient("client");
|
||||
assertThat(provider.getClient(), equalTo("client"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTelnet() throws Exception {
|
||||
void testTelnet() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setTelnet("mocktelnethandler");
|
||||
assertThat(provider.getTelnet(), equalTo("mocktelnethandler"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPrompt() throws Exception {
|
||||
void testPrompt() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setPrompt("#");
|
||||
Map<String, String> parameters = new HashMap<String, String>();
|
||||
Map<String, String> parameters = new HashMap<>();
|
||||
ProviderConfig.appendParameters(parameters, provider);
|
||||
assertThat(provider.getPrompt(), equalTo("#"));
|
||||
assertThat(parameters, hasEntry("prompt", "%23"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testStatus() throws Exception {
|
||||
void testStatus() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setStatus("mockstatuschecker");
|
||||
assertThat(provider.getStatus(), equalTo("mockstatuschecker"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTransporter() throws Exception {
|
||||
void testTransporter() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setTransporter("mocktransporter");
|
||||
assertThat(provider.getTransporter(), equalTo("mocktransporter"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testExchanger() throws Exception {
|
||||
void testExchanger() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setExchanger("mockexchanger");
|
||||
assertThat(provider.getExchanger(), equalTo("mockexchanger"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDispatcher() throws Exception {
|
||||
void testDispatcher() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setDispatcher("mockdispatcher");
|
||||
assertThat(provider.getDispatcher(), equalTo("mockdispatcher"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNetworker() throws Exception {
|
||||
void testNetworker() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setNetworker("networker");
|
||||
assertThat(provider.getNetworker(), equalTo("networker"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testWait() throws Exception {
|
||||
void testWait() {
|
||||
ProviderConfig provider = new ProviderConfig();
|
||||
provider.setWait(10);
|
||||
assertThat(provider.getWait(), equalTo(10));
|
||||
|
|
|
|||
|
|
@ -1,55 +0,0 @@
|
|||
/*
|
||||
* 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.config.bootstrap;
|
||||
|
||||
import org.apache.dubbo.config.bootstrap.rest.UserService;
|
||||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_METADATA_STORAGE_TYPE;
|
||||
|
||||
/**
|
||||
* Dubbo Provider Bootstrap
|
||||
*
|
||||
* @since 2.7.5
|
||||
*/
|
||||
public class ConsulDubboServiceConsumerBootstrap {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
DubboBootstrap bootstrap = DubboBootstrap.getInstance()
|
||||
.application("consul-dubbo-consumer", app -> app.metadata(DEFAULT_METADATA_STORAGE_TYPE))
|
||||
.registry("zookeeper", builder -> builder.address(
|
||||
"consul://127.0.0.1:8500?registry-type=service&subscribed-services=consul-dubbo-provider")
|
||||
.useAsConfigCenter(true)
|
||||
.useAsMetadataCenter(true))
|
||||
.reference("echo", builder -> builder.interfaceClass(EchoService.class)
|
||||
.protocol("dubbo"))
|
||||
.reference("user", builder -> builder.interfaceClass(UserService.class)
|
||||
.protocol("rest"))
|
||||
.start();
|
||||
|
||||
EchoService echoService = bootstrap.getCache().get(EchoService.class);
|
||||
UserService userService = bootstrap.getCache().get(UserService.class);
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
Thread.sleep(2000L);
|
||||
System.out.println(echoService.echo("Hello,World"));
|
||||
System.out.println(userService.getUser(i * 1L));
|
||||
}
|
||||
|
||||
bootstrap.stop();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* 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.config.bootstrap;
|
||||
|
||||
import org.apache.dubbo.config.bootstrap.rest.UserService;
|
||||
import org.apache.dubbo.config.bootstrap.rest.UserServiceImpl;
|
||||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_METADATA_STORAGE_TYPE;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*/
|
||||
public class ConsulDubboServiceProviderBootstrap {
|
||||
|
||||
public static void main(String[] args) {
|
||||
DubboBootstrap.getInstance()
|
||||
.application("consul-dubbo-provider", app -> app.metadata(DEFAULT_METADATA_STORAGE_TYPE))
|
||||
.registry(builder -> builder.address("consul://127.0.0.1:8500?registry-type=service")
|
||||
.useAsConfigCenter(true)
|
||||
.useAsMetadataCenter(true))
|
||||
.protocol("dubbo", builder -> builder.port(-1).name("dubbo"))
|
||||
.protocol("rest", builder -> builder.port(8081).name("rest"))
|
||||
.service("echo", builder -> builder.interfaceClass(EchoService.class)
|
||||
.ref(new EchoServiceImpl())
|
||||
.protocolIds("dubbo"))
|
||||
.service("user", builder -> builder.interfaceClass(UserService.class)
|
||||
.ref(new UserServiceImpl())
|
||||
.protocolIds("rest"))
|
||||
.start()
|
||||
.await();
|
||||
}
|
||||
}
|
||||
|
|
@ -319,21 +319,6 @@ class DubboBootstrapTest {
|
|||
registryConfig.setUseAsMetadataCenter(false);
|
||||
registryConfig.setUseAsConfigCenter(false);
|
||||
|
||||
Exception exception = null;
|
||||
try {
|
||||
DubboBootstrap.getInstance()
|
||||
.application(applicationConfig)
|
||||
.registry(registryConfig)
|
||||
.protocol(new ProtocolConfig(CommonConstants.DUBBO_PROTOCOL, -1))
|
||||
.service(service)
|
||||
.start();
|
||||
} catch (Exception e) {
|
||||
exception = e;
|
||||
DubboBootstrap.reset();
|
||||
}
|
||||
|
||||
Assertions.assertNotNull(exception);
|
||||
|
||||
DubboBootstrap.getInstance()
|
||||
.application(applicationConfig)
|
||||
.registry(registryConfig)
|
||||
|
|
@ -345,6 +330,33 @@ class DubboBootstrapTest {
|
|||
assertMetadataService(DubboBootstrap.getInstance(), availablePort, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRemoteMetadataServiceExporterCheckMetadataType() {
|
||||
|
||||
Assertions.assertThrowsExactly(IllegalStateException.class, () -> {
|
||||
ServiceConfig<DemoService> service = new ServiceConfig<>();
|
||||
service.setInterface(DemoService.class);
|
||||
service.setRef(new DemoServiceImpl());
|
||||
|
||||
int availablePort = NetUtils.getAvailablePort();
|
||||
|
||||
ApplicationConfig applicationConfig = new ApplicationConfig("bootstrap-test");
|
||||
applicationConfig.setMetadataServicePort(availablePort);
|
||||
applicationConfig.setMetadataType(REMOTE_METADATA_STORAGE_TYPE);
|
||||
|
||||
RegistryConfig registryConfig = new RegistryConfig(zkServerAddress);
|
||||
registryConfig.setUseAsMetadataCenter(false);
|
||||
registryConfig.setUseAsConfigCenter(false);
|
||||
|
||||
DubboBootstrap.getInstance()
|
||||
.application(applicationConfig)
|
||||
.registry(registryConfig)
|
||||
.protocol(new ProtocolConfig(CommonConstants.DUBBO_PROTOCOL, -1))
|
||||
.service(service)
|
||||
.start();
|
||||
});
|
||||
}
|
||||
|
||||
private ExporterDeployListener getListener(ApplicationModel model) {
|
||||
return (ExporterDeployListener)
|
||||
model.getExtensionLoader(ApplicationDeployListener.class).getExtension("exporter");
|
||||
|
|
|
|||
|
|
@ -32,24 +32,11 @@ public class DubboServiceConsumerBootstrap {
|
|||
DubboBootstrap bootstrap = DubboBootstrap.getInstance()
|
||||
.application("dubbo-consumer-demo")
|
||||
.protocol(builder -> builder.port(20887).name("dubbo"))
|
||||
// Eureka
|
||||
// .registry(builder ->
|
||||
// builder.address("eureka://127.0.0.1:8761?registry-type=service&subscribed-services=dubbo-provider-demo"))
|
||||
|
||||
// Zookeeper
|
||||
.registry(
|
||||
"zookeeper",
|
||||
builder -> builder.address(ZookeeperRegistryCenterConfig.getConnectionAddress()
|
||||
+ "?registry-type=service&subscribed-services=dubbo-provider-demo"))
|
||||
.metadataReport(new MetadataReportConfig(ZookeeperRegistryCenterConfig.getConnectionAddress()))
|
||||
|
||||
// Nacos
|
||||
// .registry("nacos", builder ->
|
||||
// builder.address("nacos://127.0.0.1:8848?registry.type=service&subscribed.services=dubbo-provider-demo"))
|
||||
|
||||
// Consul
|
||||
// .registry("consul", builder ->
|
||||
// builder.address("consul://127.0.0.1:8500?registry.type=service&subscribed.services=dubbo-provider-demo").group("namespace1"))
|
||||
.reference("echo", builder -> builder.interfaceClass(EchoService.class)
|
||||
.protocol("dubbo"))
|
||||
.reference("user", builder -> builder.interfaceClass(UserService.class)
|
||||
|
|
|
|||
|
|
@ -55,27 +55,17 @@ public class DubboServiceProviderBootstrap {
|
|||
ServiceConfig<EchoService> echoService = new ServiceConfig<>();
|
||||
echoService.setInterface(EchoService.class.getName());
|
||||
echoService.setRef(new EchoServiceImpl());
|
||||
// echoService.setRegistries(Arrays.asList(interfaceRegistry, serviceRegistry));
|
||||
|
||||
ServiceConfig<UserService> userService = new ServiceConfig<>();
|
||||
userService.setInterface(UserService.class.getName());
|
||||
userService.setRef(new UserServiceImpl());
|
||||
userService.setProtocol(restProtocol);
|
||||
// userService.setRegistries(Arrays.asList(interfaceRegistry, serviceRegistry));
|
||||
|
||||
ApplicationConfig applicationConfig = new ApplicationConfig("dubbo-provider-demo");
|
||||
applicationConfig.setMetadataType("remote");
|
||||
DubboBootstrap.getInstance()
|
||||
.application(applicationConfig)
|
||||
// Zookeeper in service registry type
|
||||
// .registry("zookeeper", builder ->
|
||||
// builder.address("zookeeper://127.0.0.1:2181?registry.type=service"))
|
||||
// Nacos
|
||||
// .registry("zookeeper", builder ->
|
||||
// builder.address("nacos://127.0.0.1:8848?registry.type=service"))
|
||||
.registries(Arrays.asList(interfaceRegistry, serviceRegistry))
|
||||
//
|
||||
// .registry(RegistryBuilder.newBuilder().address("consul://127.0.0.1:8500?registry.type=service").build())
|
||||
.protocol(builder -> builder.port(-1).name("dubbo"))
|
||||
.metadataReport(new MetadataReportConfig(ZookeeperRegistryCenterConfig.getConnectionAddress()))
|
||||
.service(echoService)
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ public class DubboServiceProviderMinimumBootstrap {
|
|||
.application("dubbo-provider-demo")
|
||||
.registry(builder -> builder.address(
|
||||
ZookeeperRegistryCenterConfig.getConnectionAddress() + "?registry-type=service"))
|
||||
// .registry(builder -> builder.address("eureka://127.0.0.1:8761?registry-type=service"))
|
||||
.protocol(builder -> builder.port(-1).name("dubbo"))
|
||||
.service("echo", builder -> builder.interfaceClass(EchoService.class)
|
||||
.ref(new EchoServiceImpl()))
|
||||
|
|
|
|||
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
* 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.config.bootstrap;
|
||||
|
||||
import org.apache.dubbo.config.MetadataReportConfig;
|
||||
import org.apache.dubbo.config.bootstrap.rest.UserService;
|
||||
|
||||
/**
|
||||
* Dubbo Provider Bootstrap
|
||||
*
|
||||
* @since 2.7.5
|
||||
*/
|
||||
public class EtcdDubboServiceConsumerBootstrap {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
DubboBootstrap bootstrap = DubboBootstrap.getInstance()
|
||||
.application("dubbo-consumer-demo")
|
||||
// Zookeeper
|
||||
.protocol(builder -> builder.port(20887).name("dubbo"))
|
||||
.registry(
|
||||
"etcd3",
|
||||
builder -> builder.address(
|
||||
"etcd3://127.0.0.1:2379?registry-type=service&subscribed-services=dubbo-provider-demo"))
|
||||
.metadataReport(new MetadataReportConfig("etcd://127.0.0.1:2379"))
|
||||
// Nacos
|
||||
// .registry("consul", builder ->
|
||||
// builder.address("consul://127.0.0.1:8500?registry.type=service&subscribed.services=dubbo-provider-demo").group("namespace1"))
|
||||
.reference("echo", builder -> builder.interfaceClass(EchoService.class)
|
||||
.protocol("dubbo"))
|
||||
.reference("user", builder -> builder.interfaceClass(UserService.class)
|
||||
.protocol("rest"))
|
||||
.start();
|
||||
|
||||
EchoService echoService = bootstrap.getCache().get(EchoService.class);
|
||||
|
||||
for (int i = 0; i < 500; i++) {
|
||||
Thread.sleep(2000L);
|
||||
System.out.println(echoService.echo("Hello,World"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,90 +0,0 @@
|
|||
/*
|
||||
* 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.config.bootstrap;
|
||||
|
||||
import org.apache.dubbo.config.ApplicationConfig;
|
||||
import org.apache.dubbo.config.ProtocolConfig;
|
||||
import org.apache.dubbo.config.RegistryConfig;
|
||||
import org.apache.dubbo.config.ServiceConfig;
|
||||
import org.apache.dubbo.config.bootstrap.rest.UserService;
|
||||
import org.apache.dubbo.config.bootstrap.rest.UserServiceImpl;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Dubbo Provider Bootstrap
|
||||
*
|
||||
* @since 2.7.5
|
||||
*/
|
||||
public class EtcdDubboServiceProviderBootstrap {
|
||||
|
||||
public static void main(String[] args) {
|
||||
multipleRegistries();
|
||||
}
|
||||
|
||||
private static void multipleRegistries() {
|
||||
ProtocolConfig restProtocol = new ProtocolConfig();
|
||||
restProtocol.setName("rest");
|
||||
restProtocol.setId("rest");
|
||||
restProtocol.setPort(-1);
|
||||
|
||||
RegistryConfig interfaceRegistry = new RegistryConfig();
|
||||
interfaceRegistry.setId("interfaceRegistry");
|
||||
interfaceRegistry.setAddress("etcd3://127.0.0.1:2379");
|
||||
|
||||
RegistryConfig serviceRegistry = new RegistryConfig();
|
||||
serviceRegistry.setId("serviceRegistry");
|
||||
serviceRegistry.setAddress("etcd3://127.0.0.1:2379?registry-type=service");
|
||||
|
||||
ServiceConfig<EchoService> echoService = new ServiceConfig<>();
|
||||
echoService.setInterface(EchoService.class.getName());
|
||||
echoService.setRef(new EchoServiceImpl());
|
||||
// echoService.setRegistries(Arrays.asList(interfaceRegistry, serviceRegistry));
|
||||
|
||||
ServiceConfig<UserService> userService = new ServiceConfig<>();
|
||||
userService.setInterface(UserService.class.getName());
|
||||
userService.setRef(new UserServiceImpl());
|
||||
userService.setProtocol(restProtocol);
|
||||
// userService.setRegistries(Arrays.asList(interfaceRegistry, serviceRegistry));
|
||||
|
||||
ApplicationConfig applicationConfig = new ApplicationConfig("dubbo-provider-demo");
|
||||
// applicationConfig.setMetadataType("remote");
|
||||
DubboBootstrap.getInstance()
|
||||
.application(applicationConfig)
|
||||
// Zookeeper in service registry type
|
||||
// .registry("zookeeper", builder ->
|
||||
// builder.address("zookeeper://127.0.0.1:2181?registry.type=service"))
|
||||
// Nacos
|
||||
// .registry("zookeeper", builder ->
|
||||
// builder.address("nacos://127.0.0.1:8848?registry.type=service"))
|
||||
.registries(Arrays.asList(interfaceRegistry, serviceRegistry))
|
||||
//
|
||||
// .registry(RegistryBuilder.newBuilder().address("consul://127.0.0.1:8500?registry.type=service").build())
|
||||
.protocol(builder -> builder.port(-1).name("dubbo"))
|
||||
// .metadataReport(new MetadataReportConfig("etcd://127.0.0.1:2379"))
|
||||
.service(echoService)
|
||||
.service(userService)
|
||||
.start()
|
||||
.await();
|
||||
}
|
||||
|
||||
private static void testSCCallDubbo() {}
|
||||
|
||||
private static void testDubboCallSC() {}
|
||||
|
||||
private static void testDubboTansormation() {}
|
||||
}
|
||||
|
|
@ -25,21 +25,21 @@ class ArgumentBuilderTest {
|
|||
|
||||
@Test
|
||||
void index() {
|
||||
ArgumentBuilder builder = new ArgumentBuilder();
|
||||
ArgumentBuilder builder = ArgumentBuilder.newBuilder();
|
||||
builder.index(1);
|
||||
Assertions.assertEquals(1, builder.build().getIndex());
|
||||
}
|
||||
|
||||
@Test
|
||||
void type() {
|
||||
ArgumentBuilder builder = new ArgumentBuilder();
|
||||
ArgumentBuilder builder = ArgumentBuilder.newBuilder();
|
||||
builder.type("int");
|
||||
Assertions.assertEquals("int", builder.build().getType());
|
||||
}
|
||||
|
||||
@Test
|
||||
void callback() {
|
||||
ArgumentBuilder builder = new ArgumentBuilder();
|
||||
ArgumentBuilder builder = ArgumentBuilder.newBuilder();
|
||||
builder.callback(true);
|
||||
Assertions.assertTrue(builder.build().isCallback());
|
||||
builder.callback(false);
|
||||
|
|
@ -48,7 +48,7 @@ class ArgumentBuilderTest {
|
|||
|
||||
@Test
|
||||
void build() {
|
||||
ArgumentBuilder builder = new ArgumentBuilder();
|
||||
ArgumentBuilder builder = ArgumentBuilder.newBuilder();
|
||||
builder.index(1).type("int").callback(true);
|
||||
|
||||
ArgumentConfig argument1 = builder.build();
|
||||
|
|
|
|||
|
|
@ -28,91 +28,91 @@ class ConfigCenterBuilderTest {
|
|||
|
||||
@Test
|
||||
void protocol() {
|
||||
ConfigCenterBuilder builder = new ConfigCenterBuilder();
|
||||
ConfigCenterBuilder builder = ConfigCenterBuilder.newBuilder();
|
||||
builder.protocol("protocol");
|
||||
Assertions.assertEquals("protocol", builder.build().getProtocol());
|
||||
}
|
||||
|
||||
@Test
|
||||
void address() {
|
||||
ConfigCenterBuilder builder = new ConfigCenterBuilder();
|
||||
ConfigCenterBuilder builder = ConfigCenterBuilder.newBuilder();
|
||||
builder.address("address");
|
||||
Assertions.assertEquals("address", builder.build().getAddress());
|
||||
}
|
||||
|
||||
@Test
|
||||
void cluster() {
|
||||
ConfigCenterBuilder builder = new ConfigCenterBuilder();
|
||||
ConfigCenterBuilder builder = ConfigCenterBuilder.newBuilder();
|
||||
builder.cluster("cluster");
|
||||
Assertions.assertEquals("cluster", builder.build().getCluster());
|
||||
}
|
||||
|
||||
@Test
|
||||
void namespace() {
|
||||
ConfigCenterBuilder builder = new ConfigCenterBuilder();
|
||||
ConfigCenterBuilder builder = ConfigCenterBuilder.newBuilder();
|
||||
builder.namespace("namespace");
|
||||
Assertions.assertEquals("namespace", builder.build().getNamespace());
|
||||
}
|
||||
|
||||
@Test
|
||||
void group() {
|
||||
ConfigCenterBuilder builder = new ConfigCenterBuilder();
|
||||
ConfigCenterBuilder builder = ConfigCenterBuilder.newBuilder();
|
||||
builder.group("group");
|
||||
Assertions.assertEquals("group", builder.build().getGroup());
|
||||
}
|
||||
|
||||
@Test
|
||||
void username() {
|
||||
ConfigCenterBuilder builder = new ConfigCenterBuilder();
|
||||
ConfigCenterBuilder builder = ConfigCenterBuilder.newBuilder();
|
||||
builder.username("username");
|
||||
Assertions.assertEquals("username", builder.build().getUsername());
|
||||
}
|
||||
|
||||
@Test
|
||||
void password() {
|
||||
ConfigCenterBuilder builder = new ConfigCenterBuilder();
|
||||
ConfigCenterBuilder builder = ConfigCenterBuilder.newBuilder();
|
||||
builder.password("password");
|
||||
Assertions.assertEquals("password", builder.build().getPassword());
|
||||
}
|
||||
|
||||
@Test
|
||||
void timeout() {
|
||||
ConfigCenterBuilder builder = new ConfigCenterBuilder();
|
||||
ConfigCenterBuilder builder = ConfigCenterBuilder.newBuilder();
|
||||
builder.timeout(1000L);
|
||||
Assertions.assertEquals(1000L, builder.build().getTimeout());
|
||||
}
|
||||
|
||||
@Test
|
||||
void highestPriority() {
|
||||
ConfigCenterBuilder builder = new ConfigCenterBuilder();
|
||||
ConfigCenterBuilder builder = ConfigCenterBuilder.newBuilder();
|
||||
builder.highestPriority(true);
|
||||
Assertions.assertTrue(builder.build().isHighestPriority());
|
||||
}
|
||||
|
||||
@Test
|
||||
void check() {
|
||||
ConfigCenterBuilder builder = new ConfigCenterBuilder();
|
||||
ConfigCenterBuilder builder = ConfigCenterBuilder.newBuilder();
|
||||
builder.check(true);
|
||||
Assertions.assertTrue(builder.build().isCheck());
|
||||
}
|
||||
|
||||
@Test
|
||||
void configFile() {
|
||||
ConfigCenterBuilder builder = new ConfigCenterBuilder();
|
||||
ConfigCenterBuilder builder = ConfigCenterBuilder.newBuilder();
|
||||
builder.configFile("configFile");
|
||||
Assertions.assertEquals("configFile", builder.build().getConfigFile());
|
||||
}
|
||||
|
||||
@Test
|
||||
void appConfigFile() {
|
||||
ConfigCenterBuilder builder = new ConfigCenterBuilder();
|
||||
ConfigCenterBuilder builder = ConfigCenterBuilder.newBuilder();
|
||||
builder.appConfigFile("appConfigFile");
|
||||
Assertions.assertEquals("appConfigFile", builder.build().getAppConfigFile());
|
||||
}
|
||||
|
||||
@Test
|
||||
void appendParameter() {
|
||||
ConfigCenterBuilder builder = new ConfigCenterBuilder();
|
||||
ConfigCenterBuilder builder = ConfigCenterBuilder.newBuilder();
|
||||
builder.appendParameter("default.num", "one").appendParameter("num", "ONE");
|
||||
|
||||
Map<String, String> parameters = builder.build().getParameters();
|
||||
|
|
@ -127,7 +127,7 @@ class ConfigCenterBuilderTest {
|
|||
source.put("default.num", "one");
|
||||
source.put("num", "ONE");
|
||||
|
||||
ConfigCenterBuilder builder = new ConfigCenterBuilder();
|
||||
ConfigCenterBuilder builder = ConfigCenterBuilder.newBuilder();
|
||||
builder.appendParameters(source);
|
||||
|
||||
Map<String, String> parameters = builder.build().getParameters();
|
||||
|
|
@ -138,7 +138,7 @@ class ConfigCenterBuilderTest {
|
|||
|
||||
@Test
|
||||
void build() {
|
||||
ConfigCenterBuilder builder = new ConfigCenterBuilder();
|
||||
ConfigCenterBuilder builder = ConfigCenterBuilder.newBuilder();
|
||||
builder.check(true)
|
||||
.protocol("protocol")
|
||||
.address("address")
|
||||
|
|
|
|||
|
|
@ -25,56 +25,56 @@ class ConsumerBuilderTest {
|
|||
|
||||
@Test
|
||||
void isDefault() {
|
||||
ConsumerBuilder builder = new ConsumerBuilder();
|
||||
ConsumerBuilder builder = ConsumerBuilder.newBuilder();
|
||||
builder.isDefault(false);
|
||||
Assertions.assertFalse(builder.build().isDefault());
|
||||
}
|
||||
|
||||
@Test
|
||||
void client() {
|
||||
ConsumerBuilder builder = new ConsumerBuilder();
|
||||
ConsumerBuilder builder = ConsumerBuilder.newBuilder();
|
||||
builder.client("client");
|
||||
Assertions.assertEquals("client", builder.build().getClient());
|
||||
}
|
||||
|
||||
@Test
|
||||
void threadPool() {
|
||||
ConsumerBuilder builder = new ConsumerBuilder();
|
||||
ConsumerBuilder builder = ConsumerBuilder.newBuilder();
|
||||
builder.threadPool("threadPool");
|
||||
Assertions.assertEquals("threadPool", builder.build().getThreadpool());
|
||||
}
|
||||
|
||||
@Test
|
||||
void coreThreads() {
|
||||
ConsumerBuilder builder = new ConsumerBuilder();
|
||||
ConsumerBuilder builder = ConsumerBuilder.newBuilder();
|
||||
builder.coreThreads(10);
|
||||
Assertions.assertEquals(10, builder.build().getCorethreads());
|
||||
}
|
||||
|
||||
@Test
|
||||
void threads() {
|
||||
ConsumerBuilder builder = new ConsumerBuilder();
|
||||
ConsumerBuilder builder = ConsumerBuilder.newBuilder();
|
||||
builder.threads(100);
|
||||
Assertions.assertEquals(100, builder.build().getThreads());
|
||||
}
|
||||
|
||||
@Test
|
||||
void queues() {
|
||||
ConsumerBuilder builder = new ConsumerBuilder();
|
||||
ConsumerBuilder builder = ConsumerBuilder.newBuilder();
|
||||
builder.queues(200);
|
||||
Assertions.assertEquals(200, builder.build().getQueues());
|
||||
}
|
||||
|
||||
@Test
|
||||
void shareConnections() {
|
||||
ConsumerBuilder builder = new ConsumerBuilder();
|
||||
ConsumerBuilder builder = ConsumerBuilder.newBuilder();
|
||||
builder.shareConnections(300);
|
||||
Assertions.assertEquals(300, builder.build().getShareconnections());
|
||||
}
|
||||
|
||||
@Test
|
||||
void build() {
|
||||
ConsumerBuilder builder = new ConsumerBuilder();
|
||||
ConsumerBuilder builder = ConsumerBuilder.newBuilder();
|
||||
builder.isDefault(true)
|
||||
.client("client")
|
||||
.threadPool("threadPool")
|
||||
|
|
|
|||
|
|
@ -28,98 +28,98 @@ class MethodBuilderTest {
|
|||
|
||||
@Test
|
||||
void name() {
|
||||
MethodBuilder builder = new MethodBuilder();
|
||||
MethodBuilder builder = MethodBuilder.newBuilder();
|
||||
builder.name("name");
|
||||
Assertions.assertEquals("name", builder.build().getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
void stat() {
|
||||
MethodBuilder builder = new MethodBuilder();
|
||||
MethodBuilder builder = MethodBuilder.newBuilder();
|
||||
builder.stat(1);
|
||||
Assertions.assertEquals(1, builder.build().getStat());
|
||||
}
|
||||
|
||||
@Test
|
||||
void retry() {
|
||||
MethodBuilder builder = new MethodBuilder();
|
||||
MethodBuilder builder = MethodBuilder.newBuilder();
|
||||
builder.retry(true);
|
||||
Assertions.assertTrue(builder.build().isRetry());
|
||||
}
|
||||
|
||||
@Test
|
||||
void reliable() {
|
||||
MethodBuilder builder = new MethodBuilder();
|
||||
MethodBuilder builder = MethodBuilder.newBuilder();
|
||||
builder.reliable(true);
|
||||
Assertions.assertTrue(builder.build().isReliable());
|
||||
}
|
||||
|
||||
@Test
|
||||
void executes() {
|
||||
MethodBuilder builder = new MethodBuilder();
|
||||
MethodBuilder builder = MethodBuilder.newBuilder();
|
||||
builder.executes(1);
|
||||
Assertions.assertEquals(1, builder.build().getExecutes());
|
||||
}
|
||||
|
||||
@Test
|
||||
void deprecated() {
|
||||
MethodBuilder builder = new MethodBuilder();
|
||||
MethodBuilder builder = MethodBuilder.newBuilder();
|
||||
builder.deprecated(true);
|
||||
Assertions.assertTrue(builder.build().getDeprecated());
|
||||
}
|
||||
|
||||
@Test
|
||||
void sticky() {
|
||||
MethodBuilder builder = new MethodBuilder();
|
||||
MethodBuilder builder = MethodBuilder.newBuilder();
|
||||
builder.sticky(true);
|
||||
Assertions.assertTrue(builder.build().getSticky());
|
||||
}
|
||||
|
||||
@Test
|
||||
void isReturn() {
|
||||
MethodBuilder builder = new MethodBuilder();
|
||||
MethodBuilder builder = MethodBuilder.newBuilder();
|
||||
builder.isReturn(true);
|
||||
Assertions.assertTrue(builder.build().isReturn());
|
||||
}
|
||||
|
||||
@Test
|
||||
void oninvoke() {
|
||||
MethodBuilder builder = new MethodBuilder();
|
||||
MethodBuilder builder = MethodBuilder.newBuilder();
|
||||
builder.oninvoke("on-invoke-object");
|
||||
Assertions.assertEquals("on-invoke-object", builder.build().getOninvoke());
|
||||
}
|
||||
|
||||
@Test
|
||||
void oninvokeMethod() {
|
||||
MethodBuilder builder = new MethodBuilder();
|
||||
MethodBuilder builder = MethodBuilder.newBuilder();
|
||||
builder.oninvokeMethod("on-invoke-method");
|
||||
Assertions.assertEquals("on-invoke-method", builder.build().getOninvokeMethod());
|
||||
}
|
||||
|
||||
@Test
|
||||
void onreturn() {
|
||||
MethodBuilder builder = new MethodBuilder();
|
||||
MethodBuilder builder = MethodBuilder.newBuilder();
|
||||
builder.onreturn("on-return-object");
|
||||
Assertions.assertEquals("on-return-object", builder.build().getOnreturn());
|
||||
}
|
||||
|
||||
@Test
|
||||
void onreturnMethod() {
|
||||
MethodBuilder builder = new MethodBuilder();
|
||||
MethodBuilder builder = MethodBuilder.newBuilder();
|
||||
builder.onreturnMethod("on-return-method");
|
||||
Assertions.assertEquals("on-return-method", builder.build().getOnreturnMethod());
|
||||
}
|
||||
|
||||
@Test
|
||||
void onthrow() {
|
||||
MethodBuilder builder = new MethodBuilder();
|
||||
MethodBuilder builder = MethodBuilder.newBuilder();
|
||||
builder.onthrow("on-throw-object");
|
||||
Assertions.assertEquals("on-throw-object", builder.build().getOnthrow());
|
||||
}
|
||||
|
||||
@Test
|
||||
void onthrowMethod() {
|
||||
MethodBuilder builder = new MethodBuilder();
|
||||
MethodBuilder builder = MethodBuilder.newBuilder();
|
||||
builder.onthrowMethod("on-throw-method");
|
||||
Assertions.assertEquals("on-throw-method", builder.build().getOnthrowMethod());
|
||||
}
|
||||
|
|
@ -127,7 +127,7 @@ class MethodBuilderTest {
|
|||
@Test
|
||||
void addArguments() {
|
||||
ArgumentConfig argument = new ArgumentConfig();
|
||||
MethodBuilder builder = new MethodBuilder();
|
||||
MethodBuilder builder = MethodBuilder.newBuilder();
|
||||
builder.addArguments(Collections.singletonList(argument));
|
||||
Assertions.assertTrue(builder.build().getArguments().contains(argument));
|
||||
Assertions.assertEquals(1, builder.build().getArguments().size());
|
||||
|
|
@ -136,7 +136,7 @@ class MethodBuilderTest {
|
|||
@Test
|
||||
void addArgument() {
|
||||
ArgumentConfig argument = new ArgumentConfig();
|
||||
MethodBuilder builder = new MethodBuilder();
|
||||
MethodBuilder builder = MethodBuilder.newBuilder();
|
||||
builder.addArgument(argument);
|
||||
Assertions.assertTrue(builder.build().getArguments().contains(argument));
|
||||
Assertions.assertEquals(1, builder.build().getArguments().size());
|
||||
|
|
@ -144,14 +144,14 @@ class MethodBuilderTest {
|
|||
|
||||
@Test
|
||||
void service() {
|
||||
MethodBuilder builder = new MethodBuilder();
|
||||
MethodBuilder builder = MethodBuilder.newBuilder();
|
||||
builder.service("service");
|
||||
Assertions.assertEquals("service", builder.build().getService());
|
||||
}
|
||||
|
||||
@Test
|
||||
void serviceId() {
|
||||
MethodBuilder builder = new MethodBuilder();
|
||||
MethodBuilder builder = MethodBuilder.newBuilder();
|
||||
builder.serviceId("serviceId");
|
||||
Assertions.assertEquals("serviceId", builder.build().getServiceId());
|
||||
}
|
||||
|
|
@ -159,7 +159,7 @@ class MethodBuilderTest {
|
|||
@Test
|
||||
void build() {
|
||||
ArgumentConfig argument = new ArgumentConfig();
|
||||
MethodBuilder builder = new MethodBuilder();
|
||||
MethodBuilder builder = MethodBuilder.newBuilder();
|
||||
builder.name("name")
|
||||
.stat(1)
|
||||
.retry(true)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,303 @@
|
|||
/*
|
||||
* 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.config.bootstrap.builders;
|
||||
|
||||
import org.apache.dubbo.config.MetricsConfig;
|
||||
import org.apache.dubbo.config.nested.AggregationConfig;
|
||||
import org.apache.dubbo.config.nested.HistogramConfig;
|
||||
import org.apache.dubbo.config.nested.PrometheusConfig;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class MetricsBuilderTest {
|
||||
|
||||
@Test
|
||||
void protocol() {
|
||||
MetricsBuilder builder = MetricsBuilder.newBuilder();
|
||||
builder.protocol("test");
|
||||
Assertions.assertEquals("test", builder.build().getProtocol());
|
||||
}
|
||||
|
||||
@Test
|
||||
void enableJvm() {
|
||||
MetricsBuilder builder = MetricsBuilder.newBuilder();
|
||||
builder.enableJvm(true);
|
||||
Assertions.assertTrue(builder.build().getEnableJvm());
|
||||
}
|
||||
|
||||
@Test
|
||||
void enableThreadPool() {
|
||||
MetricsBuilder builder = MetricsBuilder.newBuilder();
|
||||
builder.enableThreadPool(false);
|
||||
Assertions.assertFalse(builder.build().getEnableThreadpool());
|
||||
}
|
||||
|
||||
@Test
|
||||
void enableRegistry() {
|
||||
MetricsBuilder builder = MetricsBuilder.newBuilder();
|
||||
builder.enableRegistry(true);
|
||||
Assertions.assertTrue(builder.build().getEnableRegistry());
|
||||
}
|
||||
|
||||
@Test
|
||||
void enableMetadata() {
|
||||
MetricsBuilder builder = MetricsBuilder.newBuilder();
|
||||
builder.enableMetadata(true);
|
||||
Assertions.assertTrue(builder.build().getEnableMetadata());
|
||||
}
|
||||
|
||||
@Test
|
||||
void exportMetricsService() {
|
||||
MetricsBuilder builder = MetricsBuilder.newBuilder();
|
||||
builder.exportMetricsService(false);
|
||||
Assertions.assertFalse(builder.build().getExportMetricsService());
|
||||
}
|
||||
|
||||
@Test
|
||||
void enableMetricsInit() {
|
||||
MetricsBuilder builder = MetricsBuilder.newBuilder();
|
||||
builder.enableMetricsInit(true);
|
||||
Assertions.assertTrue(builder.build().getEnableMetricsInit());
|
||||
}
|
||||
|
||||
@Test
|
||||
void enableCollectorSync() {
|
||||
MetricsBuilder builder = MetricsBuilder.newBuilder();
|
||||
builder.enableCollectorSync(true);
|
||||
Assertions.assertTrue(builder.build().getEnableCollectorSync());
|
||||
}
|
||||
|
||||
@Test
|
||||
void collectorSyncPeriod() {
|
||||
MetricsBuilder builder = MetricsBuilder.newBuilder();
|
||||
builder.collectorSyncPeriod(10);
|
||||
Assertions.assertEquals(10, builder.build().getCollectorSyncPeriod());
|
||||
}
|
||||
|
||||
@Test
|
||||
void exportServiceProtocol() {
|
||||
MetricsBuilder builder = MetricsBuilder.newBuilder();
|
||||
builder.exportServiceProtocol("tri");
|
||||
Assertions.assertEquals("tri", builder.build().getExportServiceProtocol());
|
||||
}
|
||||
|
||||
@Test
|
||||
void exportServicePort() {
|
||||
MetricsBuilder builder = MetricsBuilder.newBuilder();
|
||||
builder.exportServicePort(2999);
|
||||
Assertions.assertEquals(2999, builder.build().getExportServicePort());
|
||||
}
|
||||
|
||||
@Test
|
||||
void useGlobalRegistry() {
|
||||
MetricsBuilder builder = MetricsBuilder.newBuilder();
|
||||
builder.useGlobalRegistry(true);
|
||||
Assertions.assertTrue(builder.build().getUseGlobalRegistry());
|
||||
}
|
||||
|
||||
@Test
|
||||
void enableRpc() {
|
||||
MetricsBuilder builder = MetricsBuilder.newBuilder();
|
||||
builder.enableRpc(false);
|
||||
Assertions.assertFalse(builder.build().getEnableRpc());
|
||||
}
|
||||
|
||||
@Test
|
||||
void rpcLevel() {
|
||||
MetricsBuilder builder = MetricsBuilder.newBuilder();
|
||||
builder.rpcLevel("SERVICE");
|
||||
Assertions.assertEquals("SERVICE", builder.build().getRpcLevel());
|
||||
}
|
||||
|
||||
@Test
|
||||
void aggregation() {
|
||||
AggregationConfig aggregation = new AggregationConfig();
|
||||
aggregation.setEnabled(true);
|
||||
aggregation.setEnableQps(false);
|
||||
aggregation.setBucketNum(100);
|
||||
|
||||
MetricsBuilder builder = MetricsBuilder.newBuilder();
|
||||
builder.aggregation(aggregation);
|
||||
|
||||
Assertions.assertSame(aggregation, builder.build().getAggregation());
|
||||
Assertions.assertTrue(builder.build().getAggregation().getEnabled());
|
||||
Assertions.assertFalse(builder.build().getAggregation().getEnableQps());
|
||||
Assertions.assertEquals(100, builder.build().getAggregation().getBucketNum());
|
||||
}
|
||||
|
||||
@Test
|
||||
void histogram() {
|
||||
HistogramConfig histogram = new HistogramConfig();
|
||||
histogram.setEnabled(true);
|
||||
histogram.setMaxExpectedMs(1000);
|
||||
histogram.setBucketsMs(new Integer[] {100, 200, 300, 400, 500});
|
||||
histogram.setPercentiles(new double[] {0.5, 0.9, 0.95, 0.99});
|
||||
|
||||
MetricsBuilder builder = MetricsBuilder.newBuilder();
|
||||
builder.histogram(histogram);
|
||||
|
||||
Assertions.assertSame(histogram, builder.build().getHistogram());
|
||||
Assertions.assertTrue(builder.build().getHistogram().getEnabled());
|
||||
Assertions.assertEquals(1000, builder.build().getHistogram().getMaxExpectedMs());
|
||||
Assertions.assertArrayEquals(
|
||||
new Integer[] {100, 200, 300, 400, 500},
|
||||
builder.build().getHistogram().getBucketsMs());
|
||||
Assertions.assertArrayEquals(
|
||||
new double[] {0.5, 0.9, 0.95, 0.99},
|
||||
builder.build().getHistogram().getPercentiles());
|
||||
}
|
||||
|
||||
@Test
|
||||
void prometheus() {
|
||||
PrometheusConfig.Exporter exporter = new PrometheusConfig.Exporter();
|
||||
exporter.setEnabled(true);
|
||||
exporter.setEnableHttpServiceDiscovery(true);
|
||||
exporter.setHttpServiceDiscoveryUrl("localhost:8080");
|
||||
|
||||
PrometheusConfig.Pushgateway pushGateway = new PrometheusConfig.Pushgateway();
|
||||
pushGateway.setEnabled(true);
|
||||
pushGateway.setBaseUrl("localhost:9091");
|
||||
pushGateway.setUsername("username");
|
||||
pushGateway.setPassword("password");
|
||||
pushGateway.setJob("job");
|
||||
pushGateway.setPushInterval(30);
|
||||
|
||||
PrometheusConfig prometheus = new PrometheusConfig();
|
||||
prometheus.setExporter(exporter);
|
||||
prometheus.setPushgateway(pushGateway);
|
||||
|
||||
MetricsBuilder builder = MetricsBuilder.newBuilder();
|
||||
builder.prometheus(prometheus);
|
||||
|
||||
Assertions.assertSame(prometheus, builder.build().getPrometheus());
|
||||
Assertions.assertSame(exporter, builder.build().getPrometheus().getExporter());
|
||||
Assertions.assertSame(pushGateway, builder.build().getPrometheus().getPushgateway());
|
||||
Assertions.assertTrue(builder.build().getPrometheus().getExporter().getEnabled());
|
||||
Assertions.assertTrue(builder.build().getPrometheus().getExporter().getEnableHttpServiceDiscovery());
|
||||
Assertions.assertEquals(
|
||||
"localhost:8080", builder.build().getPrometheus().getExporter().getHttpServiceDiscoveryUrl());
|
||||
Assertions.assertTrue(builder.build().getPrometheus().getPushgateway().getEnabled());
|
||||
Assertions.assertEquals(
|
||||
"localhost:9091",
|
||||
builder.build().getPrometheus().getPushgateway().getBaseUrl());
|
||||
Assertions.assertEquals(
|
||||
"username", builder.build().getPrometheus().getPushgateway().getUsername());
|
||||
Assertions.assertEquals(
|
||||
"password", builder.build().getPrometheus().getPushgateway().getPassword());
|
||||
Assertions.assertEquals(
|
||||
"job", builder.build().getPrometheus().getPushgateway().getJob());
|
||||
Assertions.assertEquals(
|
||||
30, builder.build().getPrometheus().getPushgateway().getPushInterval());
|
||||
}
|
||||
|
||||
@Test
|
||||
void build() {
|
||||
PrometheusConfig.Exporter exporter = new PrometheusConfig.Exporter();
|
||||
exporter.setEnabled(true);
|
||||
exporter.setEnableHttpServiceDiscovery(true);
|
||||
exporter.setHttpServiceDiscoveryUrl("localhost:8080");
|
||||
|
||||
PrometheusConfig.Pushgateway pushGateway = new PrometheusConfig.Pushgateway();
|
||||
pushGateway.setEnabled(true);
|
||||
pushGateway.setBaseUrl("localhost:9091");
|
||||
pushGateway.setUsername("username");
|
||||
pushGateway.setPassword("password");
|
||||
pushGateway.setJob("job");
|
||||
pushGateway.setPushInterval(30);
|
||||
|
||||
PrometheusConfig prometheus = new PrometheusConfig();
|
||||
prometheus.setExporter(exporter);
|
||||
prometheus.setPushgateway(pushGateway);
|
||||
|
||||
HistogramConfig histogram = new HistogramConfig();
|
||||
histogram.setEnabled(true);
|
||||
histogram.setMaxExpectedMs(1000);
|
||||
histogram.setBucketsMs(new Integer[] {100, 200, 300, 400, 500});
|
||||
histogram.setPercentiles(new double[] {0.5, 0.9, 0.95, 0.99});
|
||||
|
||||
AggregationConfig aggregation = new AggregationConfig();
|
||||
aggregation.setEnabled(true);
|
||||
aggregation.setEnableQps(false);
|
||||
aggregation.setBucketNum(100);
|
||||
|
||||
MetricsBuilder builder = MetricsBuilder.newBuilder();
|
||||
builder.protocol("test")
|
||||
.enableJvm(true)
|
||||
.enableThreadPool(true)
|
||||
.enableRegistry(false)
|
||||
.enableMetadata(false)
|
||||
.exportMetricsService(true)
|
||||
.enableMetricsInit(false)
|
||||
.enableCollectorSync(true)
|
||||
.collectorSyncPeriod(10)
|
||||
.prometheus(prometheus)
|
||||
.histogram(histogram)
|
||||
.aggregation(aggregation)
|
||||
.exportServiceProtocol("tri")
|
||||
.exportServicePort(10010)
|
||||
.useGlobalRegistry(true)
|
||||
.enableRpc(true)
|
||||
.rpcLevel("METHOD");
|
||||
|
||||
MetricsConfig config = builder.build();
|
||||
MetricsConfig config2 = builder.build();
|
||||
|
||||
Assertions.assertEquals("test", config.getProtocol());
|
||||
Assertions.assertTrue(config.getEnableJvm());
|
||||
Assertions.assertTrue(config.getEnableThreadpool());
|
||||
Assertions.assertFalse(config.getEnableRegistry());
|
||||
Assertions.assertFalse(config.getEnableMetadata());
|
||||
Assertions.assertTrue(config.getExportMetricsService());
|
||||
Assertions.assertFalse(config.getEnableMetricsInit());
|
||||
Assertions.assertTrue(config.getEnableCollectorSync());
|
||||
Assertions.assertEquals(10, config.getCollectorSyncPeriod());
|
||||
Assertions.assertSame(prometheus, config.getPrometheus());
|
||||
Assertions.assertSame(exporter, config.getPrometheus().getExporter());
|
||||
Assertions.assertSame(pushGateway, config.getPrometheus().getPushgateway());
|
||||
Assertions.assertTrue(config.getPrometheus().getExporter().getEnabled());
|
||||
Assertions.assertTrue(config.getPrometheus().getExporter().getEnableHttpServiceDiscovery());
|
||||
Assertions.assertEquals(
|
||||
"localhost:8080", config.getPrometheus().getExporter().getHttpServiceDiscoveryUrl());
|
||||
Assertions.assertTrue(config.getPrometheus().getPushgateway().getEnabled());
|
||||
Assertions.assertEquals(
|
||||
"localhost:9091", config.getPrometheus().getPushgateway().getBaseUrl());
|
||||
Assertions.assertEquals(
|
||||
"username", config.getPrometheus().getPushgateway().getUsername());
|
||||
Assertions.assertEquals(
|
||||
"password", config.getPrometheus().getPushgateway().getPassword());
|
||||
Assertions.assertEquals("job", config.getPrometheus().getPushgateway().getJob());
|
||||
Assertions.assertEquals(30, config.getPrometheus().getPushgateway().getPushInterval());
|
||||
Assertions.assertSame(histogram, config.getHistogram());
|
||||
Assertions.assertTrue(config.getHistogram().getEnabled());
|
||||
Assertions.assertEquals(1000, config.getHistogram().getMaxExpectedMs());
|
||||
Assertions.assertArrayEquals(
|
||||
new Integer[] {100, 200, 300, 400, 500}, config.getHistogram().getBucketsMs());
|
||||
Assertions.assertArrayEquals(
|
||||
new double[] {0.5, 0.9, 0.95, 0.99}, config.getHistogram().getPercentiles());
|
||||
Assertions.assertSame(aggregation, config.getAggregation());
|
||||
Assertions.assertTrue(config.getAggregation().getEnabled());
|
||||
Assertions.assertFalse(config.getAggregation().getEnableQps());
|
||||
Assertions.assertEquals(100, config.getAggregation().getBucketNum());
|
||||
Assertions.assertEquals("tri", config.getExportServiceProtocol());
|
||||
Assertions.assertEquals(10010, config.getExportServicePort());
|
||||
Assertions.assertTrue(config.getUseGlobalRegistry());
|
||||
Assertions.assertTrue(config.getEnableRpc());
|
||||
Assertions.assertEquals("METHOD", config.getRpcLevel());
|
||||
Assertions.assertNotSame(config, config2);
|
||||
}
|
||||
}
|
||||
|
|
@ -29,28 +29,28 @@ class ModuleBuilderTest {
|
|||
|
||||
@Test
|
||||
void name() {
|
||||
ModuleBuilder builder = new ModuleBuilder();
|
||||
ModuleBuilder builder = ModuleBuilder.newBuilder();
|
||||
builder.name("name");
|
||||
Assertions.assertEquals("name", builder.build().getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
void version() {
|
||||
ModuleBuilder builder = new ModuleBuilder();
|
||||
ModuleBuilder builder = ModuleBuilder.newBuilder();
|
||||
builder.version("version");
|
||||
Assertions.assertEquals("version", builder.build().getVersion());
|
||||
}
|
||||
|
||||
@Test
|
||||
void owner() {
|
||||
ModuleBuilder builder = new ModuleBuilder();
|
||||
ModuleBuilder builder = ModuleBuilder.newBuilder();
|
||||
builder.owner("owner");
|
||||
Assertions.assertEquals("owner", builder.build().getOwner());
|
||||
}
|
||||
|
||||
@Test
|
||||
void organization() {
|
||||
ModuleBuilder builder = new ModuleBuilder();
|
||||
ModuleBuilder builder = ModuleBuilder.newBuilder();
|
||||
builder.organization("organization");
|
||||
Assertions.assertEquals("organization", builder.build().getOrganization());
|
||||
}
|
||||
|
|
@ -58,7 +58,7 @@ class ModuleBuilderTest {
|
|||
@Test
|
||||
void addRegistries() {
|
||||
RegistryConfig registry = new RegistryConfig();
|
||||
ModuleBuilder builder = new ModuleBuilder();
|
||||
ModuleBuilder builder = ModuleBuilder.newBuilder();
|
||||
builder.addRegistries(Collections.singletonList(registry));
|
||||
Assertions.assertTrue(builder.build().getRegistries().contains(registry));
|
||||
Assertions.assertEquals(1, builder.build().getRegistries().size());
|
||||
|
|
@ -67,7 +67,7 @@ class ModuleBuilderTest {
|
|||
@Test
|
||||
void addRegistry() {
|
||||
RegistryConfig registry = new RegistryConfig();
|
||||
ModuleBuilder builder = new ModuleBuilder();
|
||||
ModuleBuilder builder = ModuleBuilder.newBuilder();
|
||||
builder.addRegistry(registry);
|
||||
Assertions.assertTrue(builder.build().getRegistries().contains(registry));
|
||||
Assertions.assertEquals(1, builder.build().getRegistries().size());
|
||||
|
|
@ -76,14 +76,14 @@ class ModuleBuilderTest {
|
|||
@Test
|
||||
void monitor() {
|
||||
MonitorConfig monitor = new MonitorConfig();
|
||||
ModuleBuilder builder = new ModuleBuilder();
|
||||
ModuleBuilder builder = ModuleBuilder.newBuilder();
|
||||
builder.monitor(monitor);
|
||||
Assertions.assertSame(monitor, builder.build().getMonitor());
|
||||
}
|
||||
|
||||
@Test
|
||||
void isDefault() {
|
||||
ModuleBuilder builder = new ModuleBuilder();
|
||||
ModuleBuilder builder = ModuleBuilder.newBuilder();
|
||||
builder.isDefault(true);
|
||||
Assertions.assertTrue(builder.build().isDefault());
|
||||
}
|
||||
|
|
@ -93,7 +93,7 @@ class ModuleBuilderTest {
|
|||
RegistryConfig registry = new RegistryConfig();
|
||||
MonitorConfig monitor = new MonitorConfig();
|
||||
|
||||
ModuleBuilder builder = new ModuleBuilder();
|
||||
ModuleBuilder builder = ModuleBuilder.newBuilder();
|
||||
builder.name("name")
|
||||
.version("version")
|
||||
.owner("owner")
|
||||
|
|
|
|||
|
|
@ -28,63 +28,63 @@ class MonitorBuilderTest {
|
|||
|
||||
@Test
|
||||
void protocol() {
|
||||
MonitorBuilder builder = new MonitorBuilder();
|
||||
MonitorBuilder builder = MonitorBuilder.newBuilder();
|
||||
builder.protocol("protocol");
|
||||
Assertions.assertEquals("protocol", builder.build().getProtocol());
|
||||
}
|
||||
|
||||
@Test
|
||||
void address() {
|
||||
MonitorBuilder builder = new MonitorBuilder();
|
||||
MonitorBuilder builder = MonitorBuilder.newBuilder();
|
||||
builder.address("address");
|
||||
Assertions.assertEquals("address", builder.build().getAddress());
|
||||
}
|
||||
|
||||
@Test
|
||||
void username() {
|
||||
MonitorBuilder builder = new MonitorBuilder();
|
||||
MonitorBuilder builder = MonitorBuilder.newBuilder();
|
||||
builder.username("username");
|
||||
Assertions.assertEquals("username", builder.build().getUsername());
|
||||
}
|
||||
|
||||
@Test
|
||||
void password() {
|
||||
MonitorBuilder builder = new MonitorBuilder();
|
||||
MonitorBuilder builder = MonitorBuilder.newBuilder();
|
||||
builder.password("password");
|
||||
Assertions.assertEquals("password", builder.build().getPassword());
|
||||
}
|
||||
|
||||
@Test
|
||||
void group() {
|
||||
MonitorBuilder builder = new MonitorBuilder();
|
||||
MonitorBuilder builder = MonitorBuilder.newBuilder();
|
||||
builder.group("group");
|
||||
Assertions.assertEquals("group", builder.build().getGroup());
|
||||
}
|
||||
|
||||
@Test
|
||||
void version() {
|
||||
MonitorBuilder builder = new MonitorBuilder();
|
||||
MonitorBuilder builder = MonitorBuilder.newBuilder();
|
||||
builder.version("version");
|
||||
Assertions.assertEquals("version", builder.build().getVersion());
|
||||
}
|
||||
|
||||
@Test
|
||||
void interval() {
|
||||
MonitorBuilder builder = new MonitorBuilder();
|
||||
MonitorBuilder builder = MonitorBuilder.newBuilder();
|
||||
builder.interval("interval");
|
||||
Assertions.assertEquals("interval", builder.build().getInterval());
|
||||
}
|
||||
|
||||
@Test
|
||||
void isDefault() {
|
||||
MonitorBuilder builder = new MonitorBuilder();
|
||||
MonitorBuilder builder = MonitorBuilder.newBuilder();
|
||||
builder.isDefault(true);
|
||||
Assertions.assertTrue(builder.build().isDefault());
|
||||
}
|
||||
|
||||
@Test
|
||||
void appendParameter() {
|
||||
MonitorBuilder builder = new MonitorBuilder();
|
||||
MonitorBuilder builder = MonitorBuilder.newBuilder();
|
||||
builder.appendParameter("default.num", "one").appendParameter("num", "ONE");
|
||||
|
||||
Map<String, String> parameters = builder.build().getParameters();
|
||||
|
|
@ -99,7 +99,7 @@ class MonitorBuilderTest {
|
|||
source.put("default.num", "one");
|
||||
source.put("num", "ONE");
|
||||
|
||||
MonitorBuilder builder = new MonitorBuilder();
|
||||
MonitorBuilder builder = MonitorBuilder.newBuilder();
|
||||
builder.appendParameters(source);
|
||||
|
||||
Map<String, String> parameters = builder.build().getParameters();
|
||||
|
|
@ -110,7 +110,7 @@ class MonitorBuilderTest {
|
|||
|
||||
@Test
|
||||
void build() {
|
||||
MonitorBuilder builder = new MonitorBuilder();
|
||||
MonitorBuilder builder = MonitorBuilder.newBuilder();
|
||||
builder.protocol("protocol")
|
||||
.address("address")
|
||||
.group("group")
|
||||
|
|
|
|||
|
|
@ -25,168 +25,168 @@ class ProviderBuilderTest {
|
|||
|
||||
@Test
|
||||
void setHost() {
|
||||
ProviderBuilder builder = new ProviderBuilder();
|
||||
ProviderBuilder builder = ProviderBuilder.newBuilder();
|
||||
builder.host("host");
|
||||
Assertions.assertEquals("host", builder.build().getHost());
|
||||
}
|
||||
|
||||
@Test
|
||||
void port() {
|
||||
ProviderBuilder builder = new ProviderBuilder();
|
||||
ProviderBuilder builder = ProviderBuilder.newBuilder();
|
||||
builder.port(8080);
|
||||
Assertions.assertEquals(8080, builder.build().getPort());
|
||||
}
|
||||
|
||||
@Test
|
||||
void contextPath() {
|
||||
ProviderBuilder builder = new ProviderBuilder();
|
||||
ProviderBuilder builder = ProviderBuilder.newBuilder();
|
||||
builder.contextPath("contextpath");
|
||||
Assertions.assertEquals("contextpath", builder.build().getContextpath());
|
||||
}
|
||||
|
||||
@Test
|
||||
void threadPool() {
|
||||
ProviderBuilder builder = new ProviderBuilder();
|
||||
ProviderBuilder builder = ProviderBuilder.newBuilder();
|
||||
builder.threadPool("mockthreadpool");
|
||||
Assertions.assertEquals("mockthreadpool", builder.build().getThreadpool());
|
||||
}
|
||||
|
||||
@Test
|
||||
void threads() {
|
||||
ProviderBuilder builder = new ProviderBuilder();
|
||||
ProviderBuilder builder = ProviderBuilder.newBuilder();
|
||||
builder.threads(20);
|
||||
Assertions.assertEquals(20, builder.build().getThreads());
|
||||
}
|
||||
|
||||
@Test
|
||||
void ioThreads() {
|
||||
ProviderBuilder builder = new ProviderBuilder();
|
||||
ProviderBuilder builder = ProviderBuilder.newBuilder();
|
||||
builder.ioThreads(25);
|
||||
Assertions.assertEquals(25, builder.build().getIothreads());
|
||||
}
|
||||
|
||||
@Test
|
||||
void queues() {
|
||||
ProviderBuilder builder = new ProviderBuilder();
|
||||
ProviderBuilder builder = ProviderBuilder.newBuilder();
|
||||
builder.queues(30);
|
||||
Assertions.assertEquals(30, builder.build().getQueues());
|
||||
}
|
||||
|
||||
@Test
|
||||
void accepts() {
|
||||
ProviderBuilder builder = new ProviderBuilder();
|
||||
ProviderBuilder builder = ProviderBuilder.newBuilder();
|
||||
builder.accepts(35);
|
||||
Assertions.assertEquals(35, builder.build().getAccepts());
|
||||
}
|
||||
|
||||
@Test
|
||||
void codec() {
|
||||
ProviderBuilder builder = new ProviderBuilder();
|
||||
ProviderBuilder builder = ProviderBuilder.newBuilder();
|
||||
builder.codec("mockcodec");
|
||||
Assertions.assertEquals("mockcodec", builder.build().getCodec());
|
||||
}
|
||||
|
||||
@Test
|
||||
void charset() {
|
||||
ProviderBuilder builder = new ProviderBuilder();
|
||||
ProviderBuilder builder = ProviderBuilder.newBuilder();
|
||||
builder.charset("utf-8");
|
||||
Assertions.assertEquals("utf-8", builder.build().getCharset());
|
||||
}
|
||||
|
||||
@Test
|
||||
void payload() {
|
||||
ProviderBuilder builder = new ProviderBuilder();
|
||||
ProviderBuilder builder = ProviderBuilder.newBuilder();
|
||||
builder.payload(40);
|
||||
Assertions.assertEquals(40, builder.build().getPayload());
|
||||
}
|
||||
|
||||
@Test
|
||||
void buffer() {
|
||||
ProviderBuilder builder = new ProviderBuilder();
|
||||
ProviderBuilder builder = ProviderBuilder.newBuilder();
|
||||
builder.buffer(1024);
|
||||
Assertions.assertEquals(1024, builder.build().getBuffer());
|
||||
}
|
||||
|
||||
@Test
|
||||
void transporter() {
|
||||
ProviderBuilder builder = new ProviderBuilder();
|
||||
ProviderBuilder builder = ProviderBuilder.newBuilder();
|
||||
builder.transporter("mocktransporter");
|
||||
Assertions.assertEquals("mocktransporter", builder.build().getTransporter());
|
||||
}
|
||||
|
||||
@Test
|
||||
void exchanger() {
|
||||
ProviderBuilder builder = new ProviderBuilder();
|
||||
ProviderBuilder builder = ProviderBuilder.newBuilder();
|
||||
builder.exchanger("mockexchanger");
|
||||
Assertions.assertEquals("mockexchanger", builder.build().getExchanger());
|
||||
}
|
||||
|
||||
@Test
|
||||
void dispatcher() {
|
||||
ProviderBuilder builder = new ProviderBuilder();
|
||||
ProviderBuilder builder = ProviderBuilder.newBuilder();
|
||||
builder.dispatcher("mockdispatcher");
|
||||
Assertions.assertEquals("mockdispatcher", builder.build().getDispatcher());
|
||||
}
|
||||
|
||||
@Test
|
||||
void networker() {
|
||||
ProviderBuilder builder = new ProviderBuilder();
|
||||
ProviderBuilder builder = ProviderBuilder.newBuilder();
|
||||
builder.networker("networker");
|
||||
Assertions.assertEquals("networker", builder.build().getNetworker());
|
||||
}
|
||||
|
||||
@Test
|
||||
void server() {
|
||||
ProviderBuilder builder = new ProviderBuilder();
|
||||
ProviderBuilder builder = ProviderBuilder.newBuilder();
|
||||
builder.server("server");
|
||||
Assertions.assertEquals("server", builder.build().getServer());
|
||||
}
|
||||
|
||||
@Test
|
||||
void client() {
|
||||
ProviderBuilder builder = new ProviderBuilder();
|
||||
ProviderBuilder builder = ProviderBuilder.newBuilder();
|
||||
builder.client("client");
|
||||
Assertions.assertEquals("client", builder.build().getClient());
|
||||
}
|
||||
|
||||
@Test
|
||||
void telnet() {
|
||||
ProviderBuilder builder = new ProviderBuilder();
|
||||
ProviderBuilder builder = ProviderBuilder.newBuilder();
|
||||
builder.telnet("mocktelnethandler");
|
||||
Assertions.assertEquals("mocktelnethandler", builder.build().getTelnet());
|
||||
}
|
||||
|
||||
@Test
|
||||
void prompt() {
|
||||
ProviderBuilder builder = new ProviderBuilder();
|
||||
ProviderBuilder builder = ProviderBuilder.newBuilder();
|
||||
builder.prompt("prompt");
|
||||
Assertions.assertEquals("prompt", builder.build().getPrompt());
|
||||
}
|
||||
|
||||
@Test
|
||||
void status() {
|
||||
ProviderBuilder builder = new ProviderBuilder();
|
||||
ProviderBuilder builder = ProviderBuilder.newBuilder();
|
||||
builder.status("mockstatuschecker");
|
||||
Assertions.assertEquals("mockstatuschecker", builder.build().getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
void Wait() {
|
||||
ProviderBuilder builder = new ProviderBuilder();
|
||||
ProviderBuilder builder = ProviderBuilder.newBuilder();
|
||||
builder.wait(Integer.valueOf(1000));
|
||||
Assertions.assertEquals(1000, builder.build().getWait());
|
||||
}
|
||||
|
||||
@Test
|
||||
void isDefault() {
|
||||
ProviderBuilder builder = new ProviderBuilder();
|
||||
ProviderBuilder builder = ProviderBuilder.newBuilder();
|
||||
builder.isDefault(true);
|
||||
Assertions.assertTrue(builder.build().isDefault());
|
||||
}
|
||||
|
||||
@Test
|
||||
void build() {
|
||||
ProviderBuilder builder = new ProviderBuilder();
|
||||
ProviderBuilder builder = ProviderBuilder.newBuilder();
|
||||
builder.host("host")
|
||||
.port(8080)
|
||||
.contextPath("contextpath")
|
||||
|
|
|
|||
|
|
@ -38,9 +38,6 @@ public class DubboInterfaceConsumerBootstrap {
|
|||
.application("dubbo-consumer-demo")
|
||||
// Zookeeper
|
||||
.registry(interfaceRegistry)
|
||||
// Nacos
|
||||
// .registry("consul", builder ->
|
||||
// builder.address("consul://127.0.0.1:8500?registry.type=service&subscribed.services=dubbo-provider-demo"))
|
||||
.reference("echo", builder -> builder.interfaceClass(EchoService.class)
|
||||
.protocol("dubbo"))
|
||||
.reference("user", builder -> builder.interfaceClass(UserService.class)
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ public class DubboAnnotationUtils {
|
|||
* be split in anytime.It will throw IllegalArgumentException If converted array length isn't
|
||||
* even number.
|
||||
* The convert cases below work in right way,which are best practice.
|
||||
* <p>
|
||||
* <pre>
|
||||
* (array->map)
|
||||
* ["a","b"] ==> {a=b}
|
||||
* [" a "," b "] ==> {a=b}
|
||||
|
|
@ -147,7 +147,7 @@ public class DubboAnnotationUtils {
|
|||
* ["a=b","c","d"] ==>{a=b,c=d}
|
||||
* ["a","a:b"] ==>{a="a:b"}
|
||||
* ["a","a,b"] ==>{a="a,b"}
|
||||
* </p>
|
||||
* </pre>
|
||||
*
|
||||
* @param parameters
|
||||
* @return
|
||||
|
|
|
|||
|
|
@ -115,7 +115,6 @@ class EnableDubboConfigTest {
|
|||
|
||||
configManager.getProtocol("dubbo").get();
|
||||
configManager.getProtocol("rest").get();
|
||||
configManager.getProtocol("thrift").get();
|
||||
|
||||
// asserts aliases
|
||||
// assertTrue(hasAlias(context, "applicationBean2", "dubbo-demo-application2"));
|
||||
|
|
|
|||
|
|
@ -77,6 +77,10 @@
|
|||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-transport-native-epoll</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-core</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
|
|
@ -149,6 +153,13 @@
|
|||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-core</artifactId>
|
||||
<version>1.4.14</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<profiles>
|
||||
|
|
@ -178,7 +189,7 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.11.0</version>
|
||||
<version>3.12.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
|
|
|
|||
|
|
@ -77,6 +77,10 @@
|
|||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-transport-native-epoll</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-core</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
|
|
@ -149,6 +153,13 @@
|
|||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-core</artifactId>
|
||||
<version>1.4.14</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<profiles>
|
||||
|
|
@ -178,7 +189,7 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.11.0</version>
|
||||
<version>3.12.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
|
|
|
|||
|
|
@ -30,6 +30,9 @@
|
|||
|
||||
<properties>
|
||||
<skip_maven_deploy>true</skip_maven_deploy>
|
||||
<source.level>1.8</source.level>
|
||||
<target.level>1.8</target.level>
|
||||
<maven-compiler-plugin.version>3.12.1</maven-compiler-plugin.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -91,27 +91,19 @@
|
|||
<!-- Common libs -->
|
||||
<!-- <spring_version>4.3.30.RELEASE</spring_version> -->
|
||||
<spring_version>5.3.25</spring_version>
|
||||
<spring_security_version>5.8.8</spring_security_version>
|
||||
<javassist_version>3.29.2-GA</javassist_version>
|
||||
<byte-buddy_version>1.14.10</byte-buddy_version>
|
||||
<spring_security_version>5.8.9</spring_security_version>
|
||||
<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>
|
||||
<mina_version>2.2.1</mina_version>
|
||||
<grizzly_version>2.4.4</grizzly_version>
|
||||
<httpclient_version>4.5.14</httpclient_version>
|
||||
<httpcore_version>4.4.16</httpcore_version>
|
||||
<fastjson_version>1.2.83</fastjson_version>
|
||||
<fastjson2_version>2.0.43</fastjson2_version>
|
||||
<fastjson2_version>2.0.44</fastjson2_version>
|
||||
<zookeeper_version>3.7.2</zookeeper_version>
|
||||
<curator_version>5.1.0</curator_version>
|
||||
<curator_test_version>2.12.0</curator_test_version>
|
||||
<jedis_version>3.10.0</jedis_version>
|
||||
<consul_version>1.4.5</consul_version>
|
||||
<consul_process_version>2.2.1</consul_process_version>
|
||||
<consul_client_version>1.5.3</consul_client_version>
|
||||
<xmemcached_version>1.4.3</xmemcached_version>
|
||||
<cxf_version>3.6.2</cxf_version>
|
||||
<thrift_version>0.19.0</thrift_version>
|
||||
<hessian_version>4.0.66</hessian_version>
|
||||
<protobuf-java_version>3.25.1</protobuf-java_version>
|
||||
<javax_annotation-api_version>1.3.2</javax_annotation-api_version>
|
||||
|
|
@ -123,35 +115,29 @@
|
|||
<hibernate_validator_new_version>7.0.5.Final</hibernate_validator_new_version>
|
||||
<jel_version>3.0.1-b12</jel_version>
|
||||
<jcache_version>1.1.1</jcache_version>
|
||||
<kryo_version>4.0.3</kryo_version>
|
||||
<kryo_serializers_version>0.45</kryo_serializers_version>
|
||||
<fst_version>2.57</fst_version>
|
||||
<avro_version>1.11.3</avro_version>
|
||||
<apollo_client_version>2.2.0</apollo_client_version>
|
||||
<snakeyaml_version>2.2</snakeyaml_version>
|
||||
<commons_lang3_version>3.14.0</commons_lang3_version>
|
||||
<protostuff_version>1.8.0</protostuff_version>
|
||||
<envoy_api_version>0.1.35</envoy_api_version>
|
||||
<micrometer.version>1.12.0</micrometer.version>
|
||||
<micrometer.version>1.12.1</micrometer.version>
|
||||
<opentelemetry.version>1.26.0</opentelemetry.version>
|
||||
<zipkin-reporter.version>2.16.4</zipkin-reporter.version>
|
||||
<micrometer-tracing.version>1.2.1</micrometer-tracing.version>
|
||||
<t_digest.version>3.3</t_digest.version>
|
||||
<prometheus_client.version>0.16.0</prometheus_client.version>
|
||||
<reactive.version>1.0.4</reactive.version>
|
||||
<reactor.version>3.6.0</reactor.version>
|
||||
<reactor.version>3.6.1</reactor.version>
|
||||
<rxjava.version>2.2.21</rxjava.version>
|
||||
<okhttp_version>3.14.9</okhttp_version>
|
||||
|
||||
<rs_api_version>2.1.1</rs_api_version>
|
||||
<resteasy_version>3.15.6.Final</resteasy_version>
|
||||
<codehaus-jackson_version>1.9.13</codehaus-jackson_version>
|
||||
<tomcat_embed_version>8.5.96</tomcat_embed_version>
|
||||
<jetcd_version>0.7.6</jetcd_version>
|
||||
<tomcat_embed_version>8.5.97</tomcat_embed_version>
|
||||
<nacos_version>2.2.4</nacos_version>
|
||||
<sentinel.version>1.8.6</sentinel.version>
|
||||
<seata.version>1.6.1</seata.version>
|
||||
<grpc.version>1.60.0</grpc.version>
|
||||
<grpc.version>1.60.1</grpc.version>
|
||||
<grpc_contrib_verdion>0.8.1</grpc_contrib_verdion>
|
||||
<jprotoc_version>1.2.2</jprotoc_version>
|
||||
<mustache_version>0.9.10</mustache_version>
|
||||
|
|
@ -159,20 +145,14 @@
|
|||
<slf4j_version>1.7.36</slf4j_version>
|
||||
<jcl_version>1.3.0</jcl_version>
|
||||
<log4j_version>1.2.17</log4j_version>
|
||||
<logback_version>1.2.11</logback_version>
|
||||
<logback_version>1.2.13</logback_version>
|
||||
<!-- Fix the bug of log4j refer:https://github.com/apache/logging-log4j2/pull/608 -->
|
||||
<log4j2_version>2.22.0</log4j2_version>
|
||||
<commons_io_version>2.11.0</commons_io_version>
|
||||
<commons_io_version>2.15.1</commons_io_version>
|
||||
<commons-codec_version>1.16.0</commons-codec_version>
|
||||
|
||||
<embedded_redis_version>0.13.0</embedded_redis_version>
|
||||
|
||||
<!-- Eureka -->
|
||||
<eureka.version>1.10.18</eureka.version>
|
||||
|
||||
<!-- Fabric8 for Kubernetes -->
|
||||
<fabric8_kubernetes_version>6.9.2</fabric8_kubernetes_version>
|
||||
|
||||
<!-- Alibaba -->
|
||||
<alibaba_spring_context_support_version>1.0.11</alibaba_spring_context_support_version>
|
||||
|
||||
|
|
@ -187,15 +167,15 @@
|
|||
<jaxb_version>2.2.7</jaxb_version>
|
||||
<activation_version>1.2.0</activation_version>
|
||||
<test_container_version>1.19.3</test_container_version>
|
||||
<etcd_launcher_version>0.7.6</etcd_launcher_version>
|
||||
<hessian_lite_version>3.2.13</hessian_lite_version>
|
||||
<swagger_version>1.6.12</swagger_version>
|
||||
|
||||
<snappy_java_version>1.1.10.5</snappy_java_version>
|
||||
<bouncycastle-bcprov_version>1.70</bouncycastle-bcprov_version>
|
||||
<sofa_registry_version>5.4.3</sofa_registry_version>
|
||||
<metrics_version>2.0.6</metrics_version>
|
||||
<gson_version>2.10.1</gson_version>
|
||||
<jackson_version>2.16.0</jackson_version>
|
||||
<jackson_version>2.16.1</jackson_version>
|
||||
<mortbay_jetty_version>6.1.26</mortbay_jetty_version>
|
||||
<portlet_version>2.0</portlet_version>
|
||||
<maven_flatten_version>1.5.0</maven_flatten_version>
|
||||
|
|
@ -288,16 +268,6 @@
|
|||
<artifactId>netty</artifactId>
|
||||
<version>${netty_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.mina</groupId>
|
||||
<artifactId>mina-core</artifactId>
|
||||
<version>${mina_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.grizzly</groupId>
|
||||
<artifactId>grizzly-core</artifactId>
|
||||
<version>${grizzly_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
|
|
@ -380,33 +350,6 @@
|
|||
<artifactId>jedis</artifactId>
|
||||
<version>${jedis_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.ecwid.consul</groupId>
|
||||
<artifactId>consul-api</artifactId>
|
||||
<version>${consul_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.pszymczyk.consul</groupId>
|
||||
<artifactId>embedded-consul</artifactId>
|
||||
<version>${consul_process_version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.orbitz.consul</groupId>
|
||||
<artifactId>consul-client</artifactId>
|
||||
<version>${consul_client_version}</version>
|
||||
</dependency>
|
||||
<!-- Eureka -->
|
||||
<dependency>
|
||||
<groupId>com.netflix.eureka</groupId>
|
||||
<artifactId>eureka-client</artifactId>
|
||||
<version>${eureka.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.netflix.eureka</groupId>
|
||||
<artifactId>eureka-core</artifactId>
|
||||
<version>${eureka.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Alibaba -->
|
||||
<dependency>
|
||||
|
|
@ -415,26 +358,6 @@
|
|||
<version>${alibaba_spring_context_support_version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.googlecode.xmemcached</groupId>
|
||||
<artifactId>xmemcached</artifactId>
|
||||
<version>${xmemcached_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-frontend-simple</artifactId>
|
||||
<version>${cxf_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-transports-http</artifactId>
|
||||
<version>${cxf_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.thrift</groupId>
|
||||
<artifactId>libthrift</artifactId>
|
||||
<version>${thrift_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.caucho</groupId>
|
||||
<artifactId>hessian</artifactId>
|
||||
|
|
@ -541,36 +464,6 @@
|
|||
<artifactId>cache-api</artifactId>
|
||||
<version>${jcache_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.esotericsoftware</groupId>
|
||||
<artifactId>kryo</artifactId>
|
||||
<version>${kryo_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.javakaffee</groupId>
|
||||
<artifactId>kryo-serializers</artifactId>
|
||||
<version>${kryo_serializers_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.ruedigermoeller</groupId>
|
||||
<artifactId>fst</artifactId>
|
||||
<version>${fst_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.avro</groupId>
|
||||
<artifactId>avro</artifactId>
|
||||
<version>${avro_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.protostuff</groupId>
|
||||
<artifactId>protostuff-core</artifactId>
|
||||
<version>${protostuff_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.protostuff</groupId>
|
||||
<artifactId>protostuff-runtime</artifactId>
|
||||
<version>${protostuff_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.ws.rs</groupId>
|
||||
<artifactId>javax.ws.rs-api</artifactId>
|
||||
|
|
@ -637,21 +530,6 @@
|
|||
<artifactId>tomcat-embed-core</artifactId>
|
||||
<version>${tomcat_embed_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.etcd</groupId>
|
||||
<artifactId>jetcd-core</artifactId>
|
||||
<version>${jetcd_version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-codec-http2</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-handler-proxy</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- Log libs -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
|
|
@ -891,18 +769,6 @@
|
|||
<artifactId>portlet-api</artifactId>
|
||||
<version>${portlet_version}</version>
|
||||
</dependency>
|
||||
<!-- for dubbo-configcenter-etcd -->
|
||||
<dependency>
|
||||
<groupId>io.etcd</groupId>
|
||||
<artifactId>jetcd-launcher</artifactId>
|
||||
<version>${etcd_launcher_version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.github.spotbugs</groupId>
|
||||
<artifactId>spotbugs-annotations</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testcontainers</groupId>
|
||||
<artifactId>testcontainers</artifactId>
|
||||
|
|
|
|||
|
|
@ -971,6 +971,10 @@
|
|||
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
|
||||
<resource>META-INF/dubbo/internal/org.apache.dubbo.config.CommonConfigPostProcessor</resource>
|
||||
</transformer>
|
||||
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
|
||||
<resource>META-INF/dubbo/internal/org.apache.dubbo.registry.integration.ServiceURLCustomizer</resource>
|
||||
</transformer>
|
||||
</transformers>
|
||||
<filters>
|
||||
<filter>
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-plugin-api</artifactId>
|
||||
<version>3.9.1</version>
|
||||
<version>3.9.6</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
|
@ -68,7 +68,7 @@
|
|||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.11.0</version>
|
||||
<version>2.15.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Takes no effect for this dependency. To notify github dependencies bot to update ${protobuf-java.version} property. -->
|
||||
|
|
|
|||
|
|
@ -160,7 +160,9 @@ public class RtStatComposite extends AbstractMetricsExport {
|
|||
public void calcMethodKeyRt(Invocation invocation, String registryOpType, Long responseTime) {
|
||||
List<Action> actions;
|
||||
|
||||
if (invocation.getServiceModel() != null && invocation.getServiceModel().getServiceMetadata() != null) {
|
||||
if (getServiceLevel()
|
||||
&& invocation.getServiceModel() != null
|
||||
&& invocation.getServiceModel().getServiceMetadata() != null) {
|
||||
Map<String, Object> attributeMap =
|
||||
invocation.getServiceModel().getServiceMetadata().getAttributeMap();
|
||||
Map<String, List<Action>> cache = (Map<String, List<Action>>) attributeMap.get("MethodKeyRt");
|
||||
|
|
|
|||
|
|
@ -16,18 +16,25 @@
|
|||
*/
|
||||
package org.apache.dubbo.metrics.model.sample;
|
||||
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.metrics.model.MetricsCategory;
|
||||
import org.apache.dubbo.metrics.model.key.MetricsKey;
|
||||
import org.apache.dubbo.metrics.model.key.MetricsKeyWrapper;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.ToDoubleFunction;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_METRICS_COLLECTOR_EXCEPTION;
|
||||
|
||||
/**
|
||||
* GaugeMetricSample.
|
||||
*/
|
||||
public class GaugeMetricSample<T> extends MetricSample {
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(GaugeMetricSample.class);
|
||||
private final AtomicBoolean warned = new AtomicBoolean(false);
|
||||
|
||||
private final T value;
|
||||
|
||||
|
|
@ -71,7 +78,22 @@ public class GaugeMetricSample<T> extends MetricSample {
|
|||
ToDoubleFunction<T> apply) {
|
||||
super(name, description, tags, Type.GAUGE, category, baseUnit);
|
||||
this.value = Objects.requireNonNull(value, "The GaugeMetricSample value cannot be null");
|
||||
this.apply = Objects.requireNonNull(apply, "The GaugeMetricSample apply cannot be null");
|
||||
Objects.requireNonNull(apply, "The GaugeMetricSample apply cannot be null");
|
||||
this.apply = (e) -> {
|
||||
try {
|
||||
return apply.applyAsDouble(e);
|
||||
} catch (Throwable t) {
|
||||
if (warned.compareAndSet(false, true)) {
|
||||
logger.error(
|
||||
COMMON_METRICS_COLLECTOR_EXCEPTION,
|
||||
"",
|
||||
"",
|
||||
"Unexpected error occurred when applying the GaugeMetricSample",
|
||||
t);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public T getValue() {
|
||||
|
|
|
|||
|
|
@ -69,20 +69,19 @@ public final class {{className}} {
|
|||
{{{javaDoc}}}
|
||||
{{/javaDoc}}
|
||||
private static final StubMethodDescriptor {{methodName}}Method = new StubMethodDescriptor("{{originMethodName}}",
|
||||
{{inputType}}.class, {{outputType}}.class, serviceDescriptor, MethodDescriptor.RpcType.UNARY,
|
||||
{{inputType}}.class, {{outputType}}.class, MethodDescriptor.RpcType.UNARY,
|
||||
obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), {{inputType}}::parseFrom,
|
||||
{{outputType}}::parseFrom);
|
||||
|
||||
private static final StubMethodDescriptor {{methodName}}AsyncMethod = new StubMethodDescriptor("{{originMethodName}}",
|
||||
{{inputType}}.class, java.util.concurrent.CompletableFuture.class, serviceDescriptor, MethodDescriptor.RpcType.UNARY,
|
||||
{{inputType}}.class, java.util.concurrent.CompletableFuture.class, MethodDescriptor.RpcType.UNARY,
|
||||
obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), {{inputType}}::parseFrom,
|
||||
{{outputType}}::parseFrom);
|
||||
|
||||
private static final StubMethodDescriptor {{methodName}}ProxyAsyncMethod = new StubMethodDescriptor("{{originMethodName}}Async",
|
||||
{{inputType}}.class, {{outputType}}.class, serviceDescriptor, MethodDescriptor.RpcType.UNARY,
|
||||
{{inputType}}.class, {{outputType}}.class, MethodDescriptor.RpcType.UNARY,
|
||||
obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), {{inputType}}::parseFrom,
|
||||
{{outputType}}::parseFrom);
|
||||
|
||||
{{/unaryMethods}}
|
||||
|
||||
{{#serverStreamingMethods}}
|
||||
|
|
@ -90,10 +89,9 @@ public final class {{className}} {
|
|||
{{{javaDoc}}}
|
||||
{{/javaDoc}}
|
||||
private static final StubMethodDescriptor {{methodName}}Method = new StubMethodDescriptor("{{originMethodName}}",
|
||||
{{inputType}}.class, {{outputType}}.class, serviceDescriptor, MethodDescriptor.RpcType.SERVER_STREAM,
|
||||
{{inputType}}.class, {{outputType}}.class, MethodDescriptor.RpcType.SERVER_STREAM,
|
||||
obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), {{inputType}}::parseFrom,
|
||||
{{outputType}}::parseFrom);
|
||||
|
||||
{{/serverStreamingMethods}}
|
||||
|
||||
{{#clientStreamingMethods}}
|
||||
|
|
@ -101,7 +99,7 @@ public final class {{className}} {
|
|||
{{{javaDoc}}}
|
||||
{{/javaDoc}}
|
||||
private static final StubMethodDescriptor {{methodName}}Method = new StubMethodDescriptor("{{originMethodName}}",
|
||||
{{inputType}}.class, {{outputType}}.class, serviceDescriptor, MethodDescriptor.RpcType.CLIENT_STREAM,
|
||||
{{inputType}}.class, {{outputType}}.class, MethodDescriptor.RpcType.CLIENT_STREAM,
|
||||
obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), {{inputType}}::parseFrom,
|
||||
{{outputType}}::parseFrom);
|
||||
{{/clientStreamingMethods}}
|
||||
|
|
@ -111,11 +109,27 @@ public final class {{className}} {
|
|||
{{{javaDoc}}}
|
||||
{{/javaDoc}}
|
||||
private static final StubMethodDescriptor {{methodName}}Method = new StubMethodDescriptor("{{originMethodName}}",
|
||||
{{inputType}}.class, {{outputType}}.class, serviceDescriptor, MethodDescriptor.RpcType.BI_STREAM,
|
||||
{{inputType}}.class, {{outputType}}.class, MethodDescriptor.RpcType.BI_STREAM,
|
||||
obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), {{inputType}}::parseFrom,
|
||||
{{outputType}}::parseFrom);
|
||||
{{/biStreamingWithoutClientStreamMethods}}
|
||||
|
||||
static{
|
||||
{{#unaryMethods}}
|
||||
serviceDescriptor.addMethod({{methodName}}Method);
|
||||
serviceDescriptor.addMethod({{methodName}}ProxyAsyncMethod);
|
||||
{{/unaryMethods}}
|
||||
{{#serverStreamingMethods}}
|
||||
serviceDescriptor.addMethod({{methodName}}Method);
|
||||
{{/serverStreamingMethods}}
|
||||
{{#clientStreamingMethods}}
|
||||
serviceDescriptor.addMethod({{methodName}}Method);
|
||||
{{/clientStreamingMethods}}
|
||||
{{#biStreamingWithoutClientStreamMethods}}
|
||||
serviceDescriptor.addMethod({{methodName}}Method);
|
||||
{{/biStreamingWithoutClientStreamMethods}}
|
||||
}
|
||||
|
||||
public static class {{interfaceClassName}}Stub implements {{interfaceClassName}}{
|
||||
private final Invoker<{{interfaceClassName}}> invoker;
|
||||
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ public final class {{className}} {
|
|||
{{{javaDoc}}}
|
||||
{{/javaDoc}}
|
||||
private static final StubMethodDescriptor {{methodName}}Method = new StubMethodDescriptor("{{originMethodName}}",
|
||||
{{inputType}}.class, {{outputType}}.class, serviceDescriptor, MethodDescriptor.RpcType.UNARY,
|
||||
{{inputType}}.class, {{outputType}}.class, MethodDescriptor.RpcType.UNARY,
|
||||
obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), {{inputType}}::parseFrom,
|
||||
{{outputType}}::parseFrom);
|
||||
{{/unaryMethods}}
|
||||
|
|
@ -80,7 +80,7 @@ public final class {{className}} {
|
|||
{{{javaDoc}}}
|
||||
{{/javaDoc}}
|
||||
private static final StubMethodDescriptor {{methodName}}Method = new StubMethodDescriptor("{{originMethodName}}",
|
||||
{{inputType}}.class, {{outputType}}.class, serviceDescriptor, MethodDescriptor.RpcType.SERVER_STREAM,
|
||||
{{inputType}}.class, {{outputType}}.class, MethodDescriptor.RpcType.SERVER_STREAM,
|
||||
obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), {{inputType}}::parseFrom,
|
||||
{{outputType}}::parseFrom);
|
||||
{{/serverStreamingMethods}}
|
||||
|
|
@ -90,7 +90,7 @@ public final class {{className}} {
|
|||
{{{javaDoc}}}
|
||||
{{/javaDoc}}
|
||||
private static final StubMethodDescriptor {{methodName}}Method = new StubMethodDescriptor("{{originMethodName}}",
|
||||
{{inputType}}.class, {{outputType}}.class, serviceDescriptor, MethodDescriptor.RpcType.CLIENT_STREAM,
|
||||
{{inputType}}.class, {{outputType}}.class, MethodDescriptor.RpcType.CLIENT_STREAM,
|
||||
obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), {{inputType}}::parseFrom,
|
||||
{{outputType}}::parseFrom);
|
||||
{{/clientStreamingMethods}}
|
||||
|
|
@ -100,11 +100,26 @@ public final class {{className}} {
|
|||
{{{javaDoc}}}
|
||||
{{/javaDoc}}
|
||||
private static final StubMethodDescriptor {{methodName}}Method = new StubMethodDescriptor("{{originMethodName}}",
|
||||
{{inputType}}.class, {{outputType}}.class, serviceDescriptor, MethodDescriptor.RpcType.BI_STREAM,
|
||||
{{inputType}}.class, {{outputType}}.class, MethodDescriptor.RpcType.BI_STREAM,
|
||||
obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), {{inputType}}::parseFrom,
|
||||
{{outputType}}::parseFrom);
|
||||
{{/biStreamingWithoutClientStreamMethods}}
|
||||
|
||||
static{
|
||||
{{#unaryMethods}}
|
||||
serviceDescriptor.addMethod({{methodName}}Method);
|
||||
{{/unaryMethods}}
|
||||
{{#serverStreamingMethods}}
|
||||
serviceDescriptor.addMethod({{methodName}}Method);
|
||||
{{/serverStreamingMethods}}
|
||||
{{#clientStreamingMethods}}
|
||||
serviceDescriptor.addMethod({{methodName}}Method);
|
||||
{{/clientStreamingMethods}}
|
||||
{{#biStreamingWithoutClientStreamMethods}}
|
||||
serviceDescriptor.addMethod({{methodName}}Method);
|
||||
{{/biStreamingWithoutClientStreamMethods}}
|
||||
}
|
||||
|
||||
public static class {{interfaceClassName}}Stub implements {{interfaceClassName}}{
|
||||
|
||||
private final Invoker<{{interfaceClassName}}> invoker;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,120 @@
|
|||
/*
|
||||
* 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.registry.integration;
|
||||
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.utils.CollectionUtils;
|
||||
import org.apache.dubbo.common.utils.StringUtils;
|
||||
import org.apache.dubbo.rpc.model.ApplicationModel;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.ALIVE_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.ANYHOST_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.BACKGROUND_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.COMMA_SPLIT_PATTERN;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.CORE_THREADS_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.EXECUTOR_MANAGEMENT_MODE;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.EXTRA_KEYS_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.HIDE_KEY_PREFIX;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.INTERFACE_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.METHODS_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.MONITOR_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.PID_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.QUEUES_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.REGISTRY_LOCAL_FILE_CACHE_ENABLED;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.THREADPOOL_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.THREADS_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.THREAD_NAME_KEY;
|
||||
import static org.apache.dubbo.common.constants.FilterConstants.VALIDATION_KEY;
|
||||
import static org.apache.dubbo.common.constants.QosConstants.ACCEPT_FOREIGN_IP;
|
||||
import static org.apache.dubbo.common.constants.QosConstants.QOS_ENABLE;
|
||||
import static org.apache.dubbo.common.constants.QosConstants.QOS_HOST;
|
||||
import static org.apache.dubbo.common.constants.QosConstants.QOS_PORT;
|
||||
import static org.apache.dubbo.common.constants.RegistryConstants.REGISTER_MODE_KEY;
|
||||
import static org.apache.dubbo.registry.Constants.SIMPLIFIED_KEY;
|
||||
import static org.apache.dubbo.registry.integration.RegistryProtocol.DEFAULT_REGISTER_PROVIDER_KEYS;
|
||||
import static org.apache.dubbo.remoting.Constants.BIND_IP_KEY;
|
||||
import static org.apache.dubbo.remoting.Constants.BIND_PORT_KEY;
|
||||
import static org.apache.dubbo.rpc.Constants.INTERFACES;
|
||||
|
||||
public class DefaultServiceURLCustomizer implements ServiceURLCustomizer {
|
||||
|
||||
private static final String[] excludedParameters = new String[] {
|
||||
MONITOR_KEY,
|
||||
BIND_IP_KEY,
|
||||
BIND_PORT_KEY,
|
||||
QOS_ENABLE,
|
||||
QOS_HOST,
|
||||
QOS_PORT,
|
||||
ACCEPT_FOREIGN_IP,
|
||||
VALIDATION_KEY,
|
||||
INTERFACES,
|
||||
REGISTER_MODE_KEY,
|
||||
PID_KEY,
|
||||
REGISTRY_LOCAL_FILE_CACHE_ENABLED,
|
||||
EXECUTOR_MANAGEMENT_MODE,
|
||||
BACKGROUND_KEY,
|
||||
ANYHOST_KEY,
|
||||
THREAD_NAME_KEY,
|
||||
THREADPOOL_KEY,
|
||||
ALIVE_KEY,
|
||||
QUEUES_KEY,
|
||||
CORE_THREADS_KEY,
|
||||
THREADS_KEY
|
||||
};
|
||||
|
||||
@Override
|
||||
public URL customize(URL serviceURL, ApplicationModel applicationModel) {
|
||||
boolean simplified = (boolean) serviceURL.getAttribute(SIMPLIFIED_KEY, false);
|
||||
if (simplified) {
|
||||
String extraKeys = (String) serviceURL.getAttribute(EXTRA_KEYS_KEY, "");
|
||||
// if path is not the same as interface name then we should keep INTERFACE_KEY,
|
||||
// otherwise, the registry structure of zookeeper would be '/dubbo/path/providers',
|
||||
// but what we expect is '/dubbo/interface/providers'
|
||||
if (!serviceURL.getPath().equals(serviceURL.getParameter(INTERFACE_KEY))) {
|
||||
if (StringUtils.isNotEmpty(extraKeys)) {
|
||||
extraKeys += ",";
|
||||
}
|
||||
extraKeys += INTERFACE_KEY;
|
||||
}
|
||||
String[] paramsToRegistry = Stream.concat(
|
||||
Arrays.stream(DEFAULT_REGISTER_PROVIDER_KEYS),
|
||||
Arrays.stream(COMMA_SPLIT_PATTERN.split(extraKeys)))
|
||||
.toArray(String[]::new);
|
||||
return URL.valueOf(serviceURL, paramsToRegistry, serviceURL.getParameter(METHODS_KEY, (String[]) null));
|
||||
}
|
||||
return serviceURL.removeParameters(getFilteredKeys(serviceURL)).removeParameters(excludedParameters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return MAX_PRIORITY;
|
||||
}
|
||||
|
||||
private String[] getFilteredKeys(URL url) {
|
||||
Map<String, String> params = url.getParameters();
|
||||
if (CollectionUtils.isNotEmptyMap(params)) {
|
||||
return params.keySet().stream()
|
||||
.filter(k -> k.startsWith(HIDE_KEY_PREFIX))
|
||||
.toArray(String[]::new);
|
||||
}
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
|
|
@ -20,6 +20,7 @@ import org.apache.dubbo.common.URL;
|
|||
import org.apache.dubbo.common.config.configcenter.DynamicConfiguration;
|
||||
import org.apache.dubbo.common.constants.RegistryConstants;
|
||||
import org.apache.dubbo.common.deploy.ApplicationDeployer;
|
||||
import org.apache.dubbo.common.extension.ExtensionLoader;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.threadpool.manager.FrameworkExecutorRepository;
|
||||
|
|
@ -76,47 +77,33 @@ import java.util.concurrent.TimeUnit;
|
|||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.ANYHOST_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.APPLICATION_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.BACKGROUND_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.CLUSTER_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.COMMA_SPLIT_PATTERN;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.CONSUMER;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.DUBBO_VERSION_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.ENABLED_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.EXECUTOR_MANAGEMENT_MODE;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.EXTRA_KEYS_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.GROUP_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.HIDE_KEY_PREFIX;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.INTERFACE_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.IPV6_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.LOADBALANCE_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.MERGEABLE_CLUSTER_NAME;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.METHODS_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.MONITOR_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.PACKABLE_METHOD_FACTORY_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.PATH_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.PID_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.PROTOCOL_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.REGISTRY_LOCAL_FILE_CACHE_ENABLED;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.REGISTRY_PROTOCOL_LISTENER_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.RELEASE_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.SIDE_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.TIMEOUT_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY;
|
||||
import static org.apache.dubbo.common.constants.FilterConstants.VALIDATION_KEY;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.INTERNAL_ERROR;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_UNSUPPORTED_CATEGORY;
|
||||
import static org.apache.dubbo.common.constants.QosConstants.ACCEPT_FOREIGN_IP;
|
||||
import static org.apache.dubbo.common.constants.QosConstants.QOS_ENABLE;
|
||||
import static org.apache.dubbo.common.constants.QosConstants.QOS_HOST;
|
||||
import static org.apache.dubbo.common.constants.QosConstants.QOS_PORT;
|
||||
import static org.apache.dubbo.common.constants.RegistryConstants.ALL_CATEGORIES;
|
||||
import static org.apache.dubbo.common.constants.RegistryConstants.CATEGORY_KEY;
|
||||
import static org.apache.dubbo.common.constants.RegistryConstants.CONFIGURATORS_CATEGORY;
|
||||
import static org.apache.dubbo.common.constants.RegistryConstants.DYNAMIC_KEY;
|
||||
import static org.apache.dubbo.common.constants.RegistryConstants.OVERRIDE_PROTOCOL;
|
||||
import static org.apache.dubbo.common.constants.RegistryConstants.REGISTER_MODE_KEY;
|
||||
import static org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_KEY;
|
||||
import static org.apache.dubbo.common.constants.RegistryConstants.SERVICE_REGISTRY_PROTOCOL;
|
||||
import static org.apache.dubbo.common.utils.StringUtils.isEmpty;
|
||||
|
|
@ -130,8 +117,6 @@ import static org.apache.dubbo.registry.Constants.REGISTER_IP_KEY;
|
|||
import static org.apache.dubbo.registry.Constants.REGISTER_KEY;
|
||||
import static org.apache.dubbo.registry.Constants.REGISTRY_RETRY_PERIOD_KEY;
|
||||
import static org.apache.dubbo.registry.Constants.SIMPLIFIED_KEY;
|
||||
import static org.apache.dubbo.remoting.Constants.BIND_IP_KEY;
|
||||
import static org.apache.dubbo.remoting.Constants.BIND_PORT_KEY;
|
||||
import static org.apache.dubbo.remoting.Constants.CHECK_KEY;
|
||||
import static org.apache.dubbo.remoting.Constants.CODEC_KEY;
|
||||
import static org.apache.dubbo.remoting.Constants.CONNECTIONS_KEY;
|
||||
|
|
@ -140,7 +125,6 @@ import static org.apache.dubbo.remoting.Constants.PREFER_SERIALIZATION_KEY;
|
|||
import static org.apache.dubbo.remoting.Constants.SERIALIZATION_KEY;
|
||||
import static org.apache.dubbo.rpc.Constants.DEPRECATED_KEY;
|
||||
import static org.apache.dubbo.rpc.Constants.GENERIC_KEY;
|
||||
import static org.apache.dubbo.rpc.Constants.INTERFACES;
|
||||
import static org.apache.dubbo.rpc.Constants.MOCK_KEY;
|
||||
import static org.apache.dubbo.rpc.Constants.TOKEN_KEY;
|
||||
import static org.apache.dubbo.rpc.cluster.Constants.CONSUMER_URL_KEY;
|
||||
|
|
@ -184,18 +168,6 @@ public class RegistryProtocol implements Protocol, ScopeModelAware {
|
|||
private FrameworkModel frameworkModel;
|
||||
private ExporterFactory exporterFactory;
|
||||
|
||||
// Filter the parameters that do not need to be output in url(Starting with .)
|
||||
private static String[] getFilteredKeys(URL url) {
|
||||
Map<String, String> params = url.getParameters();
|
||||
if (CollectionUtils.isNotEmptyMap(params)) {
|
||||
return params.keySet().stream()
|
||||
.filter(k -> k.startsWith(HIDE_KEY_PREFIX))
|
||||
.toArray(String[]::new);
|
||||
} else {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
|
||||
public RegistryProtocol() {}
|
||||
|
||||
@Override
|
||||
|
|
@ -292,7 +264,7 @@ public class RegistryProtocol implements Protocol, ScopeModelAware {
|
|||
|
||||
// url to registry
|
||||
final Registry registry = getRegistry(registryUrl);
|
||||
final URL registeredProviderUrl = getUrlToRegistry(providerUrl, registryUrl);
|
||||
final URL registeredProviderUrl = customizeURL(providerUrl, registryUrl);
|
||||
|
||||
// decide if we need to delay publish (provider itself and registry should both need to register)
|
||||
boolean register = providerUrl.getParameter(REGISTER_KEY, true) && registryUrl.getParameter(REGISTER_KEY, true);
|
||||
|
|
@ -354,10 +326,10 @@ public class RegistryProtocol implements Protocol, ScopeModelAware {
|
|||
|
||||
ReferenceCountExporter<?> exporter =
|
||||
exporterFactory.createExporter(providerUrlKey, () -> protocol.export(invokerDelegate));
|
||||
return (ExporterChangeableWrapper<T>) bounds.computeIfAbsent(providerUrlKey, _k -> new ConcurrentHashMap<>())
|
||||
.computeIfAbsent(registryUrlKey, s -> {
|
||||
return new ExporterChangeableWrapper<>((ReferenceCountExporter<T>) exporter, originInvoker);
|
||||
});
|
||||
return (ExporterChangeableWrapper<T>) bounds.computeIfAbsent(providerUrlKey, k -> new ConcurrentHashMap<>())
|
||||
.computeIfAbsent(
|
||||
registryUrlKey,
|
||||
s -> new ExporterChangeableWrapper<>((ReferenceCountExporter<T>) exporter, originInvoker));
|
||||
}
|
||||
|
||||
public <T> void reExport(Exporter<T> exporter, URL newInvokerUrl) {
|
||||
|
|
@ -402,10 +374,10 @@ public class RegistryProtocol implements Protocol, ScopeModelAware {
|
|||
URL registeredUrl = exporter.getRegisterUrl();
|
||||
|
||||
URL registryUrl = getRegistryUrl(originInvoker);
|
||||
URL newProviderUrl = getUrlToRegistry(newInvokerUrl, registryUrl);
|
||||
URL newProviderUrl = customizeURL(newInvokerUrl, registryUrl);
|
||||
|
||||
// update local exporter
|
||||
Invoker<T> invokerDelegate = new InvokerDelegate<T>(originInvoker, newInvokerUrl);
|
||||
Invoker<T> invokerDelegate = new InvokerDelegate<>(originInvoker, newInvokerUrl);
|
||||
exporter.setExporter(protocol.export(invokerDelegate));
|
||||
|
||||
// update registry
|
||||
|
|
@ -501,45 +473,19 @@ public class RegistryProtocol implements Protocol, ScopeModelAware {
|
|||
/**
|
||||
* Return the url that is registered to the registry and filter the url parameter once
|
||||
*
|
||||
* @param providerUrl
|
||||
* @param providerUrl provider service url
|
||||
* @param registryUrl registry center url
|
||||
* @return url to registry.
|
||||
*/
|
||||
private URL getUrlToRegistry(final URL providerUrl, final URL registryUrl) {
|
||||
// The address you see at the registry
|
||||
if (!registryUrl.getParameter(SIMPLIFIED_KEY, false)) {
|
||||
return providerUrl
|
||||
.removeParameters(getFilteredKeys(providerUrl))
|
||||
.removeParameters(
|
||||
MONITOR_KEY,
|
||||
BIND_IP_KEY,
|
||||
BIND_PORT_KEY,
|
||||
QOS_ENABLE,
|
||||
QOS_HOST,
|
||||
QOS_PORT,
|
||||
ACCEPT_FOREIGN_IP,
|
||||
VALIDATION_KEY,
|
||||
INTERFACES,
|
||||
REGISTER_MODE_KEY,
|
||||
PID_KEY,
|
||||
REGISTRY_LOCAL_FILE_CACHE_ENABLED,
|
||||
EXECUTOR_MANAGEMENT_MODE,
|
||||
BACKGROUND_KEY,
|
||||
ANYHOST_KEY);
|
||||
} else {
|
||||
String extraKeys = registryUrl.getParameter(EXTRA_KEYS_KEY, "");
|
||||
// if path is not the same as interface name then we should keep INTERFACE_KEY,
|
||||
// otherwise, the registry structure of zookeeper would be '/dubbo/path/providers',
|
||||
// but what we expect is '/dubbo/interface/providers'
|
||||
if (!providerUrl.getPath().equals(providerUrl.getParameter(INTERFACE_KEY))) {
|
||||
if (StringUtils.isNotEmpty(extraKeys)) {
|
||||
extraKeys += ",";
|
||||
}
|
||||
extraKeys += INTERFACE_KEY;
|
||||
}
|
||||
String[] paramsToRegistry =
|
||||
getParamsToRegistry(DEFAULT_REGISTER_PROVIDER_KEYS, COMMA_SPLIT_PATTERN.split(extraKeys));
|
||||
return URL.valueOf(providerUrl, paramsToRegistry, providerUrl.getParameter(METHODS_KEY, (String[]) null));
|
||||
private URL customizeURL(final URL providerUrl, final URL registryUrl) {
|
||||
URL newProviderURL = providerUrl.putAttribute(SIMPLIFIED_KEY, registryUrl.getParameter(SIMPLIFIED_KEY, false));
|
||||
newProviderURL = newProviderURL.putAttribute(EXTRA_KEYS_KEY, registryUrl.getParameter(EXTRA_KEYS_KEY, ""));
|
||||
ApplicationModel applicationModel = providerUrl.getOrDefaultApplicationModel();
|
||||
ExtensionLoader<ServiceURLCustomizer> loader = applicationModel.getExtensionLoader(ServiceURLCustomizer.class);
|
||||
for (ServiceURLCustomizer customizer : loader.getSupportedExtensionInstances()) {
|
||||
newProviderURL = customizer.customize(newProviderURL, applicationModel);
|
||||
}
|
||||
return newProviderURL;
|
||||
}
|
||||
|
||||
private URL getSubscribedOverrideUrl(URL registeredProviderUrl) {
|
||||
|
|
@ -571,14 +517,12 @@ public class RegistryProtocol implements Protocol, ScopeModelAware {
|
|||
*/
|
||||
private String getProviderUrlKey(final Invoker<?> originInvoker) {
|
||||
URL providerUrl = getProviderUrl(originInvoker);
|
||||
String key = providerUrl.removeParameters(DYNAMIC_KEY, ENABLED_KEY).toFullString();
|
||||
return key;
|
||||
return providerUrl.removeParameters(DYNAMIC_KEY, ENABLED_KEY).toFullString();
|
||||
}
|
||||
|
||||
private String getRegistryUrlKey(final Invoker<?> originInvoker) {
|
||||
URL registryUrl = getRegistryUrl(originInvoker);
|
||||
String key = registryUrl.removeParameters(DYNAMIC_KEY, ENABLED_KEY).toFullString();
|
||||
return key;
|
||||
return registryUrl.removeParameters(DYNAMIC_KEY, ENABLED_KEY).toFullString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -634,7 +578,7 @@ public class RegistryProtocol implements Protocol, ScopeModelAware {
|
|||
Class<T> type,
|
||||
URL url,
|
||||
URL consumerUrl) {
|
||||
return new ServiceDiscoveryMigrationInvoker<T>(registryProtocol, cluster, registry, type, url, consumerUrl);
|
||||
return new ServiceDiscoveryMigrationInvoker<>(registryProtocol, cluster, registry, type, url, consumerUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -722,15 +666,6 @@ public class RegistryProtocol implements Protocol, ScopeModelAware {
|
|||
.getActivateExtension(url, REGISTRY_PROTOCOL_LISTENER_KEY);
|
||||
}
|
||||
|
||||
// available to test
|
||||
public String[] getParamsToRegistry(String[] defaultKeys, String[] additionalParameterKeys) {
|
||||
int additionalLen = additionalParameterKeys.length;
|
||||
String[] registryParams = new String[defaultKeys.length + additionalLen];
|
||||
System.arraycopy(defaultKeys, 0, registryParams, 0, defaultKeys.length);
|
||||
System.arraycopy(additionalParameterKeys, 0, registryParams, defaultKeys.length, additionalLen);
|
||||
return registryParams;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
// FIXME all application models in framework are removed at this moment
|
||||
|
|
@ -758,7 +693,10 @@ public class RegistryProtocol implements Protocol, ScopeModelAware {
|
|||
// already removed
|
||||
continue;
|
||||
}
|
||||
if (moduleModel.getServiceRepository().getExportedServices().size() > 0) {
|
||||
if (!moduleModel
|
||||
.getServiceRepository()
|
||||
.getExportedServices()
|
||||
.isEmpty()) {
|
||||
moduleModel
|
||||
.getExtensionLoader(GovernanceRuleRepository.class)
|
||||
.getDefaultExtension()
|
||||
|
|
@ -1164,11 +1102,10 @@ public class RegistryProtocol implements Protocol, ScopeModelAware {
|
|||
.getConfiguration()
|
||||
.convert(Boolean.class, ENABLE_CONFIGURATION_LISTEN, true)) {
|
||||
for (ModuleModel moduleModel : applicationModel.getPubModuleModels()) {
|
||||
if (moduleModel
|
||||
.getServiceRepository()
|
||||
.getExportedServices()
|
||||
.size()
|
||||
> 0) {
|
||||
if (!moduleModel
|
||||
.getServiceRepository()
|
||||
.getExportedServices()
|
||||
.isEmpty()) {
|
||||
moduleModel
|
||||
.getExtensionLoader(GovernanceRuleRepository.class)
|
||||
.getDefaultExtension()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* 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.registry.integration;
|
||||
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.extension.SPI;
|
||||
import org.apache.dubbo.common.lang.Prioritized;
|
||||
import org.apache.dubbo.rpc.model.ApplicationModel;
|
||||
|
||||
import static org.apache.dubbo.common.extension.ExtensionScope.APPLICATION;
|
||||
|
||||
/**
|
||||
* Customize parameters for interface-level registration
|
||||
*/
|
||||
@SPI(scope = APPLICATION)
|
||||
public interface ServiceURLCustomizer extends Prioritized {
|
||||
|
||||
/**
|
||||
* Customizes {@link URL the service url}
|
||||
*
|
||||
* @param serviceURL {@link URL the service url}
|
||||
* @return new service url
|
||||
*/
|
||||
URL customize(URL serviceURL, ApplicationModel applicationModel);
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
default=org.apache.dubbo.registry.integration.DefaultServiceURLCustomizer
|
||||
|
|
@ -150,7 +150,9 @@ public class NettyConnectionClient extends AbstractConnectionClient {
|
|||
current.close();
|
||||
}
|
||||
this.channel.set(null);
|
||||
closePromise.setSuccess(null);
|
||||
if (!closePromise.isDone()) {
|
||||
closePromise.setSuccess(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -76,6 +76,8 @@ public class ResteasyRequestContainerFilterAdapter implements RestRequestFilter,
|
|||
restFilterContext.setComplete(true);
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException("dubbo rest resteasy ContainerRequestFilter write response encode error", e);
|
||||
} finally {
|
||||
containerRequestContext.getHttpRequest().releaseContentBuffer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* 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.rpc.protocol.rest.extension.resteasy.intercept;
|
||||
|
||||
import org.apache.dubbo.common.extension.Activate;
|
||||
import org.apache.dubbo.rpc.protocol.rest.extension.resteasy.ResteasyContext;
|
||||
import org.apache.dubbo.rpc.protocol.rest.filter.RestResponseInterceptor;
|
||||
import org.apache.dubbo.rpc.protocol.rest.filter.context.RestInterceptContext;
|
||||
|
||||
import org.jboss.resteasy.specimpl.AbstractBuiltResponse;
|
||||
|
||||
@Activate(
|
||||
value = "resteasy-resStatus",
|
||||
onClass = {
|
||||
"javax.ws.rs.ext.WriterInterceptorContext",
|
||||
"org.jboss.resteasy.specimpl.BuiltResponse",
|
||||
"org.jboss.resteasy.plugins.server.netty.NettyHttpRequest",
|
||||
"org.jboss.resteasy.plugins.server.netty.NettyHttpResponse"
|
||||
},
|
||||
order = Integer.MAX_VALUE)
|
||||
public class ResteasyStatusCodeInterceptor implements RestResponseInterceptor, ResteasyContext {
|
||||
|
||||
@Override
|
||||
public void intercept(RestInterceptContext restResponseInterceptor) throws Exception {
|
||||
Object result = restResponseInterceptor.getResult();
|
||||
|
||||
if (result == null || (!(result instanceof AbstractBuiltResponse))) {
|
||||
return;
|
||||
}
|
||||
|
||||
AbstractBuiltResponse abstractBuiltResponse = (AbstractBuiltResponse) result;
|
||||
|
||||
restResponseInterceptor.getResponse().setStatus(abstractBuiltResponse.getStatus());
|
||||
}
|
||||
}
|
||||
|
|
@ -105,8 +105,7 @@ public class SslServerTlsHandler extends ByteToMessageDecoder {
|
|||
url, channelHandlerContext.channel().remoteAddress());
|
||||
|
||||
if (providerConnectionConfig == null) {
|
||||
ChannelPipeline p = channelHandlerContext.pipeline();
|
||||
p.remove(this);
|
||||
channelHandlerContext.pipeline().remove(this);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -117,8 +116,8 @@ public class SslServerTlsHandler extends ByteToMessageDecoder {
|
|||
}
|
||||
|
||||
if (providerConnectionConfig.getAuthPolicy() == AuthPolicy.NONE) {
|
||||
ChannelPipeline p = channelHandlerContext.pipeline();
|
||||
p.remove(this);
|
||||
channelHandlerContext.pipeline().remove(this);
|
||||
return;
|
||||
}
|
||||
|
||||
logger.error(INTERNAL_ERROR, "", "", "TLS negotiation failed when trying to accept new connection.");
|
||||
|
|
|
|||
|
|
@ -1,2 +1,3 @@
|
|||
resteasy=org.apache.dubbo.rpc.protocol.rest.extension.resteasy.intercept.ResteasyWriterInterceptorAdapter
|
||||
invoke=org.apache.dubbo.rpc.protocol.rest.filter.ServiceInvokeRestResponseInterceptor
|
||||
resteasy-resStatus=org.apache.dubbo.rpc.protocol.rest.extension.resteasy.intercept.ResteasyStatusCodeInterceptor
|
||||
|
|
|
|||
|
|
@ -68,6 +68,22 @@ public class ResteasyResponseTest {
|
|||
Assertions.assertNotNull(response);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testResponseCustomStatusCode() {
|
||||
RestDemoService server = new RestDemoServiceImpl();
|
||||
URL url = this.registerProvider(exportUrl, server, RestDemoService.class);
|
||||
|
||||
URL nettyUrl = url.addParameter(SERVER_KEY, "netty").addParameter("timeout", 3000000);
|
||||
|
||||
protocol.export(proxy.getInvoker(new RestDemoServiceImpl(), RestDemoService.class, nettyUrl));
|
||||
|
||||
RestDemoService demoService = this.proxy.getProxy(protocol.refer(RestDemoService.class, nettyUrl));
|
||||
|
||||
Response response = demoService.deleteUserById("uid");
|
||||
|
||||
Assertions.assertEquals(response.getStatus(), 200);
|
||||
}
|
||||
|
||||
private URL registerProvider(URL url, Object impl, Class<?> interfaceClass) {
|
||||
ServiceDescriptor serviceDescriptor = repository.registerService(interfaceClass);
|
||||
ProviderModel providerModel = new ProviderModel(url.getServiceKey(), impl, serviceDescriptor, null, null);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,15 @@
|
|||
*/
|
||||
package org.apache.dubbo.rpc.protocol.rest.rest;
|
||||
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.FormParam;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
|
|
@ -50,4 +58,8 @@ public interface RestDemoService {
|
|||
@DELETE
|
||||
@Path("{uid}")
|
||||
String deleteUserByUid(@PathParam("uid") String uid);
|
||||
|
||||
@DELETE
|
||||
@Path("/deleteUserById/{uid}")
|
||||
public Response deleteUserById(@PathParam("uid") String uid);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,6 +69,11 @@ public class RestDemoServiceImpl implements RestDemoService {
|
|||
throw new RuntimeException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response deleteUserById(String uid) {
|
||||
return Response.status(300).entity("deleted").build();
|
||||
}
|
||||
|
||||
public static Map<String, Object> getAttachments() {
|
||||
return context;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ import java.util.stream.Stream;
|
|||
import com.google.protobuf.Message;
|
||||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.$ECHO;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.PROTOBUF_MESSAGE_CLASS_NAME;
|
||||
import static org.apache.dubbo.common.utils.ProtobufUtils.isProtobufClass;
|
||||
|
||||
public class ReflectionPackableMethod implements PackableMethod {
|
||||
|
||||
|
|
@ -270,21 +270,6 @@ public class ReflectionPackableMethod implements PackableMethod {
|
|||
return RX_RETURN_CLASS.equalsIgnoreCase(clz.getName());
|
||||
}
|
||||
|
||||
static boolean isProtobufClass(Class<?> clazz) {
|
||||
while (clazz != Object.class && clazz != null) {
|
||||
Class<?>[] interfaces = clazz.getInterfaces();
|
||||
if (interfaces.length > 0) {
|
||||
for (Class<?> clazzInterface : interfaces) {
|
||||
if (PROTOBUF_MESSAGE_CLASS_NAME.equalsIgnoreCase(clazzInterface.getName())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
clazz = clazz.getSuperclass();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static String convertHessianFromWrapper(String serializeType) {
|
||||
if (TripleConstant.HESSIAN4.equals(serializeType)) {
|
||||
return TripleConstant.HESSIAN2;
|
||||
|
|
|
|||
|
|
@ -36,9 +36,9 @@
|
|||
</modules>
|
||||
|
||||
<properties>
|
||||
<micrometer.version>1.12.0</micrometer.version>
|
||||
<micrometer.version>1.12.1</micrometer.version>
|
||||
<micrometer-tracing.version>1.2.1</micrometer-tracing.version>
|
||||
<opentelemetry.version>1.32.0</opentelemetry.version>
|
||||
<opentelemetry.version>1.33.0</opentelemetry.version>
|
||||
<zipkin-reporter.version>2.17.1</zipkin-reporter.version>
|
||||
<prometheus-client.version>0.16.0</prometheus-client.version>
|
||||
</properties>
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@
|
|||
<properties>
|
||||
<spring-boot.version>2.7.18</spring-boot.version>
|
||||
<!-- Spring boot buddy is lower than the delivery dependency package version and can only show the defined dependency version -->
|
||||
<byte-buddy.version>1.14.10</byte-buddy.version>
|
||||
<byte-buddy.version>1.14.11</byte-buddy.version>
|
||||
<mockito_version>4.11.0</mockito_version>
|
||||
</properties>
|
||||
|
||||
|
|
|
|||
8
pom.xml
8
pom.xml
|
|
@ -130,10 +130,10 @@
|
|||
|
||||
<!-- Maven plugins -->
|
||||
<maven_jar_version>3.3.0</maven_jar_version>
|
||||
<maven_surefire_version>3.0.0</maven_surefire_version>
|
||||
<maven_failsafe_version>3.0.0</maven_failsafe_version>
|
||||
<maven_surefire_version>3.2.3</maven_surefire_version>
|
||||
<maven_failsafe_version>3.2.3</maven_failsafe_version>
|
||||
<maven_deploy_version>2.8.2</maven_deploy_version>
|
||||
<maven_compiler_version>3.11.0</maven_compiler_version>
|
||||
<maven_compiler_version>3.12.1</maven_compiler_version>
|
||||
<maven_source_version>3.3.0</maven_source_version>
|
||||
<maven_javadoc_version>3.6.3</maven_javadoc_version>
|
||||
<maven_jetty_version>9.4.53.v20231009</maven_jetty_version>
|
||||
|
|
@ -255,7 +255,7 @@
|
|||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>3.5.0</version>
|
||||
<version>3.6.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<!-- Do NOT upgrade -->
|
||||
|
|
|
|||
Loading…
Reference in New Issue