當前位置: 首頁>>代碼示例>>Java>>正文


Java CTConnectionFactory類代碼示例

本文整理匯總了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;
    }
}
 
開發者ID:graben1437,項目名稱:titan1withtp3.1,代碼行數:48,代碼來源:CassandraThriftStoreManager.java

示例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;
    }
}
 
開發者ID:graben1437,項目名稱:titan0.5.4-hbase1.1.1-custom,代碼行數:47,代碼來源:CassandraThriftStoreManager.java


注:本文中的com.thinkaurelius.titan.diskstorage.cassandra.thrift.thriftpool.CTConnectionFactory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。