/** * Server sends a message and client receives it. * * @param async Async message send flag. * @throws Exception If failed. */ private void serverClientMessage(boolean async) throws Exception { Ignite ignite = grid(SERVER_NODE_IDX); ClusterGroup grp = ignite.cluster().forClients(); assert !grp.nodes().isEmpty(); registerListenerAndSendMessages(ignite, grp, async); }
/** * Client sends a message and client receives it. * * @param async Async message send flag. * @throws Exception If failed. */ private void clientClientMessage(boolean async) throws Exception { Ignite ignite = grid(CLIENT_NODE_IDX); ClusterGroup grp = ignite.cluster().forClients(); assert !grp.nodes().isEmpty(); registerListenerAndSendMessages(ignite, grp, async); }
/** * @throws Exception If fail. */ private void clientClientOrderedMessage() throws Exception { Ignite ignite = grid(CLIENT_NODE_IDX); ClusterGroup grp = ignite.cluster().forClients(); assert !grp.nodes().isEmpty(); registerListenerAndSendOrderedMessages(ignite, grp); }
/** * @throws Exception If fail. */ private void serverClientOrderedMessage() throws Exception { Ignite ignite = grid(SERVER_NODE_IDX); ClusterGroup grp = ignite.cluster().forClients(); assert !grp.nodes().isEmpty(); registerListenerAndSendOrderedMessages(ignite, grp); }
/** * @throws Exception If failed. */ @Test public void testClientReconnects() throws Exception { Ignite srv1 = startGrid("server1"); Ignite srv2 = startGrid("server2"); startGrid("client-block"); assertEquals(1, srv2.cluster().forClients().nodes().size()); assertEquals(1, srv1.cluster().forClients().nodes().size()); }
assertEquals(1, srv2.cluster().forClients().nodes().size()); assertEquals(1, srv1.cluster().forClients().nodes().size());
assertEquals(0, srv1.cluster().forClients().nodes().size()); assertEquals(0, srv2.cluster().forClients().nodes().size());
/** * Verifies that client is able to detect obsolete metadata situation and request up-to-date from the cluster. */ @Test public void testClientRequestsUpToDateMetadata() throws Exception { final IgniteEx ignite0 = startGrid(0); final IgniteEx ignite1 = startGrid(1); ignite0.executorService().submit(new Runnable() { @Override public void run() { addIntField(ignite0, "f1", 101, 1); } }).get(); final Ignite client = startDeafClient("client"); ClusterGroup clientGrp = client.cluster().forClients(); final String strVal = "strVal101"; ignite1.executorService().submit(new Runnable() { @Override public void run() { addStringField(ignite1, "f2", strVal, 1); } }).get(); String res = client.compute(clientGrp).call(new IgniteCallable<String>() { @Override public String call() throws Exception { return ((BinaryObject)client.cache(DEFAULT_CACHE_NAME).withKeepBinary().get(1)).field("f2"); } }); assertEquals(strVal, res); }
/** * @throws Exception If failed. */ @Test public void testClientServer() throws Exception { ClusterGroup srv = ignite.cluster().forServers(); assertEquals(2, srv.nodes().size()); assertTrue(srv.nodes().contains(ignite(0).cluster().localNode())); assertTrue(srv.nodes().contains(ignite(1).cluster().localNode())); ClusterGroup cli = ignite.cluster().forClients(); assertEquals(2, srv.nodes().size()); assertTrue(cli.nodes().contains(ignite(2).cluster().localNode())); assertTrue(cli.nodes().contains(ignite(3).cluster().localNode())); }
assertEquals(CLIENTS_NUM, srv1.cluster().forClients().nodes().size()); assertEquals(CLIENTS_NUM, srv2.cluster().forClients().nodes().size());
assertEquals(0, node.cluster().forClients().nodes().size()); assertEquals(1, node.cluster().forServers().nodes().size()); assertEquals(1, node.cluster().forClients().nodes().size()); assertEquals(1, node.cluster().forServers().nodes().size()); assertEquals(2, node.cluster().forClients().nodes().size()); assertEquals(2, node.cluster().forServers().nodes().size()); assertEquals(1, node.cluster().forClients().nodes().size()); assertEquals(2, node.cluster().forServers().nodes().size()); assertEquals(1, node.cluster().forClients().nodes().size()); assertEquals(1, node.cluster().forServers().nodes().size());
/** * @throws Exception If failed. */ @Test public void testClientService() throws Exception { UUID clientNodeId = grid(CLIENT_IDX).cluster().localNode().id(); for (int i = 0 ; i < NODES_CNT; i++) { log.info("Iteration: " + i); final Ignite ignite = grid(i); ignite.services(ignite.cluster().forClients()).deployNodeSingleton(SINGLETON_NAME, new TestService()); final ClusterGroup grp = ignite.cluster(); assertEquals(NODES_CNT, grp.nodes().size()); GridTestUtils.waitForCondition(new GridAbsPredicate() { @Override public boolean apply() { return ignite.services(grp).serviceDescriptors().size() == 1; } }, 5000); Collection<ServiceDescriptor> srvDscs = ignite.services(grp).serviceDescriptors(); assertEquals(1, srvDscs.size()); Map<UUID, Integer> nodesMap = F.first(srvDscs).topologySnapshot(); assertEquals(1, nodesMap.size()); for (Map.Entry<UUID, Integer> nodeInfo : nodesMap.entrySet()) { assertEquals(clientNodeId, nodeInfo.getKey()); assertEquals(1, nodeInfo.getValue().intValue()); } ignite.services().cancelAll(); } }
/** * @throws Exception If failed. */ @Test public void testClientClosure() throws Exception { for (int i = 0 ; i < NODES_CNT; i++) { log.info("Iteration: " + i); Ignite ignite = grid(i); Collection<String> res = ignite.compute(ignite.cluster().forClients()). broadcast(new IgniteCallable<String>() { @IgniteInstanceResource Ignite ignite; @Override public String call() throws Exception { assertTrue(ignite.configuration().isClientMode()); return ignite.name(); } }); assertEquals(1, res.size()); assertEquals(getTestIgniteInstanceName(CLIENT_IDX), F.first(res)); } }
/** * @throws Exception If failed. */ @Test public void testScanQuery() throws Exception { Ignite server = startGrid(0); client = true; ccfgs = new CacheConfiguration[] { new CacheConfiguration("test-cache-replicated").setCacheMode(REPLICATED) .setNodeFilter(new AlwaysFalseCacheFilter()), new CacheConfiguration("test-cache-partitioned").setCacheMode(PARTITIONED) .setNodeFilter(new AlwaysFalseCacheFilter()) }; Ignite client = startGrid(1); assertEquals(2, server.cluster().nodes().size()); assertEquals(1, server.cluster().forServers().nodes().size()); assertEquals(1, server.cluster().forClients().nodes().size()); assertEquals(2, client.cluster().nodes().size()); assertEquals(1, client.cluster().forServers().nodes().size()); assertEquals(1, client.cluster().forClients().nodes().size()); for (CacheConfiguration cfg : ccfgs) { IgniteCache<Object, Object> cache = client.cache(cfg.getName()); assertNotNull(cache); assertNotNull(cache.iterator()); assertFalse(cache.iterator().hasNext()); } }
/** * Verifies that client resends request for up-to-date metadata in case of failure on server received first request. */ @Test public void testClientRequestsUpToDateMetadataOneNodeDies() throws Exception { final Ignite srv0 = startGrid(0); replaceWithStoppingMappingRequestListener(((GridKernalContext)U.field(srv0, "ctx")).io(), 0); final Ignite srv1 = startGrid(1); replaceWithCountingMappingRequestListener(((GridKernalContext)U.field(srv1, "ctx")).io()); final Ignite srv2 = startGrid(2); replaceWithCountingMappingRequestListener(((GridKernalContext)U.field(srv2, "ctx")).io()); final Ignite client = startDeafClient("client"); ClusterGroup clientGrp = client.cluster().forClients(); srv0.executorService().submit(new Runnable() { @Override public void run() { addStringField(srv0, "f2", "strVal101", 0); } }).get(); client.compute(clientGrp).call(new IgniteCallable<String>() { @Override public String call() throws Exception { return ((BinaryObject)client.cache(DEFAULT_CACHE_NAME).withKeepBinary().get(0)).field("f2"); } }); assertEquals(metadataReqsCounter.get(), 2); }
/** * Test reproduces failure in case of client resolution failure * {@link org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi#createTcpClient} from server side, further * client reconnect and proper grid work. * * @throws Exception If failed. */ @Test public void testClientReconnects() throws Exception { blockCommSpi = true; Ignite srv1 = startGrid("server1-block"); helper.clientModeThreadLocal(true); IgniteEx cli = startGrid("client-block"); IgniteCache<Object, Object> cache = cli.getOrCreateCache(DEFAULT_CACHE_NAME); cache.put(1, 1); assertEquals(cache.get(1), 1); assertEquals(1, srv1.cluster().forClients().nodes().size()); MBeanServer srv = ManagementFactory.getPlatformMBeanServer(); IgniteEx ignite = grid("server1-block"); ObjectName spiName = U.makeMBeanName(ignite.context().igniteInstanceName(), "SPIs", ZookeeperDiscoverySpi.class.getSimpleName()); ZookeeperDiscoverySpiMBean bean = JMX.newMBeanProxy(srv, spiName, ZookeeperDiscoverySpiMBean.class); assertNotNull(bean); assertEquals(0, bean.getCommErrorProcNum()); }
@Override public ClusterGroup getClusterGroup(Ignite ignite) { return ignite.cluster().forClients(); } };