Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

F/dubbo3 #161

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 26 additions & 25 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<version>${revision}</version>

<properties>
<revision>2.7.8</revision>
<revision>3.1.10</revision>
<java.version>1.8</java.version>
<java.source.version>1.8</java.source.version>
<java.target.version>1.8</java.target.version>
Expand All @@ -31,7 +31,7 @@
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<dubbo.version>2.7.8</dubbo.version>
<dubbo.version>3.1.10</dubbo.version>
<jorphan.version>3.0</jorphan.version>
<avalon.framework.version>4.1.4</avalon.framework.version>
<jmeter.core.version>3.0</jmeter.core.version>
Expand Down Expand Up @@ -119,41 +119,42 @@
<artifactId>dubbo-registry-zookeeper</artifactId>
</dependency>
<!-- redis -->
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-registry-redis</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.apache.dubbo</groupId>-->
<!-- <artifactId>dubbo-registry-redis</artifactId>-->
<!-- </dependency>-->
<!-- serialization -->
<!-- hessian2 -->
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-serialization-hessian2</artifactId>
</dependency>
<!-- FST -->
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-serialization-fst</artifactId>
</dependency>
<!-- kryo -->
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-serialization-kryo</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.apache.dubbo</groupId>-->
<!-- <artifactId>dubbo-serialization-fst</artifactId>-->
<!-- </dependency>-->
<!-- &lt;!&ndash; kryo &ndash;&gt;-->
<!-- <dependency>-->
<!-- <groupId>org.apache.dubbo</groupId>-->
<!-- <artifactId>dubbo-serialization-kryo</artifactId>-->
<!-- </dependency>-->
<!-- fastjson -->
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-serialization-fastjson</artifactId>
<artifactId>dubbo-serialization-fastjson2</artifactId>

