Search in sources :

Example 1 with ConfigurationRegistry

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

the class SchemaConfigurationConverterTest method createRegistry.

/**
 * Prepare configuration registry for test.
 *
 * @throws ExecutionException If failed.
 * @throws InterruptedException If failed.
 */
@BeforeEach
public void createRegistry() throws ExecutionException, InterruptedException {
    confRegistry = new ConfigurationRegistry(List.of(TablesConfiguration.KEY, DataStorageConfiguration.KEY), Map.of(TableValidator.class, Set.of(TableValidatorImpl.INSTANCE)), new TestConfigurationStorage(DISTRIBUTED), List.of(), List.of(HashIndexConfigurationSchema.class, SortedIndexConfigurationSchema.class, PartialIndexConfigurationSchema.class, RocksDbDataRegionConfigurationSchema.class));
    confRegistry.start();
    tblBuilder = SchemaBuilders.tableBuilder("SNAME", "TNAME").columns(SchemaBuilders.column("COL1", ColumnType.DOUBLE).build(), SchemaBuilders.column("COL2", ColumnType.DOUBLE).build(), SchemaBuilders.column("A", ColumnType.INT8).build(), SchemaBuilders.column("B", ColumnType.INT8).build(), SchemaBuilders.column("C", ColumnType.INT8).build()).withPrimaryKey("COL1");
    TableDefinition tbl = tblBuilder.build();
    confRegistry.getConfiguration(TablesConfiguration.KEY).change(ch -> SchemaConfigurationConverter.createTable(tbl, ch).changeTables(tblsCh -> tblsCh.createOrUpdate(tbl.canonicalName(), tblCh -> tblCh.changeReplicas(1)))).get();
}
Also used : TestConfigurationStorage(org.apache.ignite.internal.configuration.storage.TestConfigurationStorage) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) HashIndexConfigurationSchema(org.apache.ignite.configuration.schemas.table.HashIndexConfigurationSchema) SortedIndexDefinitionBuilder(org.apache.ignite.schema.definition.builder.SortedIndexDefinitionBuilder) BeforeEach(org.junit.jupiter.api.BeforeEach) IndexColumnDefinition(org.apache.ignite.schema.definition.index.IndexColumnDefinition) SortOrder(org.apache.ignite.schema.definition.index.SortOrder) HashIndexDefinition(org.apache.ignite.schema.definition.index.HashIndexDefinition) DISTRIBUTED(org.apache.ignite.configuration.annotation.ConfigurationType.DISTRIBUTED) TableConfiguration(org.apache.ignite.configuration.schemas.table.TableConfiguration) PartialIndexConfigurationSchema(org.apache.ignite.configuration.schemas.table.PartialIndexConfigurationSchema) SortedIndexConfigurationSchema(org.apache.ignite.configuration.schemas.table.SortedIndexConfigurationSchema) HashIndexDefinitionBuilder(org.apache.ignite.schema.definition.builder.HashIndexDefinitionBuilder) Disabled(org.junit.jupiter.api.Disabled) Map(java.util.Map) RocksDbDataRegionConfigurationSchema(org.apache.ignite.configuration.schemas.store.RocksDbDataRegionConfigurationSchema) SortedIndexDefinition(org.apache.ignite.schema.definition.index.SortedIndexDefinition) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) IndexDefinition(org.apache.ignite.schema.definition.index.IndexDefinition) TableDefinition(org.apache.ignite.schema.definition.TableDefinition) Collection(java.util.Collection) DataStorageConfiguration(org.apache.ignite.configuration.schemas.store.DataStorageConfiguration) TablesConfiguration(org.apache.ignite.configuration.schemas.table.TablesConfiguration) PartialIndexDefinition(org.apache.ignite.schema.definition.index.PartialIndexDefinition) Set(java.util.Set) PartialIndexDefinitionBuilder(org.apache.ignite.schema.definition.builder.PartialIndexDefinitionBuilder) TableValidator(org.apache.ignite.configuration.schemas.table.TableValidator) ColumnType(org.apache.ignite.schema.definition.ColumnType) Collectors(java.util.stream.Collectors) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.jupiter.api.Test) TableDefinitionBuilder(org.apache.ignite.schema.definition.builder.TableDefinitionBuilder) List(java.util.List) AfterEach(org.junit.jupiter.api.AfterEach) ConfigurationRegistry(org.apache.ignite.internal.configuration.ConfigurationRegistry) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) TestConfigurationStorage(org.apache.ignite.internal.configuration.storage.TestConfigurationStorage) SchemaBuilders(org.apache.ignite.schema.SchemaBuilders) Collections(java.util.Collections) ConfigurationRegistry(org.apache.ignite.internal.configuration.ConfigurationRegistry) TableDefinition(org.apache.ignite.schema.definition.TableDefinition) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with ConfigurationRegistry

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

