@Test public void testShouldExecuteOnDisconnect() 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; } }; assertTrue(connectionManager.shouldExecuteOnDisconnect(connection)); assertFalse(connectionManager.shouldExecuteOnDisconnect(connection)); assertArrayEquals(new Object[0], lifecycleEvents.toArray()); }
public boolean shouldExecuteOnDisconnect(Connection connection) { if (connection == null || lastDisconnectedConnectionId >= connection.getVersion()) { return false; } lastDisconnectedConnectionId = connection.getVersion(); return true; }
ConnectionManager implements MembershipListener { public boolean shouldExecuteOnDisconnect(Connection connection) { if (connection == null || lastDisconnectedConnectionId >= connection.getVersion()) { return false; } lastDisconnectedConnectionId = connection.getVersion(); return true; } }
ConnectionManager implements MembershipListener { public boolean shouldExecuteOnDisconnect(Connection connection) { if (connection == null || lastDisconnectedConnectionId >= connection.getVersion()) { return false; } lastDisconnectedConnectionId = connection.getVersion(); return true; } ConnectionManager(HazelcastClient client, ClientConfig config, LifecycleServiceClientImpl lifecycleService); }
ConnectionManager implements MembershipListener { public boolean shouldExecuteOnDisconnect(Connection connection) { if (connection == null || lastDisconnectedConnectionId >= connection.getVersion()) { return false; } lastDisconnectedConnectionId = connection.getVersion(); return true; } 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 boolean shouldExecuteOnDisconnect(Connection connection) { if (connection == null || lastDisconnectedConnectionId >= connection.getVersion()) { return false; } lastDisconnectedConnectionId = connection.getVersion(); return true; } 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();  }