Search in sources :

Example 1 with SystemView

use of org.apache.ignite.spi.systemview.view.SystemView in project ignite by apache.

the class SystemViewSelfTest method testContinuousQuery.

/**
 */
@Test
public void testContinuousQuery() throws Exception {
    try (IgniteEx originNode = startGrid(0);
        IgniteEx remoteNode = startGrid(1)) {
        IgniteCache<Integer, Integer> cache = originNode.createCache("cache-1");
        SystemView<ContinuousQueryView> origQrys = originNode.context().systemView().view(CQ_SYS_VIEW);
        SystemView<ContinuousQueryView> remoteQrys = remoteNode.context().systemView().view(CQ_SYS_VIEW);
        assertEquals(0, origQrys.size());
        assertEquals(0, remoteQrys.size());
        try (QueryCursor qry = cache.query(new ContinuousQuery<>().setInitialQuery(new ScanQuery<>()).setPageSize(100).setTimeInterval(1000).setLocalListener(evts -> {
        // No-op.
        }).setRemoteFilterFactory(() -> evt -> true))) {
            for (int i = 0; i < 100; i++) cache.put(i, i);
            checkContinuousQueryView(originNode, origQrys, true);
            checkContinuousQueryView(originNode, remoteQrys, false);
        }
        assertEquals(0, origQrys.size());
        assertTrue(waitForCondition(() -> remoteQrys.size() == 0, getTestTimeout()));
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Arrays(java.util.Arrays) GridCacheUtils.cacheId(org.apache.ignite.internal.processors.cache.GridCacheUtils.cacheId) StripedExecutorTaskView(org.apache.ignite.spi.systemview.view.StripedExecutorTaskView) CountDownLatchView(org.apache.ignite.spi.systemview.view.datastructures.CountDownLatchView) QueueView(org.apache.ignite.spi.systemview.view.datastructures.QueueView) GridTestUtils.runAsync(org.apache.ignite.testframework.GridTestUtils.runAsync) TestObjectEnum(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses.TestObjectEnum) ComputeTaskView(org.apache.ignite.spi.systemview.view.ComputeTaskView) Map(java.util.Map) CachePagesListView(org.apache.ignite.spi.systemview.view.CachePagesListView) Cache(javax.cache.Cache) ComputeTask(org.apache.ignite.compute.ComputeTask) SEQUENCES_VIEW(org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.SEQUENCES_VIEW) NodeAttributeView(org.apache.ignite.spi.systemview.view.NodeAttributeView) IgniteUtils.toStringSafe(org.apache.ignite.internal.util.IgniteUtils.toStringSafe) BaselineNodeView(org.apache.ignite.spi.systemview.view.BaselineNodeView) DEFAULT_DS_GROUP_NAME(org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.DEFAULT_DS_GROUP_NAME) BaselineNodeAttributeViewWalker(org.apache.ignite.internal.managers.systemview.walker.BaselineNodeAttributeViewWalker) SystemView(org.apache.ignite.spi.systemview.view.SystemView) TransactionView(org.apache.ignite.spi.systemview.view.TransactionView) AtomicStampedView(org.apache.ignite.spi.systemview.view.datastructures.AtomicStampedView) IgniteSet(org.apache.ignite.IgniteSet) Set(java.util.Set) IgniteRunnable(org.apache.ignite.lang.IgniteRunnable) BASELINE_NODES_SYS_VIEW(org.apache.ignite.internal.processors.cluster.GridClusterStateProcessor.BASELINE_NODES_SYS_VIEW) IgniteCache(org.apache.ignite.IgniteCache) CountDownLatch(java.util.concurrent.CountDownLatch) BaselineNodeAttributeView(org.apache.ignite.spi.systemview.view.BaselineNodeAttributeView) LONGS_VIEW(org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.LONGS_VIEW) QueryCursor(org.apache.ignite.cache.query.QueryCursor) PagesListView(org.apache.ignite.spi.systemview.view.PagesListView) PESSIMISTIC(org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC) ClientConnectionView(org.apache.ignite.spi.systemview.view.ClientConnectionView) DFLT_ATOMIC_SEQUENCE_RESERVE_SIZE(org.apache.ignite.configuration.AtomicConfiguration.DFLT_ATOMIC_SEQUENCE_RESERVE_SIZE) ScanQuery(org.apache.ignite.cache.query.ScanQuery) IgniteCompute(org.apache.ignite.IgniteCompute) SETS_VIEW(org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.SETS_VIEW) GridFunc.alwaysTrue(org.apache.ignite.internal.util.lang.GridFunc.alwaysTrue) IgniteBiPredicate(org.apache.ignite.lang.IgniteBiPredicate) ComputeJob(org.apache.ignite.compute.ComputeJob) DEFAULT_VOLATILE_DS_GROUP_NAME(org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.DEFAULT_VOLATILE_DS_GROUP_NAME) ClusterState(org.apache.ignite.cluster.ClusterState) REFERENCES_VIEW(org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.REFERENCES_VIEW) U(org.apache.ignite.internal.util.typedef.internal.U) NODE_METRICS_SYS_VIEW(org.apache.ignite.internal.managers.discovery.GridDiscoveryManager.NODE_METRICS_SYS_VIEW) BINARY_METADATA_VIEW(org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl.BINARY_METADATA_VIEW) CACHE_GRP_IO_VIEW(org.apache.ignite.internal.processors.cache.GridCacheProcessor.CACHE_GRP_IO_VIEW) DISTRIBUTED_METASTORE_VIEW(org.apache.ignite.internal.processors.metastorage.persistence.DistributedMetaStorageImpl.DISTRIBUTED_METASTORE_VIEW) GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) Lists(com.google.common.collect.Lists) ClusterNode(org.apache.ignite.cluster.ClusterNode) ComputeJobResult(org.apache.ignite.compute.ComputeJobResult) IgniteClient(org.apache.ignite.client.IgniteClient) IgniteAtomicReference(org.apache.ignite.IgniteAtomicReference) METASTORAGE_CACHE_NAME(org.apache.ignite.internal.processors.cache.persistence.metastorage.MetaStorage.METASTORAGE_CACHE_NAME) IgniteAtomicStamped(org.apache.ignite.IgniteAtomicStamped) STREAM_POOL_QUEUE_VIEW(org.apache.ignite.internal.processors.pool.PoolProcessor.STREAM_POOL_QUEUE_VIEW) TASKS_VIEW(org.apache.ignite.internal.processors.task.GridTaskProcessor.TASKS_VIEW) Properties(java.util.Properties) QUEUES_VIEW(org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.QUEUES_VIEW) BrokenBarrierException(java.util.concurrent.BrokenBarrierException) CacheGroupIoView(org.apache.ignite.spi.systemview.view.CacheGroupIoView) Test(org.junit.Test) IgniteQueue(org.apache.ignite.IgniteQueue) AtomicSequenceView(org.apache.ignite.spi.systemview.view.datastructures.AtomicSequenceView) 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) NodeMetricsView(org.apache.ignite.spi.systemview.view.NodeMetricsView) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) SNAPSHOT_SYS_VIEW(org.apache.ignite.spi.systemview.view.SnapshotView.SNAPSHOT_SYS_VIEW) CachePagesListViewWalker(org.apache.ignite.internal.managers.systemview.walker.CachePagesListViewWalker) CQ_SYS_VIEW(org.apache.ignite.internal.processors.continuous.GridContinuousProcessor.CQ_SYS_VIEW) NODE_ATTRIBUTES_SYS_VIEW(org.apache.ignite.internal.managers.discovery.GridDiscoveryManager.NODE_ATTRIBUTES_SYS_VIEW) CacheAtomicityMode(org.apache.ignite.cache.CacheAtomicityMode) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) 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) ProtocolVersion(org.apache.ignite.internal.client.thin.ProtocolVersion) SERIALIZABLE(org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE) IgniteAtomicSequence(org.apache.ignite.IgniteAtomicSequence) DistributedMetaStorage(org.apache.ignite.internal.processors.metastorage.DistributedMetaStorage) Transaction(org.apache.ignite.transactions.Transaction) FiltrableSystemView(org.apache.ignite.spi.systemview.view.FiltrableSystemView) 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) IgniteSystemProperties(org.apache.ignite.IgniteSystemProperties) BinaryMetadataView(org.apache.ignite.spi.systemview.view.BinaryMetadataView) IgniteSemaphore(org.apache.ignite.IgniteSemaphore) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ComputeJobResultPolicy(org.apache.ignite.compute.ComputeJobResultPolicy) ClusterNodeView(org.apache.ignite.spi.systemview.view.ClusterNodeView) LOCKS_VIEW(org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.LOCKS_VIEW) NODES_SYS_VIEW(org.apache.ignite.internal.managers.discovery.GridDiscoveryManager.NODES_SYS_VIEW) AtomicReferenceView(org.apache.ignite.spi.systemview.view.datastructures.AtomicReferenceView) IgniteLock(org.apache.ignite.IgniteLock) CyclicBarrier(java.util.concurrent.CyclicBarrier) SVCS_VIEW(org.apache.ignite.internal.processors.service.IgniteServiceProcessor.SVCS_VIEW) IgniteCountDownLatch(org.apache.ignite.IgniteCountDownLatch) ServiceView(org.apache.ignite.spi.systemview.view.ServiceView) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) CLI_CONN_VIEW(org.apache.ignite.internal.processors.odbc.ClientListenerProcessor.CLI_CONN_VIEW) Collection(java.util.Collection) IgniteException(org.apache.ignite.IgniteException) OPTIMISTIC(org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC) LATCHES_VIEW(org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.LATCHES_VIEW) VOLATILE_DATA_REGION_NAME(org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.VOLATILE_DATA_REGION_NAME) GridTestUtils(org.apache.ignite.testframework.GridTestUtils) Objects(java.util.Objects) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) ClientConfiguration(org.apache.ignite.configuration.ClientConfiguration) CU(org.apache.ignite.internal.util.typedef.internal.CU) ACTIVE(org.apache.ignite.transactions.TransactionState.ACTIVE) NodeAttributeViewWalker(org.apache.ignite.internal.managers.systemview.walker.NodeAttributeViewWalker) NotNull(org.jetbrains.annotations.NotNull) DummyService(org.apache.ignite.internal.processors.service.DummyService) ContinuousQueryView(org.apache.ignite.spi.systemview.view.ContinuousQueryView) GridCacheUtils.cacheGroupId(org.apache.ignite.internal.processors.cache.GridCacheUtils.cacheGroupId) CacheView(org.apache.ignite.spi.systemview.view.CacheView) GridTestUtils.waitForCondition(org.apache.ignite.testframework.GridTestUtils.waitForCondition) SetView(org.apache.ignite.spi.systemview.view.datastructures.SetView) CACHES_VIEW(org.apache.ignite.internal.processors.cache.ClusterCachesInfo.CACHES_VIEW) AtomicLongView(org.apache.ignite.spi.systemview.view.datastructures.AtomicLongView) IgniteCallable(org.apache.ignite.lang.IgniteCallable) HashSet(java.util.HashSet) SEMAPHORES_VIEW(org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.SEMAPHORES_VIEW) SYS_POOL_QUEUE_VIEW(org.apache.ignite.internal.processors.pool.PoolProcessor.SYS_POOL_QUEUE_VIEW) SnapshotView(org.apache.ignite.spi.systemview.view.SnapshotView) ReentrantLockView(org.apache.ignite.spi.systemview.view.datastructures.ReentrantLockView) GridFunc.identity(org.apache.ignite.internal.util.lang.GridFunc.identity) IgniteClosure(org.apache.ignite.lang.IgniteClosure) IgnitePredicate(org.apache.ignite.lang.IgnitePredicate) AtomicConfiguration(org.apache.ignite.configuration.AtomicConfiguration) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) ScanQueryView(org.apache.ignite.spi.systemview.view.ScanQueryView) ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration) MetastorageView(org.apache.ignite.spi.systemview.view.MetastorageView) STAMPED_VIEW(org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.STAMPED_VIEW) F(org.apache.ignite.internal.util.typedef.F) Iterator(java.util.Iterator) TXS_MON_LIST(org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager.TXS_MON_LIST) JdbcConnectionContext(org.apache.ignite.internal.processors.odbc.jdbc.JdbcConnectionContext) CollectionConfiguration(org.apache.ignite.configuration.CollectionConfiguration) CACHE_GRPS_VIEW(org.apache.ignite.internal.processors.cache.ClusterCachesInfo.CACHE_GRPS_VIEW) CacheGroupView(org.apache.ignite.spi.systemview.view.CacheGroupView) TestObjectAllTypes(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses.TestObjectAllTypes) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) IgniteCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager) Ignition(org.apache.ignite.Ignition) IgniteAtomicLong(org.apache.ignite.IgniteAtomicLong) BASELINE_NODE_ATTRIBUTES_SYS_VIEW(org.apache.ignite.internal.processors.cluster.GridClusterStateProcessor.BASELINE_NODE_ATTRIBUTES_SYS_VIEW) Collections(java.util.Collections) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) SemaphoreView(org.apache.ignite.spi.systemview.view.datastructures.SemaphoreView) ContinuousQuery(org.apache.ignite.cache.query.ContinuousQuery) IgniteEx(org.apache.ignite.internal.IgniteEx) ContinuousQueryView(org.apache.ignite.spi.systemview.view.ContinuousQueryView) ScanQuery(org.apache.ignite.cache.query.ScanQuery) QueryCursor(org.apache.ignite.cache.query.QueryCursor) Test(org.junit.Test) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)

Example 2 with SystemView

use of org.apache.ignite.spi.systemview.view.SystemView in project ignite by apache.

the class SystemViewSelfTest method testBaselineNodes.

/**
 */
@Test
public void testBaselineNodes() throws Exception {
    cleanPersistenceDir();
    try (IgniteEx ignite0 = startGrid(getConfiguration(getTestIgniteInstanceName(0)).setDataStorageConfiguration(new DataStorageConfiguration().setDefaultDataRegionConfiguration(new DataRegionConfiguration().setPersistenceEnabled(true))).setConsistentId("consId0"));
        IgniteEx ignite1 = startGrid(getConfiguration(getTestIgniteInstanceName(1)).setDataStorageConfiguration(new DataStorageConfiguration().setDefaultDataRegionConfiguration(new DataRegionConfiguration().setPersistenceEnabled(true))).setConsistentId("consId1"))) {
        ignite0.cluster().state(ClusterState.ACTIVE);
        ignite1.close();
        awaitPartitionMapExchange();
        SystemView<BaselineNodeView> view = ignite0.context().systemView().view(BASELINE_NODES_SYS_VIEW);
        assertEquals(2, view.size());
        assertEquals(1, F.size(view.iterator(), row -> "consId0".equals(row.consistentId()) && row.online()));
        assertEquals(1, F.size(view.iterator(), row -> "consId1".equals(row.consistentId()) && !row.online()));
    }
}
Also used : DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) Arrays(java.util.Arrays) GridCacheUtils.cacheId(org.apache.ignite.internal.processors.cache.GridCacheUtils.cacheId) StripedExecutorTaskView(org.apache.ignite.spi.systemview.view.StripedExecutorTaskView) CountDownLatchView(org.apache.ignite.spi.systemview.view.datastructures.CountDownLatchView) QueueView(org.apache.ignite.spi.systemview.view.datastructures.QueueView) GridTestUtils.runAsync(org.apache.ignite.testframework.GridTestUtils.runAsync) TestObjectEnum(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses.TestObjectEnum) ComputeTaskView(org.apache.ignite.spi.systemview.view.ComputeTaskView) Map(java.util.Map) CachePagesListView(org.apache.ignite.spi.systemview.view.CachePagesListView) Cache(javax.cache.Cache) ComputeTask(org.apache.ignite.compute.ComputeTask) SEQUENCES_VIEW(org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.SEQUENCES_VIEW) NodeAttributeView(org.apache.ignite.spi.systemview.view.NodeAttributeView) IgniteUtils.toStringSafe(org.apache.ignite.internal.util.IgniteUtils.toStringSafe) BaselineNodeView(org.apache.ignite.spi.systemview.view.BaselineNodeView) DEFAULT_DS_GROUP_NAME(org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.DEFAULT_DS_GROUP_NAME) BaselineNodeAttributeViewWalker(org.apache.ignite.internal.managers.systemview.walker.BaselineNodeAttributeViewWalker) SystemView(org.apache.ignite.spi.systemview.view.SystemView) TransactionView(org.apache.ignite.spi.systemview.view.TransactionView) AtomicStampedView(org.apache.ignite.spi.systemview.view.datastructures.AtomicStampedView) IgniteSet(org.apache.ignite.IgniteSet) Set(java.util.Set) IgniteRunnable(org.apache.ignite.lang.IgniteRunnable) BASELINE_NODES_SYS_VIEW(org.apache.ignite.internal.processors.cluster.GridClusterStateProcessor.BASELINE_NODES_SYS_VIEW) IgniteCache(org.apache.ignite.IgniteCache) CountDownLatch(java.util.concurrent.CountDownLatch) BaselineNodeAttributeView(org.apache.ignite.spi.systemview.view.BaselineNodeAttributeView) LONGS_VIEW(org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.LONGS_VIEW) QueryCursor(org.apache.ignite.cache.query.QueryCursor) PagesListView(org.apache.ignite.spi.systemview.view.PagesListView) PESSIMISTIC(org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC) ClientConnectionView(org.apache.ignite.spi.systemview.view.ClientConnectionView) DFLT_ATOMIC_SEQUENCE_RESERVE_SIZE(org.apache.ignite.configuration.AtomicConfiguration.DFLT_ATOMIC_SEQUENCE_RESERVE_SIZE) ScanQuery(org.apache.ignite.cache.query.ScanQuery) IgniteCompute(org.apache.ignite.IgniteCompute) SETS_VIEW(org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.SETS_VIEW) GridFunc.alwaysTrue(org.apache.ignite.internal.util.lang.GridFunc.alwaysTrue) IgniteBiPredicate(org.apache.ignite.lang.IgniteBiPredicate) ComputeJob(org.apache.ignite.compute.ComputeJob) DEFAULT_VOLATILE_DS_GROUP_NAME(org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.DEFAULT_VOLATILE_DS_GROUP_NAME) ClusterState(org.apache.ignite.cluster.ClusterState) REFERENCES_VIEW(org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.REFERENCES_VIEW) U(org.apache.ignite.internal.util.typedef.internal.U) NODE_METRICS_SYS_VIEW(org.apache.ignite.internal.managers.discovery.GridDiscoveryManager.NODE_METRICS_SYS_VIEW) BINARY_METADATA_VIEW(org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl.BINARY_METADATA_VIEW) CACHE_GRP_IO_VIEW(org.apache.ignite.internal.processors.cache.GridCacheProcessor.CACHE_GRP_IO_VIEW) DISTRIBUTED_METASTORE_VIEW(org.apache.ignite.internal.processors.metastorage.persistence.DistributedMetaStorageImpl.DISTRIBUTED_METASTORE_VIEW) GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) Lists(com.google.common.collect.Lists) ClusterNode(org.apache.ignite.cluster.ClusterNode) ComputeJobResult(org.apache.ignite.compute.ComputeJobResult) IgniteClient(org.apache.ignite.client.IgniteClient) IgniteAtomicReference(org.apache.ignite.IgniteAtomicReference) METASTORAGE_CACHE_NAME(org.apache.ignite.internal.processors.cache.persistence.metastorage.MetaStorage.METASTORAGE_CACHE_NAME) IgniteAtomicStamped(org.apache.ignite.IgniteAtomicStamped) STREAM_POOL_QUEUE_VIEW(org.apache.ignite.internal.processors.pool.PoolProcessor.STREAM_POOL_QUEUE_VIEW) TASKS_VIEW(org.apache.ignite.internal.processors.task.GridTaskProcessor.TASKS_VIEW) Properties(java.util.Properties) QUEUES_VIEW(org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.QUEUES_VIEW) BrokenBarrierException(java.util.concurrent.BrokenBarrierException) CacheGroupIoView(org.apache.ignite.spi.systemview.view.CacheGroupIoView) Test(org.junit.Test) IgniteQueue(org.apache.ignite.IgniteQueue) AtomicSequenceView(org.apache.ignite.spi.systemview.view.datastructures.AtomicSequenceView) 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) NodeMetricsView(org.apache.ignite.spi.systemview.view.NodeMetricsView) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) SNAPSHOT_SYS_VIEW(org.apache.ignite.spi.systemview.view.SnapshotView.SNAPSHOT_SYS_VIEW) CachePagesListViewWalker(org.apache.ignite.internal.managers.systemview.walker.CachePagesListViewWalker) CQ_SYS_VIEW(org.apache.ignite.internal.processors.continuous.GridContinuousProcessor.CQ_SYS_VIEW) NODE_ATTRIBUTES_SYS_VIEW(org.apache.ignite.internal.managers.discovery.GridDiscoveryManager.NODE_ATTRIBUTES_SYS_VIEW) CacheAtomicityMode(org.apache.ignite.cache.CacheAtomicityMode) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) 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) ProtocolVersion(org.apache.ignite.internal.client.thin.ProtocolVersion) SERIALIZABLE(org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE) IgniteAtomicSequence(org.apache.ignite.IgniteAtomicSequence) DistributedMetaStorage(org.apache.ignite.internal.processors.metastorage.DistributedMetaStorage) Transaction(org.apache.ignite.transactions.Transaction) FiltrableSystemView(org.apache.ignite.spi.systemview.view.FiltrableSystemView) 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) IgniteSystemProperties(org.apache.ignite.IgniteSystemProperties) BinaryMetadataView(org.apache.ignite.spi.systemview.view.BinaryMetadataView) IgniteSemaphore(org.apache.ignite.IgniteSemaphore) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ComputeJobResultPolicy(org.apache.ignite.compute.ComputeJobResultPolicy) ClusterNodeView(org.apache.ignite.spi.systemview.view.ClusterNodeView) LOCKS_VIEW(org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.LOCKS_VIEW) NODES_SYS_VIEW(org.apache.ignite.internal.managers.discovery.GridDiscoveryManager.NODES_SYS_VIEW) AtomicReferenceView(org.apache.ignite.spi.systemview.view.datastructures.AtomicReferenceView) IgniteLock(org.apache.ignite.IgniteLock) CyclicBarrier(java.util.concurrent.CyclicBarrier) SVCS_VIEW(org.apache.ignite.internal.processors.service.IgniteServiceProcessor.SVCS_VIEW) IgniteCountDownLatch(org.apache.ignite.IgniteCountDownLatch) ServiceView(org.apache.ignite.spi.systemview.view.ServiceView) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) CLI_CONN_VIEW(org.apache.ignite.internal.processors.odbc.ClientListenerProcessor.CLI_CONN_VIEW) Collection(java.util.Collection) IgniteException(org.apache.ignite.IgniteException) OPTIMISTIC(org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC) LATCHES_VIEW(org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.LATCHES_VIEW) VOLATILE_DATA_REGION_NAME(org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.VOLATILE_DATA_REGION_NAME) GridTestUtils(org.apache.ignite.testframework.GridTestUtils) Objects(java.util.Objects) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) ClientConfiguration(org.apache.ignite.configuration.ClientConfiguration) CU(org.apache.ignite.internal.util.typedef.internal.CU) ACTIVE(org.apache.ignite.transactions.TransactionState.ACTIVE) NodeAttributeViewWalker(org.apache.ignite.internal.managers.systemview.walker.NodeAttributeViewWalker) NotNull(org.jetbrains.annotations.NotNull) DummyService(org.apache.ignite.internal.processors.service.DummyService) ContinuousQueryView(org.apache.ignite.spi.systemview.view.ContinuousQueryView) GridCacheUtils.cacheGroupId(org.apache.ignite.internal.processors.cache.GridCacheUtils.cacheGroupId) CacheView(org.apache.ignite.spi.systemview.view.CacheView) GridTestUtils.waitForCondition(org.apache.ignite.testframework.GridTestUtils.waitForCondition) SetView(org.apache.ignite.spi.systemview.view.datastructures.SetView) CACHES_VIEW(org.apache.ignite.internal.processors.cache.ClusterCachesInfo.CACHES_VIEW) AtomicLongView(org.apache.ignite.spi.systemview.view.datastructures.AtomicLongView) IgniteCallable(org.apache.ignite.lang.IgniteCallable) HashSet(java.util.HashSet) SEMAPHORES_VIEW(org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.SEMAPHORES_VIEW) SYS_POOL_QUEUE_VIEW(org.apache.ignite.internal.processors.pool.PoolProcessor.SYS_POOL_QUEUE_VIEW) SnapshotView(org.apache.ignite.spi.systemview.view.SnapshotView) ReentrantLockView(org.apache.ignite.spi.systemview.view.datastructures.ReentrantLockView) GridFunc.identity(org.apache.ignite.internal.util.lang.GridFunc.identity) IgniteClosure(org.apache.ignite.lang.IgniteClosure) IgnitePredicate(org.apache.ignite.lang.IgnitePredicate) AtomicConfiguration(org.apache.ignite.configuration.AtomicConfiguration) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) ScanQueryView(org.apache.ignite.spi.systemview.view.ScanQueryView) ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration) MetastorageView(org.apache.ignite.spi.systemview.view.MetastorageView) STAMPED_VIEW(org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.STAMPED_VIEW) F(org.apache.ignite.internal.util.typedef.F) Iterator(java.util.Iterator) TXS_MON_LIST(org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager.TXS_MON_LIST) JdbcConnectionContext(org.apache.ignite.internal.processors.odbc.jdbc.JdbcConnectionContext) CollectionConfiguration(org.apache.ignite.configuration.CollectionConfiguration) CACHE_GRPS_VIEW(org.apache.ignite.internal.processors.cache.ClusterCachesInfo.CACHE_GRPS_VIEW) CacheGroupView(org.apache.ignite.spi.systemview.view.CacheGroupView) TestObjectAllTypes(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses.TestObjectAllTypes) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) IgniteCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager) Ignition(org.apache.ignite.Ignition) IgniteAtomicLong(org.apache.ignite.IgniteAtomicLong) BASELINE_NODE_ATTRIBUTES_SYS_VIEW(org.apache.ignite.internal.processors.cluster.GridClusterStateProcessor.BASELINE_NODE_ATTRIBUTES_SYS_VIEW) Collections(java.util.Collections) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) SemaphoreView(org.apache.ignite.spi.systemview.view.datastructures.SemaphoreView) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) IgniteEx(org.apache.ignite.internal.IgniteEx) BaselineNodeView(org.apache.ignite.spi.systemview.view.BaselineNodeView) Test(org.junit.Test) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)

