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

[Dubbo-2187] Use CompletetableFuture to rewrite the embedded ListenableFuture #2213

Merged
merged 15 commits into from
Aug 13, 2018

Conversation

dengwanghua
Copy link
Contributor

What is the purpose of the change

Solve Issue #2187, Use CompletetableFuture to rewrite the embedded ListenableFuture

Brief changelog

  • delete org.apache.dubbo.common.concurrent.ListenableFuture
  • delete org.apache.dubbo.common.concurrent.ListenableFutureTask
  • delete org.apache.dubbo.common.concurrent.ListenableFutureTaskTest
  • add org.apache.dubbo.common.concurrent.CompletableFutureTaskTest
  • modify org.apache.dubbo.monitor.support.AbstractMonitorFactory
  • modify org.apache.dubbo.remoting.zookeeper.zkclient.ZkClientWrapper

Verifying this change

  • org.apache.dubbo.common.concurrent.CompletableFutureTaskTest test passed
  • Exsiting unit-test and intergration-test passed

Follow this checklist to help us incorporate your contribution quickly and easily:

  • Make sure there is a GITHUB_issue filed for the change (usually before you start working on it). Trivial changes like typos do not require a GITHUB issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
  • Format the pull request title like [Dubbo-XXX] Fix UnknownException when host config not exist #XXX. Each commit in the pull request should have a meaningful subject line and body.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add integration-test in test module.
  • Run mvn clean install -DskipTests & mvn clean test-compile failsafe:integration-test to make sure unit-test and integration-test pass.
  • If this contribution is large, please follow the Software Donation Guide.

}

public void start() {
if (!started) {
Thread connectThread = new Thread(listenableFutureTask);
Thread connectThread = new Thread();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Thread connectThread = new Thread(); is no longer needed here, because we already started ZkClient in an async thread by invoking CompletableFuture.supplyAsync

Copy link
Contributor

@chickenlj chickenlj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides, there are UT failures.

Failed tests: 
  CompletableFutureTaskTest.testCustomExecutor:90 
Wanted but not invoked:
executor.execute(<any java.lang.Runnable>);
-> at org.apache.dubbo.common.concurrent.CompletableFutureTaskTest.testCustomExecutor(CompletableFutureTaskTest.java:90)
Actually, there were zero interactions with this mock.

return newMonitor;

},executor);
completableFuture.thenRunAsync(new MonitorListener(key));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already defined an executor, specify this executor for thenRunAsync may be better.

@@ -75,11 +71,11 @@ public void start() {
}

public void addListener(final IZkStateListener listener) {
listenableFutureTask.addListener(new Runnable() {
completableFuture.thenRunAsync(new Runnable() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whenComplete or handle maybe better, and try to use lambda.

}
completableFuture.whenComplete((v,e)->{
client = v;
client.subscribeStateChanges(listener);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should handle the possible Exceptions that may come up here.

@dengwanghua
Copy link
Contributor Author

I can‘t find the reasons for failed,but test unit is success in local

@chickenlj
Copy link
Contributor

@dengwanghua
Here' s the stack trace. Bad imports.

src/main/java/org/apache/dubbo/monitor/support/AbstractMonitorFactory.java:[31] (imports) AvoidStarImport: Using the '.' form of import should be avoided - java.util.concurrent..

@chickenlj
Copy link
Contributor

 public void addListener(final IZkStateListener listener) {
        completableFuture.whenComplete((v,e)->{
            client = v;
            client.subscribeStateChanges(listener);

        });
    }

I think we should consider possible Exceptions that may come up here.

dengwanghua and others added 7 commits August 10, 2018 15:13
…ure/1_2187

# Conflicts:
#	dubbo-monitor/dubbo-monitor-api/src/main/java/org/apache/dubbo/monitor/support/AbstractMonitorFactory.java
#	dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/zkclient/ZkClientWrapper.java
@chickenlj chickenlj merged commit 1c16f78 into apache:master Aug 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/waiting-for-feedback Need reporters to triage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants