Search in sources :

Example 6 with ClientClusterGroup

use of org.apache.ignite.client.ClientClusterGroup in project ignite by apache.

the class ClusterGroupTest method testClusterNodeCaching.

/**
 * Test that ClusterNode doesn't requested each time from the server.
 */
@Test
public void testClusterNodeCaching() {
    ClientClusterGroup grp = client.cluster().forServers();
    Collection<ClusterNode> nodes1 = grp.nodes();
    Collection<ClusterNode> nodes2 = grp.nodes();
    assertEquals(3, nodes1.size());
    assertEquals(3, nodes2.size());
    int foundCnt = 0;
    for (ClusterNode node1 : nodes1) {
        for (ClusterNode node2 : nodes2) {
            if (F.eq(node1.id(), node2.id())) {
                // Should be exactly the same instance.
                assertTrue(node1 == node2);
                foundCnt++;
            }
        }
    }
    assertEquals(3, foundCnt);
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) ClientClusterGroup(org.apache.ignite.client.ClientClusterGroup) Test(org.junit.Test)

Aggregations

ClientClusterGroup (org.apache.ignite.client.ClientClusterGroup)6 IgniteClient (org.apache.ignite.client.IgniteClient)5 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)2 List (java.util.List)2 UUID (java.util.UUID)2 ClientCompute (org.apache.ignite.client.ClientCompute)1 ClusterNode (org.apache.ignite.cluster.ClusterNode)1 ClientConfiguration (org.apache.ignite.configuration.ClientConfiguration)1 ThinClientConfiguration (org.apache.ignite.configuration.ThinClientConfiguration)1