Search in sources :

Example 1 with SqlConfiguration

use of org.apache.ignite.configuration.SqlConfiguration in project ignite by apache.

the class SystemViewCommandTest method testSchemas.

/**
 */
@Test
public void testSchemas() throws Exception {
    try (IgniteEx g = startGrid(getConfiguration(getTestIgniteInstanceName(3)).setSqlConfiguration(new SqlConfiguration().setSqlSchemas("MY_SCHEMA", "ANOTHER_SCHEMA")))) {
        Set<String> schemaNames = new HashSet<>();
        HashSet<String> expSchemas = new HashSet<>(asList("MY_SCHEMA", "ANOTHER_SCHEMA", "SYS", "PUBLIC"));
        List<List<String>> sqlSchemaView = systemView(g, SQL_SCHEMA_VIEW);
        // name
        sqlSchemaView.forEach(row -> schemaNames.add(row.get(0)));
        assertEquals(schemaNames, expSchemas);
    }
}
Also used : SqlConfiguration(org.apache.ignite.configuration.SqlConfiguration) IgniteEx(org.apache.ignite.internal.IgniteEx) Arrays.asList(java.util.Arrays.asList) ArrayList(java.util.ArrayList) CommandList(org.apache.ignite.internal.commandline.CommandList) List(java.util.List) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with SqlConfiguration

use of org.apache.ignite.configuration.SqlConfiguration in project ignite by apache.

the class SqlSystemViewsSelfTest method testSchemasView.

/**
 * Test schemas system view.
 * @throws Exception in case of failure.
 */
@Test
public void testSchemasView() throws Exception {
    IgniteEx srv = startGrid(getConfiguration().setSqlConfiguration(new SqlConfiguration().setSqlSchemas("PREDIFINED_SCHEMA_1")));
    IgniteEx client = startClientGrid(getConfiguration().setIgniteInstanceName("CLIENT").setSqlConfiguration(new SqlConfiguration().setSqlSchemas("PREDIFINED_SCHEMA_2")));
    srv.createCache(cacheConfiguration("TST1"));
    String schemasSql = "SELECT * FROM " + systemSchemaName() + ".SCHEMAS";
    List<List<?>> srvNodeSchemas = execSql(schemasSql);
    List<List<?>> clientNodeSchemas = execSql(client, schemasSql);
    Set expSchemasSrv = Sets.newHashSet("PREDIFINED_SCHEMA_1", "PUBLIC", "TST1", systemSchemaName());
    Set schemasSrv = srvNodeSchemas.stream().map(f -> f.get(0)).map(String.class::cast).collect(toSet());
    Assert.assertEquals(expSchemasSrv, schemasSrv);
    Set expSchemasCli = Sets.newHashSet("PREDIFINED_SCHEMA_2", "PUBLIC", "TST1", systemSchemaName());
    Set schemasCli = clientNodeSchemas.stream().map(f -> f.get(0)).map(String.class::cast).collect(toSet());
    Assert.assertEquals(expSchemasCli, schemasCli);
}
Also used : SqlConfiguration(org.apache.ignite.configuration.SqlConfiguration) Collectors.toSet(java.util.stream.Collectors.toSet) Set(java.util.Set) IgniteEx(org.apache.ignite.internal.IgniteEx) Arrays.asList(java.util.Arrays.asList) List(java.util.List) AbstractIndexingCommonTest(org.apache.ignite.internal.processors.cache.index.AbstractIndexingCommonTest) AbstractSchemaSelfTest(org.apache.ignite.internal.processors.cache.index.AbstractSchemaSelfTest) Test(org.junit.Test)

Example 3 with SqlConfiguration

use of org.apache.ignite.configuration.SqlConfiguration in project ignite by apache.

the class SqlQueryHistorySelfTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    TcpDiscoverySpi disco = new TcpDiscoverySpi();
    disco.setIpFinder(ipFinder);
    cfg.setDiscoverySpi(disco);
    cfg.setCacheConfiguration(configureCache("A"), configureCache("B"));
    cfg.setSqlConfiguration(new SqlConfiguration().setSqlQueryHistorySize(QUERY_HISTORY_SIZE));
    return cfg;
}
Also used : SqlConfiguration(org.apache.ignite.configuration.SqlConfiguration) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 4 with SqlConfiguration

use of org.apache.ignite.configuration.SqlConfiguration in project ignite by apache.

the class SqlViewExporterSpiTest method testSchemas.

/**
 */
@Test
public void testSchemas() throws Exception {
    try (IgniteEx g = startGrid(new IgniteConfiguration().setSqlConfiguration(new SqlConfiguration().setSqlSchemas("MY_SCHEMA", "ANOTHER_SCHEMA")))) {
        SystemView<SqlSchemaView> schemasSysView = g.context().systemView().view(SQL_SCHEMA_VIEW);
        Set<String> schemaFromSysView = new HashSet<>();
        schemasSysView.forEach(v -> schemaFromSysView.add(v.schemaName()));
        HashSet<String> expSchemas = new HashSet<>(asList("MY_SCHEMA", "ANOTHER_SCHEMA", "SYS", "PUBLIC"));
        assertEquals(schemaFromSysView, expSchemas);
        List<List<?>> schemas = execute(g, "SELECT * FROM SYS.SCHEMAS");
        schemaFromSysView.clear();
        schemas.forEach(s -> schemaFromSysView.add(s.get(0).toString()));
        assertEquals(schemaFromSysView, expSchemas);
    }
}
Also used : SqlConfiguration(org.apache.ignite.configuration.SqlConfiguration) SqlSchemaView(org.apache.ignite.spi.systemview.view.SqlSchemaView) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) IgniteEx(org.apache.ignite.internal.IgniteEx) Arrays.asList(java.util.Arrays.asList) List(java.util.List) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) AbstractExporterSpiTest(org.apache.ignite.internal.metric.AbstractExporterSpiTest) Test(org.junit.Test)

Example 5 with SqlConfiguration

use of org.apache.ignite.configuration.SqlConfiguration in project ignite by apache.

the class Schemas method config.

@Test
void config() {
    // tag::custom-schemas[]
    IgniteConfiguration cfg = new IgniteConfiguration();
    SqlConfiguration sqlCfg = new SqlConfiguration();
    sqlCfg.setSqlSchemas("MY_SCHEMA", "MY_SECOND_SCHEMA");
    cfg.setSqlConfiguration(sqlCfg);
// end::custom-schemas[]
}
Also used : SqlConfiguration(org.apache.ignite.configuration.SqlConfiguration) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) Test(org.junit.jupiter.api.Test)

Aggregations

SqlConfiguration (org.apache.ignite.configuration.SqlConfiguration)11 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)8 List (java.util.List)4 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)3 Arrays.asList (java.util.Arrays.asList)3 HashSet (java.util.HashSet)3 IgniteEx (org.apache.ignite.internal.IgniteEx)3 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)2 AbstractIndexingCommonTest (org.apache.ignite.internal.processors.cache.index.AbstractIndexingCommonTest)2 LinkedHashMap (java.util.LinkedHashMap)1 Set (java.util.Set)1 Collectors.toSet (java.util.stream.Collectors.toSet)1 QueryEntity (org.apache.ignite.cache.QueryEntity)1 QueryIndex (org.apache.ignite.cache.QueryIndex)1 AffinityKey (org.apache.ignite.cache.affinity.AffinityKey)1 ConnectorConfiguration (org.apache.ignite.configuration.ConnectorConfiguration)1 CommandList (org.apache.ignite.internal.commandline.CommandList)1 AbstractExporterSpiTest (org.apache.ignite.internal.metric.AbstractExporterSpiTest)1 AbstractSchemaSelfTest (org.apache.ignite.internal.processors.cache.index.AbstractSchemaSelfTest)1