-
Notifications
You must be signed in to change notification settings - Fork 26.5k
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
Fix FailbackClusterInvoker one risk of memory leak #2425 #2822
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
5bbbd00
1.limit the size of the map,default is 1000. can config by key failca…
c5b5a1f
Repair naming and Reset the default size
7eaae16
Repair naming
f52c994
Single thread
61cf8b3
1.limit the size of the map,default is 1000. can config by key failca…
4b2e229
Repair naming and Reset the default size
2d6c948
Repair naming
c3d4aec
Single thread
200c350
1.fix the problem:the retry need invoke select,not Cluster start;
841f5ba
Ensure that the main thread is online
ef6a345
main thread 30s
faa2186
1.limit the size of the map,default is 1000. can config by key failca…
aafdcdf
Repair naming and Reset the default size
57cadf9
Repair naming
c381a0e
Single thread
1c2f608
1.limit the size of the map,default is 1000. can config by key failca…
011c1f1
Repair naming and Reset the default size
f2fd7bb
Repair naming
fa0a8b0
Single thread
5f5b27c
1.fix the problem:the retry need invoke select,not Cluster start;
5a7f4bf
Ensure that the main thread is online
c617a6c
main thread 30s
c132209
update test case
8bcf19a
update test case
16cff62
Modifying the execution priority of test cases
3eaf6ec
clear log
4a8957a
add doc
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
package org.apache.dubbo.rpc.cluster.support; | ||
|
||
import org.apache.dubbo.common.URL; | ||
import org.apache.dubbo.common.utils.DubboAppender; | ||
import org.apache.dubbo.common.utils.LogUtil; | ||
import org.apache.dubbo.rpc.Invoker; | ||
import org.apache.dubbo.rpc.Result; | ||
|
@@ -25,22 +26,32 @@ | |
import org.apache.dubbo.rpc.RpcResult; | ||
import org.apache.dubbo.rpc.cluster.Directory; | ||
|
||
import org.apache.log4j.Level; | ||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.FixMethodOrder; | ||
import org.junit.Test; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.concurrent.CountDownLatch; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.mockito.BDDMockito.given; | ||
import static org.mockito.Mockito.mock; | ||
|
||
/** | ||
* FailbackClusterInvokerTest | ||
* | ||
* add annotation @FixMethodOrder, the testARetryFailed Method must to first execution | ||
*/ | ||
@SuppressWarnings("unchecked") | ||
@FixMethodOrder(org.junit.runners.MethodSorters.NAME_ASCENDING) | ||
public class FailbackClusterInvokerTest { | ||
|
||
List<Invoker<FailbackClusterInvokerTest>> invokers = new ArrayList<Invoker<FailbackClusterInvokerTest>>(); | ||
URL url = URL.valueOf("test://test:11/test"); | ||
URL url = URL.valueOf("test://test:11/test?retries=2&failbacktasks=2"); | ||
Invoker<FailbackClusterInvokerTest> invoker = mock(Invoker.class); | ||
RpcInvocation invocation = new RpcInvocation(); | ||
Directory<FailbackClusterInvokerTest> dic; | ||
|
@@ -76,16 +87,17 @@ private void resetInvokerToNoException() { | |
} | ||
|
||
@Test | ||
public void testInvokeExceptoin() { | ||
public void testInvokeException() { | ||
resetInvokerToException(); | ||
FailbackClusterInvoker<FailbackClusterInvokerTest> invoker = new FailbackClusterInvoker<FailbackClusterInvokerTest>( | ||
dic); | ||
invoker.invoke(invocation); | ||
Assert.assertNull(RpcContext.getContext().getInvoker()); | ||
DubboAppender.clear(); | ||
} | ||
|
||
@Test() | ||
public void testInvokeNoExceptoin() { | ||
public void testInvokeNoException() { | ||
|
||
resetInvokerToNoException(); | ||
|
||
|
@@ -112,21 +124,34 @@ public void testNoInvoke() { | |
FailbackClusterInvoker<FailbackClusterInvokerTest> invoker = new FailbackClusterInvoker<FailbackClusterInvokerTest>( | ||
dic); | ||
LogUtil.start(); | ||
DubboAppender.clear(); | ||
invoker.invoke(invocation); | ||
assertEquals(1, LogUtil.findMessage("Failback to invoke")); | ||
LogUtil.stop(); | ||
} | ||
|
||
@Test() | ||
public void testRetryFailed() { | ||
public void testARetryFailed() throws Exception { | ||
//Test retries and | ||
|
||
resetInvokerToException(); | ||
|
||
FailbackClusterInvoker<FailbackClusterInvokerTest> invoker = new FailbackClusterInvoker<FailbackClusterInvokerTest>( | ||
dic); | ||
LogUtil.start(); | ||
DubboAppender.clear(); | ||
invoker.invoke(invocation); | ||
invoker.invoke(invocation); | ||
invoker.invoke(invocation); | ||
Assert.assertNull(RpcContext.getContext().getInvoker()); | ||
invoker.retryFailed();// when retry the invoker which get from failed map already is not the mocked invoker,so | ||
// invoker.retryFailed();// when retry the invoker which get from failed map already is not the mocked invoker,so | ||
//Ensure that the main thread is online | ||
CountDownLatch countDown = new CountDownLatch(1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think u should assert that the logger contains the specific msg. |
||
countDown.await(15000L, TimeUnit.MILLISECONDS); | ||
LogUtil.stop(); | ||
Assert.assertEquals("must have four error message ", 4, LogUtil.findMessage(Level.ERROR, "Failed retry to invoke method")); | ||
Assert.assertEquals("must have two error message ", 2, LogUtil.findMessage(Level.ERROR, "Failed retry times exceed threshold")); | ||
Assert.assertEquals("must have one error message ", 1, LogUtil.findMessage(Level.ERROR, "Failback background works error")); | ||
// it can be invoke successfully | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could u pls tell us why u rename the method and why u add the FixMethodOrder annotation?
:)