Search in sources :

Example 1 with CountDownLatchView

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

the class SystemViewSelfTest method testCountDownLatch.

/**
 */
@Test
public void testCountDownLatch() throws Exception {
    try (IgniteEx g0 = startGrid(0);
        IgniteEx g1 = startGrid(1)) {
        IgniteCountDownLatch l1 = g0.countDownLatch("c1", 3, false, true);
        IgniteCountDownLatch l2 = g0.countDownLatch("c2", 1, true, true);
        SystemView<CountDownLatchView> latches0 = g0.context().systemView().view(LATCHES_VIEW);
        SystemView<CountDownLatchView> latches1 = g1.context().systemView().view(LATCHES_VIEW);
        assertEquals(2, latches0.size());
        assertEquals(0, latches1.size());
        String grpName = DEFAULT_VOLATILE_DS_GROUP_NAME + "@" + VOLATILE_DATA_REGION_NAME;
        for (CountDownLatchView l : latches0) {
            if ("c1".equals(l.name())) {
                assertEquals(3, l.count());
                assertEquals(3, l.initialCount());
                assertFalse(l.autoDelete());
                l1.countDown();
                assertEquals(2, l.count());
                assertEquals(3, l.initialCount());
                assertFalse(l.removed());
            } else {
                assertEquals("c2", l.name());
                assertEquals(1, l.count());
                assertEquals(1, l.initialCount());
                assertTrue(l.autoDelete());
                assertFalse(l.removed());
                l2.countDown();
                l2.close();
                assertTrue(waitForCondition(l::removed, getTestTimeout()));
            }
            assertEquals(grpName, l.groupName());
            assertEquals(CU.cacheId(grpName), l.groupId());
        }
        IgniteCountDownLatch l3 = g1.countDownLatch("c1", 10, true, true);
        assertEquals(1, latches1.size());
        CountDownLatchView l = latches1.iterator().next();
        assertEquals(2, l.count());
        assertEquals(3, l.initialCount());
        assertEquals(grpName, l.groupName());
        assertEquals(CU.cacheId(grpName), l.groupId());
        assertFalse(l.removed());
        assertFalse(l.autoDelete());
        l3.countDown();
        l3.countDown();
        l3.close();
        assertTrue(waitForCondition(l::removed, getTestTimeout()));
        assertEquals(0, latches0.size());
        assertEquals(0, latches1.size());
    }
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx) CountDownLatchView(org.apache.ignite.spi.systemview.view.datastructures.CountDownLatchView) IgniteCountDownLatch(org.apache.ignite.IgniteCountDownLatch) Test(org.junit.Test) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)

Example 2 with CountDownLatchView

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

Aggregations

IgniteCountDownLatch (org.apache.ignite.IgniteCountDownLatch)2 CountDownLatchView (org.apache.ignite.spi.systemview.view.datastructures.CountDownLatchView)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