astyanax无法读取某些列族

kxkpmulp  于 2021-06-15  发布在  Cassandra
关注(0)|答案(3)|浏览(306)

我试图使用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

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

q9yhzks0

q9yhzks01#

节俭被弃用,Cassandra默认不再启用。您需要启用它才能使用它。请记住,在下一个版本的Cassandra它甚至不存在。很可能,即使启用和使用它,事情也可能不太正常。没有什么真正使用它了,也没有那么多的测试使用它。表的存储和检索方式在版本之间发生了变化,因此驱动程序必须知道这一点。因为astyanax没有维护,所以它很可能不会正确。
astyanax已经退役,只支持较旧的应用程序。您应该真正使用java驱动程序(与astyanax页面上的建议相同)。

oxf4rvwz

oxf4rvwz2#

你试过什么版本的锡拉?尽管Cassandra反对节俭,但《锡拉》仍然支持节俭。

rkue9o1l

rkue9o1l3#

我记得cassandra0.8.8-1.1和1.2使用astyanax。曾经有一段时间,我们将所有数据(列)作为blob(允许更快的写入)推入一个分区,然后我们将从thrift胖客户端解析数据(据称cassandra此时读取速度较慢)。我们必须跟踪模式,然后在反序列化来自thrift客户端的输出时,我们将根据所有单独列的数据类型进行解析。在引入cql之后,所有这些都发生了变化,正如chris所指出的,这是推荐的使用c*的方法。

相关问题