Search in sources :

Example 1 with AtomicReferenceView

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

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

the class SystemViewSelfTest method testAtomicReference.

/**
 */
@Test
public void testAtomicReference() throws Exception {
    try (IgniteEx g0 = startGrid(0);
        IgniteEx g1 = startGrid(1)) {
        IgniteAtomicReference<String> l1 = g0.atomicReference("ref-1", "str1", true);
        IgniteAtomicReference<Integer> l2 = g0.atomicReference("ref-2", new AtomicConfiguration().setBackups(1).setGroupName("my-group"), 43, true);
        SystemView<AtomicReferenceView> refs0 = g0.context().systemView().view(REFERENCES_VIEW);
        SystemView<AtomicReferenceView> refs1 = g1.context().systemView().view(REFERENCES_VIEW);
        assertEquals(2, refs0.size());
        assertEquals(0, refs1.size());
        for (AtomicReferenceView r : refs0) {
            if ("ref-1".equals(r.name())) {
                assertEquals("str1", r.value());
                assertEquals(DEFAULT_DS_GROUP_NAME, r.groupName());
                assertEquals(CU.cacheId(DEFAULT_DS_GROUP_NAME), r.groupId());
                l1.set("str2");
                assertEquals("str2", r.value());
                assertFalse(r.removed());
            } else {
                assertEquals("ref-2", r.name());
                assertEquals("43", r.value());
                assertEquals("my-group", r.groupName());
                assertEquals(CU.cacheId("my-group"), r.groupId());
                assertFalse(r.removed());
                l2.close();
                assertTrue(waitForCondition(r::removed, getTestTimeout()));
            }
        }
        g1.atomicReference("ref-1", "str3", true);
        assertEquals(1, refs1.size());
        AtomicReferenceView l = refs1.iterator().next();
        assertEquals("str2", l.value());
        assertEquals(DEFAULT_DS_GROUP_NAME, l.groupName());
        assertEquals(CU.cacheId(DEFAULT_DS_GROUP_NAME), l.groupId());
        assertFalse(l.removed());
        l1.close();
        assertTrue(waitForCondition(l::removed, getTestTimeout()));
        assertEquals(0, refs0.size());
        assertEquals(0, refs1.size());
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) AtomicReferenceView(org.apache.ignite.spi.systemview.view.datastructures.AtomicReferenceView) IgniteEx(org.apache.ignite.internal.IgniteEx) AtomicConfiguration(org.apache.ignite.configuration.AtomicConfiguration) Test(org.junit.Test) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)

Aggregations

AtomicConfiguration (org.apache.ignite.configuration.AtomicConfiguration)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 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)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