use of org.apache.ignite.spi.systemview.view.datastructures.AtomicStampedView 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));
}
use of org.apache.ignite.spi.systemview.view.datastructures.AtomicStampedView in project ignite by apache.
the class SystemViewSelfTest method testAtomicStamped.
/**
*/
@Test
public void testAtomicStamped() throws Exception {
try (IgniteEx g0 = startGrid(0);
IgniteEx g1 = startGrid(1)) {
IgniteAtomicStamped<String, Integer> s1 = g0.atomicStamped("s-1", "str0", 1, true);
IgniteAtomicStamped<String, Integer> s2 = g0.atomicStamped("s-2", new AtomicConfiguration().setBackups(1).setGroupName("my-group"), "str1", 43, true);
SystemView<AtomicStampedView> stamps0 = g0.context().systemView().view(STAMPED_VIEW);
SystemView<AtomicStampedView> stamps1 = g1.context().systemView().view(STAMPED_VIEW);
assertEquals(2, stamps0.size());
assertEquals(0, stamps1.size());
for (AtomicStampedView s : stamps0) {
if ("s-1".equals(s.name())) {
assertEquals("str0", s.value());
assertEquals("1", s.stamp());
assertEquals(DEFAULT_DS_GROUP_NAME, s.groupName());
assertEquals(CU.cacheId(DEFAULT_DS_GROUP_NAME), s.groupId());
s1.set("str2", 2);
assertEquals("str2", s.value());
assertEquals("2", s.stamp());
assertFalse(s.removed());
} else {
assertEquals("s-2", s.name());
assertEquals("str1", s.value());
assertEquals("43", s.stamp());
assertEquals("my-group", s.groupName());
assertEquals(CU.cacheId("my-group"), s.groupId());
assertFalse(s.removed());
s2.close();
assertTrue(waitForCondition(s::removed, getTestTimeout()));
}
}
g1.atomicStamped("s-1", "str3", 3, true);
assertEquals(1, stamps1.size());
AtomicStampedView l = stamps1.iterator().next();
assertEquals("str2", l.value());
assertEquals("2", l.stamp());
assertEquals(DEFAULT_DS_GROUP_NAME, l.groupName());
assertEquals(CU.cacheId(DEFAULT_DS_GROUP_NAME), l.groupId());
assertFalse(l.removed());
s1.close();
assertTrue(l.removed());
assertEquals(0, stamps0.size());
assertEquals(0, stamps1.size());
}
}
Aggregations