gpt4 book ai didi

java - Astyanax 无法读取某些列族

转载 作者:行者123 更新时间:2023-12-01 06:49:06 24 4
gpt4 key购买 nike

我正在尝试使用 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());
}

它可以列出键空间,但缺少许多列族。这是输出。可以看到很多默认的键空间都有,但是很多列族缺失了。

there are 0 column families in keyspace system_distributed
there are 3 column families in keyspace system
- hints
- schema_keyspaces
- IndexInfo
there are 2 column families in keyspace system_auth
- role_members
- resource_role_permissons_index
there are 0 column families in keyspace system_traces

我可以使用 cqlsh 来确认列族确实存在

cqlsh> DESCRIBE COLUMNFAMILIES

Keyspace system_traces
----------------------
events sessions

Keyspace system_auth
--------------------
resource_role_permissons_index role_permissions role_members roles

Keyspace system
---------------
available_ranges size_estimates schema_usertypes compactions_in_progress
range_xfers peers paxos schema_aggregates
schema_keyspaces schema_triggers batchlog schema_columnfamilies
schema_columns sstable_activity schema_functions local
"IndexInfo" peer_events compaction_history hints

Keyspace system_distributed
---------------------------
repair_history parent_repair_history

上面的输出使用的是 cassandra 2.2,但我已经确认了其他版本的 cassandra 和 scylla 中的行为。

最佳答案

Thrift 已弃用,默认情况下 Cassandra 不再启用。您需要启用它才能使用它。请记住,在 Cassandra 的下一个版本中,它甚至不存在。即使启用它并使用它,也很可能无法正常工作。没有什么真正使用它了,也没有那么多测试使用它。表的存储和检索方式在版本之间发生了变化,因此驱动程序必须意识到这一点。由于 Astyanax 没有得到维护,它可能不会正确。

Astyanax 已退役,仅适用于较旧的应用程序。你真的应该使用 java driver (与 Astyanax 页面上的推荐相同)。

关于java - Astyanax 无法读取某些列族,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52632314/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com