Search in sources :

Example 1 with DATA_REGION_PAGE_LIST_VIEW

use of org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager.DATA_REGION_PAGE_LIST_VIEW in project ignite by apache.

the class SystemViewCommandTest method testPagesList.

/**
 */
@Test
public void testPagesList() throws Exception {
    String cacheName = "cacheFL";
    IgniteCache<Integer, byte[]> cache = ignite0.getOrCreateCache(new CacheConfiguration<Integer, byte[]>().setName(cacheName).setAffinity(new RendezvousAffinityFunction().setPartitions(1)));
    GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager) ignite0.context().cache().context().database();
    int pageSize = dbMgr.pageSize();
    try {
        dbMgr.enableCheckpoints(false).get();
        int key = 0;
        // Fill up different free-list buckets.
        for (int j = 0; j < pageSize / 2; j++) cache.put(key++, new byte[j + 1]);
        // Put some pages to one bucket to overflow pages cache.
        for (int j = 0; j < 1000; j++) cache.put(key++, new byte[pageSize / 2]);
        List<List<String>> cacheGrpView = systemView(ignite0, CACHE_GRP_PAGE_LIST_VIEW);
        List<List<String>> dataRegionView = systemView(ignite0, DATA_REGION_PAGE_LIST_VIEW);
        String cacheId = Integer.toString(cacheId(cacheName));
        // Test filtering by 3 columns.
        assertFalse(cacheGrpView.stream().noneMatch(row -> cacheId.equals(row.get(0)) && "0".equals(row.get(1)) && "0".equals(row.get(3))));
        // Test filtering with invalid cache group id.
        assertTrue(cacheGrpView.stream().noneMatch(row -> "-1".equals(row.get(0))));
        // Test filtering with invalid partition id.
        assertTrue(cacheGrpView.stream().noneMatch(row -> "-1".equals(row.get(1))));
        // Test filtering with invalid bucket number.
        assertTrue(cacheGrpView.stream().noneMatch(row -> "-1".equals(row.get(3))));
        assertFalse(cacheGrpView.stream().noneMatch(row -> Integer.parseInt(row.get(4)) > 0 && cacheId.equals(row.get(0))));
        assertFalse(cacheGrpView.stream().noneMatch(row -> Integer.parseInt(row.get(5)) > 0 && cacheId.equals(row.get(0))));
        assertFalse(cacheGrpView.stream().noneMatch(row -> Integer.parseInt(row.get(6)) > 0 && cacheId.equals(row.get(0))));
        assertFalse(dataRegionView.stream().noneMatch(row -> row.get(0).startsWith(DATA_REGION_NAME)));
        assertTrue(dataRegionView.stream().noneMatch(row -> row.get(0).startsWith(DATA_REGION_NAME) && Integer.parseInt(row.get(4)) > 0));
    } finally {
        dbMgr.enableCheckpoints(true).get();
    }
    ignite0.cluster().state(INACTIVE);
    ignite0.cluster().state(ACTIVE);
    IgniteCache<Integer, Integer> cacheInMemory = ignite0.getOrCreateCache(new CacheConfiguration<Integer, Integer>().setName("cacheFLInMemory").setDataRegionName(DATA_REGION_NAME));
    cacheInMemory.put(0, 0);
    // After activation/deactivation new view for data region pages lists should be created, check that new view
    // correctly reflects changes in free-lists.
    assertTrue(systemView(ignite0, DATA_REGION_PAGE_LIST_VIEW).stream().noneMatch(row -> row.get(0).startsWith(DATA_REGION_NAME) && Integer.parseInt(row.get(4)) > 0));
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Arrays(java.util.Arrays) GridCacheUtils.cacheId(org.apache.ignite.internal.processors.cache.GridCacheUtils.cacheId) MAX_VALUE(java.lang.Integer.MAX_VALUE) TestObjectEnum(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses.TestObjectEnum) EXIT_CODE_INVALID_ARGUMENTS(org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_INVALID_ARGUMENTS) Arrays.asList(java.util.Arrays.asList) PART_STATES_VIEW(org.apache.ignite.internal.processors.cache.GridCacheProcessor.PART_STATES_VIEW) SQL_TBLS_VIEW(org.apache.ignite.internal.processors.query.h2.SchemaManager.SQL_TBLS_VIEW) IgniteUtils.toStringSafe(org.apache.ignite.internal.util.IgniteUtils.toStringSafe) TestAffinityFunction(org.apache.ignite.internal.processors.cache.metric.SqlViewExporterSpiTest.TestAffinityFunction) INACTIVE(org.apache.ignite.cluster.ClusterState.INACTIVE) SystemView(org.apache.ignite.spi.systemview.view.SystemView) Set(java.util.Set) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) IgniteCache(org.apache.ignite.IgniteCache) CountDownLatch(java.util.concurrent.CountDownLatch) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TEST_TRANSFORMER(org.apache.ignite.internal.metric.SystemViewSelfTest.TEST_TRANSFORMER) QueryCursor(org.apache.ignite.cache.query.QueryCursor) PESSIMISTIC(org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC) ScanQuery(org.apache.ignite.cache.query.ScanQuery) U(org.apache.ignite.internal.util.typedef.internal.U) EXIT_CODE_OK(org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_OK) BINARY_METADATA_VIEW(org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl.BINARY_METADATA_VIEW) ArrayList(java.util.ArrayList) COLUMN_SEPARATOR(org.apache.ignite.internal.commandline.systemview.SystemViewCommand.COLUMN_SEPARATOR) DISTRIBUTED_METASTORE_VIEW(org.apache.ignite.internal.processors.metastorage.persistence.DistributedMetaStorageImpl.DISTRIBUTED_METASTORE_VIEW) GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) IgniteClient(org.apache.ignite.client.IgniteClient) AbstractSchemaSelfTest.queryProcessor(org.apache.ignite.internal.processors.cache.index.AbstractSchemaSelfTest.queryProcessor) TEST_PREDICATE(org.apache.ignite.internal.metric.SystemViewSelfTest.TEST_PREDICATE) SQL_SCHEMA_VIEW(org.apache.ignite.internal.processors.query.h2.SchemaManager.SQL_SCHEMA_VIEW) TestTransformer(org.apache.ignite.internal.metric.SystemViewSelfTest.TestTransformer) STREAM_POOL_QUEUE_VIEW(org.apache.ignite.internal.processors.pool.PoolProcessor.STREAM_POOL_QUEUE_VIEW) ACTIVE(org.apache.ignite.cluster.ClusterState.ACTIVE) TASKS_VIEW(org.apache.ignite.internal.processors.task.GridTaskProcessor.TASKS_VIEW) Properties(java.util.Properties) Test(org.junit.Test) Ignite(org.apache.ignite.Ignite) Field(java.lang.reflect.Field) ContinuousQuery(org.apache.ignite.cache.query.ContinuousQuery) SCAN_QRY_SYS_VIEW(org.apache.ignite.internal.managers.systemview.ScanQuerySystemView.SCAN_QRY_SYS_VIEW) TRANSACTIONAL(org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL) NODE_ID(org.apache.ignite.internal.commandline.systemview.SystemViewCommandArg.NODE_ID) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) SQL_VIEW_COLS_VIEW(org.apache.ignite.internal.processors.query.h2.SchemaManager.SQL_VIEW_COLS_VIEW) SNAPSHOT_SYS_VIEW(org.apache.ignite.spi.systemview.view.SnapshotView.SNAPSHOT_SYS_VIEW) SYSTEM_VIEW(org.apache.ignite.internal.commandline.CommandList.SYSTEM_VIEW) CQ_SYS_VIEW(org.apache.ignite.internal.processors.continuous.GridContinuousProcessor.CQ_SYS_VIEW) CacheMode(org.apache.ignite.cache.CacheMode) IgniteJdbcThinDriver(org.apache.ignite.IgniteJdbcThinDriver) StripedExecutor(org.apache.ignite.internal.util.StripedExecutor) DATA_REGION_PAGE_LIST_VIEW(org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager.DATA_REGION_PAGE_LIST_VIEW) Connection(java.sql.Connection) SERIALIZABLE(org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE) SQL_TBL_COLS_VIEW(org.apache.ignite.internal.processors.query.h2.SchemaManager.SQL_TBL_COLS_VIEW) SqlFieldsQuery(org.apache.ignite.cache.query.SqlFieldsQuery) DistributedMetaStorage(org.apache.ignite.internal.processors.metastorage.DistributedMetaStorage) Transaction(org.apache.ignite.transactions.Transaction) CACHE_GRP_PAGE_LIST_VIEW(org.apache.ignite.internal.processors.cache.GridCacheProcessor.CACHE_GRP_PAGE_LIST_VIEW) IgniteEx(org.apache.ignite.internal.IgniteEx) METASTORE_VIEW(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager.METASTORE_VIEW) REPEATABLE_READ(org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) SystemViewCommandArg(org.apache.ignite.internal.commandline.systemview.SystemViewCommandArg) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) GridDhtPartitionState(org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState) SVCS_VIEW(org.apache.ignite.internal.processors.service.IgniteServiceProcessor.SVCS_VIEW) CLI_CONN_VIEW(org.apache.ignite.internal.processors.odbc.ClientListenerProcessor.CLI_CONN_VIEW) SCHEMA_SYS(org.apache.ignite.internal.processors.query.QueryUtils.SCHEMA_SYS) OPTIMISTIC(org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC) UUID(java.util.UUID) CommandList(org.apache.ignite.internal.commandline.CommandList) Collectors(java.util.stream.Collectors) VisorSystemViewTask(org.apache.ignite.internal.visor.systemview.VisorSystemViewTask) GridTestUtils(org.apache.ignite.testframework.GridTestUtils) Objects(java.util.Objects) List(java.util.List) ClientConfiguration(org.apache.ignite.configuration.ClientConfiguration) DFLT_SCHEMA(org.apache.ignite.internal.processors.query.QueryUtils.DFLT_SCHEMA) DummyService(org.apache.ignite.internal.processors.service.DummyService) GridCacheUtils.cacheGroupId(org.apache.ignite.internal.processors.cache.GridCacheUtils.cacheGroupId) GridTestUtils.waitForCondition(org.apache.ignite.testframework.GridTestUtils.waitForCondition) CACHES_VIEW(org.apache.ignite.internal.processors.cache.ClusterCachesInfo.CACHES_VIEW) HashSet(java.util.HashSet) SYS_POOL_QUEUE_VIEW(org.apache.ignite.internal.processors.pool.PoolProcessor.SYS_POOL_QUEUE_VIEW) AttributeVisitor(org.apache.ignite.spi.systemview.view.SystemViewRowAttributeWalker.AttributeVisitor) Pattern.quote(java.util.regex.Pattern.quote) TestRunnable(org.apache.ignite.internal.metric.SystemViewSelfTest.TestRunnable) SQL_VIEWS_VIEW(org.apache.ignite.internal.processors.query.h2.SchemaManager.SQL_VIEWS_VIEW) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration) MetricUtils.toSqlName(org.apache.ignite.internal.processors.metric.impl.MetricUtils.toSqlName) SqlConfiguration(org.apache.ignite.configuration.SqlConfiguration) TestPredicate(org.apache.ignite.internal.metric.SystemViewSelfTest.TestPredicate) TXS_MON_LIST(org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager.TXS_MON_LIST) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) CACHE_GRPS_VIEW(org.apache.ignite.internal.processors.cache.ClusterCachesInfo.CACHE_GRPS_VIEW) TestObjectAllTypes(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses.TestObjectAllTypes) GridTestUtils.assertContains(org.apache.ignite.testframework.GridTestUtils.assertContains) Consumer(java.util.function.Consumer) IgniteCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager) Ignition(org.apache.ignite.Ignition) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) Arrays.asList(java.util.Arrays.asList) ArrayList(java.util.ArrayList) CommandList(org.apache.ignite.internal.commandline.CommandList) List(java.util.List) Test(org.junit.Test)

Aggregations

MAX_VALUE (java.lang.Integer.MAX_VALUE)1 Field (java.lang.reflect.Field)1 Connection (java.sql.Connection)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Arrays.asList (java.util.Arrays.asList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Objects (java.util.Objects)1 Properties (java.util.Properties)1 Set (java.util.Set)1 UUID (java.util.UUID)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 MILLISECONDS (java.util.concurrent.TimeUnit.MILLISECONDS)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Consumer (java.util.function.Consumer)1 Pattern.quote (java.util.regex.Pattern.quote)1 Collectors (java.util.stream.Collectors)1 Ignite (org.apache.ignite.Ignite)1 IgniteCache (org.apache.ignite.IgniteCache)1