本文整理匯總了Java中com.thinkaurelius.titan.diskstorage.cassandra.thrift.thriftpool.CTConnectionFactory類的典型用法代碼示例。如果您正苦於以下問題:Java CTConnectionFactory類的具體用法?Java CTConnectionFactory怎麽用?Java CTConnectionFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CTConnectionFactory類屬於com.thinkaurelius.titan.diskstorage.cassandra.thrift.thriftpool包,在下文中一共展示了CTConnectionFactory類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: CassandraThriftStoreManager
import com.thinkaurelius.titan.diskstorage.cassandra.thrift.thriftpool.CTConnectionFactory; //導入依賴的package包/類
public CassandraThriftStoreManager(Configuration config) throws BackendException {
super(config);
/*
* This is eventually passed to Thrift's TSocket constructor. The
* constructor parameter is of type int.
*/
int thriftTimeoutMS = (int)config.get(GraphDatabaseConfiguration.CONNECTION_TIMEOUT).toMillis();
CTConnectionFactory.Config factoryConfig = new CTConnectionFactory.Config(hostnames, port, username, password)
.setTimeoutMS(thriftTimeoutMS)
.setFrameSize(thriftFrameSizeBytes);
if (config.get(SSL_ENABLED)) {
factoryConfig.setSSLTruststoreLocation(config.get(SSL_TRUSTSTORE_LOCATION));
factoryConfig.setSSLTruststorePassword(config.get(SSL_TRUSTSTORE_PASSWORD));
}
final PoolExhaustedAction poolExhaustedAction = ConfigOption.getEnumValue(
config.get(CPOOL_WHEN_EXHAUSTED), PoolExhaustedAction.class);
CTConnectionPool p = new CTConnectionPool(factoryConfig.build());
p.setTestOnBorrow(true);
p.setTestOnReturn(true);
p.setTestWhileIdle(config.get(CPOOL_IDLE_TESTS));
p.setNumTestsPerEvictionRun(config.get(CPOOL_IDLE_TESTS_PER_EVICTION_RUN));
p.setWhenExhaustedAction(poolExhaustedAction.getByte());
p.setMaxActive(config.get(CPOOL_MAX_ACTIVE));
p.setMaxTotal(config.get(CPOOL_MAX_TOTAL)); // maxTotal limits active + idle
p.setMaxIdle(config.get(CPOOL_MAX_IDLE));
p.setMinIdle(config.get(CPOOL_MIN_IDLE));
p.setMaxWait(config.get(CPOOL_MAX_WAIT));
p.setTimeBetweenEvictionRunsMillis(config.get(CPOOL_EVICTOR_PERIOD));
p.setMinEvictableIdleTimeMillis(config.get(CPOOL_MIN_EVICTABLE_IDLE_TIME));
this.pool = p;
this.openStores = new HashMap<String, CassandraThriftKeyColumnValueStore>();
// Only watch the ring and change endpoints with BOP
if (getCassandraPartitioner() instanceof ByteOrderedPartitioner) {
deployment = (hostnames.length == 1)// mark deployment as local only in case we have byte ordered partitioner and local connection
? (NetworkUtil.isLocalConnection(hostnames[0])) ? Deployment.LOCAL : Deployment.REMOTE
: Deployment.REMOTE;
} else {
deployment = Deployment.REMOTE;
}
}
示例2: CassandraThriftStoreManager
import com.thinkaurelius.titan.diskstorage.cassandra.thrift.thriftpool.CTConnectionFactory; //導入依賴的package包/類
public CassandraThriftStoreManager(Configuration config) throws BackendException {
super(config);
/*
* This is eventually passed to Thrift's TSocket constructor. The
* constructor parameter is of type int.
*/
int thriftTimeoutMS = (int)config.get(GraphDatabaseConfiguration.CONNECTION_TIMEOUT).getLength(TimeUnit.MILLISECONDS);
thriftFrameSizeBytes = config.get(THRIFT_FRAME_SIZE) * 1024 * 1024;
CTConnectionFactory.Config factoryConfig = new CTConnectionFactory.Config(hostnames, port, username, password)
.setTimeoutMS(thriftTimeoutMS)
.setFrameSize(thriftFrameSizeBytes);
if (config.get(SSL_ENABLED)) {
factoryConfig.setSSLTruststoreLocation(config.get(SSL_TRUSTSTORE_LOCATION));
factoryConfig.setSSLTruststorePassword(config.get(SSL_TRUSTSTORE_PASSWORD));
}
CTConnectionPool p = new CTConnectionPool(factoryConfig.build());
p.setTestOnBorrow(true);
p.setTestOnReturn(true);
p.setTestWhileIdle(config.get(CPOOL_IDLE_TESTS));
p.setNumTestsPerEvictionRun(config.get(CPOOL_IDLE_TESTS_PER_EVICTION_RUN));
p.setWhenExhaustedAction(config.get(CPOOL_WHEN_EXHAUSTED).getByte());
p.setMaxActive(config.get(CPOOL_MAX_ACTIVE));
p.setMaxTotal(config.get(CPOOL_MAX_TOTAL)); // maxTotal limits active + idle
p.setMaxIdle(config.get(CPOOL_MAX_IDLE));
p.setMinIdle(config.get(CPOOL_MIN_IDLE));
p.setMaxWait(config.get(CPOOL_MAX_WAIT));
p.setTimeBetweenEvictionRunsMillis(config.get(CPOOL_EVICTOR_PERIOD));
p.setMinEvictableIdleTimeMillis(config.get(CPOOL_MIN_EVICTABLE_IDLE_TIME));
this.pool = p;
this.openStores = new HashMap<String, CassandraThriftKeyColumnValueStore>();
// Only watch the ring and change endpoints with BOP
if (getCassandraPartitioner() instanceof ByteOrderedPartitioner) {
deployment = (hostnames.length == 1)// mark deployment as local only in case we have byte ordered partitioner and local connection
? (NetworkUtil.isLocalConnection(hostnames[0])) ? Deployment.LOCAL : Deployment.REMOTE
: Deployment.REMOTE;
} else {
deployment = Deployment.REMOTE;
}
}