the class UsageTest method multiRootConfiguration.

/**
 * Test to show an API to work with multiroot configurations.
 */
@Test
public void multiRootConfiguration() throws Exception {
    final int failureDetectionTimeout = 30_000;
    final int joinTimeout = 10_000;
    long autoAdjustTimeout = 30_000L;
    registry = new ConfigurationRegistry(List.of(NetworkConfiguration.KEY, LocalConfiguration.KEY), Map.of(), new TestConfigurationStorage(LOCAL), List.of(), List.of());
    registry.start();
    registry.getConfiguration(LocalConfiguration.KEY).change(local -> local.changeBaseline(baseline -> baseline.changeAutoAdjust(autoAdjust -> autoAdjust.changeEnabled(true).changeTimeout(autoAdjustTimeout)))).get(1, SECONDS);
    registry.getConfiguration(NetworkConfiguration.KEY).change(network -> network.changeDiscovery(discovery -> discovery.changeFailureDetectionTimeout(failureDetectionTimeout).changeJoinTimeout(joinTimeout))).get(1, SECONDS);
    assertEquals(failureDetectionTimeout, registry.getConfiguration(NetworkConfiguration.KEY).discovery().failureDetectionTimeout().value());
    assertEquals(autoAdjustTimeout, registry.getConfiguration(LocalConfiguration.KEY).baseline().autoAdjust().timeout().value());
}
Also used : TestConfigurationStorage(org.apache.ignite.internal.configuration.storage.TestConfigurationStorage) Test(org.junit.jupiter.api.Test) List(java.util.List) AfterEach(org.junit.jupiter.api.AfterEach) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) ConfigurationRegistry(org.apache.ignite.internal.configuration.ConfigurationRegistry) LOCAL(org.apache.ignite.configuration.annotation.ConfigurationType.LOCAL) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Map(java.util.Map) TestConfigurationStorage(org.apache.ignite.internal.configuration.storage.TestConfigurationStorage) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) SECONDS(java.util.concurrent.TimeUnit.SECONDS) ConfigurationRegistry(org.apache.ignite.internal.configuration.ConfigurationRegistry) Test(org.junit.jupiter.api.Test)

Example 3 with ConfigurationRegistry

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

the class UsageTest method test.

/**
 * Test creation of configuration and calling configuration API methods.
 */
