@Test public void testMemberRemoved() throws Exception { HazelcastClient client = mock(HazelcastClient.class); InetSocketAddress inetSocketAddress = new InetSocketAddress("localhost", 5701); final Connection connection = mock(Connection.class); final List<LifecycleState> lifecycleEvents = new ArrayList<LifecycleState>(); final LifecycleServiceClientImpl lifecycleService = createLifecycleServiceClientImpl(client, lifecycleEvents); ClientConfig clientConfig = new ClientConfig(); clientConfig.setCredentials(credentials).addInetSocketAddress(inetSocketAddress).setConnectionTimeout(60000); ConnectionManager connectionManager = new ConnectionManager(client, clientConfig, lifecycleService) { protected Connection getNextConnection() { return connection; } }; ClientBinder binder = mock(ClientBinder.class); connectionManager.setBinder(binder); Cluster cluster = mock(Cluster.class); Member member = mock(Member.class); when(member.getInetSocketAddress()).thenReturn(inetSocketAddress); MembershipEvent membershipEvent = new MembershipEvent(cluster, member, MembershipEvent.MEMBER_REMOVED); connectionManager.memberRemoved(membershipEvent); assertEquals(0, connectionManager.getClusterMembers().size()); assertArrayEquals(new Object[0], lifecycleEvents.toArray()); }
public void memberRemoved(MembershipEvent membershipEvent) { InetSocketAddress address = membershipEvent.getMember().getInetSocketAddress(); Collection<InetSocketAddress> addresses = AddressHelper.getPossibleSocketAddresses(address.getAddress(), address.getPort()); clusterMembers.removeAll(addresses); }
ConnectionManager implements MembershipListener { public void memberRemoved(MembershipEvent membershipEvent) { InetSocketAddress address = membershipEvent.getMember().getInetSocketAddress(); Collection<InetSocketAddress> addresses = AddressHelper.getPossibleSocketAddresses(address.getAddress(), address.getPort()); clusterMembers.removeAll(addresses); } }
ConnectionManager implements MembershipListener { public void memberRemoved(MembershipEvent membershipEvent) { InetSocketAddress address = membershipEvent.getMember().getInetSocketAddress(); Collection<InetSocketAddress> addresses = AddressHelper.getPossibleSocketAddresses(address.getAddress(), address.getPort()); clusterMembers.removeAll(addresses); } ConnectionManager(HazelcastClient client, ClientConfig config, LifecycleServiceClientImpl lifecycleService); }
ConnectionManager implements MembershipListener { public void memberRemoved(MembershipEvent membershipEvent) { InetSocketAddress address = membershipEvent.getMember().getInetSocketAddress(); Collection<InetSocketAddress> addresses = AddressHelper.getPossibleSocketAddresses(address.getAddress(), address.getPort()); clusterMembers.removeAll(addresses); } ConnectionManager(HazelcastClient client, ClientConfig config, LifecycleServiceClientImpl lifecycleService); Connection getInitConnection(); Connection lookForLiveConnection(); Connection getConnection(); void destroyConnection(final Connection connection); void memberAdded(MembershipEvent membershipEvent); void memberRemoved(MembershipEvent membershipEvent); void updateMembers(); boolean shouldExecuteOnDisconnect(Connection connection); void setBinder(ClientBinder binder); void shutdown(); }
ConnectionManager implements MembershipListener { public void memberRemoved(MembershipEvent membershipEvent) { InetSocketAddress address = membershipEvent.getMember().getInetSocketAddress(); Collection<InetSocketAddress> addresses = AddressHelper.getPossibleSocketAddresses(address.getAddress(), address.getPort()); clusterMembers.removeAll(addresses); } ConnectionManager(HazelcastClient client, ClientConfig config, LifecycleServiceClientImpl lifecycleService); Connection getInitConnection(); Connection lookForLiveConnection(); Connection getConnection(); void destroyConnection(final Connection connection); void memberAdded(MembershipEvent membershipEvent); void memberRemoved(MembershipEvent membershipEvent); void updateMembers(); boolean shouldExecuteOnDisconnect(Connection connection); void setBinder(ClientBinder binder); void shutdown();  }