albertlockett
albertlockett

Reputation: 204

Astyanax cannot read some column families

I am trying to list the column families in Cassandra using the Astyanax driver. It lists the keyspaces OK, but many column families are missing from the output.

I have a simple program for this:

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());
    }

It can list the keyspaces, but many of the column families are missing. here is the output. It can be seen that many of the default keyspaces are there, but many of the column families are missing.

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

I can use cqlsh to confirm that the column families do exist

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

The output above is using cassandra 2.2, but I have confirm the behaviour in other versions of cassandra and scylla.

Upvotes: 0

Views: 119

Answers (3)

Peter Corless
Peter Corless

Reputation: 811

What versions of Scylla did you try it with? Thrift, though deprecated with Cassandra, is still supported in Scylla.

Upvotes: 0

Mahee Gunturu
Mahee Gunturu

Reputation: 108

I remember using Astyanax with Cassandra 0.8.8 - 1.1 and 1.2. There was a time where we would shove all the data (columns) into one partition as a blob (enabled faster writes) and then we would parse the data out from the thrift fat client(allegedly Cassandra was slow for reads at this time). We had to keep track of the schema and then while deserializing the output from the thrift client we would parse based on the data-type of all the individual columns. All of this changed after the introduction of CQL and as Chris is pointing out this is the recommended way of working with c*.

Upvotes: 4

Chris Lohfink
Chris Lohfink

Reputation: 16400

Thrift is deprecated and no longer enabled by Cassandra by default. You would need to enable it to use it. Keep in mind that in next versions of Cassandra it doesnt even exist. Its very likely that even enabling it and using it things might not work quite right. Nothing really uses it anymore and there are not as many tests that use it. How the tables are stored and retrieved changed between versions so the driver has to be aware of that. As Astyanax isn't maintained it likely wont have it right.

Astyanax has been retired and is only around for older apps. You should really use the java driver (same recommendation as on Astyanax page).

Upvotes: 5

Related Questions