use of org.apache.ignite.spi.systemview.view.datastructures.AtomicSequenceView in project ignite by apache.
the class SystemViewSelfTest method testAtomicSequence.
/**
*/
@Test
public void testAtomicSequence() throws Exception {
try (IgniteEx g0 = startGrid(0);
IgniteEx g1 = startGrid(1)) {
IgniteAtomicSequence s1 = g0.atomicSequence("seq-1", 42, true);
IgniteAtomicSequence s2 = g0.atomicSequence("seq-2", new AtomicConfiguration().setBackups(1).setGroupName("my-group"), 43, true);
s1.batchSize(42);
SystemView<AtomicSequenceView> seqs0 = g0.context().systemView().view(SEQUENCES_VIEW);
SystemView<AtomicSequenceView> seqs1 = g1.context().systemView().view(SEQUENCES_VIEW);
assertEquals(2, seqs0.size());
assertEquals(0, seqs1.size());
for (AtomicSequenceView s : seqs0) {
if ("seq-1".equals(s.name())) {
assertEquals(42, s.value());
assertEquals(42, s.batchSize());
assertEquals(DEFAULT_DS_GROUP_NAME, s.groupName());
assertEquals(CU.cacheId(DEFAULT_DS_GROUP_NAME), s.groupId());
long val = s1.addAndGet(42);
assertEquals(val, s.value());
assertFalse(s.removed());
} else {
assertEquals("seq-2", s.name());
assertEquals(DFLT_ATOMIC_SEQUENCE_RESERVE_SIZE, s.batchSize());
assertEquals(43, s.value());
assertEquals("my-group", s.groupName());
assertEquals(CU.cacheId("my-group"), s.groupId());
assertFalse(s.removed());
s2.close();
assertTrue(waitForCondition(s::removed, getTestTimeout()));
}
}
g1.atomicSequence("seq-1", 42, true);
assertEquals(1, seqs1.size());
AtomicSequenceView s = seqs1.iterator().next();
assertEquals(DFLT_ATOMIC_SEQUENCE_RESERVE_SIZE + 42, s.value());
assertEquals(DFLT_ATOMIC_SEQUENCE_RESERVE_SIZE, s.batchSize());
assertEquals(DEFAULT_DS_GROUP_NAME, s.groupName());
assertEquals(CU.cacheId(DEFAULT_DS_GROUP_NAME), s.groupId());
assertFalse(s.removed());
s1.close();
assertTrue(waitForCondition(s::removed, getTestTimeout()));
assertEquals(0, seqs0.size());
assertEquals(0, seqs1.size());
}
}
use of org.apache.ignite.spi.systemview.view.datastructures.AtomicSequenceView 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));
}
Aggregations