简体   繁体   中英

How can I set GCGraceSeconds in Cassandra using astyanax?

I need to set GCGraceSeconds to 0, because I have only one node, but I cannot find where I can set value to this. Is it possible to set from astyanax or is it in some settings file?

In more recent versions of cassandra, you actually set gc_grace_seconds on a per column family basis as part of the schema. From what I can tell, Astyanax currently doesn't support setting that property. There is no corresponding method in the ColumnFamilyDefinition class.

https://github.com/Netflix/astyanax/blob/master/src/main/java/com/netflix/astyanax/ddl/ColumnFamilyDefinition.java

You can use the cassandra-cli tool to set the property on any existing column families if you wish.

Additionally, it doesn't look like it would be too hard to add support to Astyanax. I'm sure they would accept a pull request.

Update

Astyanax (for a while) now supports this setting. See ColumnFamilyDefinition . This can be set in the astyanax column family creation like so:

OperationResult<SchemaChangeResult> opres = keyspace.createColumnFamily(cf, ImmutableMap.<String, Object> builder()
    .put("comparator", "UTF8Type")
    .put("key_validation_class", "UTF8Type")
    .put("gc_grace_seconds", 60*60*24) // gc grace seconds of one day
    .build()
);

That is done in conf/cassandra.yaml (Cassandra configuration file)

Prior version 0.7: conf/storage-conf.xml

Remember: " Set this to a large enough value that you are confident that the deletion marker will be propagated to all replicas by the time this many seconds has elapsed, even in the face of hardware failures. The default value is ten days. "

Default is: ' 864000 ' seconds, or 10 days.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM