use of org.apache.ignite.internal.configuration.storage.TestConfigurationStorage 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.storage.TestConfigurationStorage 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.storage.TestConfigurationStorage 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.storage.TestConfigurationStorage in project ignite-3 by apache.
the class ClusterServiceTestUtils method clusterService.
/**
* Creates a cluster service and required node configuration manager beneath it. Populates node configuration with specified port.
* Manages configuration manager lifecycle: on cluster service start starts node configuration manager, on cluster service stop - stops
* node configuration manager.
*
* @param testInfo Test info.
* @param port Local port.
* @param nodeFinder Node finder.
* @param clusterSvcFactory Cluster service factory.
*/
public static ClusterService clusterService(TestInfo testInfo, int port, NodeFinder nodeFinder, TestScaleCubeClusterServiceFactory clusterSvcFactory) {
var registry = new MessageSerializationRegistryImpl();
REGISTRY_INITIALIZERS.forEach(c -> {
try {
c.invoke(c.getDeclaringClass(), registry);
} catch (Throwable e) {
throw new RuntimeException("Failed to invoke registry initializer", e);
}
});
var ctx = new ClusterLocalConfiguration(testNodeName(testInfo, port), registry);
ConfigurationManager nodeConfigurationMgr = new ConfigurationManager(Collections.singleton(NetworkConfiguration.KEY), Map.of(), new TestConfigurationStorage(ConfigurationType.LOCAL), List.of(), List.of());
NetworkConfiguration configuration = nodeConfigurationMgr.configurationRegistry().getConfiguration(NetworkConfiguration.KEY);
var bootstrapFactory = new NettyBootstrapFactory(configuration, ctx.getName());
var clusterSvc = clusterSvcFactory.createClusterService(ctx, configuration, bootstrapFactory);
assert nodeFinder instanceof StaticNodeFinder : "Only StaticNodeFinder is supported at the moment";
return new ClusterService() {
@Override
public TopologyService topologyService() {
return clusterSvc.topologyService();
}
@Override
public MessagingService messagingService() {
return clusterSvc.messagingService();
}
@Override
public ClusterLocalConfiguration localConfiguration() {
return clusterSvc.localConfiguration();
}
@Override
public boolean isStopped() {
return clusterSvc.isStopped();
}
@Override
public void start() {
nodeConfigurationMgr.start();
NetworkConfiguration configuration = nodeConfigurationMgr.configurationRegistry().getConfiguration(NetworkConfiguration.KEY);
configuration.change(netCfg -> netCfg.changePort(port).changeNodeFinder(c -> c.changeType(NodeFinderType.STATIC.toString()).changeNetClusterNodes(nodeFinder.findNodes().stream().map(NetworkAddress::toString).toArray(String[]::new)))).join();
bootstrapFactory.start();
clusterSvc.start();
}
@Override
public void stop() {
try {
clusterSvc.stop();
bootstrapFactory.stop();
nodeConfigurationMgr.stop();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
};
}
use of org.apache.ignite.internal.configuration.storage.TestConfigurationStorage 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);
}
Aggregations