Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Commit

Permalink
do host up check asynchronously
Browse files Browse the repository at this point in the history
  • Loading branch information
sbridges committed Jul 11, 2011
1 parent c5d468e commit 06e1fe3
Showing 1 changed file with 13 additions and 10 deletions.
Expand Up @@ -10,16 +10,11 @@
import me.prettyprint.cassandra.service.CassandraHost;
import me.prettyprint.cassandra.service.CassandraHostConfigurator;
import me.prettyprint.cassandra.service.ExceptionsTranslator;
import me.prettyprint.hector.api.exceptions.HCassandraInternalException;
import me.prettyprint.hector.api.exceptions.HectorException;
import me.prettyprint.hector.api.exceptions.HectorTransportException;

import org.apache.thrift.transport.TTransportException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.collect.Sets;

public class CassandraHostRetryService extends BackgroundCassandraHostService {

private static Logger log = LoggerFactory.getLogger(CassandraHostRetryService.class);
Expand Down Expand Up @@ -56,15 +51,23 @@ void shutdown() {
log.info("Downed Host retry shutdown complete");
}

public void add(CassandraHost cassandraHost) {
if(verifyConnection(cassandraHost)) {
connectionManager.addCassandraHost(cassandraHost);
return;
}
public void add(final CassandraHost cassandraHost) {
downedHostQueue.add(cassandraHost);
if ( log.isInfoEnabled() ) {
log.info("Host detected as down was added to retry queue: {}", cassandraHost.getName());
}

//schedule a check of this host immediately,
executor.submit(new Runnable() {
@Override
public void run() {
if(verifyConnection(cassandraHost)) {
connectionManager.addCassandraHost(cassandraHost);
downedHostQueue.remove(cassandraHost);
return;
}
}
});
}

public boolean remove(CassandraHost cassandraHost) {
Expand Down

0 comments on commit 06e1fe3

Please sign in to comment.