Search in sources :

Example 1 with GridTopic

use of org.apache.ignite.internal.GridTopic in project ignite by apache.

the class GridIoManager method send.

/**
     * @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.
     * @param ordered Ordered flag.
     * @param timeout Timeout.
     * @param skipOnTimeout Whether message can be skipped on timeout.
     * @param ackC Ack closure.
     * @param async If {@code true} message for local node will be processed in pool, otherwise in current thread.
     * @throws IgniteCheckedException Thrown in case of any errors.
     */
private void send(ClusterNode node, Object topic, int topicOrd, Message msg, byte plc, boolean ordered, long timeout, boolean skipOnTimeout, IgniteInClosure<IgniteException> ackC, boolean async) throws IgniteCheckedException {
    assert node != null;
    assert topic != null;
    assert msg != null;
    // Async execution was added only for IgniteMessaging.
    assert !async || msg instanceof GridIoUserMessage : msg;
    assert topicOrd >= 0 || !(topic instanceof GridTopic) : msg;
    GridIoMessage ioMsg = new GridIoMessage(plc, topic, topicOrd, msg, ordered, timeout, skipOnTimeout);
    if (locNodeId.equals(node.id())) {
        assert plc != P2P_POOL;
        CommunicationListener commLsnr = this.commLsnr;
        if (commLsnr == null)
            throw new IgniteCheckedException("Trying to send message when grid is not fully started.");
        if (ordered)
            processOrderedMessage(locNodeId, ioMsg, plc, null);
        else if (async)
            processRegularMessage(locNodeId, ioMsg, plc, NOOP);
        else
            processRegularMessage0(ioMsg, locNodeId);
        if (ackC != null)
            ackC.apply(null);
    } else {
        if (topicOrd < 0)
            ioMsg.topicBytes(U.marshal(marsh, topic));
        try {
            if ((CommunicationSpi) getSpi() instanceof TcpCommunicationSpi)
                ((TcpCommunicationSpi) (CommunicationSpi) getSpi()).sendMessage(node, ioMsg, ackC);
            else
                getSpi().sendMessage(node, ioMsg);
        } catch (IgniteSpiException e) {
            throw new IgniteCheckedException("Failed to send message (node may have left the grid or " + "TCP connection cannot be established due to firewall issues) " + "[node=" + node + ", topic=" + topic + ", msg=" + msg + ", policy=" + plc + ']', e);
        }
    }
}
Also used : CommunicationListener(org.apache.ignite.spi.communication.CommunicationListener) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi) CommunicationSpi(org.apache.ignite.spi.communication.CommunicationSpi) IgniteSpiException(org.apache.ignite.spi.IgniteSpiException) GridTopic(org.apache.ignite.internal.GridTopic) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi)

Aggregations

IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 GridTopic (org.apache.ignite.internal.GridTopic)1 IgniteSpiException (org.apache.ignite.spi.IgniteSpiException)1 CommunicationListener (org.apache.ignite.spi.communication.CommunicationListener)1 CommunicationSpi (org.apache.ignite.spi.communication.CommunicationSpi)1 TcpCommunicationSpi (org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi)1