Skip to content

Commit

Permalink
cleanup of overloaded methods for createCluster, getOrCreateCluster. …
Browse files Browse the repository at this point in the history
…Addresses issue #376
  • Loading branch information
zznate committed Dec 28, 2011
1 parent 93f16f9 commit 7d9b2ce
Showing 1 changed file with 18 additions and 21 deletions.
39 changes: 18 additions & 21 deletions core/src/main/java/me/prettyprint/hector/api/factory/HFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,45 +129,42 @@ public static Cluster getOrCreateCluster(String clusterName, String hostIp) {
new CassandraHostConfigurator(hostIp));
}

/**
* Calls the three argument version with a null credentials map.
* {@link #getOrCreateCluster(String, me.prettyprint.cassandra.service.CassandraHostConfigurator, java.util.Map)}
* for details.
*/
public static Cluster getOrCreateCluster(String clusterName,
CassandraHostConfigurator cassandraHostConfigurator) {
return createCluster(clusterName, cassandraHostConfigurator, null);
}

/**
* Method tries to create a Cluster instance for an existing Cassandra
* cluster. If another class already called getOrCreateCluster, the factory
* returns the cached instance. If the instance doesn't exist in memory, a new
* ThriftCluster is created and cached.
*
*
* Example usage for a default installation of Cassandra.
*
*
* String clusterName = "Test Cluster"; String host = "localhost:9160";
* Cluster cluster = HFactory.getOrCreateCluster(clusterName, new
* CassandraHostConfigurator(host));
*
*
* @param clusterName
* The cluster name. This is an identifying string for the cluster,
* e.g. "production" or "test" etc. Clusters will be created on
* demand per each unique clusterName key.
* @param cassandraHostConfigurator
* @param credentials The credentials map for authenticating a Keyspace
*/
public static Cluster getOrCreateCluster(String clusterName,
CassandraHostConfigurator cassandraHostConfigurator) {
synchronized (clusters) {
Cluster c = clusters.get(clusterName);
if (c == null) {
c = createCluster(clusterName, cassandraHostConfigurator);
clusters.put(clusterName, c);
}
return c;
}
CassandraHostConfigurator cassandraHostConfigurator, Map<String, String> credentials) {
return createCluster(clusterName, cassandraHostConfigurator, credentials);
}

/**
* Method looks in the cache for the cluster by name. If none exists, a new
* ThriftCluster instance is created.
*
* @param clusterName
* The cluster name. This is an identifying string for the cluster,
* e.g. "production" or "test" etc. Clusters will be created on
* demand per each unique clusterName key.
* @param cassandraHostConfigurator
* @deprecated use getOrCreateCluster instead
*
*/
public static Cluster createCluster(String clusterName,
Expand All @@ -177,7 +174,7 @@ public static Cluster createCluster(String clusterName,

/**
* Method looks in the cache for the cluster by name. If none exists, a new
* ThriftCluster instance is created.
* ThriftCluster instance is created and added to the map of known clusters
*
* @param clusterName
* The cluster name. This is an identifying string for the cluster,
Expand Down

0 comments on commit 7d9b2ce

Please sign in to comment.