Example 3 with SystemView

use of org.apache.ignite.spi.systemview.view.SystemView 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)

Example 4 with SystemView

use of org.apache.ignite.spi.systemview.view.SystemView in project ignite by apache.

the class SystemViewCommandTest method testPartitionStates.

/**
 */
@Test
public void testPartitionStates() throws Exception {
    String nodeName0 = getTestIgniteInstanceName(0);
    String nodeName1 = getTestIgniteInstanceName(1);
    String nodeName2 = getTestIgniteInstanceName(2);
    IgniteCache<Integer, Integer> cache1 = ignite0.createCache(new CacheConfiguration<Integer, Integer>().setName("cache1").setCacheMode(CacheMode.PARTITIONED).setAffinity(new TestAffinityFunction(new String[][] { { nodeName0, nodeName1 }, { nodeName1, nodeName2 }, { nodeName2, nodeName0 } })));
    IgniteCache<Integer, Integer> cache2 = ignite0.createCache(new CacheConfiguration<Integer, Integer>().setName("cache2").setCacheMode(CacheMode.PARTITIONED).setAffinity(new TestAffinityFunction(new String[][] { { nodeName0, nodeName1, nodeName2 }, { nodeName1 } })));
    for (int i = 0; i < 100; i++) {
        cache1.put(i, i);
        cache2.put(i, i);
    }
    try (IgniteEx ignite2 = startGrid(nodeName2)) {
        ignite2.rebalanceEnabled(false);
        ignite0.cluster().setBaselineTopology(ignite0.cluster().topologyVersion());
        String nodeId0 = ignite0.cluster().localNode().id().toString();
        String nodeId1 = ignite(1).cluster().localNode().id().toString();
        String nodeId2 = ignite2.cluster().localNode().id().toString();
        String cacheGrpId1 = Integer.toString(ignite0.cachex("cache1").context().groupId());
        String cacheGrpId2 = Integer.toString(ignite0.cachex("cache2").context().groupId());
        String owningState = GridDhtPartitionState.OWNING.name();
        String movingState = GridDhtPartitionState.MOVING.name();
        for (int i = 0; i < 3; i++) {
            List<List<String>> partStatesView = systemView(ignite(i), PART_STATES_VIEW);
            // Check partitions for cache1.
            checkPartitionStatesView(partStatesView, owningState, true, cacheGrpId1, nodeId0, 0);
            checkPartitionStatesView(partStatesView, owningState, false, cacheGrpId1, nodeId1, 0);
            checkPartitionStatesView(partStatesView, owningState, true, cacheGrpId1, nodeId1, 1);
            checkPartitionStatesView(partStatesView, movingState, false, cacheGrpId1, nodeId2, 1);
            checkPartitionStatesView(partStatesView, owningState, true, cacheGrpId1, nodeId0, 2);
            checkPartitionStatesView(partStatesView, movingState, false, cacheGrpId1, nodeId2, 2);
            checkPartitionStatesView(partStatesView, owningState, true, cacheGrpId2, nodeId0, 0);
            checkPartitionStatesView(partStatesView, owningState, false, cacheGrpId2, nodeId1, 0);
            checkPartitionStatesView(partStatesView, movingState, false, cacheGrpId2, nodeId2, 0);
            checkPartitionStatesView(partStatesView, owningState, true, cacheGrpId2, nodeId1, 1);
        }
        AffinityTopologyVersion topVer = ignite0.context().discovery().topologyVersionEx();
        ignite2.rebalanceEnabled(true);
        // Wait until rebalance complete.
        assertTrue(waitForCondition(() -> ignite0.context().discovery().topologyVersionEx().compareTo(topVer) > 0, getTestTimeout()));
        for (int i = 0; i < 3; i++) {
            List<List<String>> rows = systemView(ignite(i), PART_STATES_VIEW);
            assertEquals(10, rows.stream().filter(row -> (cacheGrpId1.equals(row.get(0)) || cacheGrpId2.equals(row.get(0))) && owningState.equals(row.get(3))).count());
            assertTrue(rows.stream().noneMatch(row -> (cacheGrpId1.equals(row.get(0)) || cacheGrpId2.equals(row.get(0))) && movingState.equals(row.get(3))));
        }
        // Check that assignment is now changed to ideal.
        for (int i = 0; i < 3; i++) {
            List<List<String>> rows = systemView(ignite(i), PART_STATES_VIEW);
            checkPartitionStatesView(rows, owningState, false, cacheGrpId1, nodeId0, 2);
            checkPartitionStatesView(rows, owningState, true, cacheGrpId1, nodeId2, 2);
        }
    } finally {
        ignite0.cluster().setBaselineTopology(ignite0.cluster().topologyVersion());
    }
}
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) TestAffinityFunction(org.apache.ignite.internal.processors.cache.metric.SqlViewExporterSpiTest.TestAffinityFunction) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) 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) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) Test(org.junit.Test)

