/** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { startGridsMultiThreaded(3, false); Ignition.setClientMode(true); try { startGrid(CLIENT); } finally { Ignition.setClientMode(false); } }
/** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { startGridsMultiThreaded(3); try { Ignition.setClientMode(true); startGrid(); } finally { Ignition.setClientMode(false); } }
/** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { startGridsMultiThreaded(3); Ignition.setClientMode(true); try { startGrid("client1"); startGrid("client2"); } finally { Ignition.setClientMode(false); } }
/** {@inheritDoc} */ @Override public void init(long dataPtr) { final PlatformInputStream input = new PlatformExternalMemory(null, dataPtr).input(); Ignition.setClientMode(input.readBoolean()); processInput(input); }
/** * Ignite grid of 3 server nodes with passed parameters. * * @param atomicityMode atomicity mode * @param mode cache mode * @param writeSyncMode cache write synchronization mode * @param backupsCnt backups count * @throws Exception If failed. */ private void initGrid(CacheAtomicityMode atomicityMode, CacheMode mode, CacheWriteSynchronizationMode writeSyncMode, int backupsCnt) throws Exception { this.atomicityMode = atomicityMode; this.mode = mode; this.backupsCnt = backupsCnt; this.writeSyncMode = writeSyncMode; Ignition.setClientMode(false); for (int i = 0; i < NODES; i++) startGrid(i); Ignition.setClientMode(true); client = startGrid(NODES + 1); // it is required to start first node in test jvm, but we can not start client node, // because client will fail to connect and test will fail too. // as workaround start first server node in test jvm and then stop it. stopGrid(0); }
/** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { assert NODES_CNT > 2; ids = new LinkedList<>(); try { for (int i = 0; i < NODES_CNT; i++) { Ignition.setClientMode(i > 1); Ignite g = startGrid(i); ids.add(g.cluster().localNode().id()); if (i == 0) ignite = g; } waitForTopology(NODES_CNT); } finally { Ignition.setClientMode(false); } }
/** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { MvccFeatureChecker.skipIfNotSupported(MvccFeatureChecker.Feature.CACHE_EVENTS); startGridsMultiThreaded(3); Ignition.setClientMode(true); try { Ignite ignite = startGrid("client"); ignite.events().remoteListen( new IgniteBiPredicate<UUID, Event>() { @Override public boolean apply(UUID uuid, Event evt) { return true; } }, new IgnitePredicate<Event>() { @Override public boolean apply(Event evt) { throw new NoClassDefFoundError("XXX"); } }, EventType.EVT_CACHE_OBJECT_PUT ); } finally { Ignition.setClientMode(false); } }
/** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { startGridsMultiThreaded(3, false); Ignition.setClientMode(true); try { startGrid(CLIENT); } finally { Ignition.setClientMode(false); } IgniteCache c = grid(CLIENT).cache(CACHE_NAME); int k = 0; for (int grp = 1; grp < 7; ++grp) { for (int i = 0; i < grp; ++i) { c.put(new Key(k, grp), new Value(k, Character.toString((char)('A' + k)))); k++; } } }
return; Ignition.setClientMode(true);
/** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { igfsSecondaryFileSystem = createSecondaryFileSystemStack(); nodes = new Ignite[nodeCount()]; for (int i = 0; i < nodes.length; i++) { String nodeName = i == 0 ? "ignite" : "ignite" + i; nodes[i] = startGridWithIgfs(nodeName, "igfs", mode, igfsSecondaryFileSystem, PRIMARY_REST_CFG, primaryIpFinder); } igfs = (IgfsImpl) nodes[0].fileSystem("igfs"); if (client()) { // Start client. Ignition.setClientMode(true); try { Ignite ignite = startGridWithIgfs("ignite-client", "igfs", mode, igfsSecondaryFileSystem, PRIMARY_REST_CFG, primaryIpFinder); igfs = (IgfsImpl) ignite.fileSystem("igfs"); } finally { Ignition.setClientMode(false); } } }
/** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { startGridsMultiThreaded(3, false); Ignition.setClientMode(true); try { startGrid(CLIENT); } finally { Ignition.setClientMode(false); } IgniteCache c = grid(CLIENT).cache(CACHE_NAME); int k = 0; for (int grp = 1; grp < 7; ++grp) { for (int i = 0; i < grp; ++i) { c.put(new Key(k, grp), new Value(k, Character.toString((char)('A' + k)))); k++; } } // Add duplicates k = 0; for (int grp = 1; grp < 7; ++grp) { for (int i = 0; i < grp; ++i) { c.put(new Key(k + KEY_BASE_FOR_DUPLICATES, grp), new Value(k + KEY_BASE_FOR_DUPLICATES, Character.toString((char)('A' + k)))); k++; } } }
/** * @throws Exception If failed. */ @Test public void testJobCancel() throws Exception { Ignite server = startGrid("server"); server.services().deployNodeSingleton("my-service", new MyService()); Ignition.setClientMode(true); Ignite client = startGrid("client"); ComputeTaskFuture<Integer> fut = client.compute().executeAsync(new MyTask(), null); Thread.sleep(3000); server.close(); assertEquals(42, fut.get().intValue()); }
/** * @param serverCnt Servers count. * @throws Exception If failed. */ private void doTestClientSuspension(int serverCnt) throws Exception { startGrids(serverCnt); Ignition.setClientMode(true); Ignite client = startGrid("client"); for (int i = 0; i < serverCnt; i++) assertEquals(1, grid(i).cluster().forClients().nodes().size()); Thread.sleep(2000); for (int i = 0; i < serverCnt; i++) assertEquals(1, grid(i).cluster().forClients().nodes().size()); suspendClientMetricsUpdate(client); Thread.sleep(2000); for (int i = 0; i < serverCnt; i++) assertEquals(0, grid(i).cluster().forClients().nodes().size()); }
/** * @throws Exception If failed. */ @Test public void testExecution() throws Exception { startGrid(0); // Server. Ignition.setClientMode(true); Ignite ignite = startGrid(); // Client. ignite.services().deployClusterSingleton("my-service", new MyServiceImpl()); MyService svc = ignite.services().serviceProxy("my-service", MyService.class, false); svc.hello(); }
Ignition.setClientMode(true);
Ignition.setClientMode(true); Ignition.setClientMode(false);
/** * @throws Exception If failed. */ @Test public void testPackagePrivateService() throws Exception { try { Ignite server = startGrid("server"); server.services().deployClusterSingleton("my-service", MyServiceFactory.create()); Ignition.setClientMode(true); Ignite client = startGrid("client"); MyService svc = client.services().serviceProxy("my-service", MyService.class, true); assertEquals(42, svc.hello()); } finally { stopAllGrids(); } } }
/** * @throws Exception If failed. */ @Test public void testQueryFromNewClientCustomSchemaName() throws Exception { Ignite srv = startGrid("server"); IgniteCache<Integer, Integer> cache1 = srv.createCache(new CacheConfiguration<Integer, Integer>(). setName("cache1").setSqlSchema("cache1_sql").setIndexedTypes(Integer.class, Integer.class)); IgniteCache<Integer, Integer> cache2 = srv.createCache(new CacheConfiguration<Integer, Integer>(). setName("cache2").setSqlSchema("cache2_sql").setIndexedTypes(Integer.class, Integer.class)); for (int i = 0; i < 10; i++) { cache1.put(i, i); cache2.put(i, i); } Ignition.setClientMode(true); Ignite client = startGrid("client"); IgniteCache<Integer, Integer> cache = client.cache("cache1"); List<List<?>> res = cache.query(new SqlFieldsQuery( "select i1._val, i2._val from Integer i1 cross join cache2_sql.Integer i2")).getAll(); assertEquals(100, res.size()); } }
/** * @throws Exception If failed. */ @Test public void testQueryFromNewClient() throws Exception { Ignite srv = startGrid("server"); for (int iter = 0; iter < 2; iter++) { log.info("Iteration: " + iter); IgniteCache<Integer, Integer> cache1 = srv.createCache(new CacheConfiguration<Integer, Integer>(). setName("cache1").setIndexedTypes(Integer.class, Integer.class)); IgniteCache<Integer, Integer> cache2 = srv.createCache(new CacheConfiguration<Integer, Integer>(). setName("cache2").setIndexedTypes(Integer.class, Integer.class)); for (int i = 0; i < 10; i++) { cache1.put(i, i); cache2.put(i, i); } Ignition.setClientMode(true); Ignite client = (iter == 0) ? startGrid("client") : grid("client"); IgniteCache<Integer, Integer> cache = client.cache("cache1"); List<List<?>> res = cache.query(new SqlFieldsQuery( "select i1._val, i2._val from Integer i1 cross join \"cache2\".Integer i2")).getAll(); assertEquals(100, res.size()); srv.destroyCache(cache1.getName()); srv.destroyCache(cache2.getName()); } }
/** * @throws Exception If failed. */ @Test public void testDataPageScan() throws Exception { final String cacheName = "test"; GridQueryProcessor.idxCls = DirectPageScanIndexing.class; IgniteEx server = startGrid(0); server.cluster().active(true); Ignition.setClientMode(true); IgniteEx client = startGrid(1); CacheConfiguration<Long,TestData> ccfg = new CacheConfiguration<>(cacheName); ccfg.setIndexedTypes(Long.class, TestData.class); ccfg.setSqlFunctionClasses(QueryDataPageScanTest.class); IgniteCache<Long,TestData> clientCache = client.createCache(ccfg); final int keysCnt = 1000; for (long i = 0; i < keysCnt; i++) clientCache.put(i, new TestData(i)); IgniteCache<Long,TestData> serverCache = server.cache(cacheName); doTestScanQuery(clientCache, keysCnt); doTestScanQuery(serverCache, keysCnt); doTestSqlQuery(clientCache); doTestSqlQuery(serverCache); doTestDml(clientCache); doTestDml(serverCache); doTestLazySql(clientCache, keysCnt); doTestLazySql(serverCache, keysCnt); }