Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
touzizhuo03
Dubbo
提交
443616d6
D
Dubbo
项目概览
touzizhuo03
/
Dubbo
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Dubbo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
443616d6
编写于
7月 04, 2012
作者:
L
liangfei0201
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
https://github.com/AlibabaTech/dubbo
上级
e624f2d2
5c6f5678
变更
12
展开全部
隐藏空白更改
内联
并排
Showing
12 changed file
with
969 addition
and
797 deletion
+969
-797
dubbo-common/src/main/java/com/alibaba/dubbo/common/Constants.java
...mon/src/main/java/com/alibaba/dubbo/common/Constants.java
+574
-566
dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/ThreadPool.java
.../java/com/alibaba/dubbo/common/threadpool/ThreadPool.java
+41
-41
dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/scaleable/ScaleableThreadPool.java
...mon/threadpool/support/scaleable/ScaleableThreadPool.java
+45
-0
dubbo-common/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.threadpool.ThreadPool
...o/internal/com.alibaba.dubbo.common.threadpool.ThreadPool
+3
-2
dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/protocol/AbstractProtocol.java
...java/com/alibaba/dubbo/rpc/protocol/AbstractProtocol.java
+20
-32
dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/support/ProtocolUtils.java
...ain/java/com/alibaba/dubbo/rpc/support/ProtocolUtils.java
+35
-0
dubbo-test/dubbo-test-benchmark/pom.xml
dubbo-test/dubbo-test-benchmark/pom.xml
+89
-69
dubbo-test/dubbo-test-benchmark/src/assembly/dev.xml
dubbo-test/dubbo-test-benchmark/src/assembly/dev.xml
+23
-18
dubbo-test/dubbo-test-benchmark/src/assembly/release.xml
dubbo-test/dubbo-test-benchmark/src/assembly/release.xml
+23
-18
dubbo-test/dubbo-test-benchmark/src/main/java/com/alibaba/dubbo/rpc/benchmark/DemoServiceImpl.java
...java/com/alibaba/dubbo/rpc/benchmark/DemoServiceImpl.java
+15
-15
dubbo-test/dubbo-test-benchmark/src/main/java/com/alibaba/dubbo/rpc/benchmark/RpcClient.java
.../main/java/com/alibaba/dubbo/rpc/benchmark/RpcClient.java
+65
-0
dubbo-test/dubbo-test-benchmark/src/main/resources/ProviderSample.xml
...ubbo-test-benchmark/src/main/resources/ProviderSample.xml
+36
-36
未找到文件。
dubbo-common/src/main/java/com/alibaba/dubbo/common/Constants.java
浏览文件 @
443616d6
此差异已折叠。
点击以展开。
dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/ThreadPool.java
浏览文件 @
443616d6
/*
* Copyright 1999-2011 Alibaba Group.
*
* Licensed 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
com.alibaba.dubbo.common.threadpool
;
import
java.util.concurrent.Executor
;
import
com.alibaba.dubbo.common.Constants
;
import
com.alibaba.dubbo.common.URL
;
import
com.alibaba.dubbo.common.extension.Adaptive
;
import
com.alibaba.dubbo.common.extension.SPI
;
/**
* ThreadPool
*
* @author william.liangf
*/
@SPI
(
"
fixed"
)
public
interface
ThreadPool
{
/**
* 线程池
*
* @param url 线程参数
* @return 线程池
*/
@Adaptive
({
Constants
.
THREADPOOL_KEY
})
Executor
getExecutor
(
URL
url
);
/*
* Copyright 1999-2011 Alibaba Group.
*
* Licensed 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
com.alibaba.dubbo.common.threadpool
;
import
java.util.concurrent.Executor
;
import
com.alibaba.dubbo.common.Constants
;
import
com.alibaba.dubbo.common.URL
;
import
com.alibaba.dubbo.common.extension.Adaptive
;
import
com.alibaba.dubbo.common.extension.SPI
;
/**
* ThreadPool
*
* @author william.liangf
*/
@SPI
(
"
scaleable"
)
public
interface
ThreadPool
{
/**
* 线程池
*
* @param url 线程参数
* @return 线程池
*/
@Adaptive
({
Constants
.
THREADPOOL_KEY
})
Executor
getExecutor
(
URL
url
);
}
\ No newline at end of file
dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/scaleable/ScaleableThreadPool.java
0 → 100644
浏览文件 @
443616d6
/*
* Copyright 1999-2011 Alibaba Group.
*
* Licensed 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
com.alibaba.dubbo.common.threadpool.support.scaleable
;
import
java.util.concurrent.Executor
;
import
java.util.concurrent.LinkedBlockingQueue
;
import
java.util.concurrent.SynchronousQueue
;
import
java.util.concurrent.ThreadPoolExecutor
;
import
java.util.concurrent.TimeUnit
;
import
com.alibaba.dubbo.common.Constants
;
import
com.alibaba.dubbo.common.URL
;
import
com.alibaba.dubbo.common.threadpool.ThreadPool
;
import
com.alibaba.dubbo.common.threadpool.support.AbortPolicyWithReport
;
import
com.alibaba.dubbo.common.utils.NamedThreadFactory
;
/**
* @author <a href="mailto:gang.lvg@alibaba-inc.com">kimi</a>
*/
public
class
ScaleableThreadPool
implements
ThreadPool
{
public
Executor
getExecutor
(
URL
url
)
{
String
threadName
=
url
.
getParameter
(
Constants
.
THREAD_NAME_KEY
,
Constants
.
DEFAULT_THREAD_NAME
);
int
min
=
url
.
getParameter
(
Constants
.
THREADS_MIN_KEY
,
Constants
.
DEFAULT_MIN_THREADS
);
int
max
=
url
.
getParameter
(
Constants
.
THREADS_MAX_KEY
,
Constants
.
DEFAULT_MAX_THREADS
);
int
queues
=
url
.
getParameter
(
Constants
.
QUEUES_KEY
,
Constants
.
DEFAULT_QUEUES
);
return
new
ThreadPoolExecutor
(
min
,
max
,
Long
.
MAX_VALUE
,
TimeUnit
.
MILLISECONDS
,
queues
<=
0
?
new
SynchronousQueue
<
Runnable
>()
:
new
LinkedBlockingQueue
<
Runnable
>(
queues
),
new
NamedThreadFactory
(
threadName
,
true
),
new
AbortPolicyWithReport
(
threadName
,
url
));
}
}
dubbo-common/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.threadpool.ThreadPool
浏览文件 @
443616d6
fixed=com.alibaba.dubbo.common.threadpool.support.fixed.FixedThreadPool
cached=com.alibaba.dubbo.common.threadpool.support.cached.CachedThreadPool
\ No newline at end of file
fixed=com.alibaba.dubbo.common.threadpool.support.fixed.FixedThreadPool
cached=com.alibaba.dubbo.common.threadpool.support.cached.CachedThreadPool
scaleable=com.alibaba.dubbo.common.threadpool.support.scaleable.ScaleableThreadPool
dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/protocol/AbstractProtocol.java
浏览文件 @
443616d6
/*
* Copyright 1999-2011 Alibaba Group.
*
* Licensed 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.
*/
/*
* Copyright 1999-2011 Alibaba Group.
*
* Licensed 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
com.alibaba.dubbo.rpc.protocol
;
import
java.util.ArrayList
;
...
...
@@ -25,10 +25,11 @@ import com.alibaba.dubbo.common.URL;
import
com.alibaba.dubbo.common.logger.Logger
;
import
com.alibaba.dubbo.common.logger.LoggerFactory
;
import
com.alibaba.dubbo.common.utils.ConcurrentHashSet
;
import
com.alibaba.dubbo.common.utils.ConfigUtils
;
import
com.alibaba.dubbo.common.utils.ConfigUtils
;
import
com.alibaba.dubbo.rpc.Exporter
;
import
com.alibaba.dubbo.rpc.Invoker
;
import
com.alibaba.dubbo.rpc.Protocol
;
import
com.alibaba.dubbo.rpc.support.ProtocolUtils
;
/**
* abstract ProtocolSupport.
...
...
@@ -41,29 +42,16 @@ public abstract class AbstractProtocol implements Protocol {
protected
final
Logger
logger
=
LoggerFactory
.
getLogger
(
getClass
());
protected
final
Map
<
String
,
Exporter
<?>>
exporterMap
=
new
ConcurrentHashMap
<
String
,
Exporter
<?>>();
//TODO SOFEREFENCE
protected
final
Set
<
Invoker
<?>>
invokers
=
new
ConcurrentHashSet
<
Invoker
<?>>();
protected
static
String
serviceKey
(
URL
url
)
{
return
serviceKey
(
url
.
getPort
(),
url
.
getPath
(),
url
.
getParameter
(
Constants
.
VERSION_KEY
),
url
.
getParameter
(
Constants
.
GROUP_KEY
));
return
ProtocolUtils
.
serviceKey
(
url
);
}
protected
static
String
serviceKey
(
int
port
,
String
serviceName
,
String
serviceVersion
,
String
serviceGroup
)
{
StringBuilder
buf
=
new
StringBuilder
();
if
(
serviceGroup
!=
null
&&
serviceGroup
.
length
()
>
0
)
{
buf
.
append
(
serviceGroup
);
buf
.
append
(
"/"
);
}
buf
.
append
(
serviceName
);
if
(
serviceVersion
!=
null
&&
serviceVersion
.
length
()
>
0
&&
!
"0.0.0"
.
equals
(
serviceVersion
))
{
buf
.
append
(
":"
);
buf
.
append
(
serviceVersion
);
}
buf
.
append
(
":"
);
buf
.
append
(
port
);
return
buf
.
toString
();
return
ProtocolUtils
.
serviceKey
(
port
,
serviceName
,
serviceVersion
,
serviceGroup
);
}
public
void
destroy
()
{
...
...
dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/support/ProtocolUtils.java
0 → 100644
浏览文件 @
443616d6
package
com.alibaba.dubbo.rpc.support
;
import
com.alibaba.dubbo.common.Constants
;
import
com.alibaba.dubbo.common.URL
;
/**
* @author <a href="mailto:gang.lvg@alibaba-inc.com">kimi</a>
*/
public
class
ProtocolUtils
{
private
ProtocolUtils
()
{
}
public
static
String
serviceKey
(
URL
url
)
{
return
serviceKey
(
url
.
getPort
(),
url
.
getPath
(),
url
.
getParameter
(
Constants
.
VERSION_KEY
),
url
.
getParameter
(
Constants
.
GROUP_KEY
));
}
public
static
String
serviceKey
(
int
port
,
String
serviceName
,
String
serviceVersion
,
String
serviceGroup
)
{
StringBuilder
buf
=
new
StringBuilder
();
if
(
serviceGroup
!=
null
&&
serviceGroup
.
length
()
>
0
)
{
buf
.
append
(
serviceGroup
);
buf
.
append
(
"/"
);
}
buf
.
append
(
serviceName
);
if
(
serviceVersion
!=
null
&&
serviceVersion
.
length
()
>
0
&&
!
"0.0.0"
.
equals
(
serviceVersion
))
{
buf
.
append
(
":"
);
buf
.
append
(
serviceVersion
);
}
buf
.
append
(
":"
);
buf
.
append
(
port
);
return
buf
.
toString
();
}
}
dubbo-test/dubbo-test-benchmark/pom.xml
浏览文件 @
443616d6
<!--
- Copyright 1999-2011 Alibaba Group.
-
- Licensed 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.
-->
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<groupId>
com.alibaba
</groupId>
<artifactId>
dubbo-test
</artifactId>
<version>
2.4.0-SNAPSHOT
</version>
</parent>
<artifactId>
dubbo-test-benchmark
</artifactId>
<packaging>
jar
</packaging>
<name>
${project.artifactId}
</name>
<description>
The performance benchmark kit test module of dubbo project
</description>
<properties>
<skip_maven_deploy>
true
</skip_maven_deploy>
</properties>
<dependencies>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
dubbo
</artifactId>
<version>
${project.parent.version}
</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<configuration>
<source>
1.6
</source>
<target>
1.6
</target>
<encoding>
UTF-8
</encoding>
</configuration>
</plugin>
<plugin>
<artifactId>
maven-assembly-plugin
</artifactId>
<version>
2.2.1
</version>
<executions>
<execution>
<id>
assembly
</id>
<phase>
package
</phase>
<goals>
<goal>
single
</goal>
</goals>
<configuration>
<descriptors>
<descriptor>
${basedir}/src/assembly/release.xml
</descriptor>
</descriptors>
<appendAssemblyId>
false
</appendAssemblyId>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<!--
- Copyright 1999-2011 Alibaba Group.
-
- Licensed 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.
-->
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<groupId>
com.alibaba
</groupId>
<artifactId>
dubbo-test
</artifactId>
<version>
2.4.0-SNAPSHOT
</version>
</parent>
<artifactId>
dubbo-test-benchmark
</artifactId>
<packaging>
jar
</packaging>
<name>
${project.artifactId}
</name>
<description>
The performance benchmark kit test module of dubbo project
</description>
<properties>
<skip_maven_deploy>
true
</skip_maven_deploy>
</properties>
<dependencies>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
dubbo
</artifactId>
<version>
${project.parent.version}
</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-jar-plugin
</artifactId>
<executions>
<execution>
<id>
package-exclude-resources
</id>
<goals>
<goal>
jar
</goal>
</goals>
<phase>
package
</phase>
<configuration>
<excludes>
<exclude>
dubbo.properties
</exclude>
<exclude>
ProviderSample.xml
</exclude>
</excludes>
<classifier>
assemble
</classifier>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<configuration>
<source>
1.6
</source>
<target>
1.6
</target>
<encoding>
UTF-8
</encoding>
</configuration>
</plugin>
<plugin>
<artifactId>
maven-assembly-plugin
</artifactId>
<version>
2.2.1
</version>
<executions>
<execution>
<id>
assembly
</id>
<phase>
package
</phase>
<goals>
<goal>
single
</goal>
</goals>
<configuration>
<descriptors>
<descriptor>
${basedir}/src/assembly/release.xml
</descriptor>
</descriptors>
<appendAssemblyId>
false
</appendAssemblyId>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
dubbo-test/dubbo-test-benchmark/src/assembly/dev.xml
浏览文件 @
443616d6
<assembly>
<id>
dist
</id>
<formats>
<format>
tar.gz
</format>
</formats>
<includeBaseDirectory>
false
</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>
src/main/resources
</directory>
<outputDirectory>
dubbo.benchmark
</outputDirectory>
<fileMode>
0755
</fileMode>
</fileSet>
</fileSets>
<dependencySets>
<dependencySet>
<outputDirectory>
dubbo.benchmark/lib
</outputDirectory>
</dependencySet>
</dependencySets>
<assembly>
<id>
dist
</id>
<formats>
<format>
tar.gz
</format>
</formats>
<includeBaseDirectory>
false
</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>
src/main/resources
</directory>
<outputDirectory>
dubbo.benchmark
</outputDirectory>
<fileMode>
0755
</fileMode>
</fileSet>
</fileSets>
<dependencySets>
<dependencySet>
<outputDirectory>
dubbo.benchmark/lib
</outputDirectory>
<useProjectArtifact>
false
</useProjectArtifact>
<useProjectAttachments>
true
</useProjectAttachments>
<excludes>
<exclude>
*:sources
</exclude>
</excludes>
</dependencySet>
</dependencySets>
</assembly>
\ No newline at end of file
dubbo-test/dubbo-test-benchmark/src/assembly/release.xml
浏览文件 @
443616d6
<assembly>
<id>
dist
</id>
<formats>
<format>
tar.gz
</format>
</formats>
<includeBaseDirectory>
false
</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>
src/main/resources
</directory>
<outputDirectory>
dubbo.benchmark
</outputDirectory>
<fileMode>
0755
</fileMode>
</fileSet>
</fileSets>
<dependencySets>
<dependencySet>
<outputDirectory>
dubbo.benchmark/lib
</outputDirectory>
</dependencySet>
</dependencySets>
<assembly>
<id>
dist
</id>
<formats>
<format>
tar.gz
</format>
</formats>
<includeBaseDirectory>
false
</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>
src/main/resources
</directory>
<outputDirectory>
dubbo.benchmark
</outputDirectory>
<fileMode>
0755
</fileMode>
</fileSet>
</fileSets>
<dependencySets>
<dependencySet>
<outputDirectory>
dubbo.benchmark/lib
</outputDirectory>
<useProjectArtifact>
false
</useProjectArtifact>
<useProjectAttachments>
true
</useProjectAttachments>
<excludes>
<exclude>
*:sources
</exclude>
</excludes>
</dependencySet>
</dependencySets>
</assembly>
\ No newline at end of file
dubbo-test/dubbo-test-benchmark/src/main/java/com/alibaba/dubbo/rpc/benchmark/DemoServiceImpl.java
浏览文件 @
443616d6
package
com.alibaba.dubbo.rpc.benchmark
;
/**
* TODO Comment of HelloService
*
* @author tony.chenl
*/
public
class
DemoServiceImpl
implements
DemoService
{
ResponseObject
responseObject
=
new
ResponseObject
(
100
);
public
Object
sendRequest
(
Object
request
)
{
return
re
sponseObject
;
}
}
package
com.alibaba.dubbo.rpc.benchmark
;
/**
* TODO Comment of HelloService
*
* @author tony.chenl
*/
public
class
DemoServiceImpl
implements
DemoService
{
ResponseObject
responseObject
=
new
ResponseObject
(
100
);
public
Object
sendRequest
(
Object
request
)
{
return
re
quest
;
}
}
dubbo-test/dubbo-test-benchmark/src/main/java/com/alibaba/dubbo/rpc/benchmark/RpcClient.java
0 → 100644
浏览文件 @
443616d6
/*
* Copyright 1999-2011 Alibaba Group.
*
* Licensed 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
com.alibaba.dubbo.rpc.benchmark
;
import
java.util.concurrent.CountDownLatch
;
import
java.util.concurrent.CyclicBarrier
;
/**
* RpcClient.java
* @author tony.chenl
*/
public
class
RpcClient
extends
AbstractClientRunnable
{
private
static
String
message
=
null
;
private
static
int
length
=
100
;
static
{
length
=
Integer
.
valueOf
(
System
.
getProperty
(
"message.length"
,
"1000"
));
StringBuilder
sb
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
length
;
i
++){
sb
.
append
(
"a"
);
}
message
=
sb
.
toString
();
}
/**
* @param targetIP
* @param targetPort
* @param clientNums
* @param rpcTimeout
* @param barrier
* @param latch
* @param startTime
* @param endTime
*/
public
RpcClient
(
String
targetIP
,
int
targetPort
,
int
clientNums
,
int
rpcTimeout
,
CyclicBarrier
barrier
,
CountDownLatch
latch
,
long
startTime
,
long
endTime
){
super
(
targetIP
,
targetPort
,
clientNums
,
rpcTimeout
,
barrier
,
latch
,
startTime
,
endTime
);
}
@SuppressWarnings
({
"unchecked"
,
"rawtypes"
})
@Override
public
Object
invoke
(
ServiceFactory
serviceFactory
)
{
DemoService
demoService
=
(
DemoService
)
serviceFactory
.
get
(
DemoService
.
class
);
Object
result
=
demoService
.
sendRequest
(
message
);
return
result
;
/*if(result.equals(message)){
return result;
}else{
throw new RuntimeException("Result Error");
}*/
}
}
dubbo-test/dubbo-test-benchmark/src/
test
/resources/ProviderSample.xml
→
dubbo-test/dubbo-test-benchmark/src/
main
/resources/ProviderSample.xml
浏览文件 @
443616d6
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns=
"http://www.springframework.org/schema/beans"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo=
"http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd
"
>
<bean
id=
"demo.local"
class=
"com.alibaba.dubbo.rpc.benchmark.DemoServiceImpl"
/>
<bean
id=
"persistPropertyPlaceholderConfigurer"
class=
"org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
>
<property
name=
"systemPropertiesModeName"
value=
"SYSTEM_PROPERTIES_MODE_OVERRIDE"
/>
<property
name=
"ignoreResourceNotFound"
value=
"true"
/>
<property
name=
"ignoreUnresolvablePlaceholders"
value=
"true"
/>
<property
name=
"locations"
>
<list>
<value>
classpath:dubbo-default.properties
</value>
<value>
classpath:dubbo.properties
</value>
</list>
</property>
</bean>
<dubbo:registry
address=
"N/A"
/>
<!-- 服务应用配置 -->
<dubbo:application
name=
"dubbo_provider"
/>
<!-- 服务提供者全局配置 -->
<dubbo:protocol
name=
"dubbo"
port=
"20885"
/>
<!-- 服务提供者暴露服务配置 -->
<dubbo:service
id=
"helloService"
interface=
"com.alibaba.dubbo.rpc.benchmark.DemoService"
ref=
"demo.local"
/>
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns=
"http://www.springframework.org/schema/beans"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo=
"http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd
"
>
<bean
id=
"demo.local"
class=
"com.alibaba.dubbo.rpc.benchmark.DemoServiceImpl"
/>
<bean
id=
"persistPropertyPlaceholderConfigurer"
class=
"org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
>
<property
name=
"systemPropertiesModeName"
value=
"SYSTEM_PROPERTIES_MODE_OVERRIDE"
/>
<property
name=
"ignoreResourceNotFound"
value=
"true"
/>
<property
name=
"ignoreUnresolvablePlaceholders"
value=
"true"
/>
<property
name=
"locations"
>
<list>
<value>
classpath:dubbo-default.properties
</value>
<value>
classpath:dubbo.properties
</value>
</list>
</property>
</bean>
<dubbo:registry
address=
"N/A"
/>
<!-- 服务应用配置 -->
<dubbo:application
name=
"dubbo_provider"
/>
<!-- 服务提供者全局配置 -->
<dubbo:protocol
name=
"dubbo"
port=
"20885"
/>
<!-- 服务提供者暴露服务配置 -->
<dubbo:service
id=
"helloService"
interface=
"com.alibaba.dubbo.rpc.benchmark.DemoService"
ref=
"demo.local"
/>
</beans>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录