/** {@inheritDoc} */ @Override public IgniteMessaging message(ClusterGroup prj) { checkIgnite(); return g.message(prj); }
/** {@inheritDoc} */ @Override public IgniteMessaging message() { checkIgnite(); return g.message(); }
/** * Starts TensorFlow cluster. */ private void startCluster() { TensorFlowCluster cluster = clusterMgr.createCluster( clusterId, jobArchive, str -> ignite.message().sendOrdered("us_out_" + clusterId, str, 60 * 1000), str -> ignite.message().sendOrdered("us_err_" + clusterId, str, 60 * 1000) ); ignite.message().send(topicName, Optional.of(cluster)); }
/** * Stops TensorFlow cluster. * * @param terminate Terminate TensorFlow cluster and notify all listeners that cluster won't be started again. */ private void stopCluster(boolean terminate) { clusterMgr.stopClusterIfExists(clusterId); if (terminate) ignite.message().send(topicName, Optional.empty()); }
/** {@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; } }
@Override public Object call() throws Exception { ignite1.message().send(null, Collections.emptyList()); return null; } }, IllegalArgumentException.class, "Ouch! Argument is invalid: msgs cannot be null or empty");
/** * Creates TensorFlow cluster gateway. * * @param topicName Topic name. * @return TensorFlow cluster gateway. */ private TensorFlowClusterGateway createTensorFlowClusterGateway(String topicName) { TensorFlowClusterGateway gateway = new TensorFlowClusterGateway(subscriber -> { ignite.message().stopLocalListen(topicName, subscriber); log.info("Stop listen to cluster gateway [topicName=" + topicName + "]"); }); ignite.message().localListen(topicName, gateway); log.info("Start listen to cluster gateway [topicName=" + topicName + "]"); return gateway; } }
@Override public Object call() throws Exception { ignite1.message().send(null, (Object)null); return null; } }, NullPointerException.class, "Ouch! Argument cannot be null: msg");
@Override public Object call() throws Exception { ignite1.message().send(null, Arrays.asList(null, new Object())); return null; } }, NullPointerException.class, "Ouch! Argument cannot be null: msg");
/** {@inheritDoc} */ @Override public Collection<? extends ComputeJob> split(int gridSize, Object arg) { ignite.message().localListen(null, new P2<UUID, Object>() { @Override public boolean apply(UUID uuid, Object o) { return stop.get(); } }); return Arrays.asList(new ComputeJobAdapter() { @Override public Object execute() { return null; } }); }
/** * @param prj Projection. * @return {@link org.apache.ignite.IgniteMessaging} for given projection. */ protected IgniteMessaging message(ClusterGroup prj) { return prj.ignite().message(prj); }
@Override public Object call() throws Exception { ignite1.message().send(null, null); return null; } }, IllegalArgumentException.class, "Ouch! Argument is invalid: msgs cannot be null or empty");
@Override public Boolean apply(Object o) { assertNotNull(o); IgniteMessaging msg = client.message(); msg.send(null, "Test message."); try { assertTrue(recvLatch.await(2, SECONDS)); } catch (InterruptedException ignored) { fail("Message wasn't received."); } return true; } }
/** * @param nodeSnd Sender Ignite node. * @param grp Cluster group. * @param msg Message. * @param async Async message send flag. */ private void sendMessage(Ignite nodeSnd, ClusterGroup grp, Object msg, boolean async) { if (async) nodeSnd.message(grp).withAsync().send(MESSAGE_TOPIC, msg); else nodeSnd.message(grp).send(MESSAGE_TOPIC, msg); }
/** * @throws Exception If failed. */ @Test public void testSendOrderedDefaultModeMultiThreads() throws Exception { Ignite ignite = startGrid(1); sendOrderedMultiThreads(ignite.message()); }
/** * @param grp Cluster group. * @return Message listener uuid. * @throws Exception If failed. */ private UUID registerListener(ClusterGroup grp) throws Exception { Ignite ignite = grid(SERVER_NODE_IDX); IgniteBiPredicate<UUID,Object> lsnr = new MessageListener(); return ignite.message(grp).remoteListen(MESSAGE_TOPIC, lsnr); }
/** {@inheritDoc} */ @Override public boolean apply(UUID nodeId, String msg) { ignite.message(ignite.cluster().forNodeId(nodeId)).send(TOPIC.ORDERED, msg); return true; } }
/** * Checks if use default mode, local listeners execute in the same thread, 1 node in topology. * * @throws Exception If failed. */ @Test public void testSendDefaultMode() throws Exception { Ignite ignite1 = startGrid(1); send(ignite1.message(), msgStr, new IgniteBiInClosure<String, Thread> () { @Override public void apply(String msg, Thread thread) { Assert.assertEquals(Thread.currentThread(), thread); Assert.assertEquals(msgStr, msg); } }, false); }
/** * @throws Exception If failed. */ @Test public void testSendOrderedDefaultModeMultiThreadsWith2Node() throws Exception { Ignite ignite1 = startGrid(1); Ignite ignite2 = startGrid(2); sendOrderedMultiThreadsWith2Node(ignite2, ignite1.message()); }