我正在尝试使用 Astyanax 驱动程序在 Cassandra 中列出列族。它列出了键空间,但输出中缺少许多列族。
我有一个简单的程序:
import com.netflix.astyanax.AstyanaxContext;
import com.netflix.astyanax.Cluster;
import com.netflix.astyanax.connectionpool.impl.ConnectionPoolConfigurationImpl;
import com.netflix.astyanax.connectionpool.impl.CountingConnectionPoolMonitor;
import com.netflix.astyanax.ddl.ColumnFamilyDefinition;
import com.netflix.astyanax.ddl.KeyspaceDefinition;
import com.netflix.astyanax.impl.AstyanaxConfigurationImpl;
import com.netflix.astyanax.thrift.ThriftFamilyFactory;
public class App {
public static void main(String[] args) throws Exception {
ConnectionPoolConfigurationImpl cpool = new ConnectionPoolConfigurationImpl("ConnectionPool")
.setPort(9160)
.setSeeds("localhost");
AstyanaxConfigurationImpl astyanaxConfiguration = new AstyanaxConfigurationImpl();
AstyanaxContext.Builder ctxBuilder = new AstyanaxContext.Builder();
ctxBuilder.forCluster("Cluster")
.withAstyanaxConfiguration(astyanaxConfiguration)
.withConnectionPoolConfiguration(cpool)
.withConnectionPoolMonitor(new CountingConnectionPoolMonitor());
AstyanaxContext<Cluster> clusterContext = ctxBuilder.buildCluster(ThriftFamilyFactory.getInstance());
clusterContext.start();
Cluster cluster = clusterContext.getClient();
for (KeyspaceDefinition ksDef : cluster.describeKeyspaces()) {
List<ColumnFamilyDefinition> cfDefList = ksDef.getColumnFamilyList();
System.out.println("there are " + cfDefList.size() + " column families in keyspace " + ksDef.getName());
for (ColumnFamilyDefinition cfDef : cfDefList) System.out.println(" - " + cfDef.getName());
}
上面的输出使用的是 cassandra 2.2,但我已经确认了其他版本的 cassandra 和 scylla 中的行为。
繁花不似锦
炎炎设计
慕桂英3389331
相关分类