Achilles comes with some configuration parameters in the class info.archinnov.achilles.configuration.ConfigurationParameters
Example: my.project.entity,another.project.entity
If set to false and no table is found for any entity, Achilles will raise an AchillesInvalidTableException
keyspace@Table annotation.If you do not provide the keyspace name in configuration and your entity does not define any keyspace
name statically on the@Tableannotation, Achilles will raise an exception at runtime
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:
Example:
"table1" -> "ONE"
"table2" -> "QUORUM"
...
Example:
"table1" -> "ALL"
"table2" -> "EACH_QUORUM"
...
Example:
"table1" -> "SERIAL"
"table2" -> "LOCAL_SERIAL"
...
POST_LOAD_BEAN_VALIDATION_ENABLE (OPTIONAL): whether to enable Bean Validation for POST_LOAD events.
Please note that this flag is taken into account only if BEAN_VALIDATION_ENABLE is true
BEAN_VALIDATION_VALIDATOR (OPTIONAL): custom validator to be used.
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
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
info.archinnov.achilles.internals.cache.StatementsCacheConfigurationParameters.InsertStrategy.ALL_FIELDS and ConfigurationParameters.InsertStrategy.NOT_NULL_FIELDS.ConfigurationParameters.InsertStrategy.ALL_FIELDS.For more details, please check Insert Strategy
NamingStrategy.LOWER_CASEFor more details, please check Naming Strategy
info.archinnov.achilles.type.factory.BeanFactory
@Override
public <T> T newInstance(Class<T> clazz) {
try{
return clazz.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
....
}
}
info.archinnov.achilles.type.SchemaNameProvider interface
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
See Runtime Codecs for more details
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
To configure Achilles with the above parameters, you need to provide a MapPersistenceManagerFactory 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();