/** {@inheritDoc} */ @Override public boolean apply(Event evt) { try { int[] res = new int[] { System.identityHashCode(getClass().getClassLoader()) }; ignite.message(ignite.cluster().forRemotes()).send(null, res); } catch (IgniteException e) { throw new RuntimeException(e); } return true; } }
/** {@inheritDoc} */ @Override public boolean apply(Event evt) { try { int[] res = new int[] { System.identityHashCode(getClass().getClassLoader()) }; ignite.message(ignite.cluster().forRemotes()).send(null, res); } catch (IgniteException e) { throw new RuntimeException(e); } return true; } }
/** {@inheritDoc} */ @Nullable @Override public Object call() throws Exception { final IgniteInClosure<IgniteFuture<?>> lsnr = new CI1<IgniteFuture<?>>() { @Override public void apply(IgniteFuture<?> t) { tasksSem.release(); } }; ClusterGroup rmts = g.cluster().forRemotes(); while (!finish) { tasksSem.acquire(); g.compute(rmts).executeAsync(GridJobExecutionLoadTestTask.class, null).listen(lsnr); txCnt.increment(); } return null; }
/** {@inheritDoc} */ @Nullable @Override public Object call() throws Exception { IgniteCompute rmts = g.compute(g.cluster().forRemotes()); while (!finish) { try { rmts.execute(GridJobExecutionLoadTestTask.class, null); txCnt.increment(); } catch (IgniteException e) { e.printStackTrace(); } } return null; }
@Override public Void call() throws Exception { int idx = b.await(); Ignite node = ignite(idx % 3); IgniteCompute comp = node.compute(node.cluster().forRemotes()); comp.run(new TestJob()); return null; }
/** * Test that Binarylizable IgniteRunnable with ComputeJobMasterLeaveAware interface is serialized * using BinaryMarshaller. * * @throws Exception If failed. */ @Test public void testMasterLeaveAwareRunnable() throws Exception { Ignite ignite = startGrid(1); startGrid(2); final TestBinarylizableMasterLeaveAwareRunnable runnable = new TestBinarylizableMasterLeaveAwareRunnable(); ignite.compute(ignite.cluster().forRemotes()).run(runnable); assert TestBinarylizableRunnable.executed.get(); assert TestBinarylizableRunnable.writeCalled.get(); assert TestBinarylizableRunnable.readCalled.get(); assert TestBinarylizableMasterLeaveAwareRunnable.writeCalled.get(); assert TestBinarylizableMasterLeaveAwareRunnable.readCalled.get(); }
/** * Test that Binarylizable IgniteCallable with ComputeJobMasterLeaveAware interface is serialized * using BinaryMarshaller. * * @throws Exception If failed. */ @Test public void testMasterLeaveAwareCallable() throws Exception { Ignite ignite = startGrid(1); startGrid(2); final TestBinarylizableMasterLeaveAwareCallable callable = new TestBinarylizableMasterLeaveAwareCallable(); ignite.compute(ignite.cluster().forRemotes()).call(callable); assert TestBinarylizableCallable.executed.get(); assert TestBinarylizableCallable.writeCalled.get(); assert TestBinarylizableCallable.readCalled.get(); assert TestBinarylizableMasterLeaveAwareCallable.writeCalled.get(); assert TestBinarylizableMasterLeaveAwareCallable.readCalled.get(); }
/** * Test that Binarylizable IgniteClosure is serialized using BinaryMarshaller. * * @throws Exception If failed. */ @Test public void testJob() throws Exception { Ignite ignite = startGrid(1); startGrid(2); final TestBinarylizableClosure closure = new TestBinarylizableClosure(); ignite.compute(ignite.cluster().forRemotes()).apply(closure, new TestBinarylizableObject()); assert TestBinarylizableClosure.executed.get(); assert TestBinarylizableClosure.writeCalled.get(); assert TestBinarylizableClosure.readCalled.get(); assert TestBinarylizableObject.writeCalled.get(); assert TestBinarylizableObject.readCalled.get(); }
/** * Test that Binarylizable IgniteRunnable is serialized using BinaryMarshaller. * * @throws Exception If failed. */ @Test public void testRunnable() throws Exception { Ignite ignite = startGrid(1); startGrid(2); final TestBinarylizableRunnable runnable = new TestBinarylizableRunnable(); ignite.compute(ignite.cluster().forRemotes()).run(runnable); assert TestBinarylizableRunnable.executed.get(); assert TestBinarylizableRunnable.writeCalled.get(); assert TestBinarylizableRunnable.readCalled.get(); }
/** * Test that Binarylizable IgniteCallable is serialized using BinaryMarshaller. * * @throws Exception If failed. */ @Test public void testCallable() throws Exception { Ignite ignite = startGrid(1); startGrid(2); final TestBinarylizableCallable callable = new TestBinarylizableCallable(); ignite.compute(ignite.cluster().forRemotes()).call(callable); assert TestBinarylizableCallable.executed.get(); assert TestBinarylizableCallable.writeCalled.get(); assert TestBinarylizableCallable.readCalled.get(); }
/** * @throws Exception If failed. */ @Test public void testGetRemoteNodes() throws Exception { Collection<ClusterNode> nodes = ignite.cluster().forRemotes().nodes(); printNodes(nodes); }
/** * @throws Exception If fail. */ private void orderedMessage() throws Exception { Ignite ignite = grid(SERVER_NODE_IDX); ClusterGroup grp = gridCount() > 1 ? ignite.cluster().forRemotes() : ignite.cluster().forLocal(); assert !grp.nodes().isEmpty(); registerListenerAndSendOrderedMessages(ignite, grp); }
/** * @param ignite Grid. * @param expCnt Expected nodes count. */ private void checkRemoteNodes(Ignite ignite, int expCnt) { Collection<ClusterNode> nodes = ignite.cluster().forRemotes().nodes(); assertEquals("Unexpected state for node: " + ignite.name(), expCnt, nodes.size()); for (ClusterNode node : nodes) { UUID id = node.id(); if (clientNodeIds.contains(id)) assertTrue(node.isClient()); else if (srvNodeIds.contains(id)) assertFalse(node.isClient()); else assert false : "Unexpected node ID: " + id; } }
/** * @throws Exception If failed. */ @SuppressWarnings("unchecked") @Test public void testDeployment() throws Exception { startGridsMultiThreaded(GRID_CNT); Ignite ignite = startGrid(IGNITE_INSTANCE_NAME); Class cls = getExternalClassLoader().loadClass(TEST_TASK_1); compute(ignite.cluster().forRemotes()).execute(cls, null); stopGrid(IGNITE_INSTANCE_NAME); ignite = startGrid(IGNITE_INSTANCE_NAME); cls = getExternalClassLoader().loadClass(TEST_TASK_2); compute(ignite.cluster().forRemotes()).execute(cls, null); stopGrid(IGNITE_INSTANCE_NAME); }
/** * @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); }
/** * Method executes GridP2PTestTask. * @throws IgniteCheckedException If failed. */ @Test public void testGridP2PTestTask() throws IgniteCheckedException { try (Ignite g = G.start()) { assert g != null; assert !g.cluster().forRemotes().nodes().isEmpty() : "Test requires at least 1 remote node."; /* Execute GridP2PTestTask. */ ComputeTaskFuture<Integer> fut = executeAsync(g.compute(), GridP2PTestTask.class, 1); /* Wait for task completion. */ Integer res = fut.get(); X.println("Result of execution is: " + res); assert res > 0 : "Result of execution is: " + res + " for more information see GridP2PTestJob"; } } }
/** * @throws Exception Thrown in case of failure. */ @Test public void testAnonymousUnicast() throws Exception { Ignite g = grid(0); assert g.cluster().nodes().size() == NODES_CNT; execCntr.set(0); ClusterNode rmt = F.first(g.cluster().forRemotes().nodes()); compute(g.cluster().forNode(rmt)).run(new CARemote() { @Override public void apply() { log.info("UNICASTING...."); ignite.countDownLatch("unicast", 1, false, true).countDown(); execCntr.incrementAndGet(); } }); assertTrue(g.countDownLatch("unicast", 1, false, true).await(2000)); assertEquals(0, execCntr.get()); }
/** * Unwraps error message from InvocationTargetException. * * @throws Exception If failed. */ @SuppressWarnings("ThrowableNotThrown") @Test public void testException() throws Exception { String name = "errorService"; Ignite ignite = grid(0); ignite.services(ignite.cluster().forRemotes()).deployNodeSingleton(name, new ErrorServiceImpl()); final ErrorService svc = ignite.services().serviceProxy(name, ErrorService.class, false); GridTestUtils.assertThrows(log, new Callable<Object>() { @Override public Object call() throws Exception { svc.go(); return null; } }, ErrorServiceException.class, "Test exception"); }
/** */ 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)); }
/** * @throws Exception If failed. */ @Test public void testBinaryField() throws Exception { marshFactory = new Callable<Marshaller>() { @Override public Marshaller call() throws Exception { return new BinaryMarshaller(); } }; Ignite ignite = startGrids(2); BinaryObject bo = ignite.binary().builder("ProxyWrapper").setField("proxy", create()).build(); int val = ignite.compute(ignite.cluster().forRemotes()).call(new FieldTestCallable(bo)); assertEquals(42, val); }