Search in sources :

Example 6 with ConfigurationRegistry

use of org.apache.ignite.internal.configuration.ConfigurationRegistry in project ignite-3 by apache.

the class ConfigurationAnyListenerTest method before.

/**
 * Before each.
 */
@BeforeEach
public void before() throws Exception {
    registry = new ConfigurationRegistry(List.of(RootConfiguration.KEY), Map.of(), new TestConfigurationStorage(LOCAL), List.of(), List.of(FirstPolyAnyConfigurationSchema.class, SecondPolyAnyConfigurationSchema.class));
    registry.start();
    registry.initializeDefaults();
    rootConfig = registry.getConfiguration(RootConfiguration.KEY);
    // Add "regular" listeners.
    rootConfig.listen(configListener(ctx -> events.add("root")));
    rootConfig.child().listen(configListener(ctx -> events.add("root.child")));
    rootConfig.child().str().listen(configListener(ctx -> events.add("root.child.str")));
    rootConfig.child().child2().listen(configListener(ctx -> events.add("root.child.child2")));
    rootConfig.child().child2().intVal().listen(configListener(ctx -> events.add("root.child.child2.i")));
    rootConfig.elements().listen(configListener(ctx -> events.add("root.elements")));
    rootConfig.elements().listenElements(configNamedListenerOnCreate(ctx -> events.add("root.elements.onCrt")));
    rootConfig.elements().listenElements(configNamedListenerOnUpdate(ctx -> events.add("root.elements.onUpd")));
    rootConfig.elements().listenElements(configNamedListenerOnRename(ctx -> events.add("root.elements.onRen")));
    rootConfig.elements().listenElements(configNamedListenerOnDelete(ctx -> events.add("root.elements.onDel")));
    rootConfig.elements().change(c -> c.create("0", doNothingConsumer())).get(1, SECONDS);
    FirstSubConfiguration childCfg = this.rootConfig.elements().get("0");
    childCfg.listen(configListener(ctx -> events.add("root.elements.0")));
    childCfg.str().listen(configListener(ctx -> events.add("root.elements.0.str")));
    childCfg.child2().listen(configListener(ctx -> events.add("root.elements.0.child2")));
    childCfg.child2().intVal().listen(configListener(ctx -> events.add("root.elements.0.child2.i")));
    NamedConfigurationTree<SecondSubConfiguration, SecondSubView, SecondSubChange> elements2 = childCfg.elements2();
    elements2.listen(configListener(ctx -> events.add("root.elements.0.elements2")));
    elements2.listenElements(configNamedListenerOnCreate(ctx -> events.add("root.elements.0.elements2.onCrt")));
    elements2.listenElements(configNamedListenerOnUpdate(ctx -> events.add("root.elements.0.elements2.onUpd")));
    elements2.listenElements(configNamedListenerOnRename(ctx -> events.add("root.elements.0.elements2.onRen")));
    elements2.listenElements(configNamedListenerOnDelete(ctx -> events.add("root.elements.0.elements2.onDel")));
    elements2.change(c -> c.create("0", doNothingConsumer())).get(1, SECONDS);
    SecondSubConfiguration child2 = elements2.get("0");
    child2.listen(configListener(ctx -> events.add("root.elements.0.elements2.0")));
    child2.intVal().listen(configListener(ctx -> events.add("root.elements.0.elements2.0.i")));
    // Adding "any" listeners.
    FirstSubConfiguration anyChild = rootConfig.elements().any();
    anyChild.listen(configListener(ctx -> events.add("root.elements.any")));
    anyChild.str().listen(configListener(ctx -> events.add("root.elements.any.str")));
    anyChild.child2().listen(configListener(ctx -> events.add("root.elements.any.child2")));
    anyChild.child2().intVal().listen(configListener(ctx -> events.add("root.elements.any.child2.i")));
    NamedConfigurationTree<SecondSubConfiguration, SecondSubView, SecondSubChange> anyEl2 = anyChild.elements2();
    anyEl2.listen(configListener(ctx -> events.add("root.elements.any.elements2")));
    anyEl2.listenElements(configNamedListenerOnCreate(ctx -> events.add("root.elements.any.elements2.onCrt")));
    anyEl2.listenElements(configNamedListenerOnUpdate(ctx -> events.add("root.elements.any.elements2.onUpd")));
    anyEl2.listenElements(configNamedListenerOnRename(ctx -> events.add("root.elements.any.elements2.onRen")));
    anyEl2.listenElements(configNamedListenerOnDelete(ctx -> events.add("root.elements.any.elements2.onDel")));
    SecondSubConfiguration anyChild2 = anyEl2.any();
    anyChild2.listen(configListener(ctx -> events.add("root.elements.any.elements2.any")));
    anyChild2.intVal().listen(configListener(ctx -> events.add("root.elements.any.elements2.any.i")));
    childCfg.elements2().any().listen(configListener(ctx -> events.add("root.elements.0.elements2.any")));
    childCfg.elements2().any().intVal().listen(configListener(ctx -> events.add("root.elements.0.elements2.any.i")));
}
Also used : TestConfigurationStorage(org.apache.ignite.internal.configuration.storage.TestConfigurationStorage) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) PolymorphicId(org.apache.ignite.configuration.annotation.PolymorphicId) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) BeforeEach(org.junit.jupiter.api.BeforeEach) ConfigurationListenerTestUtils.configNamedListenerOnRename(org.apache.ignite.internal.configuration.notifications.ConfigurationListenerTestUtils.configNamedListenerOnRename) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ConfigurationListenerTestUtils.configNamedListenerOnDelete(org.apache.ignite.internal.configuration.notifications.ConfigurationListenerTestUtils.configNamedListenerOnDelete) NamedConfigValue(org.apache.ignite.configuration.annotation.NamedConfigValue) ConfigurationListenerTestUtils.configListener(org.apache.ignite.internal.configuration.notifications.ConfigurationListenerTestUtils.configListener) Map(java.util.Map) PolymorphicConfig(org.apache.ignite.configuration.annotation.PolymorphicConfig) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) NamedConfigurationTree(org.apache.ignite.configuration.NamedConfigurationTree) ConfigurationListenerTestUtils.configNamedListenerOnUpdate(org.apache.ignite.internal.configuration.notifications.ConfigurationListenerTestUtils.configNamedListenerOnUpdate) ConfigurationListenerTestUtils.configNamedListenerOnCreate(org.apache.ignite.internal.configuration.notifications.ConfigurationListenerTestUtils.configNamedListenerOnCreate) ConfigurationListenOnlyException(org.apache.ignite.configuration.ConfigurationListenOnlyException) ConfigurationRoot(org.apache.ignite.configuration.annotation.ConfigurationRoot) ConfigurationListenerTestUtils.checkEqualsListeners(org.apache.ignite.internal.configuration.notifications.ConfigurationListenerTestUtils.checkEqualsListeners) Assertions.assertInstanceOf(org.junit.jupiter.api.Assertions.assertInstanceOf) UUID(java.util.UUID) ConfigurationNamedListListener(org.apache.ignite.configuration.notifications.ConfigurationNamedListListener) Test(org.junit.jupiter.api.Test) ConfigValue(org.apache.ignite.configuration.annotation.ConfigValue) ConfigurationListener(org.apache.ignite.configuration.notifications.ConfigurationListener) List(java.util.List) AfterEach(org.junit.jupiter.api.AfterEach) ConfigurationListenerTestUtils.checkContainsListeners(org.apache.ignite.internal.configuration.notifications.ConfigurationListenerTestUtils.checkContainsListeners) ConfigurationRegistry(org.apache.ignite.internal.configuration.ConfigurationRegistry) LOCAL(org.apache.ignite.configuration.annotation.ConfigurationType.LOCAL) PolymorphicConfigInstance(org.apache.ignite.configuration.annotation.PolymorphicConfigInstance) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Config(org.apache.ignite.configuration.annotation.Config) TestConfigurationStorage(org.apache.ignite.internal.configuration.storage.TestConfigurationStorage) ConfigurationListenerTestUtils.doNothingConsumer(org.apache.ignite.internal.configuration.notifications.ConfigurationListenerTestUtils.doNothingConsumer) SECONDS(java.util.concurrent.TimeUnit.SECONDS) Value(org.apache.ignite.configuration.annotation.Value) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ConfigurationRegistry(org.apache.ignite.internal.configuration.ConfigurationRegistry) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 7 with ConfigurationRegistry

