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

Update last address #665

Merged
merged 1 commit into from
Jun 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,7 @@ protected Map<ProviderInfo, ClientTransport> clearProviders() {
aliveConnections.clear();
retryConnections.clear();
uninitializedConnections.clear();
lastAddresses.clear();
return all;
} finally {
providerLock.unlock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,36 @@ public void getAvailableClientTransport3() throws Exception {

consumerConfig.unRefer();
}

@Test
public void getAvailableClientTransport4() throws Exception {
ConsumerConfig<HelloService> consumerConfig = new ConsumerConfig<HelloService>()
.setInterfaceId(HelloService.class.getName())
.setDirectUrl("bolt://127.0.0.1:22223,bolt://127.0.0.1:22224")
.setConnectionHolder("all")
.setRegister(false)
.setLazy(true)
.setTimeout(3000);
HelloService helloService = consumerConfig.refer();
ClientProxyInvoker invoker = (ClientProxyInvoker) ProxyFactory.getInvoker(helloService,
consumerConfig.getProxy());
Cluster cluster = invoker.getCluster();
Assert.assertTrue(cluster.getConnectionHolder() instanceof AllConnectConnectionHolder);
AllConnectConnectionHolder holder = (AllConnectConnectionHolder) cluster.getConnectionHolder();

ProviderGroup providerGroups = new ProviderGroup();
providerGroups.add(ProviderHelper.toProviderInfo("bolt://127.0.0.1:22223"));
providerGroups.add(ProviderHelper.toProviderInfo("bolt://127.0.0.1:22224"));
holder.updateProviders(providerGroups);
Set<ProviderInfo> last = holder.currentProviderList();
Assert.assertEquals(2, last.size());

ProviderGroup providerGroups2 = new ProviderGroup();
holder.updateProviders(providerGroups2);
Set<ProviderInfo> current = holder.currentProviderList();

Assert.assertEquals(0, current.size());

consumerConfig.unRefer();
}
}