Search in sources :

Example 1 with QueueView

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

the class DataStructuresProcessor method registerSystemViews.

/**
 * Register system views.
 */
private void registerSystemViews() {
    ctx.systemView().registerView(SEQUENCES_VIEW, SEQUENCES_VIEW_DESC, new AtomicSequenceViewWalker(), new PredicateCollectionView<>(dsMap.values(), v -> v instanceof IgniteAtomicSequence), AtomicSequenceView::new);
    ctx.systemView().registerView(LONGS_VIEW, LONGS_VIEW_DESC, new AtomicLongViewWalker(), new PredicateCollectionView<>(dsMap.values(), v -> v instanceof IgniteAtomicLong), AtomicLongView::new);
    ctx.systemView().registerView(REFERENCES_VIEW, REFERENCES_VIEW_DESC, new AtomicReferenceViewWalker(), new PredicateCollectionView<>(dsMap.values(), v -> v instanceof IgniteAtomicReference), AtomicReferenceView::new);
    ctx.systemView().registerView(STAMPED_VIEW, STAMPED_VIEW_DESC, new AtomicStampedViewWalker(), new PredicateCollectionView<>(dsMap.values(), v -> v instanceof IgniteAtomicStamped), AtomicStampedView::new);
    ctx.systemView().registerView(LATCHES_VIEW, LATCHES_VIEW_DESC, new CountDownLatchViewWalker(), new PredicateCollectionView<>(dsMap.values(), v -> v instanceof IgniteCountDownLatch), CountDownLatchView::new);
    ctx.systemView().registerView(SEMAPHORES_VIEW, SEMAPHORES_VIEW_DESC, new SemaphoreViewWalker(), new PredicateCollectionView<>(dsMap.values(), v -> v instanceof IgniteSemaphore), SemaphoreView::new);
    ctx.systemView().registerView(LOCKS_VIEW, LOCKS_VIEW_DESC, new ReentrantLockViewWalker(), new PredicateCollectionView<>(dsMap.values(), v -> v instanceof IgniteLock), ReentrantLockView::new);
    ctx.systemView().registerInnerCollectionView(QUEUES_VIEW, QUEUES_VIEW_DESC, new QueueViewWalker(), new TransformCollectionView<>(ctx.cache().cacheDescriptors().values(), desc -> ctx.cache().cache(desc.cacheName()).context().dataStructures(), desc -> desc.cacheType() == CacheType.DATA_STRUCTURES), cctx -> cctx.queues().values(), (cctx, queue) -> new QueueView(queue));
    ctx.systemView().registerInnerCollectionView(SETS_VIEW, SETS_VIEW_DESC, new SetViewWalker(), F.viewReadOnly(ctx.cache().cacheDescriptors().values(), desc -> ctx.cache().cache(desc.cacheName()).context().dataStructures(), desc -> desc.cacheType() == CacheType.DATA_STRUCTURES), cctx -> cctx.sets().values(), (cctx, set) -> new SetView(set));
}
Also used : CacheType(org.apache.ignite.internal.processors.cache.CacheType) EVT_NODE_LEFT(org.apache.ignite.events.EventType.EVT_NODE_LEFT) CountDownLatchView(org.apache.ignite.spi.systemview.view.datastructures.CountDownLatchView) CacheEntryEventSerializableFilter(org.apache.ignite.cache.CacheEntryEventSerializableFilter) SYNC(org.apache.ignite.cache.CacheRebalanceMode.SYNC) QueueView(org.apache.ignite.spi.systemview.view.datastructures.QueueView) Map(java.util.Map) CacheEntryUpdatedListener(javax.cache.event.CacheEntryUpdatedListener) ATOMIC_REF(org.apache.ignite.internal.processors.datastructures.DataStructureType.ATOMIC_REF) CIX1(org.apache.ignite.internal.util.typedef.CIX1) COUNT_DOWN_LATCH(org.apache.ignite.internal.processors.datastructures.DataStructureType.COUNT_DOWN_LATCH) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) Event(org.apache.ignite.events.Event) AtomicStampedView(org.apache.ignite.spi.systemview.view.datastructures.AtomicStampedView) IgniteSet(org.apache.ignite.IgniteSet) IgniteInClosureX(org.apache.ignite.internal.util.lang.IgniteInClosureX) SemaphoreViewWalker(org.apache.ignite.internal.managers.systemview.walker.SemaphoreViewWalker) CountDownLatch(java.util.concurrent.CountDownLatch) PESSIMISTIC(org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC) GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext) IgnitePredicateX(org.apache.ignite.internal.util.lang.IgnitePredicateX) U(org.apache.ignite.internal.util.typedef.internal.U) Callable(java.util.concurrent.Callable) IgniteLogger(org.apache.ignite.IgniteLogger) IgniteOutClosureX(org.apache.ignite.internal.util.lang.IgniteOutClosureX) GridKernalContext(org.apache.ignite.internal.GridKernalContext) ClusterNode(org.apache.ignite.cluster.ClusterNode) CI1(org.apache.ignite.internal.util.typedef.CI1) CountDownLatchViewWalker(org.apache.ignite.internal.managers.systemview.walker.CountDownLatchViewWalker) IgniteAtomicReference(org.apache.ignite.IgniteAtomicReference) S(org.apache.ignite.internal.util.typedef.internal.S) IgniteInterruptedCheckedException(org.apache.ignite.internal.IgniteInterruptedCheckedException) SEMAPHORE(org.apache.ignite.internal.processors.datastructures.DataStructureType.SEMAPHORE) ClusterTopologyServerNotFoundException(org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException) IgniteAtomicStamped(org.apache.ignite.IgniteAtomicStamped) AtomicLongViewWalker(org.apache.ignite.internal.managers.systemview.walker.AtomicLongViewWalker) SET(org.apache.ignite.internal.processors.datastructures.DataStructureType.SET) EventType(javax.cache.event.EventType) A(org.apache.ignite.internal.util.typedef.internal.A) AtomicReferenceViewWalker(org.apache.ignite.internal.managers.systemview.walker.AtomicReferenceViewWalker) AtomicStampedViewWalker(org.apache.ignite.internal.managers.systemview.walker.AtomicStampedViewWalker) IgniteQueue(org.apache.ignite.IgniteQueue) AtomicSequenceView(org.apache.ignite.spi.systemview.view.datastructures.AtomicSequenceView) TRANSACTIONAL(org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL) T2(org.apache.ignite.internal.util.typedef.T2) QueueViewWalker(org.apache.ignite.internal.managers.systemview.walker.QueueViewWalker) GridCacheInternal(org.apache.ignite.internal.processors.cache.GridCacheInternal) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) GridProcessorAdapter(org.apache.ignite.internal.processors.GridProcessorAdapter) CX1(org.apache.ignite.internal.util.typedef.CX1) QUEUE(org.apache.ignite.internal.processors.datastructures.DataStructureType.QUEUE) AtomicSequenceViewWalker(org.apache.ignite.internal.managers.systemview.walker.AtomicSequenceViewWalker) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) IgniteAtomicSequence(org.apache.ignite.IgniteAtomicSequence) IgniteChangeGlobalStateSupport(org.apache.ignite.internal.processors.cluster.IgniteChangeGlobalStateSupport) REPEATABLE_READ(org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ) IgniteSemaphore(org.apache.ignite.IgniteSemaphore) ATOMIC_LONG(org.apache.ignite.internal.processors.datastructures.DataStructureType.ATOMIC_LONG) X(org.apache.ignite.internal.util.typedef.X) GridPlainCallable(org.apache.ignite.internal.util.lang.GridPlainCallable) SetViewWalker(org.apache.ignite.internal.managers.systemview.walker.SetViewWalker) AtomicReferenceView(org.apache.ignite.spi.systemview.view.datastructures.AtomicReferenceView) PARTITIONED(org.apache.ignite.cache.CacheMode.PARTITIONED) MetricUtils.metricName(org.apache.ignite.internal.processors.metric.impl.MetricUtils.metricName) IgniteLock(org.apache.ignite.IgniteLock) IgniteInternalCache(org.apache.ignite.internal.processors.cache.IgniteInternalCache) IgniteCountDownLatch(org.apache.ignite.IgniteCountDownLatch) IgniteException(org.apache.ignite.IgniteException) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) UUID(java.util.UUID) Nullable(org.jetbrains.annotations.Nullable) EVT_NODE_FAILED(org.apache.ignite.events.EventType.EVT_NODE_FAILED) PredicateCollectionView(org.apache.ignite.internal.util.lang.gridfunc.PredicateCollectionView) CacheEntryListenerException(javax.cache.event.CacheEntryListenerException) IgniteProductVersion(org.apache.ignite.lang.IgniteProductVersion) ATOMIC_STAMPED(org.apache.ignite.internal.processors.datastructures.DataStructureType.ATOMIC_STAMPED) NodeStoppingException(org.apache.ignite.internal.NodeStoppingException) DiscoveryEvent(org.apache.ignite.events.DiscoveryEvent) GridCacheAdapter(org.apache.ignite.internal.processors.cache.GridCacheAdapter) SetView(org.apache.ignite.spi.systemview.view.datastructures.SetView) HashMap(java.util.HashMap) IgniteClosureX(org.apache.ignite.internal.util.lang.IgniteClosureX) TransformCollectionView(org.apache.ignite.internal.util.lang.gridfunc.TransformCollectionView) AtomicLongView(org.apache.ignite.spi.systemview.view.datastructures.AtomicLongView) ConcurrentMap(java.util.concurrent.ConcurrentMap) HashSet(java.util.HashSet) ReentrantLockView(org.apache.ignite.spi.systemview.view.datastructures.ReentrantLockView) IgnitePredicate(org.apache.ignite.lang.IgnitePredicate) AtomicConfiguration(org.apache.ignite.configuration.AtomicConfiguration) REENTRANT_LOCK(org.apache.ignite.internal.processors.datastructures.DataStructureType.REENTRANT_LOCK) F(org.apache.ignite.internal.util.typedef.F) GridNearTxLocal(org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal) Iterator(java.util.Iterator) DynamicCacheDescriptor(org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor) GPR(org.apache.ignite.internal.util.typedef.internal.GPR) ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException) CollectionConfiguration(org.apache.ignite.configuration.CollectionConfiguration) FULL_SYNC(org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC) CacheEntryEvent(javax.cache.event.CacheEntryEvent) ATOMIC_SEQ(org.apache.ignite.internal.processors.datastructures.DataStructureType.ATOMIC_SEQ) IgniteAtomicLong(org.apache.ignite.IgniteAtomicLong) ReentrantLockViewWalker(org.apache.ignite.internal.managers.systemview.walker.ReentrantLockViewWalker) GridCacheUtils(org.apache.ignite.internal.processors.cache.GridCacheUtils) GridLocalEventListener(org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener) SemaphoreView(org.apache.ignite.spi.systemview.view.datastructures.SemaphoreView) SemaphoreViewWalker(org.apache.ignite.internal.managers.systemview.walker.SemaphoreViewWalker) AtomicSequenceViewWalker(org.apache.ignite.internal.managers.systemview.walker.AtomicSequenceViewWalker) IgniteCountDownLatch(org.apache.ignite.IgniteCountDownLatch) SetView(org.apache.ignite.spi.systemview.view.datastructures.SetView) AtomicLongView(org.apache.ignite.spi.systemview.view.datastructures.AtomicLongView) IgniteAtomicStamped(org.apache.ignite.IgniteAtomicStamped) ReentrantLockView(org.apache.ignite.spi.systemview.view.datastructures.ReentrantLockView) CountDownLatchViewWalker(org.apache.ignite.internal.managers.systemview.walker.CountDownLatchViewWalker) SetViewWalker(org.apache.ignite.internal.managers.systemview.walker.SetViewWalker) CountDownLatchView(org.apache.ignite.spi.systemview.view.datastructures.CountDownLatchView) IgniteAtomicReference(org.apache.ignite.IgniteAtomicReference) ReentrantLockViewWalker(org.apache.ignite.internal.managers.systemview.walker.ReentrantLockViewWalker) IgniteAtomicLong(org.apache.ignite.IgniteAtomicLong) AtomicStampedView(org.apache.ignite.spi.systemview.view.datastructures.AtomicStampedView) AtomicLongViewWalker(org.apache.ignite.internal.managers.systemview.walker.AtomicLongViewWalker) SemaphoreView(org.apache.ignite.spi.systemview.view.datastructures.SemaphoreView) QueueView(org.apache.ignite.spi.systemview.view.datastructures.QueueView) AtomicSequenceView(org.apache.ignite.spi.systemview.view.datastructures.AtomicSequenceView) QueueViewWalker(org.apache.ignite.internal.managers.systemview.walker.QueueViewWalker) AtomicReferenceView(org.apache.ignite.spi.systemview.view.datastructures.AtomicReferenceView) IgniteAtomicSequence(org.apache.ignite.IgniteAtomicSequence) AtomicReferenceViewWalker(org.apache.ignite.internal.managers.systemview.walker.AtomicReferenceViewWalker) IgniteSemaphore(org.apache.ignite.IgniteSemaphore) IgniteLock(org.apache.ignite.IgniteLock) AtomicStampedViewWalker(org.apache.ignite.internal.managers.systemview.walker.AtomicStampedViewWalker)

