cassandraHostConfigurator.setRetryDownedHostsDelayInSeconds(retryDelay);
@Test public void testOnHostRestored() throws InterruptedException { cassandraHostConfigurator = new CassandraHostConfigurator("127.0.0.1:9170"); cassandraHostConfigurator.setRetryDownedHostsDelayInSeconds(1); cassandraHostConfigurator.setRetryDownedHosts(true); connectionManager = new HConnectionManager(clusterName,cassandraHostConfigurator); final CassandraHost host = new CassandraHost("127.0.0.1", 9170); final boolean[] eventFired = {false}; connectionManager.addListener(listenerName, new ConnectionManagerEmptyListener() { @Override public void onHostRestored(CassandraHost cassandraHost) { assertEquals(cassandraHost, host); eventFired[0] = true; } }); connectionManager.markHostAsDown(host); Thread.sleep(1100); assertTrue(eventFired[0]); }
cassandraHostConfigurator.setRetryDownedHostsDelayInSeconds(retryDelay);
cassandraHostConfigurator.setRetryDownedHostsDelayInSeconds(retryDelay);
protected void init(String clustername, String hosts, String username, String password, String keyspace) { CassandraHostConfigurator hostconfig = new CassandraHostConfigurator(hosts); hostconfig.setRetryDownedHosts(true); hostconfig.setRetryDownedHostsDelayInSeconds(5); hostconfig.setRetryDownedHostsQueueSize(-1); // no bounds this.cluster = HFactory.getOrCreateCluster(clustername, hostconfig); Map<String,String> credentials = new HashMap<String, String>(); if (username != null && username.length() > 0) { credentials.put("username", username); credentials.put("password", password); } this.keyspace = HFactory.createKeyspace( keyspace, cluster, new AllOneConsistencyLevelPolicy(), FailoverPolicy.ON_FAIL_TRY_ALL_AVAILABLE); }
config.setRetryDownedHostsDelayInSeconds(configuration.getAttribute(RETRY_DOWNED_HOSTS_DELAY_IN_SECONDS, Integer.valueOf(10))); config.setRetryDownedHostsQueueSize(configuration.getAttribute(RETRY_DOWNED_HOSTS_QUEUE_SIZE, Integer.valueOf(256)));
config.setRetryDownedHostsDelayInSeconds(configuration.getAttribute(RETRY_DOWNED_HOSTS_DELAY_IN_SECONDS, Integer.valueOf(10))); config.setRetryDownedHostsQueueSize(configuration.getAttribute(RETRY_DOWNED_HOSTS_QUEUE_SIZE, Integer.valueOf(256)));
cassandraHostConfigurator.setRetryDownedHostsDelayInSeconds(getIntValueOrExit(cmd, "retry-delay"));