/** @throws Exception If failed. */ public void testClusterNodeMetrics() throws Exception { final Ignite ignite0 = grid(); final Ignite ignite1 = startGrid(1); GridTestUtils.waitForCondition( new GridAbsPredicate() { @Override public boolean apply() { return ignite0.cluster().nodes().size() == 2 && ignite1.cluster().nodes().size() == 2; } }, 3000L); ClusterMetrics metrics0 = ignite0.cluster().localNode().metrics(); ClusterMetrics nodesMetrics = ignite0 .cluster() .forNode(ignite0.cluster().localNode(), ignite1.cluster().localNode()) .metrics(); assertEquals(metrics0.getTotalCpus(), nodesMetrics.getTotalCpus()); assertEquals(1, metrics0.getTotalNodes()); assertEquals(2, nodesMetrics.getTotalNodes()); assert metrics0.getHeapMemoryUsed() > 0; assert metrics0.getHeapMemoryTotal() > 0; assert metrics0.getNonHeapMemoryMaximum() > 0; }
/** @throws Exception If failed. */ @SuppressWarnings({"TooBroadScope"}) public void testAsyncListen() throws Exception { final String hello = "HELLO!"; final String bye = "BYE!"; final Ignite g = grid(0); final UUID locNodeId = g.cluster().localNode().id(); g.message() .remoteListen( null, new MessagingListenActor<String>() { @Override protected void receive(UUID nodeId, String rcvMsg) throws Throwable { if (hello.equals(rcvMsg)) { assertEquals(locNodeId, nodeId); assertEquals(hello, rcvMsg); stop(bye); } } }); final AtomicInteger cnt = new AtomicInteger(); g.message() .localListen( null, new P2<UUID, String>() { @Override public boolean apply(UUID nodeId, String msg) { if (msg.equals(bye)) cnt.incrementAndGet(); return true; } }); g.message().send(null, hello); GridTestUtils.waitForCondition( new GridAbsPredicate() { @Override public boolean apply() { return cnt.get() == g.cluster().nodes().size(); } }, 5000); assertEquals(cnt.get(), g.cluster().nodes().size()); }