Example 2 with QueueView

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

the class SystemViewSelfTest method testQueue.

/**
 */
@Test
public void testQueue() throws Exception {
    try (IgniteEx g0 = startGrid(0);
        IgniteEx g1 = startGrid(1)) {
        IgniteQueue<String> q0 = g0.queue("queue-1", 42, new CollectionConfiguration().setCollocated(true).setBackups(1).setGroupName("my-group"));
        IgniteQueue<?> q1 = g0.queue("queue-2", 0, new CollectionConfiguration());
        SystemView<QueueView> queues0 = g0.context().systemView().view(QUEUES_VIEW);
        SystemView<QueueView> queues1 = g1.context().systemView().view(QUEUES_VIEW);
        assertEquals(2, queues0.size());
        assertEquals(0, queues1.size());
        for (QueueView q : queues0) {
            if ("queue-1".equals(q.name())) {
                assertNotNull(q.id());
                assertEquals("queue-1", q.name());
                assertEquals(42, q.capacity());
                assertTrue(q.bounded());
                assertTrue(q.collocated());
                assertEquals("my-group", q.groupName());
                assertEquals(CU.cacheId("my-group"), q.groupId());
                assertFalse(q.removed());
                assertEquals(0, q.size());
                q0.add("first");
                assertEquals(1, q.size());
            } else {
                assertNotNull(q.id());
                assertEquals("queue-2", q.name());
                assertEquals(Integer.MAX_VALUE, q.capacity());
                assertFalse(q.bounded());
                assertFalse(q.collocated());
                assertEquals(DEFAULT_DS_GROUP_NAME, q.groupName());
                assertEquals(CU.cacheId(DEFAULT_DS_GROUP_NAME), q.groupId());
                assertFalse(q.removed());
                assertEquals(0, q.size());
                q1.close();
                assertTrue(waitForCondition(q::removed, getTestTimeout()));
            }
        }
        IgniteQueue<?> q2 = g1.queue("queue-1", 42, new CollectionConfiguration().setCollocated(true).setBackups(1).setGroupName("my-group"));
        assertEquals(1, queues1.size());
        QueueView q = queues1.iterator().next();
        assertNotNull(q.id());
        assertEquals("queue-1", q.name());
        assertEquals(42, q.capacity());
        assertTrue(q.bounded());
        assertTrue(q.collocated());
        assertEquals("my-group", q.groupName());
        assertEquals(CU.cacheId("my-group"), q.groupId());
        assertFalse(q.removed());
        assertEquals(1, q.size());
        q2.close();
        assertTrue(waitForCondition(q::removed, getTestTimeout()));
        assertEquals(0, queues0.size());
        assertEquals(0, queues1.size());
    }
}
Also used : QueueView(org.apache.ignite.spi.systemview.view.datastructures.QueueView) IgniteEx(org.apache.ignite.internal.IgniteEx) CollectionConfiguration(org.apache.ignite.configuration.CollectionConfiguration) Test(org.junit.Test) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)

Aggregations

CollectionConfiguration (org.apache.ignite.configuration.CollectionConfiguration)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 UUID (java.util.UUID)1 Callable (java.util.concurrent.Callable)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 CacheEntryEvent (javax.cache.event.CacheEntryEvent)1 CacheEntryListenerException (javax.cache.event.CacheEntryListenerException)1 CacheEntryUpdatedListener (javax.cache.event.CacheEntryUpdatedListener)1 EventType (javax.cache.event.EventType)1 IgniteAtomicLong (org.apache.ignite.IgniteAtomicLong)1 IgniteAtomicReference (org.apache.ignite.IgniteAtomicReference)1 IgniteAtomicSequence (org.apache.ignite.IgniteAtomicSequence)1 IgniteAtomicStamped (org.apache.ignite.IgniteAtomicStamped)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 IgniteCountDownLatch (org.apache.ignite.IgniteCountDownLatch)1