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));
}
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());
}
}
Aggregations