Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
simplified connection on retry service, nodediscovery service is func…
…tionalbut off by default
- Loading branch information
zznate
committed
Nov 14, 2010
1 parent
1aa5740
commit 3e11c65
Showing
6 changed files
with
33 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,7 @@ public class NodeAutoDiscoverService extends BackgroundCassandraHostService { | |
|
||
public NodeAutoDiscoverService(HConnectionManager connectionManager, | ||
CassandraHostConfigurator cassandraHostConfigurator) { | ||
super(connectionManager, cassandraHostConfigurator); | ||
super(connectionManager, cassandraHostConfigurator); | ||
This comment has been minimized.
Sorry, something went wrong. |
||
sf = executor.scheduleWithFixedDelay(new QueryRing(), this.retryDelayInSeconds,this.retryDelayInSeconds, TimeUnit.SECONDS); | ||
} | ||
|
||
|
@@ -42,7 +42,7 @@ void shutdown() { | |
} | ||
|
||
public void applyRetryDelay() { | ||
|
||
// no op for now | ||
} | ||
|
||
class QueryRing implements Runnable { | ||
|
@@ -67,23 +67,24 @@ public void run() { | |
|
||
} | ||
|
||
private Set<CassandraHost> discoverNodes() { | ||
public Set<CassandraHost> discoverNodes() { | ||
Set<CassandraHost> existingHosts = connectionManager.getHosts(); | ||
Set<CassandraHost> foundHosts = new HashSet<CassandraHost>(); | ||
TTransport tr = cassandraHost.getUseThriftFramedTransport() ? | ||
new TFramedTransport(new TSocket(cassandraHost.getHost(), cassandraHost.getPort(), 10)) : | ||
new TSocket(cassandraHost.getHost(), cassandraHost.getPort(), 10); | ||
|
||
TProtocol proto = new TBinaryProtocol(tr); | ||
Cassandra.Client client = new Cassandra.Client(proto); | ||
HThriftClient thriftClient = null; | ||
try { | ||
tr.open(); | ||
List<TokenRange> tokens = client.describe_ring("System"); | ||
thriftClient = connectionManager.borrowClient(); | ||
List<TokenRange> tokens = thriftClient.getCassandra().describe_ring("System"); | ||
for (TokenRange tokenRange : tokens) { | ||
if ( log.isDebugEnabled() ) { | ||
log.debug("Looking over TokenRange {} for new hosts", tokenRange); | ||
} | ||
List<String> endpoints = tokenRange.getEndpoints(); | ||
for (String endpoint : endpoints) { | ||
CassandraHost foundHost = new CassandraHost(endpoint,cassandraHostConfigurator.getPort()); | ||
if ( !existingHosts.contains(foundHost) ) { | ||
log.info("Found a node we don't know about {} for TokenRange {}", foundHost, tokenRange); | ||
foundHosts.add(foundHost); | ||
} | ||
} | ||
|
@@ -92,7 +93,7 @@ private Set<CassandraHost> discoverNodes() { | |
} catch (Exception e) { | ||
//log.error("Downed Host retry failed attempt to verify CassandraHost", e); | ||
This comment has been minimized.
Sorry, something went wrong.
rantav
Collaborator
|
||
} finally { | ||
tr.close(); | ||
connectionManager.releaseClient(thriftClient); | ||
} | ||
return foundHosts; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Perhaps rename this to DEFAULT_RETRY_DELAY_SEC