</dependency>
<!-- gson -->
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-serialization-gson</artifactId>
</dependency>
<!-- avro -->
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-serialization-avro</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.apache.dubbo</groupId>-->
<!-- <artifactId>dubbo-serialization-gson</artifactId>-->
<!-- </dependency>-->
<!-- &lt;!&ndash; avro &ndash;&gt;-->
<!-- <dependency>-->
<!-- <groupId>org.apache.dubbo</groupId>-->
<!-- <artifactId>dubbo-serialization-avro</artifactId>-->
<!-- </dependency>-->
<!-- Log -->
<!-- slf4j -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void modifyTestElement(TestElement element) {
*/
@Override
public String getStaticLabel() {
return "Dubbo Sample";
return "Dubbo Sampler";
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.apache.dubbo.config.ConfigCenterConfig;
import org.apache.dubbo.config.ReferenceConfig;
import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.utils.ReferenceConfigCache;
import org.apache.dubbo.config.utils.SimpleReferenceCache;
import org.apache.dubbo.rpc.RpcContext;
import org.apache.dubbo.rpc.RpcException;
import org.apache.dubbo.rpc.service.GenericService;
Expand Down Expand Up @@ -269,7 +269,7 @@ private Object callDubbo(SampleResult res) {
}

// The registry's address is to generate the ReferenceConfigCache key
ReferenceConfigCache cache = ReferenceConfigCache.getCache(Constants.getAddress(this));
SimpleReferenceCache cache = SimpleReferenceCache.getCache(Constants.getAddress(this));
GenericService genericService = (GenericService) cache.get(reference);
if (genericService == null) {
setResponseError(res, ErrorCode.GENERIC_SERVICE_IS_NULL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.apache.dubbo.common.URL;
import org.apache.dubbo.config.ReferenceConfig;
import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.utils.ReferenceConfigCache;
import org.apache.dubbo.config.utils.SimpleReferenceCache;
import org.apache.dubbo.registry.RegistryService;
import org.apache.jorphan.logging.LoggingManager;
import org.apache.log.Logger;
Expand Down Expand Up @@ -102,7 +102,7 @@ private List<String> executeRegistry(String protocol, String address, String gro
}
reference.setInterface("org.apache.dubbo.registry.RegistryService");
try {
ReferenceConfigCache cache = ReferenceConfigCache.getCache(address + "_" + group);
SimpleReferenceCache cache = SimpleReferenceCache.getCache(address + "_" + group);
RegistryService registryService = (RegistryService) cache.get(reference);
if (registryService == null) {
throw new RuntimeException("Can't get the interface list, please check if the address is wrong!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public static RegistryServerSync get(String key) {
// + Constants.CONSUMERS_CATEGORY + ","
// + Constants.ROUTERS_CATEGORY + ","
// + Constants.CONFIGURATORS_CATEGORY,
// CommonConstants.INTERFACE_KEY, "com.pupu.depot.api.apply.IReplenishApplyDetailApi",
CommonConstants.ENABLED_KEY, CommonConstants.ANY_VALUE,
CommonConstants.CHECK_KEY, String.valueOf(false));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.github.ningyu.jmeter.plugin.test;

import io.github.ningyu.jmeter.plugin.bean.EnumA;
import io.github.ningyu.jmeter.plugin.bean.EnumB;
import io.github.ningyu.jmeter.plugin.dubbo.sample.MethodArgument;
import io.github.ningyu.jmeter.plugin.util.ClassUtils;
import io.github.ningyu.jmeter.plugin.util.Constants;
Expand All @@ -10,6 +12,7 @@
import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.rpc.RpcContext;
import org.apache.dubbo.rpc.service.GenericService;
import org.junit.Assert;
import org.junit.Test;

import java.util.ArrayList;
Expand All @@ -21,14 +24,14 @@ public void test() {
ApplicationConfig application = new ApplicationConfig();
application.setName("api-generic-consumer");
ReferenceConfig<GenericService> reference = new ReferenceConfig<>();
reference.setUrl("dubbo://192.168.56.1:20880/org.apache.dubbo.samples.basic.api.DemoService");
reference.setUrl("dubbo://192.168.9.182:28077/com.pupu.account.api.ITemperatureRecordingApi");
reference.setVersion("1.0.0");
reference.setTimeout(2000);
reference.setGeneric(true);
reference.setApplication(application);
reference.setInterface("com.jiuyescm.account.api.IUserService");
reference.setInterface("com.pupu.account.api.ITemperatureRecordingApi");
GenericService genericService = reference.get();
Object obj = genericService.$invoke("getUserById", new String[]{Long.class.getName()}, new Long[]{1L});
Object obj = genericService.$invoke("countByAdminUser", new String[]{String.class.getName()}, new String[]{"118303"});
String json = JsonUtils.toJson(obj);
System.out.println(json);
}
Expand All @@ -38,15 +41,15 @@ public void testAttachment() {
ApplicationConfig application = new ApplicationConfig();
application.setName("api-generic-consumer");
ReferenceConfig<GenericService> reference = new ReferenceConfig<>();
reference.setUrl("dubbo://192.168.56.1:20880/org.apache.dubbo.samples.basic.api.DemoService");
reference.setUrl("dubbo://192.168.9.182:28077/com.pupu.account.api.ITemperatureRecordingApi");
reference.setVersion("1.0.0");
reference.setTimeout(2000);
reference.setGeneric(true);
reference.setApplication(application);
reference.setInterface("com.jiuyescm.account.api.IUserService");
reference.setInterface("com.pupu.account.api.ITemperatureRecordingApi");
GenericService genericService = reference.get();
RpcContext.getContext().setAttachment("test.ningyu","this is attachmentValue");
Object obj = genericService.$invoke("sayHello", new String[]{String.class.getName()}, new String[]{"ningyu"});
Object obj = genericService.$invoke("countByAdminUser", new String[]{String.class.getName()}, new String[]{"118303"});
String json = JsonUtils.toJson(obj);
System.out.println(json);
}
Expand All @@ -61,11 +64,15 @@ public void testZk() {
reference.setGroup("");
RegistryConfig registry = new RegistryConfig();
registry.setProtocol(Constants.REGISTRY_ZOOKEEPER);
registry.setAddress("192.168.0.44:2181,192.168.0.44:2182,192.168.0.44:2183");
registry.setAddress("qa-config.zookeeper.service.consul");
registry.setPort(2181);
// registry.setAddress("192.168.0.44:2181,192.168.0.44:2182,192.168.0.44:2183");
registry.setTimeout(10000);
reference.setRegistry(registry);
ConfigCenterConfig cc = new ConfigCenterConfig();
cc.setAddress("192.168.0.44:2181,192.168.0.44:2182,192.168.0.44:2183");
// cc.setAddress("192.168.0.44:2181,192.168.0.44:2182,192.168.0.44:2183");
cc.setAddress("qa-config.zookeeper.service.consul:2181");

cc.setProtocol(Constants.REGISTRY_ZOOKEEPER);
cc.setTimeout(Long.valueOf("10000"));
cc.setGroup("");
Expand All @@ -74,9 +81,9 @@ public void testZk() {
reference.setTimeout(2000);
reference.setGeneric(true);
reference.setApplication(application);
reference.setInterface("com.jiuyescm.account.api.IUserService");
reference.setInterface("com.pupu.account.api.ITemperatureRecordingApi");
GenericService genericService = reference.get();
Object obj = genericService.$invoke("getUserById", new String[]{Long.class.getName()}, new Long[]{1L});
Object obj = genericService.$invoke("countByAdminUser", new String[]{String.class.getName()}, new String[]{"118303"});
String json = JsonUtils.toJson(obj);
System.out.println(json);
}
Expand All @@ -86,19 +93,21 @@ public void testZk() {
public void testEnumA() {
List<String> paramterTypeList = new ArrayList<>();
List<Object> parameterValuesList = new ArrayList<>();
MethodArgument arg = new MethodArgument("io.github.ningyu.jmeter.plugin.EnumA1", "WECHAT");
MethodArgument arg = new MethodArgument("io.github.ningyu.jmeter.plugin.bean.EnumA", "WECHAT");
ClassUtils.parseParameter(paramterTypeList, parameterValuesList, arg);
System.out.println(paramterTypeList.toString());
System.out.println(parameterValuesList.toString());
Assert.assertEquals(EnumA.WECHAT, parameterValuesList.get(0));
}

@Test
public void testEnumB() {
List<String> paramterTypeList = new ArrayList<>();
List<Object> parameterValuesList = new ArrayList<>();
MethodArgument arg = new MethodArgument("io.github.ningyu.jmeter.plugin.EnumB1", "PASSED");
MethodArgument arg = new MethodArgument("io.github.ningyu.jmeter.plugin.bean.EnumB", "PASSED");
ClassUtils.parseParameter(paramterTypeList, parameterValuesList, arg);
System.out.println(paramterTypeList.toString());
System.out.println(parameterValuesList.toString());
Assert.assertEquals(EnumB.PASSED, parameterValuesList.get(0));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package io.github.ningyu.jmeter.plugin.test;

import io.github.ningyu.jmeter.plugin.dubbo.sample.ProviderService;
import org.junit.Test;

import java.util.List;

/**
* @Author: Jason Wu
* @Date: 2023/9/18
* @Description:
*/
public class ProviderServiceTest {

// @Test
public void testGetProviders() {
ProviderService providerService = new ProviderService();
List<String> result = providerService.getProviders("zookeeper", "qa-config.zookeeper.service.consul:2181", "");
result.forEach(s->{});
}
}