@Override public void run(IgniteServices services, String svcName, TestService svc) { IgniteCache<Object, Object> cache = grid(testedNodeIdx).getOrCreateCache(CACHE_NAME); try { services.deployKeyAffinitySingleton(svcName, (Service)svc, cache.getName(), primaryKey(cache)); } catch (IgniteCheckedException e) { throw new IgniteException(e); } } }));
/** * Test OOME in service execute. */ @Test public void testServiceExecuteOomError() throws Exception { IgniteEx ignite0 = startGrid(0); IgniteEx ignite1 = startGrid(1); IgniteCache<Integer, Integer> cache1 = ignite1.getOrCreateCache(DEFAULT_CACHE_NAME); awaitPartitionMapExchange(); Integer key = primaryKey(cache1); ignite0.services().deployKeyAffinitySingleton("fail-execute-service", new FailServiceImpl(true), DEFAULT_CACHE_NAME, key); assertFailureState(ignite0, ignite1); }
/** * @throws Exception If failed. */ @Test public void testAffinityDeployOld() throws Exception { Ignite g = randomGrid(); final Integer affKey = 1; // Store a cache key. g.cache(CACHE_NAME).put(affKey, affKey.toString()); String name = "serviceAffinityOld"; IgniteServices svcs = g.services().withAsync(); svcs.deployKeyAffinitySingleton(name, new AffinityService(affKey), CACHE_NAME, affKey); IgniteFuture<?> fut = svcs.future(); info("Deployed service: " + name); fut.get(); info("Finished waiting for service future: " + name); checkCount(name, g.services().serviceDescriptors(), 1); }
/** * @throws Exception If failed. */ @Test public void testServiceReassign() throws Exception { skipCheckOrder = true; Ignite ignite0 = startServer(0, 1); IgniteServices svcs = ignite0.services(); for (int i = 0; i < 10; i++) svcs.deployKeyAffinitySingleton("service-" + i, new TestServiceImpl(i), CACHE_NAME1, i); startServer(1, 2); startServer(2, 3); Map<String, List<List<ClusterNode>>> assignments = checkAffinity(3, topVer(3, 1), true); checkServicesDeploy(ignite(0), assignments.get(CACHE_NAME1)); stopGrid(0); boolean primaryChanged = calculateAffinity(4, false, assignments); assignments = checkAffinity(2, topVer(4, 0), !primaryChanged); if (primaryChanged) checkAffinity(2, topVer(4, 1), true); checkServicesDeploy(ignite(1), assignments.get(CACHE_NAME1)); }
/** * Test OOME in service method invocation. */ @Test public void testServiceInvokeOomError() throws Exception { IgniteEx ignite0 = startGrid(0); IgniteEx ignite1 = startGrid(1); IgniteCache<Integer, Integer> cache1 = ignite1.getOrCreateCache(DEFAULT_CACHE_NAME); awaitPartitionMapExchange(); Integer key = primaryKey(cache1); ignite0.services().deployKeyAffinitySingleton("fail-invoke-service", new FailServiceImpl(false), DEFAULT_CACHE_NAME, key); FailService svc = ignite0.services().serviceProxy("fail-invoke-service", FailService.class, false); try { svc.fail(); } catch (Throwable ignore) { // Expected. } assertFailureState(ignite0, ignite1); }
svcs.deployKeyAffinitySingleton(svcName, new TestService(), cacheName, key); svcs.deployKeyAffinitySingleton(svcName, new TestService(), cacheName, key); svcs.deployKeyAffinitySingleton(svcName, new TestService(), cacheName, key);
svcs.deployKeyAffinitySingleton(svcName, new TestService(), cacheName, primaryKey(ig.cache(cacheName)));