Configuration-Parameters

Parameters

Achilles comes with some configuration parameters in the class info.archinnov.achilles.configuration.ConfigurationParameters

Entity Management

Example: my.project.entity,another.project.entity

DDL

If set to false and no table is found for any entity, Achilles will raise an AchillesInvalidTableException

Native Session

Keyspace name

If you do not provide the keyspace name in configuration and your entity does not define any keyspace
name statically on the @Table annotation, Achilles will raise an exception at runtime

JSON Serialization

If both JACKSON_MAPPER_FACTORY and JACKSON_MAPPER parameters are provided, Achilles will ignore the JACKSON_MAPPER parameter and use JACKSON_MAPPER_FACTORY

If none is provided, Achilles will use a default Jackson ObjectMapper with the following configuration:

  1. MapperFeature.SORT_PROPERTIES_ALPHABETICALLY = true
  2. SerializationInclusion = JsonInclude.Include.NON_NULL
  3. DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES = false
  4. AnnotationIntrospector pair : primary = JacksonAnnotationIntrospector, secondary = JaxbAnnotationIntrospector

Consistency Level

Example:

"table1" -> "ONE" 
"table2" -> "QUORUM"
...

Example:

"table1" -> "ALL" 
"table2" -> "EACH_QUORUM"
...

Example:

"table1" -> "SERIAL" 
"table2" -> "LOCAL_SERIAL"
...

Events Interceptors

Bean Validation

If no validator is provided, Achilles will get the default validator provided by the default Validation provider.
If Bean Validation is enabled at runtime but no default Validation provider can be found, an exception will be raised and the bootstrap is aborted

Prepared Statements Cache

By default, common operations like insert, find and delete are prepared before-hand for each entity class.
For update and all operations generated by the DSL API, since the updated fields and timestamp value are only known at runtime,
Achilless will prepare the statements only on the fly and save them into a Guava LRU cache.

The default size is 10000 entries. Once the limit is reached, oldest prepared statements are evicted, causing Achilles to re-prepare them and get warnings from the Java Driver.

You can get details on the LRU cache state by putting the logger info.archinnov.achilles.internals.cache.StatementsCache on DEBUG

Insert Strategy

For more details, please check Insert Strategy

Naming Strategy

For more details, please check Naming Strategy

Bean Factory

    
    @Override
    public <T> T newInstance(Class<T> clazz) {
        try{
            return clazz.newInstance();
        } catch (InstantiationException | IllegalAccessException e) {
            ....
        }
    }

Schema Name Provider


    public interface SchemaNameProvider {
        /**
         * Provide keyspace name for entity class
         */
        <T> String keyspaceFor(Class<T> entityClass);
    
        /**
         * Provide table name for entity class
         */
        <T> String tableNameFor(Class<T> entityClass);
    }
    

More details on Dynamic Schema Name

Runtime Codec

See Runtime Codecs for more details

Asynchronous Operations

The default thread pool will be configured as follow:

    new ThreadPoolExecutor(DEFAULT_EXECUTOR_SERVICE_MIN_THREAD, DEFAULT_EXECUTOR_SERVICE_MAX_THREAD,
        DEFAULT_EXECUTOR_SERVICE_THREAD_KEEPALIVE, TimeUnit.SECONDS,
        new LinkedBlockingQueue<Runnable>(DEFAULT_EXECUTOR_SERVICE_QUEUE_SIZE),
        DEFAULT_EXECUTOR_SERVICE_THREAD_FACTORY)

To close properly the thread pool on application removal, Achilles exposes the PersistenceManagerFactory.shutDown() method.
This method is annotated with javax.annotation.PreDestroy so that in a managed contained, it will be invoked automatically.
Otherwise you can always manually call the shutDown()method.

For more details, please check Asynchronous Operations


Configuration

To configure Achilles with the above parameters, you need to provide a Map of key/value as constructor argument to the PersistenceManagerFactory class.

Example:

    
    Map<ConfigurationParameters,Object> configMap = new HashMap<ConfigurationParameters,Object>();
    
    Cluster cluster = Cluster.builder().contactPoints("localhost").withPort(9042).build();
    
    configMap.put(FORCE_TABLE_CREATION,true);

    ManagerFactory factory = ManagerFactoryBuilder
        .build(cluster, configMap); // providing the cluster object is MANDATORY
        
    

Alternatively, you can use the the builder API from the ManagerFactoryBuilder:

 
    ManagerFactory factory = ManagerFactoryBuilder
            .builder(cqlCluster)
            .withDefaultReadConsistency(ConsistencyLevel.QUORUM)
            .withDefaultWriteConsistency(ConsistencyLevel.QUORUM)
            .withKeyspaceName("my_keyspace")
            .withExecutorServiceMinThreadCount(5)
            .withExecutorServiceMaxThreadCount(10)
            .doForceTableCreation(false)
            .build();