.withAstyanaxConfiguration(aconf) .withConnectionPoolConfiguration(cpool) .withConnectionPoolMonitor(new CountingConnectionPoolMonitor());
@Override public long getHostCount() { return getHostAddedCount() - getHostRemovedCount(); }
.append("CountingConnectionPoolMonitor(") .append("Connections[" ) .append( "open=" ).append(getNumOpenConnections()) .append(",busy=" ).append(getNumBusyConnections()) .append(",create=" ).append(connectionCreateCount.get()) .append(",close=" ).append(connectionClosedCount.get()) .append(",down=" ).append(hostDownCount.get()) .append(",reactivate=" ).append(hostReactivatedCount.get()) .append(",active=" ).append(getHostActiveCount()) .append("])").toString();
.append("CountingConnectionPoolMonitor(") .append("Connections[" ) .append( "open=" ).append(getNumOpenConnections()) .append(",busy=" ).append(getNumBusyConnections()) .append(",create=" ).append(connectionCreateCount.get()) .append(",close=" ).append(connectionClosedCount.get()) .append(",down=" ).append(hostDownCount.get()) .append(",reactivate=" ).append(hostReactivatedCount.get()) .append(",active=" ).append(getHostActiveCount()) .append("])").toString();
public CassandraStorage(CassandraDataSegmentConfig config) { this.astyanaxContext = new AstyanaxContext.Builder() .forCluster(CLUSTER_NAME) .forKeyspace(config.getKeyspace()) .withAstyanaxConfiguration(new AstyanaxConfigurationImpl().setDiscoveryType(NodeDiscoveryType.NONE)) .withConnectionPoolConfiguration( new ConnectionPoolConfigurationImpl("MyConnectionPool").setMaxConnsPerHost(10) .setSeeds(config.getHost())).withConnectionPoolMonitor(new CountingConnectionPoolMonitor()) .buildKeyspace(ThriftFamilyFactory.getInstance()); this.astyanaxContext.start(); this.keyspace = this.astyanaxContext.getEntity(); this.config = config; indexStorage = new CassandraChunkedStorageProvider(keyspace, INDEX_TABLE_NAME); descriptorStorage = new ColumnFamily<String, String>(DESCRIPTOR_TABLE_NAME, StringSerializer.get(), StringSerializer.get()); } }
@Override public long getHostCount() { return getHostAddedCount() - getHostRemovedCount(); }
AstyanaxContext<Keyspace> context = new AstyanaxContext.Builder() .forCluster("ClusterName") .forKeyspace("KeyspaceName") .withAstyanaxConfiguration(new AstyanaxConfigurationImpl() .setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE) ) .withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("MyConnectionPool") .setPort(9160) .setMaxConnsPerHost(1) .setSeeds("127.0.0.1:9160") ) .withConnectionPoolMonitor(new CountingConnectionPoolMonitor()) .buildKeyspace(ThriftFamilyFactory.getInstance()); context.start(); Keyspace keyspace = context.getClient();
ConnectionPoolMonitor connectionPoolMonitor = new CountingConnectionPoolMonitor(); builder.withConnectionPoolConfiguration(poolConfig); builder.withConnectionPoolMonitor(connectionPoolMonitor); builder.withConnectionPoolMonitor(new CountingConnectionPoolMonitor());
private AstyanaxContext<Keyspace> initWithThriftDriverWithEurekaHostsSupplier() { logger.info("BOOT_CLUSTER = {}, KS_NAME = {}",BOOT_CLUSTER,KS_NAME); return new AstyanaxContext.Builder() .forCluster(BOOT_CLUSTER) .forKeyspace(KS_NAME) .withAstyanaxConfiguration( new AstyanaxConfigurationImpl() .setDiscoveryType( NodeDiscoveryType.DISCOVERY_SERVICE) ) .withConnectionPoolConfiguration( new ConnectionPoolConfigurationImpl( "MyConnectionPool") .setMaxConnsPerHost(3) .setPort(thriftPortForAstyanax)) .withHostSupplier(eurekaHostsSupplier.getSupplier(BOOT_CLUSTER)) .withConnectionPoolMonitor(new CountingConnectionPoolMonitor()) .buildKeyspace(ThriftFamilyFactory.getInstance()); }
private AstyanaxContext<Keyspace> initWithThriftDriverWithEurekaHostsSupplier() { logger.info("BOOT_CLUSTER = {}, KS_NAME = {}", BOOT_CLUSTER, KS_NAME); return new AstyanaxContext.Builder().forCluster(BOOT_CLUSTER).forKeyspace(KS_NAME) .withAstyanaxConfiguration( new AstyanaxConfigurationImpl().setDiscoveryType(NodeDiscoveryType.DISCOVERY_SERVICE)) .withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("MyConnectionPool") .setMaxConnsPerHost(3).setPort(thriftPortForAstyanax)) .withHostSupplier(hostSupplier.getSupplier(BOOT_CLUSTER)) .withConnectionPoolMonitor(new CountingConnectionPoolMonitor()) .buildKeyspace(ThriftFamilyFactory.getInstance()); }
public synchronized Cluster registerCluster(String clusterName, String contactPoint, int port) { logger.info("Connected Cassandra Cluster: " + clusterName); if(clusterContext == null) { clusterContext = new AstyanaxContext.Builder().forCluster(clusterName) .withAstyanaxConfiguration(new AstyanaxConfigurationImpl() .setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE) ) .withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("MyConnectionPool") .setPort(port) .setMaxConnsPerHost(1) .setSeeds(contactPoint) ) .withConnectionPoolMonitor(new CountingConnectionPoolMonitor()) .buildCluster(ThriftFamilyFactory.getInstance()); clusterContext.start(); } logger.warn("Cluster already registered"); return clusterContext.getClient(); }
public synchronized Cluster registerCluster(String clusterName, String contactPoint, int port) { logger.info("Connected Cassandra Cluster: " + clusterName); if(clusterContext == null) { clusterContext = new AstyanaxContext.Builder().forCluster(clusterName) .withAstyanaxConfiguration(new AstyanaxConfigurationImpl() .setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE) ) .withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("MyConnectionPool") .setPort(port) .setMaxConnsPerHost(1) .setSeeds(contactPoint) ) .withConnectionPoolMonitor(new CountingConnectionPoolMonitor()) .buildCluster(ThriftFamilyFactory.getInstance()); clusterContext.start(); } logger.warn("Cluster already registered"); return clusterContext.getClient(); }
private AstyanaxContext<Keyspace> initWithThriftDriverWithExternalHostsSupplier() { logger.info("BOOT_CLUSTER = {}, KS_NAME = {}", BOOT_CLUSTER, KS_NAME); return new AstyanaxContext.Builder().forCluster(BOOT_CLUSTER).forKeyspace(KS_NAME) .withAstyanaxConfiguration( new AstyanaxConfigurationImpl().setDiscoveryType(NodeDiscoveryType.DISCOVERY_SERVICE) .setConnectionPoolType(ConnectionPoolType.ROUND_ROBIN)) .withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("MyConnectionPool") .setMaxConnsPerHost(3).setPort(thriftPortForAstyanax)) .withHostSupplier(getSupplier()).withConnectionPoolMonitor(new CountingConnectionPoolMonitor()) .buildKeyspace(ThriftFamilyFactory.getInstance()); }
/** * Builds a {@link Keyspace} from current configuration. */ public Keyspace build() { final AstyanaxContext<Keyspace> context = new AstyanaxContext.Builder() .forCluster(clusterName) .forKeyspace(keyspaceName) .withAstyanaxConfiguration(new AstyanaxConfigurationImpl() .setDiscoveryType(RING_DESCRIBE) ) .withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("ConnectionPool") .setPort(thriftPort) .setSeeds(hosts) ) .withConnectionPoolMonitor(new CountingConnectionPoolMonitor()) .buildKeyspace(ThriftFamilyFactory.getInstance()); context.start(); Runtime.getRuntime().addShutdownHook(new Thread() { @Override public synchronized void run() { context.shutdown(); } }); return context.getClient(); } }
public synchronized Keyspace registerKeyspace(String clusterName, String ksName, String contactPoint, int port) { logger.info("Cassandra Cluster: " + clusterName); if(keyspaceContext == null) { keyspaceContext = new AstyanaxContext.Builder() .forCluster(clusterName) .forKeyspace(ksName) .withAstyanaxConfiguration(new AstyanaxConfigurationImpl() .setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE) ) .withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("MyConnectionPool") .setPort(port) .setMaxConnsPerHost(1) .setSeeds(contactPoint) ) .withConnectionPoolMonitor(new CountingConnectionPoolMonitor()) .buildKeyspace(ThriftFamilyFactory.getInstance()); keyspaceContext.start(); } logger.warn("Keyspace already registered"); return keyspaceContext.getClient(); }
public synchronized Keyspace registerKeyspace(String clusterName, String ksName, String contactPoint, int port) { logger.info("Cassandra Cluster: " + clusterName); if(keyspaceContext == null) { keyspaceContext = new AstyanaxContext.Builder() .forCluster(clusterName) .forKeyspace(ksName) .withAstyanaxConfiguration(new AstyanaxConfigurationImpl() .setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE) ) .withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("MyConnectionPool") .setPort(port) .setMaxConnsPerHost(1) .setSeeds(contactPoint) ) .withConnectionPoolMonitor(new CountingConnectionPoolMonitor()) .buildKeyspace(ThriftFamilyFactory.getInstance()); keyspaceContext.start(); } logger.warn("Keyspace already registered"); return keyspaceContext.getClient(); }
.withAstyanaxConfiguration(aconf) .withConnectionPoolConfiguration(cpool) .withConnectionPoolMonitor(new CountingConnectionPoolMonitor());
.withAstyanaxConfiguration(aconf) .withConnectionPoolConfiguration(cpool) .withConnectionPoolMonitor(new CountingConnectionPoolMonitor());