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
[WIP]Collect "cpu.user" metric #4195
[WIP]Collect "cpu.user" metric #4195
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4195 +/- ##
===========================================
- Coverage 63.34% 63.2% -0.14%
+ Complexity 450 448 -2
===========================================
Files 770 774 +4
Lines 33015 33099 +84
Branches 5218 5222 +4
===========================================
+ Hits 20912 20919 +7
- Misses 9705 9776 +71
- Partials 2398 2404 +6
Continue to review full report at Codecov.
|
UT failed, the reason is:
|
I made a test with 1 provider and 1 consumer. I found 2 problems in my tests:
CPU usage data:
dubbo-consumer.xml <dubbo:application name="demo-consumer"/>
<dubbo:registry address="multicast://224.5.6.7:1234"/>
<dubbo:protocol name="dubbo" port="20880"/>
<dubbo:reference id="demoService" check="false" interface="org.apache.dubbo.demo.DemoService" timeout="20000"/> dubbo-provider.xml <dubbo:application name="demo-provider"/>
<dubbo:registry address="multicast://224.5.6.7:1234" />
<dubbo:protocol name="dubbo"/>
<bean id="demoService" class="org.apache.dubbo.demo.provider.DemoServiceImpl"/>
<bean id="cpuUsageService" class="org.apache.dubbo.rpc.cluster.loadbalance.statistics.CpuUsageServiceImpl">
</bean>
<dubbo:service interface="org.apache.dubbo.demo.DemoService" ref="demoService" loadbalance="statistics"/>
<dubbo:service interface="org.apache.dubbo.rpc.cluster.loadbalance.statistics.CpuUsageService" ref="cpuUsageService" connections="1" callbacks="1000">
<dubbo:method name="addListener">
<dubbo:argument index="1" callback="true" />
</dubbo:method>
</dubbo:service> dubbo.properties (provider side)
|
urlBuilder.setPath(CpuUsageService.class.getName()); | ||
|
||
Invoker<CpuUsageService> cpuUsageInvoker = protocol.refer(CpuUsageService.class, urlBuilder.build()); | ||
return proxyFactory.getProxy(cpuUsageInvoker); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ralf0131 The class which implements CpuUsageService has a default constructor that schedule the thread to collect CPU Usage.
Questions:
- Should I call the default constructor? Does the proxyFactory do it?
- In dubbo-provider.xml I added:
<bean id="cpuUsageService" class="org.apache.dubbo.rpc.cluster.loadbalance.statistics.CpuUsageServiceImpl"/>
Will Spring/Dubbo call the factory class (DubboCpuUsageServiceFactory)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, why do you need to create CpuUsageFactory? I think right now it is ok to put the logic to StatisticsLoadBalance
and refactor it later.
You need to have at least 2 provider and 1 consumer in order to make a load balance to work. Please check the logic of
This is because you registered the listener to When a provider failed to send cpu usage data to a consumer, it should throw an expcetion
Because the thread has been switched when There is a third issue, which is mentioned by @guohao , if the provider restart, the consumer should remove the statistics from the |
…rovider restarts)
@danielamorais hi, thanks for your contribution Please merge the latest master branch to resolve conflict files. |
Close for long time no response. Please feel free to reopen if you have any question. If you think these changes still useful in the latest master branch, please submit a new pull request. |
What is the purpose of the change
Collect "cpu.user" for load balancer statistics
Verifying this change
Run CpuUsageServiceImplTest.java
Follow this checklist to help us incorporate your contribution quickly and easily:
[Dubbo-XXX] Fix UnknownException when host config not exist #XXX
. Each commit in the pull request should have a meaningful subject line and body.mvn clean install -DskipTests=false
&mvn clean test-compile failsafe:integration-test
to make sure unit-test and integration-test pass.