我最近开始使用 Cassandra 数据库,并且正在使用 Netflix 客户端来填充和读取 Cassandra 数据库中的数据。
我有一个带有四个节点的集群。我已经创建了这样的键空间-
create keyspace profilekeyspace
with placement_strategy = 'NetworkTopologyStrategy'
and strategy_options = {DC2 : 1, DC1 : 1}
and durable_writes = true;
我的专栏家族名称是-profile_columnfamily
这是我的四个节点-
lp-host01.vip.slc.qa.host.com:9160
lp-host02.vip.slc.qa.host.com:9160
lp-host03.vip.phx.qa.host.com:9160
lp-host04.vip.phx.qa.host.com:9160
现在我只使用上面的一个节点来连接 Cassandra 数据库并填充数据。但是我的 DBA 说,您需要使用所有四个节点来建立连接。
private AstyanaxContext<Keyspace> context;
private CassandraAstyanaxConnection() {
context = new AstyanaxContext.Builder()
.forCluster("TEST CLUSTER")
.forKeyspace("PROFILE")
.withAstyanaxConfiguration(new AstyanaxConfigurationImpl()
.setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE)
)
.withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("MyConnectionPool")
.setPort(9160)
.setMaxConnsPerHost(1)
.setSeeds("lp-host01.vip.slc.qa.host.com:9160:9160")//using only node from above to make the connection
)
.withAstyanaxConfiguration(new AstyanaxConfigurationImpl()
.setCqlVersion("3.0.0")
.setTargetCassandraVersion("1.2"))
.withConnectionPoolMonitor(new CountingConnectionPoolMonitor())
.buildKeyspace(ThriftFamilyFactory.getInstance());
context.start();
keyspace = context.getEntity();
emp_cf = ColumnFamily.newColumnFamily(
"PROFILE_COLUMNFAMILY",
StringSerializer.get(),
StringSerializer.get());
}
现在我不确定如何使用所有四个节点使用 Netflix 客户端进行连接?任何人都可以帮助我吗?
谢谢您的帮助。