Astyanax无法阅读一些列族

alb*_*ett 0 java thrift cassandra astyanax scylla

我正在尝试使用Astyanax驱动程序列出Cassandra中的列族.它列出了键空间OK,但输出中缺少许多列族.

我有一个简单的程序:

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());
    }
Run Code Online (Sandbox Code Playgroud)

它可以列出键空间,但缺少许多列族.这是输出.可以看出,许多默认键空间都在那里,但许多列族都缺失了.

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
Run Code Online (Sandbox Code Playgroud)

我可以使用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
Run Code Online (Sandbox Code Playgroud)

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

Chr*_*ink 5

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

Astyanax已退休,只适用于较旧的应用程序.你应该真的使用java驱动程序(与Astyanax页面上的建议相同).