Example 5 with SystemView

use of org.apache.ignite.spi.systemview.view.SystemView in project ignite by apache.

the class KillCommandsCommandShTest method testCancelConsistencyTask.

/**
 */
@Test
public void testCancelConsistencyTask() throws InterruptedException {
    String consistencyCacheName = "consistencyCache";
    CacheConfiguration<Integer, Integer> cfg = new CacheConfiguration<>();
    cfg.setName(consistencyCacheName);
    cfg.setBackups(SERVER_NODE_CNT - 1);
    cfg.setAffinity(new RendezvousAffinityFunction().setPartitions(1));
    IgniteCache<Integer, Integer> cache = client.getOrCreateCache(cfg);
    int entries = 10_000;
    for (int i = 0; i < entries; i++) cache.put(i, i);
    AtomicInteger getCnt = new AtomicInteger();
    CountDownLatch thLatch = new CountDownLatch(1);
    Thread th = new Thread(() -> {
        IgnitePredicate<ComputeJobView> repairJobFilter = job -> job.taskClassName().equals(VisorConsistencyRepairTask.class.getName());
        for (IgniteEx node : srvs) {
            SystemView<ComputeJobView> jobs = node.context().systemView().view(JOBS_VIEW);
            // Found.
            assertTrue(F.iterator0(jobs, true, repairJobFilter).hasNext());
        }
        int res = execute("--consistency", "status");
        assertEquals(EXIT_CODE_OK, res);
        assertContains(log, testOut.toString(), "Status: 1024/" + entries);
        assertNotContains(log, testOut.toString(), VisorConsistencyStatusTask.NOTHING_FOUND);
        testOut.reset();
        res = execute("--kill", "consistency");
        assertEquals(EXIT_CODE_OK, res);
        try {
            assertTrue(GridTestUtils.waitForCondition(() -> {
                for (IgniteEx node : srvs) {
                    SystemView<ComputeJobView> jobs = node.context().systemView().view(JOBS_VIEW);
                    if (// Found.
                    F.iterator0(jobs, true, repairJobFilter).hasNext())
                        return false;
                }
                return true;
            }, // Missed.
            5000L));
        } catch (IgniteInterruptedCheckedException e) {
            fail();
        }
        thLatch.countDown();
    });
    // GridNearGetRequest messages count required to pefrom getAll() with readRepair from all nodes twice.
    // First will be finished (which generates status), second will be frozen.
    int twiceGetMsgCnt = SERVER_NODE_CNT * (SERVER_NODE_CNT - 1) * 2;
    for (IgniteEx server : srvs) {
        TestRecordingCommunicationSpi spi = ((TestRecordingCommunicationSpi) server.configuration().getCommunicationSpi());
        AtomicInteger locLimit = new AtomicInteger(SERVER_NODE_CNT - 1);
        spi.blockMessages((node, message) -> {
            if (message instanceof GridNearGetRequest) {
                // Each node should perform get twice.
                if (getCnt.incrementAndGet() == twiceGetMsgCnt)
                    th.start();
                // Cancellation should stop the process.
                assertTrue(getCnt.get() <= twiceGetMsgCnt);
                // Blocking to freeze '--consistency repair' operation (except first get).
                return locLimit.decrementAndGet() < 0;
            }
            return false;
        });
    }
    injectTestSystemOut();
    assertEquals(EXIT_CODE_UNEXPECTED_ERROR, execute("--consistency", "repair", ConsistencyCommand.STRATEGY, ReadRepairStrategy.LWW.toString(), ConsistencyCommand.PARTITION, "0", ConsistencyCommand.CACHE, consistencyCacheName));
    assertContains(log, testOut.toString(), "Operation execution cancelled.");
    assertContains(log, testOut.toString(), VisorConsistencyRepairTask.NOTHING_FOUND);
    assertNotContains(log, testOut.toString(), VisorConsistencyRepairTask.CONSISTENCY_VIOLATIONS_FOUND);
    thLatch.await();
    for (IgniteEx server : srvs) {
        // Restoring messaging for other tests.
        TestRecordingCommunicationSpi spi = ((TestRecordingCommunicationSpi) server.configuration().getCommunicationSpi());
        spi.stopBlock();
    }
    testOut.reset();
    int res = execute("--consistency", "status");
    assertEquals(EXIT_CODE_OK, res);
    assertContains(log, testOut.toString(), VisorConsistencyStatusTask.NOTHING_FOUND);
    assertNotContains(log, testOut.toString(), "Status");
}
Also used : CacheAtomicityMode(org.apache.ignite.cache.CacheAtomicityMode) KillCommandsTests.doTestScanQueryCancel(org.apache.ignite.util.KillCommandsTests.doTestScanQueryCancel) KillCommandsTests.doTestCancelService(org.apache.ignite.util.KillCommandsTests.doTestCancelService) IgniteEx(org.apache.ignite.internal.IgniteEx) EXIT_CODE_OK(org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_OK) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) ArrayList(java.util.ArrayList) KillCommandsTests.doTestCancelSQLQuery(org.apache.ignite.util.KillCommandsTests.doTestCancelSQLQuery) KillCommandsTests.doTestCancelTx(org.apache.ignite.util.KillCommandsTests.doTestCancelTx) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) IgnitePredicate(org.apache.ignite.lang.IgnitePredicate) IgniteInterruptedCheckedException(org.apache.ignite.internal.IgniteInterruptedCheckedException) VisorConsistencyStatusTask(org.apache.ignite.internal.visor.consistency.VisorConsistencyStatusTask) GridTestUtils.assertNotContains(org.apache.ignite.testframework.GridTestUtils.assertNotContains) GridNearGetRequest(org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetRequest) F(org.apache.ignite.internal.util.typedef.F) KillCommandsTests.doTestCancelComputeTask(org.apache.ignite.util.KillCommandsTests.doTestCancelComputeTask) SystemView(org.apache.ignite.spi.systemview.view.SystemView) JOBS_VIEW(org.apache.ignite.internal.processors.job.GridJobProcessor.JOBS_VIEW) ReadRepairStrategy(org.apache.ignite.cache.ReadRepairStrategy) Test(org.junit.Test) UUID(java.util.UUID) IgniteCache(org.apache.ignite.IgniteCache) ConsistencyCommand(org.apache.ignite.internal.commandline.consistency.ConsistencyCommand) EXIT_CODE_UNEXPECTED_ERROR(org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_UNEXPECTED_ERROR) GridTestUtils(org.apache.ignite.testframework.GridTestUtils) GridTestUtils.assertContains(org.apache.ignite.testframework.GridTestUtils.assertContains) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) PAGES_CNT(org.apache.ignite.util.KillCommandsTests.PAGES_CNT) AbstractSnapshotSelfTest.doSnapshotCancellationTest(org.apache.ignite.internal.processors.cache.persistence.snapshot.AbstractSnapshotSelfTest.doSnapshotCancellationTest) VisorConsistencyRepairTask(org.apache.ignite.internal.visor.consistency.VisorConsistencyRepairTask) ComputeJobView(org.apache.ignite.spi.systemview.view.ComputeJobView) KillCommandsTests.doTestCancelContinuousQuery(org.apache.ignite.util.KillCommandsTests.doTestCancelContinuousQuery) TestRecordingCommunicationSpi(org.apache.ignite.internal.TestRecordingCommunicationSpi) PAGE_SZ(org.apache.ignite.util.KillCommandsTests.PAGE_SZ) IgniteUuid(org.apache.ignite.lang.IgniteUuid) CountDownLatch(java.util.concurrent.CountDownLatch) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ComputeJobView(org.apache.ignite.spi.systemview.view.ComputeJobView) SystemView(org.apache.ignite.spi.systemview.view.SystemView) IgniteInterruptedCheckedException(org.apache.ignite.internal.IgniteInterruptedCheckedException) TestRecordingCommunicationSpi(org.apache.ignite.internal.TestRecordingCommunicationSpi) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) IgniteEx(org.apache.ignite.internal.IgniteEx) VisorConsistencyRepairTask(org.apache.ignite.internal.visor.consistency.VisorConsistencyRepairTask) GridNearGetRequest(org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetRequest) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) Test(org.junit.Test) AbstractSnapshotSelfTest.doSnapshotCancellationTest(org.apache.ignite.internal.processors.cache.persistence.snapshot.AbstractSnapshotSelfTest.doSnapshotCancellationTest)

Aggregations

List (java.util.List)12 CountDownLatch (java.util.concurrent.CountDownLatch)12 IgniteCache (org.apache.ignite.IgniteCache)12 Arrays (java.util.Arrays)11 HashSet (java.util.HashSet)11 Set (java.util.Set)11 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)11 Ignition (org.apache.ignite.Ignition)11 RendezvousAffinityFunction (org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction)11 Field (java.lang.reflect.Field)10 Connection (java.sql.Connection)10 Objects (java.util.Objects)10 Properties (java.util.Properties)10 Consumer (java.util.function.Consumer)10 IgniteJdbcThinDriver (org.apache.ignite.IgniteJdbcThinDriver)10 CacheAtomicityMode (org.apache.ignite.cache.CacheAtomicityMode)10 ContinuousQuery (org.apache.ignite.cache.query.ContinuousQuery)10 QueryCursor (org.apache.ignite.cache.query.QueryCursor)10 ScanQuery (org.apache.ignite.cache.query.ScanQuery)10 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)8