Package org.sqlproc.engine.config
Class SqlEngineConfiguration
java.lang.Object
org.sqlproc.engine.config.SqlEngineConfiguration
The dynamic configuration of the SQL Processor.
The primary goal of this configuration is the eager initialization of the selected SQL Engines. The overall
configuration can be also persisted using the sql-processor-spring.
The configuration can be dynamically changed using the JMX interface
SqlDefaultFactoryMXBean.
For more info please see the Tutorials.
- Author:
- Vladimir Hudec
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate IntegerThe number of threads used for asynchronous initialization.private ConcurrentHashMap<String, AtomicInteger> The container of initialized CRUD Engines' names (static or dynamic ones) together with the number of their usage.Negative list of engines, for which the processing cache can be used.Positive list of engines, for which the processing cache can be used.private ConcurrentHashMap<String, String> The container of initialized dynamic CRUD Engines' names together with their SQL statement.private ConcurrentHashMap<String, String> The container of initialized dynamic Procedure Engines' names together with their SQL statement.private ConcurrentHashMap<String, String> The container of initialized dynamic Query Engines' names together with their SQL statement.private BooleanAfter the engines instantiations the users should be cleared.private BooleanThe most frequently used engines should be initialized preferentially.private IntegerThe engines, which usage is at least this number should be initialized directly.private BooleanThis flag indicates to speed up the initialization process.(package private) final org.slf4j.LoggerThe internal slf4j logger.private ConcurrentHashMap<String, AtomicInteger> The container of initialized Procedure Engines' names (static or dynamic ones) together with the number of their usage.private ConcurrentHashMap<String, AtomicInteger> The container of initialized Query Engines' names (static or dynamic ones) together with the number of their usage.private SqlEngineConfigurationStoreThe store to persist this configuration;private BooleanThe processing cache can be used forSqlProcessResultinstances dynamically.private BooleanThe processing cache can be used forSqlProcessResultinstances. -
Constructor Summary
ConstructorsConstructorDescriptionThe default constructor.SqlEngineConfiguration(String directory, String fileName) The constructor takes data from the persisted state in external file.The constructor takes data from the persisted state in external file. -
Method Summary
Modifier and TypeMethodDescriptionintaddCrudEngine(String name) Adds the CRUD Engine to the container of initialized engines.intaddDynamicCrudEngine(String name, String sqlStatement) Adds the dynamic CRUD Engine to the container of initialized engines.intaddDynamicProcedureEngine(String name, String sqlStatement) Adds the dynamic Procedure Engine to the container of initialized engines.intaddDynamicQueryEngine(String name, String sqlStatement) Adds the dynamic Query Engine to the container of initialized engines.protected intaddEngine(String name, ConcurrentHashMap<String, AtomicInteger> engines) Adds the SQL Engine to the container of initialized engines.intaddProcedureEngine(String name) Adds the Procedure Engine to the container of initialized engines.intaddQueryEngine(String name) Adds the Query Engine to the container of initialized engines.voidclear()Reset the state of the dynamic configuration instance.voidReset the engines' usage counters.Returns the number of threads used for asynchronous initializationReturns the container of initialized CRUD Engines' names (static or dynamic ones) together with the number of their usagegetCrudEnginesToInit(Integer treshold) Returns the container of the CRUD Engines' names, which has to be initialized.Returns the list of engines, for which the processing cache can't be usedReturns the list of engines, for which the processing cache can be usedReturns the container of initialized dynamic CRUD Engines' names together with their SQL statementReturns the container of initialized dynamic Procedure Engines' names together with their SQL statementReturns the container of initialized dynamic Query Engines' names together with their SQL statementgetEnginesToInit(ConcurrentHashMap<String, AtomicInteger> engines, Integer treshold) Returns the container of the SQL Engines' names, which has to be initialized.Returns the indicator that after the engines instantiations the users should be clearedReturns the indicator that the most frequently used engines should be initialized preferentiallyReturns the initialization threshold.Returns the indicator to speed up the initialization processReturns the container of initialized Procedure Engines' names (static or dynamic ones) together with the number of their usagegetProcedureEnginesToInit(Integer treshold) Returns the container of the Procedure Engines' names, which has to be initialized.Returns the container of initialized Query Engines' names (static or dynamic ones) together with the number of their usagegetQueryEnginesToInit(Integer treshold) Returns the container of the Query Engines' names, which has to be initialized.Returns the indicator that the processing cache can be used dynamicallyReturns the indicator that the processing cache can be usedvoidload()Loads the persisted configuration.intremoveCrudEngine(String name) Removes the CRUD Engine from the container of initialized engines.intRemoves the dynamic CRUD Engine from the container of initialized engines.intRemoves the dynamic Procedure Engine from the container of initialized engines.intRemoves the dynamic Query Engine from the container of initialized engines.protected intremoveEngine(String name, ConcurrentHashMap<String, AtomicInteger> engines) Removes the SQL Engine from the container of initialized engines.intremoveProcedureEngine(String name) Removes the Procedure Engine from the container of initialized engines.intremoveQueryEngine(String name) Removes the Query Engine from the container of initialized engines.voidsetAsyncInitThreads(Integer asyncInitThreads) Sets the number of threads used for asynchronous initializationvoidsetCrudEngines(ConcurrentHashMap<String, AtomicInteger> crudEngines) Sets the container of initialized CRUD Engines' names (static or dynamic ones) together with the number of their usagevoidsetDontProcessingCacheEngines(Set<String> dontProcessingCacheEngines) Sets the list of engines, for which the processing cache can't be usedvoidsetDoProcessingCacheEngines(Set<String> doProcessingCacheEngines) Sets the list of engines, for which the processing cache can be usedvoidsetDynamicCrudEngines(ConcurrentHashMap<String, String> dynamicCrudEngines) Sets the container of initialized dynamic CRUD Engines' names together with their SQL statementvoidsetDynamicProcedureEngines(ConcurrentHashMap<String, String> dynamicProcedureEngines) Sets the container of initialized dynamic Procedure Engines' names together with their SQL statementvoidsetDynamicQueryEngines(ConcurrentHashMap<String, String> dynamicQueryEngines) Sets the container of initialized dynamic Query Engines' names together with their SQL statementvoidsetInitClearUsage(Boolean initClearUsage) Sets the indicator that after the engines instantiations the users should be clearedvoidsetInitInUsageOrder(Boolean initInUsageOrder) Sets the indicator that the most frequently used engines should be initialized preferentiallyvoidsetInitTreshold(Integer initTreshold) Sets the initialization threshold.voidsetLazyInit(Boolean lazyInit) Sets the indicator to speed up the initialization processvoidsetProcedureEngines(ConcurrentHashMap<String, AtomicInteger> procedureEngines) Sets the container of initialized Procedure Engines' names (static or dynamic ones) together with the number of their usagevoidsetQueryEngines(ConcurrentHashMap<String, AtomicInteger> queryEngines) Sets the container of initialized Query Engines' names (static or dynamic ones) together with the number of their usagevoidsetUseDynamicProcessingCache(Boolean useDynamicProcessingCache) Sets the indicator that the processing cache can be used for dynamicallyvoidsetUseProcessingCache(Boolean useProcessingCache) Sets the indicator that the processing cache can be usedvoidstore()Persist the configuration into the external file.toString()
-
Field Details
-
logger
final org.slf4j.Logger loggerThe internal slf4j logger. -
queryEngines
The container of initialized Query Engines' names (static or dynamic ones) together with the number of their usage. -
crudEngines
The container of initialized CRUD Engines' names (static or dynamic ones) together with the number of their usage. -
procedureEngines
The container of initialized Procedure Engines' names (static or dynamic ones) together with the number of their usage. -
dynamicQueryEngines
The container of initialized dynamic Query Engines' names together with their SQL statement. -
dynamicCrudEngines
The container of initialized dynamic CRUD Engines' names together with their SQL statement. -
dynamicProcedureEngines
The container of initialized dynamic Procedure Engines' names together with their SQL statement. -
lazyInit
This flag indicates to speed up the initialization process. -
asyncInitThreads
The number of threads used for asynchronous initialization. -
initTreshold
The engines, which usage is at least this number should be initialized directly. -
initInUsageOrder
The most frequently used engines should be initialized preferentially. -
initClearUsage
After the engines instantiations the users should be cleared. -
useProcessingCache
The processing cache can be used forSqlProcessResultinstances. -
useDynamicProcessingCache
The processing cache can be used forSqlProcessResultinstances dynamically. -
doProcessingCacheEngines
Positive list of engines, for which the processing cache can be used. -
dontProcessingCacheEngines
Negative list of engines, for which the processing cache can be used. -
store
The store to persist this configuration;
-
-
Constructor Details
-
SqlEngineConfiguration
public SqlEngineConfiguration()The default constructor. -
SqlEngineConfiguration
public SqlEngineConfiguration(String directory, String fileName) throws IOException, javax.xml.bind.JAXBException The constructor takes data from the persisted state in external file.- Parameters:
directory- the directory, where the persisted file is placedfileName- the name of the persisted file- Throws:
IOException- in the case there's a I/O problem with the persisted filejavax.xml.bind.JAXBException- in the case there's a problem with JAXB deserialization
-
SqlEngineConfiguration
The constructor takes data from the persisted state in external file.- Parameters:
store- the store to persist this configuration
-
-
Method Details
-
load
public void load() throws javax.xml.bind.JAXBExceptionLoads the persisted configuration.- Throws:
javax.xml.bind.JAXBException
-
store
public void store()Persist the configuration into the external file. -
clear
public void clear()Reset the state of the dynamic configuration instance. -
clearUsage
public void clearUsage()Reset the engines' usage counters. -
addEngine
Adds the SQL Engine to the container of initialized engines.- Parameters:
name- the name of the SQL Engineengines- the container of initialized engines- Returns:
- the actual number of the engine's usage
-
removeEngine
Removes the SQL Engine from the container of initialized engines.- Parameters:
name- the name of the SQL Engineengines- the container of initialized engines- Returns:
- the actual number of the engine's usage
-
addQueryEngine
Adds the Query Engine to the container of initialized engines.- Parameters:
name- the name of the Query Engine- Returns:
- the actual number of the engine's usage
-
addCrudEngine
Adds the CRUD Engine to the container of initialized engines.- Parameters:
name- the name of the CRUD Engine- Returns:
- the actual number of the engine's usage
-
addProcedureEngine
Adds the Procedure Engine to the container of initialized engines.- Parameters:
name- the name of the Procedure Engine- Returns:
- the actual number of the engine's usage
-
removeQueryEngine
Removes the Query Engine from the container of initialized engines.- Parameters:
name- the name of the Query Engine- Returns:
- the actual number of the engine's usage
-
removeCrudEngine
Removes the CRUD Engine from the container of initialized engines.- Parameters:
name- the name of the CRUD Engine- Returns:
- the actual number of the engine's usage
-
removeProcedureEngine
Removes the Procedure Engine from the container of initialized engines.- Parameters:
name- the name of the Procedure Engine- Returns:
- the actual number of the engine's usage
-
addDynamicQueryEngine
Adds the dynamic Query Engine to the container of initialized engines.- Parameters:
name- the name of the dynamic Query Engine- Returns:
- the actual number of the engine's usage
-
addDynamicCrudEngine
Adds the dynamic CRUD Engine to the container of initialized engines.- Parameters:
name- the name of the dynamic CRUD Engine- Returns:
- the actual number of the engine's usage
-
addDynamicProcedureEngine
Adds the dynamic Procedure Engine to the container of initialized engines.- Parameters:
name- the name of the dynamic Procedure Engine- Returns:
- the actual number of the engine's usage
-
removeDynamicQueryEngine
Removes the dynamic Query Engine from the container of initialized engines.- Parameters:
name- the name of the dynamic Query Engine- Returns:
- the actual number of the engine's usage
-
removeDynamicCrudEngine
Removes the dynamic CRUD Engine from the container of initialized engines.- Parameters:
name- the name of the dynamic CRUD Engine- Returns:
- the actual number of the engine's usage
-
removeDynamicProcedureEngine
Removes the dynamic Procedure Engine from the container of initialized engines.- Parameters:
name- the name of the dynamic Procedure Engine- Returns:
- the actual number of the engine's usage
-
getQueryEngines
Returns the container of initialized Query Engines' names (static or dynamic ones) together with the number of their usage- Returns:
- the container of initialized Query Engines' names (static or dynamic ones) together with the number of their usage
-
getCrudEngines
Returns the container of initialized CRUD Engines' names (static or dynamic ones) together with the number of their usage- Returns:
- the container of initialized CRUD Engines' names (static or dynamic ones) together with the number of their usage
-
getProcedureEngines
Returns the container of initialized Procedure Engines' names (static or dynamic ones) together with the number of their usage- Returns:
- the container of initialized Procedure Engines' names (static or dynamic ones) together with the number of their usage
-
getDynamicQueryEngines
Returns the container of initialized dynamic Query Engines' names together with their SQL statement- Returns:
- the container of initialized dynamic Query Engines' names together with their SQL statement
-
getDynamicCrudEngines
Returns the container of initialized dynamic CRUD Engines' names together with their SQL statement- Returns:
- the container of initialized dynamic CRUD Engines' names together with their SQL statement
-
getDynamicProcedureEngines
Returns the container of initialized dynamic Procedure Engines' names together with their SQL statement- Returns:
- the container of initialized dynamic Procedure Engines' names together with their SQL statement
-
setQueryEngines
Sets the container of initialized Query Engines' names (static or dynamic ones) together with the number of their usage- Parameters:
queryEngines- the container of initialized Query Engines' names (static or dynamic ones) together with the number of their usage
-
setCrudEngines
Sets the container of initialized CRUD Engines' names (static or dynamic ones) together with the number of their usage- Parameters:
crudEngines- the container of initialized CRUD Engines' names (static or dynamic ones) together with the number of their usage
-
setProcedureEngines
Sets the container of initialized Procedure Engines' names (static or dynamic ones) together with the number of their usage- Parameters:
procedureEngines- the container of initialized Procedure Engines' names (static or dynamic ones) together with the number of their usage
-
setDynamicQueryEngines
Sets the container of initialized dynamic Query Engines' names together with their SQL statement- Parameters:
dynamicQueryEngines- the container of initialized dynamic Query Engines' names together with their SQL statement
-
setDynamicCrudEngines
Sets the container of initialized dynamic CRUD Engines' names together with their SQL statement- Parameters:
dynamicCrudEngines- the container of initialized dynamic CRUD Engines' names together with their SQL statement
-
setDynamicProcedureEngines
Sets the container of initialized dynamic Procedure Engines' names together with their SQL statement- Parameters:
dynamicProcedureEngines- the container of initialized dynamic Procedure Engines' names together with their SQL statement
-
getLazyInit
Returns the indicator to speed up the initialization process- Returns:
- the indicator to speed up the initialization process
-
setLazyInit
Sets the indicator to speed up the initialization process- Parameters:
lazyInit- the indicator to speed up the initialization process
-
getAsyncInitThreads
Returns the number of threads used for asynchronous initialization- Returns:
- the number of threads used for asynchronous initialization
-
setAsyncInitThreads
Sets the number of threads used for asynchronous initialization- Parameters:
asyncInitThreads- the number of threads used for asynchronous initialization
-
getInitTreshold
Returns the initialization threshold. The engines, which usage is at least this number should be initialized directly- Returns:
- the initialization threshold. The engines, which usage is at least this number should be initialized directly
-
setInitTreshold
Sets the initialization threshold. The engines, which usage is at least this number should be initialized directly- Parameters:
initTreshold- the initialization threshold. The engines, which usage is at least this number should be initialized directly
-
getInitInUsageOrder
Returns the indicator that the most frequently used engines should be initialized preferentially- Returns:
- the indicator that the most frequently used engines should be initialized preferentially
-
setInitInUsageOrder
Sets the indicator that the most frequently used engines should be initialized preferentially- Parameters:
initInUsageOrder- the indicator that the most frequently used engines should be initialized preferentially
-
getInitClearUsage
Returns the indicator that after the engines instantiations the users should be cleared- Returns:
- the indicator that after the engines instantiations the users should be cleared
-
setInitClearUsage
Sets the indicator that after the engines instantiations the users should be cleared- Parameters:
initClearUsage- the indicator that after the engines instantiations the users should be cleared
-
getUseProcessingCache
Returns the indicator that the processing cache can be used- Returns:
- the indicator that the processing cache can be used
-
setUseProcessingCache
Sets the indicator that the processing cache can be used- Parameters:
useProcessingCache- the indicator that the processing cache can be used
-
getUseDynamicProcessingCache
Returns the indicator that the processing cache can be used dynamically- Returns:
- the indicator that the processing cache can be used dynamically
-
setUseDynamicProcessingCache
Sets the indicator that the processing cache can be used for dynamically- Parameters:
useDynamicProcessingCache- the indicator that the processing cache can be used dynamically
-
getDoProcessingCacheEngines
Returns the list of engines, for which the processing cache can be used- Returns:
- the list of engines, for which the processing cache can be used
-
setDoProcessingCacheEngines
Sets the list of engines, for which the processing cache can be used- Parameters:
doProcessingCacheEngines- the list of engines, for which the processing cache can be used
-
getDontProcessingCacheEngines
Returns the list of engines, for which the processing cache can't be used- Returns:
- the list of engines, for which the processing cache can't be used
-
setDontProcessingCacheEngines
Sets the list of engines, for which the processing cache can't be used- Parameters:
dontProcessingCacheEngines- the list of engines, for which the processing cache can't be used
-
getEnginesToInit
protected Map<String,Integer> getEnginesToInit(ConcurrentHashMap<String, AtomicInteger> engines, Integer treshold) Returns the container of the SQL Engines' names, which has to be initialized. This is called during The SQL Processor initialization, so there's no need to handle concurrent changes.- Parameters:
engines- the container of initialized enginestreshold- the engines, which usage is at least this number should be initialized directly- Returns:
- the container of the Query Engines' names, which has to be initialized
-
getQueryEnginesToInit
Returns the container of the Query Engines' names, which has to be initialized. This is called during The SQL Processor initialization, so there's no need to handle concurrent changes.- Parameters:
treshold- the engines, which usage is at least this number should be initialized directly- Returns:
- the container of the Query Engines' names, which has to be initialized
-
getCrudEnginesToInit
Returns the container of the CRUD Engines' names, which has to be initialized. This is called during The SQL Processor initialization, so there's no need to handle concurrent changes.- Parameters:
treshold- the engines, which usage is at least this number should be initialized directly- Returns:
- the container of the CRUD Engines' names, which has to be initialized
-
getProcedureEnginesToInit
Returns the container of the Procedure Engines' names, which has to be initialized. This is called during The SQL Processor initialization, so there's no need to handle concurrent changes.- Parameters:
treshold- the engines, which usage is at least this number should be initialized directly- Returns:
- the container of the Procedure Engines' names, which has to be initialized
-
toString
-