Skip to content

Commit

Permalink
static test to avoid reinitialization
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro committed Sep 7, 2011
1 parent 3012a1e commit 87cbe5d
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/org/datanucleus/store/cassandra/CassandraConnectionInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,17 @@

public class CassandraConnectionInfo {

private Map<String, Integer> ring_connections;
private String keyspace;
private static Map<String, Integer> ring_connections;
private static String keyspace;

private static boolean intialized = false;

public CassandraConnectionInfo(PersistenceConfiguration conf) {

if(intialized){
return;
}

ring_connections = new TreeMap<String, Integer>();

String url = conf.getStringProperty("datanucleus.ConnectionURL");
Expand Down Expand Up @@ -168,16 +174,19 @@ public CassandraConnectionInfo(PersistenceConfiguration conf) {
.describe_ring(keyspace);
for (TokenRange tr : ring) {
List<String> endpoints = tr.endpoints;
for (String enpoint : endpoints) {
ring_connections.put(enpoint, endpoint_port);
for (String endpoint : endpoints) {
if(!ring_connections.containsKey(endpoint)){
//System.out.println("New node connection->"+endpoint+":"+endpoint_port);
ring_connections.put(endpoint, endpoint_port);
}
}
}
} catch (TException e) {
throw new NucleusDataStoreException(e.getMessage(), e);
}

}

intialized = true;
}

public Map<String, Integer> getConnections() {
Expand Down

0 comments on commit 87cbe5d

Please sign in to comment.