Details
-
Task
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
Description
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.
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; }
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:
@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; }
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).
Attachments
Issue Links
- blocks
-
IGNITE-17149 Separation of the PageMemoryStorageEngineConfigurationSchema into in-memory and persistent
- Resolved
- links to