Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
51 additions
and
1 deletion.
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,50 @@ | |||
package codehead; | |||
|
|||
import me.prettyprint.hector.api.Cluster; | |||
import me.prettyprint.hector.api.Keyspace; | |||
import me.prettyprint.hector.api.factory.HFactory; | |||
|
|||
public class KeyspaceHolder extends ThreadLocal <Keyspace>{ | |||
|
|||
private String clusterName="Test Cluster"; | |||
private String keyspaceName="Keyspace1"; | |||
private String servers="localhost:9160"; | |||
|
|||
protected Keyspace initialValue() { | |||
return HFactory.createKeyspace(keyspaceName, getCluster()); | |||
} | |||
|
|||
/** | |||
* Returns the hector cluster object | |||
* @return | |||
*/ | |||
public Cluster getCluster(){ | |||
return HFactory.getOrCreateCluster(clusterName, servers); | |||
} | |||
|
|||
public String getClusterName() { | |||
return clusterName; | |||
} | |||
|
|||
public void setClusterName(String clusterName) { | |||
this.clusterName = clusterName; | |||
} | |||
|
|||
public String getKeyspaceName() { | |||
return keyspaceName; | |||
} | |||
|
|||
public void setKeyspaceName(String keyspaceName) { | |||
this.keyspaceName = keyspaceName; | |||
} | |||
|
|||
public String getServers() { | |||
return servers; | |||
} | |||
|
|||
public void setServers(String servers) { | |||
this.servers = servers; | |||
} | |||
|
|||
|
|||
} |