@Override public Void call() throws Exception { comp.broadcast(new FailCallable()); return null; } }, ClusterGroupEmptyException.class, null);
/** * @param cnt Counter. * @throws Exception If failed. */ private void call1(AtomicInteger cnt) throws Exception { IgniteFuture<Collection<String>> fut = compute(prj).broadcastAsync(calJob); waitForExecution(fut); cnt.set(0); compute(prj).broadcast(calJob); waitForValue(cnt, projectionSize()); }
/** * @param ignite Ignite instance. * @param timeout Timeout. * @param param Parameter. * @throws Exception If failed. */ private Collection<Object> runJob2(ClassLoader testClassLoader, Ignite ignite, long timeout, int param) throws Exception { Constructor ctor = testClassLoader.loadClass(RUN_CLS2).getConstructor(int.class); return ignite.compute().withTimeout(timeout).broadcast((IgniteCallable<Object>)ctor.newInstance(param)); } }
/** * @param cnt Counter. * @throws Exception If failed. */ private void run1(AtomicInteger cnt) throws Exception { IgniteFuture<Void> fut = compute(prj).broadcastAsync(runJob); waitForExecution(fut); cnt.set(0); compute(prj).broadcast(runJob); waitForValue(cnt, projectionSize()); }
/** * @param ignite Ignite instance. * @param timeout Timeout. * @param param Parameter. * @throws Exception If failed. */ private Collection<Object> runJob1(ClassLoader testClassLoader, Ignite ignite, long timeout, int param) throws Exception { Constructor ctor = testClassLoader.loadClass(RUN_CLS1).getConstructor(int.class); return ignite.compute().withTimeout(timeout).broadcast((IgniteCallable<Object>)ctor.newInstance(param)); }
@Override public void test(Factory factory, Ignite ignite) throws Exception { final Collection<Object> resultsAllNull = ignite.compute() .broadcast((IgniteClosure<Object, Object>)factory.create(), null); assertEquals("Result's size mismatch: job must be run on all server nodes", gridCount() - clientsCount(), resultsAllNull.size()); for (Object o : resultsAllNull) assertNull("All results must be null", o); IgniteFuture<Collection<Object>> fut = ignite.compute() .broadcastAsync((IgniteClosure<Object, Object>)factory.create(), value(0)); checkResultsClassCount(gridCount() - clientsCount(), fut.get(), value(0).getClass()); } });
/** * @param ignite Ignite instance. * @param timeout Timeout. * @param param Parameter. * @throws Exception If failed. */ private Collection<Object> runJob0(ClassLoader testClassLoader, Ignite ignite, long timeout, int param) throws Exception { Constructor ctor = testClassLoader.loadClass(RUN_CLS).getConstructor(int.class); return ignite.compute().withTimeout(timeout).broadcast((IgniteCallable<Object>)ctor.newInstance(param)); }
@Override public Void call() throws Exception { barrier.await(); grid(3).compute().withNoFailover().broadcast(new IgniteRunnable() { @Override public void run() { // No-op. } }); return null; } });
@Override public Void call() throws Exception { barrier.await(); grid(1).compute().withNoFailover().broadcast(new IgniteRunnable() { @Override public void run() { // No-op. } }); return null; } });
/** * @param ignite Ignite instance. * @param timeout Timeout. * @throws Exception If failed. */ private void runJob1(Ignite ignite, long timeout) throws Exception { ClassLoader testClassLoader1 = new GridTestExternalClassLoader(new URL[] { new URL(GridTestProperties.getProperty("p2p.uri.cls"))}, RUN_CLS, RUN_CLS2); Constructor ctor = testClassLoader1.loadClass(RUN_CLS1).getConstructor(); ignite.compute().withTimeout(timeout).broadcast((IgniteCallable<?>)ctor.newInstance()); }
/** * @param ignite Ignite instance. * @param timeout Timeout. * @throws Exception If failed. */ private void runJob0(Ignite ignite, long timeout) throws Exception { ClassLoader testClassLoader = new GridTestExternalClassLoader(new URL[] { new URL(GridTestProperties.getProperty("p2p.uri.cls"))}, RUN_CLS1, RUN_CLS2); Constructor ctor = testClassLoader.loadClass(RUN_CLS).getConstructor(); ignite.compute().withTimeout(timeout).broadcast((IgniteCallable<?>)ctor.newInstance()); }
/** * @param ignite Ignite instance. * @param timeout Timeout. * @throws Exception If failed. */ private void runJob2(Ignite ignite, long timeout) throws Exception { ClassLoader testClassLoader = new GridTestExternalClassLoader(new URL[] { new URL(GridTestProperties.getProperty("p2p.uri.cls"))}, RUN_CLS, RUN_CLS1); Constructor ctor = testClassLoader.loadClass(RUN_CLS2).getConstructor(); ignite.compute().withTimeout(timeout).broadcast((IgniteCallable<?>)ctor.newInstance()); } }
@Override public void test(Factory factory, Ignite ignite) throws Exception { IgniteRunnable job = (IgniteRunnable)factory.create(); ignite.compute().broadcast(job); // All checks are inside the run() method of the job. } });
@Override public void test(Factory factory, Ignite ignite) throws Exception { final Collection<Object> resultsAllNull = ignite.compute() .broadcast((IgniteClosure<Object, Object>)factory.create(), null); assertEquals("Result's size mismatch: job must be run on all server nodes", gridCount() - clientsCount(), resultsAllNull.size()); for (Object o : resultsAllNull) assertNull("All results must be null", o); Collection<Object> resultsNotNull = ignite.compute() .broadcast((IgniteClosure<Object, Object>)factory.create(), value(0)); checkResultsClassCount(gridCount() - clientsCount(), resultsNotNull, value(0).getClass()); } });
@Override public void apply(Integer integer) { Ignite ignite = ignite(integer % 4); while (!fut.isDone()) { for (int i = 0; i < 10; i++) ignite.compute().broadcast(job(i)); } } }, (NODES + 1) * 5, "test");
@Override public Void call() throws Exception { comp.call(new DummyClosure()); comp.broadcast(new DummyClosure()); return null; } });
/** * @throws Exception If fails. */ @Test public void testInvalidCustomExecutor() throws Exception { grid(0).compute().withExecutor("invalid").broadcast(new IgniteRunnable() { @Override public void run() { assertTrue(Thread.currentThread().getName().contains("pub")); } }); }
/** */ private void warnDevOnly(final String msg) { grid(0).compute(grid(0).cluster().forRemotes()).broadcast(new IgniteRunnable() { @IgniteInstanceResource private Ignite ignite; @Override public void run() { IgniteUtils.warnDevOnly(ignite.log(), msg); } }); }
/** * @throws Exception If failed. */ @Test public void testPut() throws Exception { String queueName = UUID.randomUUID().toString(); IgniteQueue<Integer> queue = grid(0).queue(queueName, QUEUE_CAPACITY, config(false)); assertTrue(queue.isEmpty()); grid(0).compute().broadcast(new PutJob(queueName, RETRIES)); assertEquals(GRID_CNT * RETRIES, queue.size()); }
/** * @throws Exception If failed. */ @Test public void testPutTake() throws Exception { String queueName = UUID.randomUUID().toString(); info("Queue name: " + queueName); IgniteQueue<Integer> queue = grid(0).queue(queueName, QUEUE_CAPACITY, config(false)); assertTrue(queue.isEmpty()); grid(0).compute().broadcast(new PutTakeJob(queueName, RETRIES)); assertEquals(0, queue.size()); queue.close(); }