Two main updates:
Astyanax dependency version updated Keyspace reference is now unique git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portal/social-networking-library@121704 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
567713d064
commit
eda8fce8f6
1
pom.xml
1
pom.xml
|
@ -45,6 +45,7 @@
|
|||
<dependency>
|
||||
<groupId>com.netflix.astyanax</groupId>
|
||||
<artifactId>astyanax</artifactId>
|
||||
<version>1.56.26</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.resources.discovery</groupId>
|
||||
|
|
|
@ -14,6 +14,7 @@ import com.netflix.astyanax.connectionpool.NodeDiscoveryType;
|
|||
import com.netflix.astyanax.connectionpool.OperationResult;
|
||||
import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
|
||||
import com.netflix.astyanax.connectionpool.impl.ConnectionPoolConfigurationImpl;
|
||||
import com.netflix.astyanax.connectionpool.impl.ConnectionPoolType;
|
||||
import com.netflix.astyanax.connectionpool.impl.CountingConnectionPoolMonitor;
|
||||
import com.netflix.astyanax.ddl.ColumnDefinition;
|
||||
import com.netflix.astyanax.ddl.ColumnFamilyDefinition;
|
||||
|
@ -74,27 +75,43 @@ public class CassandraClusterConnection {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* Get the reference to the current keyspace
|
||||
* @return keyspace reference
|
||||
*/
|
||||
public Keyspace getKeyspace() {
|
||||
|
||||
// The Keyspace instance can be shared among different requests
|
||||
if(myKeyspace == null){
|
||||
synchronized(this){
|
||||
if(myKeyspace == null){ // double check lock
|
||||
AstyanaxContext<Keyspace> context = new AstyanaxContext.Builder()
|
||||
.forCluster(clusterName)
|
||||
.forKeyspace(keyspaceName)
|
||||
.withAstyanaxConfiguration(new AstyanaxConfigurationImpl()
|
||||
.setDiscoveryType(NodeDiscoveryType.NONE)
|
||||
.withAstyanaxConfiguration(
|
||||
new AstyanaxConfigurationImpl()
|
||||
.setDiscoveryType(NodeDiscoveryType.NONE) // use only the host given as seeds (do not discover)
|
||||
.setConnectionPoolType(ConnectionPoolType.ROUND_ROBIN) // how handle connections of the the connection pool
|
||||
)
|
||||
.withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("MyConnectionPool")
|
||||
.setPort(9160)
|
||||
.setMaxConnsPerHost(1)
|
||||
.withConnectionPoolConfiguration(
|
||||
new ConnectionPoolConfigurationImpl("MyConnectionPool")
|
||||
.setMaxConnsPerHost(3) // for each seed(host)
|
||||
//.setSocketTimeout(1000) -> default: 11 seconds
|
||||
//.setConnectTimeout(1000) -> default: 2 seconds
|
||||
.setSeeds(host)
|
||||
)
|
||||
.withConnectionPoolMonitor(new CountingConnectionPoolMonitor())
|
||||
.buildKeyspace(ThriftFamilyFactory.getInstance());
|
||||
|
||||
|
||||
context.start();
|
||||
|
||||
// save keyspace reference
|
||||
myKeyspace = context.getEntity();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return myKeyspace;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue