Search in sources :

Example 1 with HadoopMessage

use of org.apache.ignite.internal.processors.hadoop.message.HadoopMessage in project ignite by apache.

the class HadoopExternalCommunication method resetNioServer.

/**
     * Recreates tpcSrvr socket instance.
     *
     * @return Server instance.
     * @throws IgniteCheckedException Thrown if it's not possible to create server.
     */
private GridNioServer<HadoopMessage> resetNioServer() throws IgniteCheckedException {
    if (boundTcpPort >= 0)
        throw new IgniteCheckedException("Tcp NIO server was already created on port " + boundTcpPort);
    IgniteCheckedException lastEx = null;
    // If configured TCP port is busy, find first available in range.
    for (int port = locPort; port < locPort + locPortRange; port++) {
        try {
            GridNioServer<HadoopMessage> srvr = GridNioServer.<HadoopMessage>builder().address(locHost).port(port).listener(srvLsnr).logger(log.getLogger(GridNioServer.class)).selectorCount(selectorsCnt).igniteInstanceName(igniteInstanceName).serverName("hadoop").tcpNoDelay(tcpNoDelay).directBuffer(directBuf).byteOrder(ByteOrder.nativeOrder()).socketSendBufferSize(sockSndBuf).socketReceiveBufferSize(sockRcvBuf).sendQueueLimit(msgQueueLimit).directMode(false).filters(filters()).build();
            boundTcpPort = port;
            // Ack Port the TCP server was bound to.
            if (log.isInfoEnabled())
                log.info("Successfully bound to TCP port [port=" + boundTcpPort + ", locHost=" + locHost + ']');
            return srvr;
        } catch (IgniteCheckedException e) {
            lastEx = e;
            if (log.isDebugEnabled())
                log.debug("Failed to bind to local port (will try next port within range) [port=" + port + ", locHost=" + locHost + ']');
        }
    }
    // If free port wasn't found.
    throw new IgniteCheckedException("Failed to bind to any port within range [startPort=" + locPort + ", portRange=" + locPortRange + ", locHost=" + locHost + ']', lastEx);
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) HadoopMessage(org.apache.ignite.internal.processors.hadoop.message.HadoopMessage) IpcEndpoint(org.apache.ignite.internal.util.ipc.IpcEndpoint) IpcSharedMemoryClientEndpoint(org.apache.ignite.internal.util.ipc.shmem.IpcSharedMemoryClientEndpoint) IpcSharedMemoryServerEndpoint(org.apache.ignite.internal.util.ipc.shmem.IpcSharedMemoryServerEndpoint) GridNioServer(org.apache.ignite.internal.util.nio.GridNioServer)

Example 2 with HadoopMessage

use of org.apache.ignite.internal.processors.hadoop.message.HadoopMessage in project ignite by apache.

the class HadoopShuffle method start.

/** {@inheritDoc} */
@Override
public void start(HadoopContext ctx) throws IgniteCheckedException {
    super.start(ctx);
    ctx.kernalContext().io().addMessageListener(GridTopic.TOPIC_HADOOP_MSG, new GridMessageListener() {

        @Override
        public void onMessage(UUID nodeId, Object msg) {
            onMessageReceived(nodeId, (HadoopMessage) msg);
        }
    });
    ctx.kernalContext().io().addUserMessageListener(GridTopic.TOPIC_HADOOP, new IgniteBiPredicate<UUID, Object>() {

        @Override
        public boolean apply(UUID nodeId, Object msg) {
            return onMessageReceived(nodeId, (HadoopMessage) msg);
        }
    });
}
Also used : GridMessageListener(org.apache.ignite.internal.managers.communication.GridMessageListener) HadoopMessage(org.apache.ignite.internal.processors.hadoop.message.HadoopMessage) UUID(java.util.UUID)

Aggregations

HadoopMessage (org.apache.ignite.internal.processors.hadoop.message.HadoopMessage)2 UUID (java.util.UUID)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 GridMessageListener (org.apache.ignite.internal.managers.communication.GridMessageListener)1 IpcEndpoint (org.apache.ignite.internal.util.ipc.IpcEndpoint)1 IpcSharedMemoryClientEndpoint (org.apache.ignite.internal.util.ipc.shmem.IpcSharedMemoryClientEndpoint)1 IpcSharedMemoryServerEndpoint (org.apache.ignite.internal.util.ipc.shmem.IpcSharedMemoryServerEndpoint)1 GridNioServer (org.apache.ignite.internal.util.nio.GridNioServer)1