/** {@inheritDoc} */ @Override public <T> Map<K, EntryProcessorResult<T>> invokeAll( Set<? extends K> keys, EntryProcessor<K, V, T> processor, Object... args) { return compute.call(new InvokeAllTask<>(cacheName, isAsync, keys, processor, args)); }
/** * @param cnt Counter. * @throws Exception If failed. */ private void call2(AtomicInteger cnt) throws Exception { Collection<IgniteCallable<String>> jobs = F.asList(calJob); IgniteFuture<Collection<String>> fut = compute(prj).callAsync(jobs); waitForExecution(fut); cnt.set(0); compute(prj).call(jobs); waitForValue(cnt, jobs.size()); }
@Override public Void call() throws Exception { while (!stop.get()) { final Class<?> clazz = root.loadClass("org.apache.ignite.p2p.GridP2PLocalDeploymentSelfTest$TestClosure"); ignite.compute(). call((IgniteCallable) clazz.getDeclaredConstructor(ClassLoader.class).newInstance(root)); } return null; } }, 1);
/** {@inheritDoc} */ @Override public boolean replace(K key, V val) { return compute.call(new ReplaceTask<>(cacheName, isAsync, key, val)); }
/** {@inheritDoc} */ @Override public void clear() { compute.call(new ClearTask(cacheName, isAsync)); }
/** {@inheritDoc} */ @Override public boolean isPrimaryOrBackup(ClusterNode n, K key) { return compute.call(new PrimaryOrBackupNodeTask<>(cacheName, key, n, true, true)); }
/** {@inheritDoc} */ @Override public int[] primaryPartitions(ClusterNode n) { return compute.call(new GetPartitionsTask(cacheName, n, true, false)); }
/** {@inheritDoc} */ @Override public int[] allPartitions(ClusterNode n) { return compute.call(new GetPartitionsTask(cacheName, n, true, true)); }
/** {@inheritDoc} */ @Override public Object affinityKey(K key) { return compute.call(new AffinityKeyTask<>(cacheName, key)); }
@Override public Void call() throws Exception { g.compute().call(jobs, new IgniteReducer<Integer, Object>() { @Override public boolean collect(@Nullable Integer e) { fail("Expects failed jobs never call 'collect' method."); return true; } @Override public Object reduce() { return null; } }); return null; } }, IgniteException.class, null);
/** * Called to remove object from cache without regard to transaction. * * @param ignite Grid. * @param cache Cache. * @param key Key. */ public static void evict(Ignite ignite, HibernateCacheProxy cache, Object key) { key = cache.keyTransformer().transform(key); ignite.compute(ignite.cluster()).call(new ClearKeyCallable(key, cache.name())); }
@Override public void test(Factory factory, Ignite ignite) throws Exception { Collection<EchoCallable> jobs = new ArrayList<>(MAX_JOB_COUNT); for (int i = 0; i < MAX_JOB_COUNT; ++i) { EchoCallable job = (EchoCallable)factory.create(); job.setArg(value(i - 1)); jobs.add(job); } Collection<Object> results = ignite.compute().call(jobs); checkResultsClassCount(MAX_JOB_COUNT - 1, results, value(0).getClass()); assertCollectionsEquals("Results value mismatch", createGoldenResults(), results); } });
@Override public void test(Factory factory, Ignite ignite) throws Exception { Collection<Object> results = new ArrayList<>(MAX_JOB_COUNT); for (int i = 0; i < MAX_JOB_COUNT; ++i) { EchoCallable job = (EchoCallable)factory.create(); job.setArg(value(i - 1)); results.add(ignite.compute().call(job)); } checkResultsClassCount(MAX_JOB_COUNT - 1, results, value(0).getClass()); assertCollectionsEquals("Results value mismatch", createGoldenResults(), results); } });
/** * Calls job on remote JVM. * * @param proxy Ignite. * @param job Job. */ public static <R> R executeRemotely(IgniteProcessProxy proxy, final TestIgniteCallable<R> job) { return proxy.remoteCompute().call(new TestRemoteTask<>(proxy.getId(), job)); }
@Override public Object call() throws Exception { ignite1.compute(ignite1.cluster().forNode(ignite0.localNode())).call(new IgniteCallable<Object>() { @Override public Object call() throws Exception { jobCtx.setAttribute("test-attr", new BrokenAttribute()); return null; } }); return null; } }, IgniteException.class, null);
@Override public Object call() throws Exception { ignite1.compute(ignite1.cluster().forNode(ignite0.localNode())).call(new IgniteCallable<Object>() { @Override public Object call() throws Exception { throw new BrokenException(); } }); return null; } }, IgniteException.class, null);
/** * @throws Exception If failed. */ @Test public void testWithName() throws Exception { grid(0).compute().withName("TestTaskName").call(new ClosureTestCallable()); }
@Override public void run() { doSleep(1000); //spi1.failSend = false; cnt.getAndAdd(c1.compute(c1.cluster().forNodeId(c2.cluster().localNode().id())).call(new TestClosure())); } }, 1, "hang-thread");
/** * @throws Exception If failed. */ private void doTestMarshaller() throws Exception { Ignite ignite = startGrids(2); int val = ignite.compute(ignite.cluster().forRemotes()).call(new MarshallerTestCallable(create())); assertEquals(42, val); }
/** */ private void runRemoteUnmarshal() throws Exception { Ignite ignite = startGrid(0); byte[] one = ignite.configuration().getMarshaller().marshal(DeclaredBodyEnum.ONE); byte[] two = ignite.configuration().getMarshaller().marshal(DeclaredBodyEnum.TWO); startGrid(1); ignite.compute(ignite.cluster().forRemotes()).call(new UnmarshalCallable(one, two)); }