我正在尝试使用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中的行为。
发布于 2018-10-04 02:51:56
默认情况下,Cassandra不再支持Thrift。您需要启用它才能使用它。请记住,在Cassandra的下一个版本中,它甚至不存在。很可能,即使启用它并使用它,事情可能也不会很好地工作。没有人再真正使用它了,使用它的测试也不多了。表的存储和检索方式在不同版本之间会发生变化,因此驱动程序必须意识到这一点。由于Astyanax没有得到维护,它可能不会正确。
Astyanax已经退役,只适用于较旧的应用程序。你真的应该使用java driver (和Astyanax页面上的建议一样)。
发布于 2018-10-04 15:22:19
我记得在Cassandra 0.8.8 - 1.1和1.2中使用了Astyanax。曾经有一段时间,我们会将所有数据(列)作为一个blob放入一个分区(允许更快的写入),然后我们会从thrift胖客户端解析出数据(据说Cassandra此时读取速度很慢)。我们必须跟踪模式,然后在反序列化来自thrift客户端的输出时,我们将根据所有单独列的数据类型进行解析。在引入CQL之后,所有这些都改变了,正如Chris指出的那样,这是使用c*的推荐方式。
发布于 2018-10-12 07:53:43
你用什么版本的“锡拉”试过?节俭,虽然在Cassandra中已弃用,但在Scylla中仍受支持。
https://stackoverflow.com/questions/52632314
复制相似问题