public class CassandraStateRepository extends Object implements StateRepository
This repository implementation can be used to store the feature state in Cassandra using Astyanax client.
CassandraStateRepository
stores the feature state in a column family called Togglz
by default.
You can choose the name of this column family using a builder provided by this class.
If the repository doesn't find the column family, it will automatically create it.
The column family has the following format:
create column family Togglz with comparator = 'UTF8Type' and default_validation_class = UTF8Type and key_validation_class = UTF8Type;
The class provides a builder which can be used to configure the repository:
StateRepository repository = CassandraStateRepository.newBuilder(keyspace) .columnFamily("Togglz") .autoCreateColumnFamily(false) .mapSerializer(DefaultMapSerializer.singleline()) .build();
You need to provide a Keyspace
to use CassandraStateRepository
.
It can be created using KeyspaceBuilder
or any other way.
Modifier and Type | Class and Description |
---|---|
static class |
CassandraStateRepository.Builder
Builder for a
CassandraStateRepository |
Constructor and Description |
---|
CassandraStateRepository(com.netflix.astyanax.Keyspace keyspace) |
Modifier and Type | Method and Description |
---|---|
FeatureState |
getFeatureState(Feature feature)
Get the persisted state of a feature from the repository.
|
static CassandraStateRepository.Builder |
newBuilder(com.netflix.astyanax.Keyspace keyspace)
Creates a new builder for creating a
CassandraStateRepository . |
void |
setFeatureState(FeatureState featureState)
Persist the supplied feature state.
|
public CassandraStateRepository(com.netflix.astyanax.Keyspace keyspace)
public FeatureState getFeatureState(Feature feature)
StateRepository
null
.getFeatureState
in interface StateRepository
feature
- The feature to read the state fornull
public void setFeatureState(FeatureState featureState)
StateRepository
StateRepository.getFeatureState(Feature)
return the same state as persisted using this method.setFeatureState
in interface StateRepository
featureState
- The feature state to persistpublic static CassandraStateRepository.Builder newBuilder(com.netflix.astyanax.Keyspace keyspace)
CassandraStateRepository
.keyspace
- the Keyspace
Togglz should use to query cassandra.
Can be created using the KeyspaceBuilder
.Copyright © 2017. All Rights Reserved.