use of org.apache.ignite.internal.configuration.ConfigurationRegistry in project ignite-3 by apache.

the class HoconConverterTest method beforeAll.

/**
 * Before all.
 */
@BeforeAll
public static void beforeAll() {
    registry = new ConfigurationRegistry(List.of(HoconRootConfiguration.KEY, HoconInjectedNameRootConfiguration.KEY), Map.of(), new TestConfigurationStorage(LOCAL), List.of(), List.of(HoconFirstPolymorphicInstanceConfigurationSchema.class, HoconSecondPolymorphicInstanceConfigurationSchema.class));
    registry.start();
    configuration = registry.getConfiguration(HoconRootConfiguration.KEY);
    injectedNameRootConfig = registry.getConfiguration(HoconInjectedNameRootConfiguration.KEY);
}
Also used : TestConfigurationStorage(org.apache.ignite.internal.configuration.storage.TestConfigurationStorage) ConfigurationRegistry(org.apache.ignite.internal.configuration.ConfigurationRegistry) BeforeAll(org.junit.jupiter.api.BeforeAll)

Aggregations

ConfigurationRegistry (org.apache.ignite.internal.configuration.ConfigurationRegistry)7 TestConfigurationStorage (org.apache.ignite.internal.configuration.storage.TestConfigurationStorage)7 List (java.util.List)4 Map (java.util.Map)4 AfterEach (org.junit.jupiter.api.AfterEach)4 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)4 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)4 Test (org.junit.jupiter.api.Test)4 SECONDS (java.util.concurrent.TimeUnit.SECONDS)3 LOCAL (org.apache.ignite.configuration.annotation.ConfigurationType.LOCAL)3 Assertions.assertNull (org.junit.jupiter.api.Assertions.assertNull)3 BeforeEach (org.junit.jupiter.api.BeforeEach)3 ConfigValue (org.apache.ignite.configuration.annotation.ConfigValue)2 Value (org.apache.ignite.configuration.annotation.Value)2 Assertions.assertFalse (org.junit.jupiter.api.Assertions.assertFalse)2 Assertions.assertNotNull (org.junit.jupiter.api.Assertions.assertNotNull)2 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Set (java.util.Set)1 UUID (java.util.UUID)1