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();
}
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());
}
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"));
}
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);
}
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);
}
Aggregations