/** * @param msg Message. * @param nodeId Node ID. */ private void processRegularMessage0(GridIoMessage msg, UUID nodeId) { GridMessageListener lsnr = listenerGet0(msg.topic()); if (lsnr == null) return; Object obj = msg.message(); assert obj != null; invokeListener(msg.policy(), lsnr, nodeId, obj); }
/** * Get IO policy. * * @return IO policy. */ private static byte threadIoPolicy() { Byte plc = GridIoManager.currentPolicy(); if (plc == null) plc = DATA_STREAMER_POOL; return plc; }
/** * @param node Destination node. * @param topic Topic to send the message to. * @param topicOrd GridTopic enumeration ordinal. * @param msg Message to send. * @param plc Type of processing. * @throws IgniteCheckedException Thrown in case of any errors. */ public void sendGeneric(ClusterNode node, Object topic, int topicOrd, Message msg, byte plc) throws IgniteCheckedException { send(node, topic, topicOrd, msg, plc, false, 0, false, null, false); }
@Override public Object call() throws Exception { new GridIoManager(ctx).sendToGridTopic(F.asList(locNode, rmtNode), GridTopic.TOPIC_CACHE, new TestMessage(), GridIoPolicy.P2P_POOL); return null; } }, AssertionError.class, "Internal Ignite code should never call the method with local node in a node list.");
/** * @param topic Listener's topic. * @param lsnr Listener to add. */ public void addMessageListener(GridTopic topic, GridMessageListener lsnr) { addMessageListener((Object)topic, lsnr); }
/** * Checks if it is a p2p deployment message. * * @param msg Message to check. * @return {@code True} if this is a p2p message. */ private boolean isDeploymentMessage(GridIoMessage msg) { Object origMsg = msg.message(); boolean dep = (origMsg instanceof GridDeploymentRequest) || (origMsg instanceof GridDeploymentResponse); if (dep) info(">>> Got deployment message: " + origMsg); return dep; } }
/** * @throws Exception If failed. */ @Test public void testSendMessage() throws Exception { try { startGridsMultiThreaded(2); doSend(new TestMessage(), TestMessage.class); } finally { stopAllGrids(); } }
/** * @throws Exception If failed. */ @Test public void testSendMessageOverByteId() throws Exception { try { startGridsMultiThreaded(2); doSend(new TestOverByteIdMessage(), TestOverByteIdMessage.class); } finally { stopAllGrids(); } }
/** * @param topic Message topic. * @return Whether or not listener was indeed removed. */ public boolean removeMessageListener(Object topic) { return removeMessageListener(topic, null); }
/** * Passes message to the whole chain. * * @param nodeId Node ID. * @param msg Message. */ @Override public void onMessage(UUID nodeId, Object msg, byte plc) { GridMessageListener[] arr0 = arr; if (arr0 == null) return; for (GridMessageListener l : arr0) l.onMessage(nodeId, msg, plc); }
/** {@inheritDoc} */ @Override public GridIoManager io() { return new GridIoManager(this); }
/** {@inheritDoc} */ @Override public MessageFactory messageFactory() { if (factory == null) factory = new GridIoMessageFactory(null); return factory; }
@Override public Message apply() { return new GridIoUserMessage(); } });
/** * @param procFromNioThread {@code True} if message should be processed from NIO thread. */ public void processFromNioThread(boolean procFromNioThread) { setFlag(procFromNioThread, FLAG_PROC_FROM_NIO); }
@Override public void onDisconnected(UUID nodeId) { for (GridDisconnectListener lsnr : disconnectLsnrs) lsnr.onNodeDisconnected(nodeId); } });
/** * @return {@code True} if message should be processed from NIO thread * (otherwise message is submitted to system pool). */ public boolean processFromNioThread() { return isFlag(FLAG_PROC_FROM_NIO); }
@Override public Message apply() { return new TestOverByteIdMessage(); } });
/** * @param topic Message topic. * @return Whether or not listener was indeed removed. */ public boolean removeMessageListener(GridTopic topic) { return removeMessageListener((Object)topic); }
/** * @param node Destination node. * @param topic Topic to send the message to. * @param msg Message to send. * @param plc Type of processing. * @throws IgniteCheckedException Thrown in case of any errors. */ public void sendToCustomTopic(ClusterNode node, Object topic, Message msg, byte plc) throws IgniteCheckedException { send(node, topic, -1, msg, plc, false, 0, false, null, false); }