@Test
public void test() throws Exception {
    registry = new ConfigurationRegistry(List.of(LocalConfiguration.KEY), Map.of(), new TestConfigurationStorage(LOCAL), List.of(), List.of());
    registry.start();
    registry.initializeDefaults();
    LocalConfiguration root = registry.getConfiguration(LocalConfiguration.KEY);
    root.change(local -> local.changeBaseline(baseline -> baseline.changeNodes(nodes -> nodes.create("node1", node -> node.changeConsistentId("test").changePort(1000))).changeAutoAdjust(autoAdjust -> autoAdjust.changeEnabled(true).changeTimeout(100_000L)))).get(1, SECONDS);
    assertTrue(root.baseline().autoAdjust().enabled().value());
    root.baseline().autoAdjust().enabled().update(false).get(1, SECONDS);
    assertFalse(root.value().baseline().autoAdjust().enabled());
    assertFalse(root.baseline().value().autoAdjust().enabled());
    assertFalse(root.baseline().autoAdjust().value().enabled());
    assertFalse(root.baseline().autoAdjust().enabled().value());
    root.baseline().nodes().get("node1").autoAdjustEnabled().update(true).get(1, SECONDS);
    assertTrue(root.value().baseline().nodes().get("node1").autoAdjustEnabled());
    assertTrue(root.baseline().value().nodes().get("node1").autoAdjustEnabled());
    assertTrue(root.baseline().nodes().value().get("node1").autoAdjustEnabled());
    assertTrue(root.baseline().nodes().get("node1").value().autoAdjustEnabled());
    assertTrue(root.baseline().nodes().get("node1").autoAdjustEnabled().value());
    root.baseline().nodes().get("node1").change(node -> node.changeAutoAdjustEnabled(false)).get(1, SECONDS);
    assertFalse(root.value().baseline().nodes().get("node1").autoAdjustEnabled());
    root.baseline().nodes().change(nodes -> nodes.delete("node1")).get(1, SECONDS);
    assertNull(root.baseline().nodes().get("node1"));
    assertNull(root.value().baseline().nodes().get("node1"));
}
Also used : TestConfigurationStorage(org.apache.ignite.internal.configuration.storage.TestConfigurationStorage) Test(org.junit.jupiter.api.Test) List(java.util.List) AfterEach(org.junit.jupiter.api.AfterEach) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) ConfigurationRegistry(org.apache.ignite.internal.configuration.ConfigurationRegistry) LOCAL(org.apache.ignite.configuration.annotation.ConfigurationType.LOCAL) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Map(java.util.Map) TestConfigurationStorage(org.apache.ignite.internal.configuration.storage.TestConfigurationStorage) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) SECONDS(java.util.concurrent.TimeUnit.SECONDS) ConfigurationRegistry(org.apache.ignite.internal.configuration.ConfigurationRegistry) Test(org.junit.jupiter.api.Test)

Example 4 with ConfigurationRegistry

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

the class ConfigurationListenerTest method before.

/**
 * Before each.
 */
@BeforeEach
public void before() {
    storage = new TestConfigurationStorage(LOCAL);
    registry = new ConfigurationRegistry(List.of(ParentConfiguration.KEY), Map.of(), storage, List.of(InternalChildConfigurationSchema.class), List.of(StringPolyConfigurationSchema.class, LongPolyConfigurationSchema.class));
    registry.start();
    registry.initializeDefaults();
    config = registry.getConfiguration(ParentConfiguration.KEY);
}
Also used : TestConfigurationStorage(org.apache.ignite.internal.configuration.storage.TestConfigurationStorage) ConfigurationRegistry(org.apache.ignite.internal.configuration.ConfigurationRegistry) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 5 with ConfigurationRegistry

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

the class ConfigurationPresentationTest method beforeAll.

/**
 * Before all.
 */
@BeforeAll
static void beforeAll() {
    Validator<Value, Object> validator = new Validator<>() {

        /**
         * {@inheritDoc}
         */
        @Override
        public void validate(Value annotation, ValidationContext<Object> ctx) {
            if (Objects.equals("error", ctx.getNewValue())) {
                ctx.addIssue(new ValidationIssue("Error word"));
            }
        }
    };
    cfgRegistry = new ConfigurationRegistry(List.of(TestRootConfiguration.KEY), Map.of(Value.class, Set.of(validator)), new TestConfigurationStorage(LOCAL), List.of(), List.of());
    cfgRegistry.start();
    cfgPresentation = new HoconPresentation(cfgRegistry);
    cfg = cfgRegistry.getConfiguration(TestRootConfiguration.KEY);
}
Also used : TestConfigurationStorage(org.apache.ignite.internal.configuration.storage.TestConfigurationStorage) Matchers.nullValue(org.hamcrest.Matchers.nullValue) ConfigValue(org.apache.ignite.configuration.annotation.ConfigValue) Value(org.apache.ignite.configuration.annotation.Value) HoconPresentation(org.apache.ignite.internal.configuration.rest.presentation.hocon.HoconPresentation) ConfigurationRegistry(org.apache.ignite.internal.configuration.ConfigurationRegistry) ValidationIssue(org.apache.ignite.configuration.validation.ValidationIssue) Validator(org.apache.ignite.configuration.validation.Validator) ValidationContext(org.apache.ignite.configuration.validation.ValidationContext) 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