Package org.sqlproc.engine.config
Class SqlEngineConfiguration
- java.lang.Object
-
- org.sqlproc.engine.config.SqlEngineConfiguration
-
public class SqlEngineConfiguration extends Object
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 Modifier and Type Class Description class
SqlEngineConfiguration.NameValue
The simple container.
-
Field Summary
Fields Modifier and Type Field Description private Integer
asyncInitThreads
The number of threads used for asynchronous initialization.private ConcurrentHashMap<String,AtomicInteger>
crudEngines
The container of initialized CRUD Engines' names (static or dynamic ones) together with the number of their usage.private Set<String>
dontProcessingCacheEngines
Negative list of engines, for which the processing cache can be used.private Set<String>
doProcessingCacheEngines
Positive list of engines, for which the processing cache can be used.private ConcurrentHashMap<String,String>
dynamicCrudEngines
The container of initialized dynamic CRUD Engines' names together with their SQL statement.private ConcurrentHashMap<String,String>
dynamicProcedureEngines
The container of initialized dynamic Procedure Engines' names together with their SQL statement.private ConcurrentHashMap<String,String>
dynamicQueryEngines
The container of initialized dynamic Query Engines' names together with their SQL statement.private Boolean
initClearUsage
After the engines instantiations the users should be cleared.private Boolean
initInUsageOrder
The most frequently used engines should be initialized preferentially.private Integer
initTreshold
The engines, which usage is at least this number should be initialized directly.private Boolean
lazyInit
This flag indicates to speed up the initialization process.(package private) org.slf4j.Logger
logger
The internal slf4j logger.private ConcurrentHashMap<String,AtomicInteger>
procedureEngines
The container of initialized Procedure Engines' names (static or dynamic ones) together with the number of their usage.private ConcurrentHashMap<String,AtomicInteger>
queryEngines
The container of initialized Query Engines' names (static or dynamic ones) together with the number of their usage.private SqlEngineConfigurationStore
store
The store to persist this configuration;private Boolean
useDynamicProcessingCache
The processing cache can be used forSqlProcessResult
instances dynamically.private Boolean
useProcessingCache
The processing cache can be used forSqlProcessResult
instances.
-
Constructor Summary
Constructors Constructor Description SqlEngineConfiguration()
The default constructor.SqlEngineConfiguration(String directory, String fileName)
The constructor takes data from the persisted state in external file.SqlEngineConfiguration(SqlEngineConfigurationStore store)
The constructor takes data from the persisted state in external file.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
addCrudEngine(String name)
Adds the CRUD Engine to the container of initialized engines.int
addDynamicCrudEngine(String name, String sqlStatement)
Adds the dynamic CRUD Engine to the container of initialized engines.int
addDynamicProcedureEngine(String name, String sqlStatement)
Adds the dynamic Procedure Engine to the container of initialized engines.int
addDynamicQueryEngine(String name, String sqlStatement)
Adds the dynamic Query Engine to the container of initialized engines.protected int
addEngine(String name, ConcurrentHashMap<String,AtomicInteger> engines)
Adds the SQL Engine to the container of initialized engines.int
addProcedureEngine(String name)
Adds the Procedure Engine to the container of initialized engines.int
addQueryEngine(String name)
Adds the Query Engine to the container of initialized engines.void
clear()
Reset the state of the dynamic configuration instance.void
clearUsage()
Reset the engines' usage counters.Integer
getAsyncInitThreads()
Returns the number of threads used for asynchronous initializationConcurrentHashMap<String,AtomicInteger>
getCrudEngines()
Returns the container of initialized CRUD Engines' names (static or dynamic ones) together with the number of their usageMap<String,Integer>
getCrudEnginesToInit(Integer treshold)
Returns the container of the CRUD Engines' names, which has to be initialized.Set<String>
getDontProcessingCacheEngines()
Returns the list of engines, for which the processing cache can't be usedSet<String>
getDoProcessingCacheEngines()
Returns the list of engines, for which the processing cache can be usedConcurrentHashMap<String,String>
getDynamicCrudEngines()
Returns the container of initialized dynamic CRUD Engines' names together with their SQL statementConcurrentHashMap<String,String>
getDynamicProcedureEngines()
Returns the container of initialized dynamic Procedure Engines' names together with their SQL statementConcurrentHashMap<String,String>
getDynamicQueryEngines()
Returns the container of initialized dynamic Query Engines' names together with their SQL statementprotected Map<String,Integer>
getEnginesToInit(ConcurrentHashMap<String,AtomicInteger> engines, Integer treshold)
Returns the container of the SQL Engines' names, which has to be initialized.Boolean
getInitClearUsage()
Returns the indicator that after the engines instantiations the users should be clearedBoolean
getInitInUsageOrder()
Returns the indicator that the most frequently used engines should be initialized preferentiallyInteger
getInitTreshold()
Returns the initialization threshold.Boolean
getLazyInit()
Returns the indicator to speed up the initialization processConcurrentHashMap<String,AtomicInteger>
getProcedureEngines()
Returns the container of initialized Procedure Engines' names (static or dynamic ones) together with the number of their usageMap<String,Integer>
getProcedureEnginesToInit(Integer treshold)
Returns the container of the Procedure Engines' names, which has to be initialized.ConcurrentHashMap<String,AtomicInteger>
getQueryEngines()
Returns the container of initialized Query Engines' names (static or dynamic ones) together with the number of their usageMap<String,Integer>
getQueryEnginesToInit(Integer treshold)
Returns the container of the Query Engines' names, which has to be initialized.Boolean
getUseDynamicProcessingCache()
Returns the indicator that the processing cache can be used dynamicallyBoolean
getUseProcessingCache()
Returns the indicator that the processing cache can be usedvoid
load()
Loads the persisted configuration.int
removeCrudEngine(String name)
Removes the CRUD Engine from the container of initialized engines.int
removeDynamicCrudEngine(String name)
Removes the dynamic CRUD Engine from the container of initialized engines.int
removeDynamicProcedureEngine(String name)
Removes the dynamic Procedure Engine from the container of initialized engines.int
removeDynamicQueryEngine(String name)
Removes the dynamic Query Engine from the container of initialized engines.protected int
removeEngine(String name, ConcurrentHashMap<String,AtomicInteger> engines)
Removes the SQL Engine from the container of initialized engines.int
removeProcedureEngine(String name)
Removes the Procedure Engine from the container of initialized engines.int
removeQueryEngine(String name)
Removes the Query Engine from the container of initialized engines.void
setAsyncInitThreads(Integer asyncInitThreads)
Sets the number of threads used for asynchronous initializationvoid
setCrudEngines(ConcurrentHashMap<String,AtomicInteger> crudEngines)
Sets the container of initialized CRUD Engines' names (static or dynamic ones) together with the number of their usagevoid
setDontProcessingCacheEngines(Set<String> dontProcessingCacheEngines)
Sets the list of engines, for which the processing cache can't be usedvoid
setDoProcessingCacheEngines(Set<String> doProcessingCacheEngines)
Sets the list of engines, for which the processing cache can be usedvoid
setDynamicCrudEngines(ConcurrentHashMap<String,String> dynamicCrudEngines)
Sets the container of initialized dynamic CRUD Engines' names together with their SQL statementvoid
setDynamicProcedureEngines(ConcurrentHashMap<String,String> dynamicProcedureEngines)
Sets the container of initialized dynamic Procedure Engines' names together with their SQL statementvoid
setDynamicQueryEngines(ConcurrentHashMap<String,String> dynamicQueryEngines)
Sets the container of initialized dynamic Query Engines' names together with their SQL statementvoid
setInitClearUsage(Boolean initClearUsage)
Sets the indicator that after the engines instantiations the users should be clearedvoid
setInitInUsageOrder(Boolean initInUsageOrder)
Sets the indicator that the most frequently used engines should be initialized preferentiallyvoid
setInitTreshold(Integer initTreshold)
Sets the initialization threshold.void
setLazyInit(Boolean lazyInit)
Sets the indicator to speed up the initialization processvoid
setProcedureEngines(ConcurrentHashMap<String,AtomicInteger> procedureEngines)
Sets the container of initialized Procedure Engines' names (static or dynamic ones) together with the number of their usagevoid
setQueryEngines(ConcurrentHashMap<String,AtomicInteger> queryEngines)
Sets the container of initialized Query Engines' names (static or dynamic ones) together with the number of their usagevoid
setUseDynamicProcessingCache(Boolean useDynamicProcessingCache)
Sets the indicator that the processing cache can be used for dynamicallyvoid
setUseProcessingCache(Boolean useProcessingCache)
Sets the indicator that the processing cache can be usedvoid
store()
Persist the configuration into the external file.String
toString()
-
-
-
Field Detail
-
logger
final org.slf4j.Logger logger
The internal slf4j logger.
-
queryEngines
private ConcurrentHashMap<String,AtomicInteger> queryEngines
The container of initialized Query Engines' names (static or dynamic ones) together with the number of their usage.
-
crudEngines
private ConcurrentHashMap<String,AtomicInteger> crudEngines
The container of initialized CRUD Engines' names (static or dynamic ones) together with the number of their usage.
-
procedureEngines
private ConcurrentHashMap<String,AtomicInteger> procedureEngines
The container of initialized Procedure Engines' names (static or dynamic ones) together with the number of their usage.
-
dynamicQueryEngines
private ConcurrentHashMap<String,String> dynamicQueryEngines
The container of initialized dynamic Query Engines' names together with their SQL statement.
-
dynamicCrudEngines
private ConcurrentHashMap<String,String> dynamicCrudEngines
The container of initialized dynamic CRUD Engines' names together with their SQL statement.
-
dynamicProcedureEngines
private ConcurrentHashMap<String,String> dynamicProcedureEngines
The container of initialized dynamic Procedure Engines' names together with their SQL statement.
-
lazyInit
private Boolean lazyInit
This flag indicates to speed up the initialization process.
-
asyncInitThreads
private Integer asyncInitThreads
The number of threads used for asynchronous initialization.
-
initTreshold
private Integer initTreshold
The engines, which usage is at least this number should be initialized directly.
-
initInUsageOrder
private Boolean initInUsageOrder
The most frequently used engines should be initialized preferentially.
-
initClearUsage
private Boolean initClearUsage
After the engines instantiations the users should be cleared.
-
useProcessingCache
private Boolean useProcessingCache
The processing cache can be used forSqlProcessResult
instances.
-
useDynamicProcessingCache
private Boolean useDynamicProcessingCache
The processing cache can be used forSqlProcessResult
instances dynamically.
-
doProcessingCacheEngines
private Set<String> doProcessingCacheEngines
Positive list of engines, for which the processing cache can be used.
-
dontProcessingCacheEngines
private Set<String> dontProcessingCacheEngines
Negative list of engines, for which the processing cache can be used.
-
store
private SqlEngineConfigurationStore store
The store to persist this configuration;
-
-
Constructor Detail
-
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
public SqlEngineConfiguration(SqlEngineConfigurationStore store)
The constructor takes data from the persisted state in external file.- Parameters:
store
- the store to persist this configuration- 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
-
-
Method Detail
-
load
public void load() throws javax.xml.bind.JAXBException
Loads 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
protected int addEngine(String name, ConcurrentHashMap<String,AtomicInteger> engines)
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
protected int removeEngine(String name, ConcurrentHashMap<String,AtomicInteger> engines)
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
public int addQueryEngine(String name)
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
public int addCrudEngine(String name)
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
public int addProcedureEngine(String name)
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
public int removeQueryEngine(String name)
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
public int removeCrudEngine(String name)
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
public int removeProcedureEngine(String name)
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
public int addDynamicQueryEngine(String name, String sqlStatement)
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
public int addDynamicCrudEngine(String name, String sqlStatement)
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
public int addDynamicProcedureEngine(String name, String sqlStatement)
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
public int removeDynamicQueryEngine(String name)
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
public int removeDynamicCrudEngine(String name)
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
public int removeDynamicProcedureEngine(String name)
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
public ConcurrentHashMap<String,AtomicInteger> 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
public ConcurrentHashMap<String,AtomicInteger> 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
public ConcurrentHashMap<String,AtomicInteger> 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
public ConcurrentHashMap<String,String> 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
public ConcurrentHashMap<String,String> 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
public ConcurrentHashMap<String,String> 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
public void setQueryEngines(ConcurrentHashMap<String,AtomicInteger> queryEngines)
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
public void setCrudEngines(ConcurrentHashMap<String,AtomicInteger> crudEngines)
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
public void setProcedureEngines(ConcurrentHashMap<String,AtomicInteger> procedureEngines)
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
public void setDynamicQueryEngines(ConcurrentHashMap<String,String> dynamicQueryEngines)
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
public void setDynamicCrudEngines(ConcurrentHashMap<String,String> dynamicCrudEngines)
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
public void setDynamicProcedureEngines(ConcurrentHashMap<String,String> dynamicProcedureEngines)
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
public Boolean getLazyInit()
Returns the indicator to speed up the initialization process- Returns:
- the indicator to speed up the initialization process
-
setLazyInit
public void setLazyInit(Boolean lazyInit)
Sets the indicator to speed up the initialization process- Parameters:
lazyInit
- the indicator to speed up the initialization process
-
getAsyncInitThreads
public Integer getAsyncInitThreads()
Returns the number of threads used for asynchronous initialization- Returns:
- the number of threads used for asynchronous initialization
-
setAsyncInitThreads
public void setAsyncInitThreads(Integer asyncInitThreads)
Sets the number of threads used for asynchronous initialization- Parameters:
asyncInitThreads
- the number of threads used for asynchronous initialization
-
getInitTreshold
public Integer 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
public void setInitTreshold(Integer initTreshold)
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
public Boolean 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
public void setInitInUsageOrder(Boolean initInUsageOrder)
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
public Boolean 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
public void setInitClearUsage(Boolean initClearUsage)
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
public Boolean getUseProcessingCache()
Returns the indicator that the processing cache can be used- Returns:
- the indicator that the processing cache can be used
-
setUseProcessingCache
public void setUseProcessingCache(Boolean useProcessingCache)
Sets the indicator that the processing cache can be used- Parameters:
useProcessingCache
- the indicator that the processing cache can be used
-
getUseDynamicProcessingCache
public Boolean getUseDynamicProcessingCache()
Returns the indicator that the processing cache can be used dynamically- Returns:
- the indicator that the processing cache can be used dynamically
-
setUseDynamicProcessingCache
public void setUseDynamicProcessingCache(Boolean useDynamicProcessingCache)
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
public Set<String> 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
public void setDoProcessingCacheEngines(Set<String> doProcessingCacheEngines)
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
public Set<String> 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
public void setDontProcessingCacheEngines(Set<String> dontProcessingCacheEngines)
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
public Map<String,Integer> getQueryEnginesToInit(Integer treshold)
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
public Map<String,Integer> getCrudEnginesToInit(Integer treshold)
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
public Map<String,Integer> getProcedureEnginesToInit(Integer treshold)
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
-
-