测试connections 性能
This commit is contained in:
parent
1f1f6d99c8
commit
5369fcb8be
|
@ -1,5 +1,7 @@
|
|||
package cn.ecpark.service.usergw;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.apache.dubbo.config.spring.context.annotation.EnableDubboConfig;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
|
@ -17,6 +19,8 @@ import org.springframework.context.annotation.Configuration;
|
|||
public class App {
|
||||
|
||||
public static void main(String[] args) {
|
||||
URI a = URI.create("dubbo://127.0.0.1/com.a.b?group=test&version=123");
|
||||
URI b = URI.create("dubbo://com.a.b?group=test&version=123");
|
||||
SpringApplication.run(App.class, args);
|
||||
}
|
||||
|
||||
|
|
|
@ -75,11 +75,11 @@ public class DubboGatewayFilterFactory extends AbstractGatewayFilterFactory<Dubb
|
|||
|
||||
reference.setApplication(new ApplicationConfig("dubbo-exchange")); // 必须
|
||||
// reference.setRegistry(new RegistryConfig("zookeeper://127.0.0.1:2181"));
|
||||
// reference.setGroup("group");
|
||||
reference.setGroup("test");
|
||||
reference.setInterface("ocean.demo.api.IExchange"); // 弱类型接口名 必须
|
||||
reference.setConnections(5);
|
||||
reference.setVersion("1.0.0"); // 必须
|
||||
reference.setGeneric(true); // 声明为泛化接口
|
||||
|
||||
gsPool.add(rkey, reference.get());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -176,7 +176,7 @@ public class ConfigGateway implements RouteDefinitionLocator {
|
|||
RouteDefinition rd = new RouteDefinition();
|
||||
|
||||
// 设置基础属性
|
||||
this.ParseAndSetBase(rd, iter);
|
||||
String uri = this.ParseDubboUriAndSetBase(rd, iter);
|
||||
|
||||
// predicates: 下的相关属性
|
||||
this.ParseAndAddPredicates(predicates, iter, "predicates");
|
||||
|
@ -240,6 +240,48 @@ public class ConfigGateway implements RouteDefinitionLocator {
|
|||
}
|
||||
}
|
||||
|
||||
private String ParseDubboUriAndSetBase(RouteDefinition rd, LinkedHashMap<String, List<String>> iter) {
|
||||
// 设置id
|
||||
Object id = iter.get("id");
|
||||
if (id != null) {
|
||||
rd.setId((String) id);
|
||||
}
|
||||
|
||||
// 设置uri
|
||||
Object uri = iter.get("uri");
|
||||
if (uri != null) {
|
||||
rd.setUri(URI.create((String) uri));
|
||||
} else {
|
||||
rd.setUri(URI.create("dubbo://"));
|
||||
}
|
||||
|
||||
// 设置uri
|
||||
Object order = iter.get("order");
|
||||
if (order != null) {
|
||||
rd.setOrder((int) order);
|
||||
}
|
||||
|
||||
if(uri != null) {
|
||||
String uriString = (String)uri;
|
||||
uriString = uriString.trim();
|
||||
if(uriString.startsWith("dubbo://")) { // dubbo://127.0.0.1/interface?
|
||||
return uriString ;
|
||||
}
|
||||
}
|
||||
|
||||
Object registry = iter.get("registry");
|
||||
if (registry != null) {
|
||||
rd.setOrder((int) order);
|
||||
}
|
||||
|
||||
Object application = iter.get("application");
|
||||
if (registry != null) {
|
||||
rd.setOrder((int) order);
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
private void ParseAndAddPredicates(List<PredicateDefinition> predicates, LinkedHashMap<String, List<String>> iter,
|
||||
String yamlField) {
|
||||
List<String> predicatesYaml = iter.get(yamlField);
|
||||
|
|
|
@ -20,8 +20,8 @@ dubbo:
|
|||
- id: test
|
||||
order: 10
|
||||
application: dubbo-exchange
|
||||
uri: http://httpbin.org:80/get
|
||||
# path: /dubbo/hello
|
||||
registry: zookeeper://127.0.0.1:2181
|
||||
uri: unknown
|
||||
interface: ocean.demo.api.IExchange
|
||||
version: 1.0.0
|
||||
predicates:
|
||||
|
|
Loading…
Reference in New Issue
Block a user