/** * Implementation of send. * @param topic Topic. * @param msg Message. * @param async Async flag. * @throws IgniteException On error. */ private void send0(@Nullable Object topic, Object msg, boolean async) throws IgniteException { A.notNull(msg, "msg"); guard(); try { Collection<ClusterNode> snapshot = prj.nodes(); if (snapshot.isEmpty()) throw U.emptyTopologyException(); ctx.io().sendUserMessage(snapshot, msg, topic, false, 0, async); } catch (IgniteCheckedException e) { throw U.convertException(e); } finally { unguard(); } }
@Override public void send(ClusterNode node, Serializable msg, String topic) throws IgniteSpiException { A.notNull(node, "node"); A.notNull(msg, "msg"); A.notNull(topic, "topic"); try { if (msg instanceof Message) ctx.io().sendToCustomTopic(node, topic, (Message)msg, SYSTEM_POOL); else ctx.io().sendUserMessage(Collections.singletonList(node), msg, topic, false, 0, false); } catch (IgniteCheckedException e) { throw unwrapException(e); } }
/** {@inheritDoc} */ @Override public void sendOrdered(@Nullable Object topic, Object msg, long timeout) { A.notNull(msg, "msg"); guard(); try { Collection<ClusterNode> snapshot = prj.nodes(); if (snapshot.isEmpty()) throw U.emptyTopologyException(); if (timeout == 0) timeout = ctx.config().getNetworkTimeout(); ctx.io().sendUserMessage(snapshot, msg, topic, true, timeout, false); } catch (IgniteCheckedException e) { throw U.convertException(e); } finally { unguard(); } }
/** * Implementation of send. * @param topic Topic. * @param msgs Messages. * @param async Async flag. * @throws IgniteException On error. */ private void send0(@Nullable Object topic, Collection<?> msgs, boolean async) throws IgniteException { A.ensure(!F.isEmpty(msgs), "msgs cannot be null or empty"); guard(); try { Collection<ClusterNode> snapshot = prj.nodes(); if (snapshot.isEmpty()) throw U.emptyTopologyException(); for (Object msg : msgs) { A.notNull(msg, "msg"); ctx.io().sendUserMessage(snapshot, msg, topic, false, 0, async); } } catch (IgniteCheckedException e) { throw U.convertException(e); } finally { unguard(); } }
/** * @throws Exception If failed. */ @Test public void testSendUserMessageUnorderedThickVersionIfOneOfNodesIsLocal() throws Exception { Object msg = new Object(); GridIoManager ioMgr = spy(new TestGridIoManager(ctx)); try { ioMgr.sendUserMessage(F.asList(locNode, rmtNode), msg, GridTopic.TOPIC_IGFS, false, 123L, false); } catch (IgniteCheckedException ignored) { // No-op. We are using mocks so real sending is impossible. } verify(ioMgr).sendToGridTopic(eq(locNode), eq(GridTopic.TOPIC_COMM_USER), any(GridIoUserMessage.class), eq(GridIoPolicy.PUBLIC_POOL)); Collection<? extends ClusterNode> rmtNodes = F.view(F.asList(rmtNode), F.remoteNodes(locNode.id())); verify(ioMgr).sendToGridTopic(argThat(new IsEqualCollection(rmtNodes)), eq(GridTopic.TOPIC_COMM_USER), any(GridIoUserMessage.class), eq(GridIoPolicy.PUBLIC_POOL)); }
/** * @throws Exception If failed. */ @Test public void testSendUserMessageThinVersionIfOneOfNodesIsLocal() throws Exception { Object msg = new Object(); GridIoManager ioMgr = spy(new TestGridIoManager(ctx)); try { ioMgr.sendUserMessage(F.asList(locNode, rmtNode), msg, null, false, 0, false); } catch (IgniteCheckedException ignored) { // No-op. We are using mocks so real sending is impossible. } verify(ioMgr).sendToGridTopic(eq(locNode), eq(GridTopic.TOPIC_COMM_USER), any(GridIoUserMessage.class), eq(GridIoPolicy.PUBLIC_POOL)); Collection<? extends ClusterNode> rmtNodes = F.view(F.asList(rmtNode), F.remoteNodes(locNode.id())); verify(ioMgr).sendToGridTopic(argThat(new IsEqualCollection(rmtNodes)), eq(GridTopic.TOPIC_COMM_USER), any(GridIoUserMessage.class), eq(GridIoPolicy.PUBLIC_POOL)); }
/** * @throws Exception If failed. */ @Test public void testSendUserMessageOrderedThickVersionIfOneOfNodesIsLocal() throws Exception { Object msg = new Object(); GridIoManager ioMgr = spy(new TestGridIoManager(ctx)); try { ioMgr.sendUserMessage(F.asList(locNode, rmtNode), msg, GridTopic.TOPIC_IGFS, true, 123L, false); } catch (Exception ignored) { // No-op. We are using mocks so real sending is impossible. } verify(ioMgr).sendOrderedMessageToGridTopic( argThat(new IsEqualCollection(F.asList(locNode, rmtNode))), eq(GridTopic.TOPIC_COMM_USER), any(GridIoUserMessage.class), eq(GridIoPolicy.PUBLIC_POOL), eq(123L), false); }
/** * @param nodeId Node ID to send message to. * @param msg Message to send. * @throws IgniteCheckedException If send failed. */ private void send0(UUID nodeId, Object msg) throws IgniteCheckedException { ClusterNode node = ctx.kernalContext().discovery().node(nodeId); if (msg instanceof Message) ctx.kernalContext().io().sendToGridTopic(node, GridTopic.TOPIC_HADOOP_MSG, (Message)msg, GridIoPolicy.PUBLIC_POOL); else ctx.kernalContext().io().sendUserMessage(F.asList(node), msg, GridTopic.TOPIC_HADOOP, false, 0, false); }
/** * Implementation of send. * @param topic Topic. * @param msg Message. * @param async Async flag. * @throws IgniteException On error. */ private void send0(@Nullable Object topic, Object msg, boolean async) throws IgniteException { A.notNull(msg, "msg"); guard(); try { Collection<ClusterNode> snapshot = prj.nodes(); if (snapshot.isEmpty()) throw U.emptyTopologyException(); ctx.io().sendUserMessage(snapshot, msg, topic, false, 0, async); } catch (IgniteCheckedException e) { throw U.convertException(e); } finally { unguard(); } }
@Override public void send(ClusterNode node, Serializable msg, String topic) throws IgniteSpiException { A.notNull(node, "node"); A.notNull(msg, "msg"); A.notNull(topic, "topic"); try { if (msg instanceof Message) ctx.io().sendToCustomTopic(node, topic, (Message)msg, SYSTEM_POOL); else ctx.io().sendUserMessage(Collections.singletonList(node), msg, topic, false, 0, false); } catch (IgniteCheckedException e) { throw unwrapException(e); } }
/** {@inheritDoc} */ @Override public void sendOrdered(@Nullable Object topic, Object msg, long timeout) { A.notNull(msg, "msg"); guard(); try { Collection<ClusterNode> snapshot = prj.nodes(); if (snapshot.isEmpty()) throw U.emptyTopologyException(); if (timeout == 0) timeout = ctx.config().getNetworkTimeout(); ctx.io().sendUserMessage(snapshot, msg, topic, true, timeout, false); } catch (IgniteCheckedException e) { throw U.convertException(e); } finally { unguard(); } }
/** * Implementation of send. * @param topic Topic. * @param msgs Messages. * @param async Async flag. * @throws IgniteException On error. */ private void send0(@Nullable Object topic, Collection<?> msgs, boolean async) throws IgniteException { A.ensure(!F.isEmpty(msgs), "msgs cannot be null or empty"); guard(); try { Collection<ClusterNode> snapshot = prj.nodes(); if (snapshot.isEmpty()) throw U.emptyTopologyException(); for (Object msg : msgs) { A.notNull(msg, "msg"); ctx.io().sendUserMessage(snapshot, msg, topic, false, 0, async); } } catch (IgniteCheckedException e) { throw U.convertException(e); } finally { unguard(); } }