info.archinnov.achilles.configuration.ConfigurationParameters Maven / Gradle / Ivy
Show all versions of achilles-core Show documentation
/*
* Copyright (C) 2012-2014 DuyHai DOAN
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package info.archinnov.achilles.configuration;
/**
*
* Enum listing all configuration parameters
*
*
* Entity Parsing
*
* -
*
ENTITY_PACKAGES (OPTIONAL): list of java packages for entity scanning, separated by comma.
*
* Example: my.project.entity,another.project.entity
*
* ENTITIES_LIST (OPTIONAL): list of entity classes for entity scanning.
*
* Note: entities discovered by ENTITY_PACKAGES will be merged into entities provided by ENTITIES_LIST
*
*
* 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
*
*
* -
* JACKSON_MAPPER_FACTORY (OPTIONAL): an implementation of the info.archinnov.achilles.json.JacksonMapperFactory interface to build custom Jackson ObjectMapper based on entity class
* -
* JACKSON_MAPPER (OPTIONAL): default Jackson ObjectMapper to use for serializing entities
*
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:
*
*
* - SerializationInclusion = JsonInclude.Include.NON_NULL
* - DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES = false
* - AnnotationIntrospector pair : primary = JacksonAnnotationIntrospector, secondary = JaxbAnnotationIntrospector
*
*
* Consistency Level
*
*
* -
* CONSISTENCY_LEVEL_READ_DEFAULT (OPTIONAL): default read consistency level for all entities
* -
* CONSISTENCY_LEVEL_WRITE_DEFAULT (OPTIONAL): default write consistency level for all entities
* -
*
CONSISTENCY_LEVEL_READ_MAP (OPTIONAL): map(String,String) of read consistency levels for column families/tables
*
* Example:
*
* "columnFamily1" -> "ONE"
* "columnFamily2" -> "QUORUM"
* ...
*
* -
*
CONSISTENCY_LEVEL_WRITE_MAP (OPTIONAL): map(String,String) of write consistency levels for column families
*
* Example:
*
* "columnFamily1" -> "ALL"
* "columnFamily2" -> "EACH_QUORUM"
* ...
*
*
* Events Interceptors
*
*
* -
* EVENT_INTERCEPTORS (OPTIONAL): list of events interceptors.
*
*
* Lossless Schema Update
*
*
* -
* ENABLE_SCHEMA_UPDATE (OPTIONAL): allow
ALTER TABLE xxx ADD
statements at runtime to add missing fields to existing tables in Cassandra
*
* -
* ENABLE_SCHEMA_UPDATE_FOR_TABLES (OPTIONAL): map of
*
For more details on this feature, see Lossless Dynamic Schema Update
*
* Bean Validation
*
*
* -
* BEAN_VALIDATION_ENABLE (OPTIONAL): whether to enable Bean Validation.
* -
*
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
*
*
* -
* PREPARED_STATEMENTS_CACHE_SIZE (OPTIONAL): define the LRU cache size for 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 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
*
*
* -
* 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.
*
* Strategies
*
*
* -
* GLOBAL_INSERT_STRATEGY (OPTIONAL): choose between
InsertStrategy.ALL_FIELDS
and InsertStrategy.NOT_NULL_FIELDS
.
* Default value is ConfigurationParameters.InsertStrategy.ALL_FIELDS
.
* For more details, please check Insert Strategy
*
* -
* GLOBAL_NAMING_STRATEGY (OPTIONAL): choose between
NamingStrategy.LOWER_CASE
, NamingStrategy.SNAKE_CASE
and NamingStrategy.CASE_SENSITIVE
.
* Default value is NamingStrategy.LOWER_CASE
.
* For more details, please check Naming Strategy
*
*
*
* OSGI Class loader
*
*
* -
* OSGI_CLASS_LOADER (OPTIONAL): define the class loader to be use for entity introspection and proxies creation, instead of the default class loader.
*
For more details, please check OSGI Support
*
*
* Asynchronous Operations
*
*
* -
* EXECUTOR_SERVICE (OPTIONAL): define the executor service (thread pool) to be used by Achilles for its internal asynchronous operations.
* By default, the thread pool is configured as follow:
*
* new ThreadPoolExecutor(5, 20, 60, TimeUnit.SECONDS,
* new LinkedBlockingQueue(1000),
* new DefaultExecutorThreadFactory())
*
*
* -
* DEFAULT_EXECUTOR_SERVICE_MIN_THREAD (OPTIONAL): define the minimum thread count for the executor service used by Achilles for its internal asynchronous operations.
* The thread pool will configured as follow:
*
* new ThreadPoolExecutor(DEFAULT_EXECUTOR_SERVICE_MIN_THREAD, 20, 60, TimeUnit.SECONDS,
* new LinkedBlockingQueue(1000),
* new DefaultExecutorThreadFactory())
*
*
* -
* DEFAULT_EXECUTOR_SERVICE_MAX_THREAD (OPTIONAL): define the maximum thread count for the executor service used by Achilles for its internal asynchronous operations.
* The thread pool will configured as follow:
*
* new ThreadPoolExecutor(5, DEFAULT_EXECUTOR_SERVICE_MAX_THREAD, 60, TimeUnit.SECONDS,
* new LinkedBlockingQueue(1000),
* new DefaultExecutorThreadFactory())
*
*
* -
* DEFAULT_EXECUTOR_SERVICE_THREAD_KEEPALIVE (OPTIONAL): define the duration in seconds during which a thread is kept alive before being destroyed, on the executor service used by Achilles for its internal asynchronous operations.
* The thread pool will configured as follow:
*
* new ThreadPoolExecutor(5, 20, DEFAULT_EXECUTOR_SERVICE_THREAD_KEEPALIVE, TimeUnit.SECONDS,
* new LinkedBlockingQueue(1000),
* new DefaultExecutorThreadFactory())
*
*
* -
* DEFAULT_EXECUTOR_SERVICE_QUEUE_SIZE (OPTIONAL): define the size of the LinkedBlockingQueue used by the executor service used by Achilles for its internal asynchronous operations.
* The thread pool will configured as follow:
*
* new ThreadPoolExecutor(5, 20, 60, TimeUnit.SECONDS,
* new LinkedBlockingQueue(DEFAULT_EXECUTOR_SERVICE_QUEUE_SIZE),
* new DefaultExecutorThreadFactory())
*
*
* -
* DEFAULT_EXECUTOR_SERVICE_THREAD_FACTORY (OPTIONAL): define the thread factory used by Achilles for its internal asynchronous operations.
* The thread pool will configured as follow:
*
* new ThreadPoolExecutor(5, 20, 60, TimeUnit.SECONDS,
* new LinkedBlockingQueue(1000),
* DEFAULT_EXECUTOR_SERVICE_THREAD_FACTORY)
*
*
*
* For more details, please check Asynchronous Operations
*/
public enum ConfigurationParameters {
ENTITY_PACKAGES("achilles.entity.packages"),
ENTITIES_LIST("achilles.entities.list"),
NATIVE_SESSION("achilles.cassandra.native.session"),
KEYSPACE_NAME("achilles.cassandra.keyspace.name"),
JACKSON_MAPPER_FACTORY("achilles.json.jackson.mapper.factory"),
JACKSON_MAPPER("achilles.json.jackson.mapper"),
CONSISTENCY_LEVEL_READ_DEFAULT("achilles.consistency.read.default"),
CONSISTENCY_LEVEL_WRITE_DEFAULT("achilles.consistency.write.default"),
CONSISTENCY_LEVEL_READ_MAP("achilles.consistency.read.map"),
CONSISTENCY_LEVEL_WRITE_MAP("achilles.consistency.write.map"),
EVENT_INTERCEPTORS("achilles.event.interceptors"),
FORCE_TABLE_CREATION("achilles.ddl.force.table.creation"),
ENABLE_SCHEMA_UPDATE("achilles.ddl.enable.schema.update"),
ENABLE_SCHEMA_UPDATE_FOR_TABLES("achilles.ddl.enable.schema.update.for.tables"),
BEAN_VALIDATION_ENABLE("achilles.bean.validation.enable"),
BEAN_VALIDATION_VALIDATOR("achilles.bean.validation.validator"),
PREPARED_STATEMENTS_CACHE_SIZE("achilles.prepared.statements.cache.size"),
PROXIES_WARM_UP_DISABLED("achilles.proxies.warm.up.disabled"),
GLOBAL_INSERT_STRATEGY("achilles.global.insert.strategy"),
OSGI_CLASS_LOADER("achilles.osgi.class.loader"),
RELAX_INDEX_VALIDATION("achilles.relax.index.validation"),
GLOBAL_NAMING_STRATEGY("achilles.global.naming.strategy"),
EXECUTOR_SERVICE("achilles.executor.service"),
DEFAULT_EXECUTOR_SERVICE_MIN_THREAD("achilles.executor.service.default.thread.min"),
DEFAULT_EXECUTOR_SERVICE_MAX_THREAD("achilles.executor.service.default.thread.max"),
DEFAULT_EXECUTOR_SERVICE_THREAD_KEEPALIVE("achilles.executor.service.default.thread.keepalive"),
DEFAULT_EXECUTOR_SERVICE_QUEUE_SIZE("achilles.executor.service.default.queue.size"),
DEFAULT_EXECUTOR_SERVICE_THREAD_FACTORY("achilles.executor.service.thread.factory");
private String label;
ConfigurationParameters(String label) {
this.label = label;
}
/**
* Small utility method that resolves a configuration based on its label.
* @param label the configuration label that would be populated in the map.
* @return the label in ConfigurationParameters format, or null if no match found.
*/
public static ConfigurationParameters fromLabel(String label) {
for(ConfigurationParameters param : ConfigurationParameters.values()) {
if(param.label.equals(label)) {
return param;
}
}
return null;
}
}