Search in sources :

Example 1 with SQL_TBL_COLS_VIEW

use of org.apache.ignite.internal.processors.query.h2.SchemaManager.SQL_TBL_COLS_VIEW in project ignite by apache.

the class JmxExporterSpiTest method testTableColumns.

/**
 * @throws Exception If failed.
 */
@Test
public void testTableColumns() throws Exception {
    String tableName = "TEST";
    IgniteEx ignite = startGrid(getConfiguration().setCacheConfiguration(new CacheConfiguration<>(DEFAULT_CACHE_NAME).setQueryEntities(F.asList(new QueryEntity().setTableName(tableName).setKeyFieldName("ID").setValueType(Integer.class.getName()).addQueryField("ID", Integer.class.getName(), null)))));
    Map<String, String> expTypes = new HashMap<>();
    expTypes.put("_KEY", null);
    expTypes.put("_VAL", null);
    expTypes.put("ID", Integer.class.getName());
    TabularDataSupport columns = (TabularDataSupport) metricRegistry(ignite.name(), VIEWS, SQL_TBL_COLS_VIEW).getAttribute(VIEWS);
    columns.values().stream().map(data -> (CompositeData) data).filter(data -> tableName.equals(data.get("tableName"))).forEach(data -> {
        String columnName = (String) data.get("columnName");
        assertTrue("Unexpected column: " + columnName, expTypes.containsKey(columnName));
        assertEquals(expTypes.remove(columnName), data.get("type"));
    });
    assertTrue("Expected columns: " + expTypes.keySet(), expTypes.isEmpty());
}
Also used : F(org.apache.ignite.internal.util.typedef.F) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) SQL_TBL_COLS_VIEW(org.apache.ignite.internal.processors.query.h2.SchemaManager.SQL_TBL_COLS_VIEW) CompositeData(javax.management.openmbean.CompositeData) HashMap(java.util.HashMap) IgniteEx(org.apache.ignite.internal.IgniteEx) Test(org.junit.Test) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) Map(java.util.Map) TabularDataSupport(javax.management.openmbean.TabularDataSupport) QueryEntity(org.apache.ignite.cache.QueryEntity) JmxSystemViewExporterSpi(org.apache.ignite.internal.managers.systemview.JmxSystemViewExporterSpi) VIEWS(org.apache.ignite.internal.managers.systemview.SystemViewMBean.VIEWS) HashMap(java.util.HashMap) TabularDataSupport(javax.management.openmbean.TabularDataSupport) IgniteEx(org.apache.ignite.internal.IgniteEx) QueryEntity(org.apache.ignite.cache.QueryEntity) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 CompositeData (javax.management.openmbean.CompositeData)1 TabularDataSupport (javax.management.openmbean.TabularDataSupport)1 QueryEntity (org.apache.ignite.cache.QueryEntity)1 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)1 IgniteEx (org.apache.ignite.internal.IgniteEx)1 JmxSystemViewExporterSpi (org.apache.ignite.internal.managers.systemview.JmxSystemViewExporterSpi)1 VIEWS (org.apache.ignite.internal.managers.systemview.SystemViewMBean.VIEWS)1 SQL_TBL_COLS_VIEW (org.apache.ignite.internal.processors.query.h2.SchemaManager.SQL_TBL_COLS_VIEW)1 F (org.apache.ignite.internal.util.typedef.F)1 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)1 Test (org.junit.Test)1