@Override protected void onReconnection(Connection connection) { // Make sure we have up-to-date infos on that host before adding it (so we typically // catch that an upgraded node uses a new cassandra version). if (controlConnection.refreshNodeInfo(host)) { logger.debug("Successful reconnection to {}, setting host UP", host); try { if (isHostAddition) { onAdd(host, connection); submitNodeListRefresh(); } else onUp(host, connection); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } catch (Exception e) { logger.error("Unexpected error while setting node up", e); } } else { logger.debug("Not enough info for {}, ignoring host", host); connection.closeAsync(); } }
@Override public void runMayThrow() throws Exception { if (controlConnection.refreshNodeInfo(host)) { onAdd(host, null); submitNodeListRefresh(); } else { logger.debug("Not enough info for {}, ignoring host", host); } } };
@Override public void runMayThrow() throws Exception { if (metadata.remove(host)) { logger.info("Cassandra host {} removed", host); onRemove(host); submitNodeListRefresh(); } } };
Futures.addCallback(manager.submitNodeListRefresh(), new MoreFutures.SuccessCallback<Void>() { @Override public void onSuccess(Void result) {
Futures.addCallback(manager.submitNodeListRefresh(), new MoreFutures.SuccessCallback<Void>() { @Override public void onSuccess(Void result) {
/** * Tests that settings for a debouncer can be modified dynamically without requiring the cluster * to be restarted. * * @throws InterruptedException * @jira_ticket JAVA-1192 */ @CCMConfig(numberOfNodes = 1) @Test(groups = "short") public void should_change_debouncer_settings_dynamically() throws InterruptedException { // Create a spy of the Cluster's control connection and replace it with the spy. ControlConnection controlConnection = spy(cluster().manager.controlConnection); cluster().manager.controlConnection = controlConnection; for (int i = 0; i < 10; i++) { cluster().manager.submitNodeListRefresh(); Thread.sleep(100); } // all requests should be coalesced into a single one verify(controlConnection, timeout(10000)).refreshNodeListAndTokenMap(); reset(controlConnection); // disable debouncing cluster().getConfiguration().getQueryOptions().setRefreshNodeListIntervalMillis(0); for (int i = 0; i < 10; i++) { cluster().manager.submitNodeListRefresh(); Thread.sleep(100); } // each request should have been handled separately verify(controlConnection, timeout(10000).times(10)).refreshNodeListAndTokenMap(); }
@Override protected void onReconnection(Connection connection) { // Make sure we have up-to-date infos on that host before adding it (so we typically // catch that an upgraded node uses a new cassandra version). if (controlConnection.refreshNodeInfo(host)) { logger.debug("Successful reconnection to {}, setting host UP", host); try { if (isHostAddition) { onAdd(host, connection); submitNodeListRefresh(); } else onUp(host, connection); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } catch (Exception e) { logger.error("Unexpected error while setting node up", e); } } else { logger.debug("Not enough info for {}, ignoring host", host); connection.closeAsync(); } }
@Override protected void onReconnection(Connection connection) { // Make sure we have up-to-date infos on that host before adding it (so we typically // catch that an upgraded node uses a new cassandra version). if (controlConnection.refreshNodeInfo(host)) { logger.debug("Successful reconnection to {}, setting host UP", host); try { if (isHostAddition) { onAdd(host, connection); submitNodeListRefresh(); } else onUp(host, connection); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } catch (Exception e) { logger.error("Unexpected error while setting node up", e); } } else { logger.debug("Not enough info for {}, ignoring host", host); connection.closeAsync(); } }
@Override protected void onReconnection(Connection connection) { // Make sure we have up-to-date infos on that host before adding it (so we typically // catch that an upgraded node uses a new cassandra version). if (controlConnection.refreshNodeInfo(host)) { logger.debug("Successful reconnection to {}, setting host UP", host); try { if (isHostAddition) { onAdd(host, connection); submitNodeListRefresh(); } else onUp(host, connection); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } catch (Exception e) { logger.error("Unexpected error while setting node up", e); } } else { logger.debug("Not enough info for {}, ignoring host", host); connection.closeAsync(); } }
/** * Ensures that when enough refreshNodeList requests have been received to reach {@link * QueryOptions#getMaxPendingRefreshNodeListRequests()} that a node list refresh is submitted * right away. * * @jira_ticket JAVA-657 * @since 2.0.11 */ @Test(groups = "short") public void should_refresh_when_max_pending_requests_reached() { for (int i = 0; i < 5; i++) { cluster2.manager.submitNodeListRefresh(); } // add delay to account for executor submit. verify(controlConnection, timeout(DEBOUNCE_TIME)).refreshNodeListAndTokenMap(); } }
@Override public void runMayThrow() throws Exception { if (metadata.remove(host)) { logger.info("Cassandra host {} removed", host); onRemove(host); submitNodeListRefresh(); } } };
@Override public void runMayThrow() throws Exception { if (controlConnection.refreshNodeInfo(host)) { onAdd(host, null); submitNodeListRefresh(); } else { logger.debug("Not enough info for {}, ignoring host", host); } } };
@Override public void runMayThrow() throws Exception { if (controlConnection.refreshNodeInfo(host)) { onAdd(host, null); submitNodeListRefresh(); } else { logger.debug("Not enough info for {}, ignoring host", host); } } };
@Override public void runMayThrow() throws Exception { if (metadata.remove(host)) { logger.info("Cassandra host {} removed", host); onRemove(host); submitNodeListRefresh(); } } };
@Override public void runMayThrow() throws Exception { if (controlConnection.refreshNodeInfo(host)) { onAdd(host, null); submitNodeListRefresh(); } else { logger.debug("Not enough info for {}, ignoring host", host); } } };
@Override public void runMayThrow() throws Exception { if (metadata.remove(host)) { logger.info("Cassandra host {} removed", host); onRemove(host); submitNodeListRefresh(); } } };
break; case MOVED_NODE: submitNodeListRefresh(); break;
manager.submitNodeListRefresh(), new MoreFutures.SuccessCallback<Void>() { @Override
/** * Tests that settings for a debouncer can be modified dynamically without requiring the cluster * to be restarted. * * @throws InterruptedException * @jira_ticket JAVA-1192 */ @CCMConfig(numberOfNodes = 1) @Test(groups = "short") public void should_change_debouncer_settings_dynamically() throws InterruptedException { // Create a spy of the Cluster's control connection and replace it with the spy. ControlConnection controlConnection = spy(cluster().manager.controlConnection); cluster().manager.controlConnection = controlConnection; for (int i = 0; i < 10; i++) { cluster().manager.submitNodeListRefresh(); Thread.sleep(100); } // all requests should be coalesced into a single one verify(controlConnection, timeout(10000)).refreshNodeListAndTokenMap(); reset(controlConnection); // disable debouncing cluster().getConfiguration().getQueryOptions().setRefreshNodeListIntervalMillis(0); for (int i = 0; i < 10; i++) { cluster().manager.submitNodeListRefresh(); Thread.sleep(100); } // each request should have been handled separately verify(controlConnection, timeout(10000).times(10)).refreshNodeListAndTokenMap(); }
/** * Ensures that when enough refreshNodeList requests have been received to reach {@link * QueryOptions#getMaxPendingRefreshNodeListRequests()} that a node list refresh is submitted * right away. * * @jira_ticket JAVA-657 * @since 2.0.11 */ @Test(groups = "short") public void should_refresh_when_max_pending_requests_reached() { for (int i = 0; i < 5; i++) { cluster2.manager.submitNodeListRefresh(); } // add delay to account for executor submit. verify(controlConnection, timeout(DEBOUNCE_TIME)).refreshNodeListAndTokenMap(); } }