Skip to content

Configuration Parameters

DuyHai DOAN edited this page May 8, 2014 · 25 revisions

Parameters

Achilles comes with some configuration parameters:

Entity Parsing

  • achilles.entity.packages (OPTIONAL): list of java packages for entity scanning, separated by comma.

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

  • achilles.entities.list (OPTIONAL): list of entity classes for entity scanning.

Note: entities discovered by achilles.entity.packages will be merged into entities provided by achilles.entities.list

DDL

  • achilles.ddl.force.table.creation (OPTIONAL): create missing column families for entities if they are not found. Default = 'false'.

    If set to false and no column family is found for any entity, Achilles will raise an AchillesInvalidColumnFamilyException

JSON Serialization

  • achilles.json.object.mapper.factory (OPTIONAL): an implementation of the info.archinnov.achilles.json.ObjectMapperFactory interface to build custom Jackson ObjectMapper based on entity class
  • achilles.json.object.mapper (OPTIONAL): default Jackson ObjectMapper to use for serializing entities

If both achilles.json.object.mapper.factory and achilles.json.object.mapper parameters are provided, Achilles will ignore the achilles.json.object.mapper parameter and use achilles.json.object.mapper.factory

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

  1. SerializationInclusion = Inclusion.NON_NULL
  2. DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES = false
  3. AnnotationIntrospector pair : primary = JacksonAnnotationIntrospector, secondary = JaxbAnnotationIntrospector

Consistency Level

  • achilles.default.consistency.read (OPTIONAL): default read consistency level for all entities

  • achilles.default.consistency.write (OPTIONAL): default write consistency level for all entities

  • achilles.consistency.read.map (OPTIONAL): map(String,String) of read consistency levels for column families/tables

    Example:

    "columnFamily1" -> "ONE"
    "columnFamily2" -> "QUORUM" ...

  • achilles.consistency.write.map (OPTIONAL): map(String,String) of write consistency levels for column families

    Example:

    "columnFamily1" -> "ALL"
    "columnFamily2" -> "EACH_QUORUM" ...

Cluster and Keyspace

  • achilles.cassandra.connection.contactPoints: comma separated list of contact points/hosts of the cluster

  • achilles.cassandra.connection.port: port for native protocole. Default = 9042

  • achilles.cassandra.cluster: pre-built java driver core Cluster object

  • achilles.cassandra.native.session: pre-built java driver core Session object

  • achilles.cassandra.cluster.name (OPTIONAL): name of the cluster

  • achilles.cassandra.keyspace.name (MANDATORY): keyspace name

Either achilles.cassandra.cluster/achilles.cassandra.native.session or achilles.cassandra.connection.contactPoints/achilles.cassandra.connection.port parameters should be provided

Compression

  • achilles.cassandra.compression.type (OPTIONAL): Compression.SNAPPY or Compression.NONE. Default = Compression.SNAPPY

Policies

  • achilles.cassandra.retry.policy (OPTIONAL): retry policy. Default = Policies.defaultRetryPolicy() of java driver core
  • achilles.cassandra.load.balancing.policy (OPTIONAL): retry policy. Default = Policies.defaultLoadBalancingPolicy() of java driver core
  • achilles.cassandra.reconnection.policy (OPTIONAL): retry policy. Default = Policies.defaultReconnectionPolicy() of java driver core

Credentials

  • achilles.cassandra.username (OPTIONAL): user login
  • achilles.cassandra.password (OPTIONAL): user password

Metrics

  • achilles.cassandra.disable.jmx (OPTIONAL): disable JMX. Default = false
  • achilles.cassandra.disable.metrics (OPTIONAL): disable metrics. Default = false

SSL

  • achilles.cassandra.ssl.enabled (OPTIONAL): enable SSL Default = false
  • achilles.cassandra.ssl.options (OPTIONAL): Instance of com.datastax.driver.core.SSLOptions. Should be set if the property achilles.cassandra.ssl.enabled is true

Events Interceptors

  • achilles.event.interceptors (OPTIONAL): list of events interceptors.

Bean Validation

  • achilles.bean.validation.enable (OPTIONAL): whether to enable Bean Validation.
  • achilles.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

Prepared Statements Cache

  • achilles.prepared.statements.cache.size (OPTIONAL): define the LRU cache size for prepared statements cache.

By default, common operations like persist, find and remove are prepared before-hand for each entity class. For update and all operations with timestamp, 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.internal.statement.cache.CacheManager on DEBUG

Proxies

  • achilles.proxies.warm.up.disabled (OPTIONAL): disable CGLIB proxies warm-up. Default = false

The first time Achilles creates a proxy for an entity class, there is a penalty of a hundreds millisecs (value may change from different plateforms) required for CGLIB to read bytecode and add the proxy to its cache.

This delay may be detrimental for real time applications that need very fast response-time.

Therefore, at bootstrap time, Achilles will force proxy creation for each managed entities to warm up CGLIB. This behavior is enabled by default.

If you want to speed up start up, you may disable this behavior.

Batches

  • achilles.batch.force.statements.ordering (OPTIONAL): forces the statements ordering for CQL3 atomic batches. Default value = false

For more details, please check Batch Statements Ordering

Insert Strategy

  • achilles.insert.strategy (OPTIONAL): choose between ConfigurationParameters.InsertStrategy.ALL_FIELDS and ConfigurationParameters.InsertStrategy.NOT_NULL_FIELDS. Default value is ConfigurationParameters.InsertStrategy.ALL_FIELDS.

For more details, please check Insert Strategy


Configuration

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

Example:

	Map<String,Object> configMap = new HashMap<String,Object>();
	
	configMap.put("achilles.entity.packages","my.package1,my.package2");
	configMap.put("achilles.cassandra.connection.contactPoints","localhost");
	configMap.put("achilles.cassandra.connection.port",9042);
	configMap.put("achilles.cassandra.keyspace.name","Test Keyspace");
	configMap.put("achilles.ddl.force.column.family.creation",true);

	PersistenceManagerFactory pmf = new PersistenceManagerFactory (configMap);

For Spring users:

<bean id="achillesPersistenceManagerFactory" 
 	class="info.archinnov.achilles.integration.spring.PersistenceManagerFactoryBean"
	init-method="initialize">
	<property name="entityPackages" value="my.package1,my.package2"/>
	<property name="contactPoints" value="localhost"/>
	<property name="port" value="9042"/>
	<property name="keyspaceName" value="achilles"/>
	<property name="objectMapper" ref="objectMapperFactoryBean"/>
	<property name="consistencyLevelReadDefault" value="ONE"/>
	<property name="consistencyLevelWriteDefault" value="ONE"/>
	<property name="forceColumnFamilyCreation" value="true" />
</bean>	

Home

Clone this wiki locally