[ 
https://issues.apache.org/jira/browse/IGNITE-17148?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Kirill Tkalenko updated IGNITE-17148:
-------------------------------------
    Reviewer: Aleksandr Polovtcev

> Support for abstract configuration
> ----------------------------------
>
>                 Key: IGNITE-17148
>                 URL: https://issues.apache.org/jira/browse/IGNITE-17148
>             Project: Ignite
>          Issue Type: Task
>            Reporter: Kirill Tkalenko
>            Assignee: Kirill Tkalenko
>            Priority: Major
>              Labels: iep-55, ignite-3
>             Fix For: 3.0.0-alpha6
>
>          Time Spent: 10.5h
>  Remaining Estimate: 0h
>
> *NOTE*
> Description may not be complete.
> *Problem*
> We need the ability to create a basic configuration schema so that we can 
> define a common configuration schema and inherit from it with additional 
> configuration added.
> Let's look at an example:
> We need to create two configuration schemes for the PageMemory based storage 
> engine, they should have a common property "page size in bytes" and then they 
> should be different, let's sketch an example scheme.
> {code:java}
> public class BasePageMemoryStorageEngineConfigurationSchema {
>     @Value(hasDefault = true)
>     public int pageSize = 16 * 1024;
> }
> @ConfigurationRoot(rootName = "in-memory-page-memory", type = DISTRIBUTED) 
> public class VolatilePageMemoryStorageEngineConfigurationSchema extends 
> BasePageMemoryStorageEngineConfigurationSchema{
>     @ConfigValue
>     public VolatilePageMemoryDataRegionConfigurationSchema defaultRegion;
>     @NamedConfigValue
>     public VolatilePageMemoryDataRegionConfigurationSchema regions;
> }
> @ConfigurationRoot(rootName = "persistent-page-memory", type = DISTRIBUTED)
> public class PersistentPageMemoryStorageEngineConfigurationSchema extends 
> BasePageMemoryStorageEngineConfigurationSchema{
>     @ConfigValue
>     public PersistentPageMemoryDataRegionConfigurationSchema defaultRegion;
>     @NamedConfigValue
>     public PersistentPageMemoryDataRegionConfigurationSchema regions;
>     @ConfigValue
>     public PageMemoryCheckpointConfigurationSchema checkpoint;
> }{code}
> How can we implement this at the moment:
>  * internal extension of the configuration: then the user will not be able to 
> see and change it - not suitable;
>  * polymorphic configuration:
>  ** by design, we cannot create root config schemas for polymorphic config or 
> instances;
>  ** by design, we can change the type of polymorphic configuration to any 
> instance, we do not fix its type, which does not suit us;
>  ** by design, we cannot expose a polymorphic instance as a configuration 
> schema property;
>  ** hocon will display the type of polymorphic configuration, which is not 
> necessary in this case and will look a little strange.
> The possible options do not suit us, so I propose to add another solution.
> *Proposal*
> Add an abstract configuration schema from which we can inherit, add 
> properties, but only its heirs could be used as properties of other 
> configurations schemas or configuration roots. Unlike a polymorphic 
> configuration, it will not store and display the type in hocon, and the type 
> cannot be changed. 
> The abstract configuration schema from which will be inherited will contain 
> the annotation {*}@AbstractConfiguration{*}, and any successor must extend it 
> and contain *@Config* or {*}@ConfigurationRoot{*}, consider examples:
> {code:java}
> @AbstractConfiguration
> public class BasePageMemoryStorageEngineConfigurationSchema {
>     @Value(hasDefault = true)
>     public int pageSize = 16 * 1024;
> }
> @ConfigurationRoot(rootName = "in-memory-page-memory", type = DISTRIBUTED) 
> public class VolatilePageMemoryStorageEngineConfigurationSchema extends 
> BasePageMemoryStorageEngineConfigurationSchema{
>     @ConfigValue
>     public VolatilePageMemoryDataRegionConfigurationSchema defaultRegion;
>     @NamedConfigValue
>     public VolatilePageMemoryDataRegionConfigurationSchema regions;
> }
> @Config
> public class PersistentPageMemoryStorageEngineConfigurationSchema extends 
> BasePageMemoryStorageEngineConfigurationSchema{
>     @ConfigValue
>     public PersistentPageMemoryDataRegionConfigurationSchema defaultRegion;
>     @NamedConfigValue
>     public PersistentPageMemoryDataRegionConfigurationSchema regions;
>     @ConfigValue
>     public PageMemoryCheckpointConfigurationSchema checkpoint;
> }{code}
> *Implementation notes*
> # Add annotation 
> *org.apache.ignite.configuration.annotation.AbstractConfiguration*;
> # Add processing to 
> *org.apache.ignite.internal.configuration.processor.Processor*;
> # Add processing to 
> *org.apache.ignite.internal.configuration.asm.ConfigurationAsmGenerator*;
> # Cover with tests.
> *Further development*
>  * Consider the possibility and necessity of crossing with the annotation 
> *InternalConfiguration* and *PolymorphicConfig* in a separate ticket, at the 
> moment they cannot be used together in the same class (for simplicity).



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to