Search in sources :

Example 1 with IpcOutOfSystemResourcesException

use of org.apache.ignite.internal.util.ipc.shmem.IpcOutOfSystemResourcesException in project ignite by apache.

the class TcpCommunicationSpi method createNioClient.

/**
 * @param node Node to create client for.
 * @param connIdx Connection index.
 * @return Client.
 * @throws IgniteCheckedException If failed.
 */
@Nullable
private GridCommunicationClient createNioClient(ClusterNode node, int connIdx) throws IgniteCheckedException {
    assert node != null;
    Integer shmemPort = node.attribute(createSpiAttributeName(ATTR_SHMEM_PORT));
    ClusterNode locNode = getSpiContext().localNode();
    if (locNode == null)
        throw new IgniteCheckedException("Failed to create NIO client (local node is stopping)");
    if (log.isDebugEnabled())
        log.debug("Creating NIO client to node: " + node);
    // then we are likely to run on the same host and shared memory communication could be tried.
    if (shmemPort != null && U.sameMacs(locNode, node)) {
        try {
            GridCommunicationClient client = createShmemClient(node, connIdx, shmemPort);
            if (log.isDebugEnabled())
                log.debug("Shmem client created: " + client);
            return client;
        } catch (IgniteCheckedException e) {
            if (e.hasCause(IpcOutOfSystemResourcesException.class))
                // Has cause or is itself the IpcOutOfSystemResourcesException.
                LT.warn(log, OUT_OF_RESOURCES_TCP_MSG);
            else if (getSpiContext().node(node.id()) != null)
                LT.warn(log, e.getMessage());
            else if (log.isDebugEnabled())
                log.debug("Failed to establish shared memory connection with local node (node has left): " + node.id());
        }
    }
    connectGate.enter();
    try {
        GridCommunicationClient client = createTcpClient(node, connIdx);
        if (log.isDebugEnabled())
            log.debug("TCP client created: " + client);
        return client;
    } finally {
        connectGate.leave();
    }
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IpcOutOfSystemResourcesException(org.apache.ignite.internal.util.ipc.shmem.IpcOutOfSystemResourcesException) GridCommunicationClient(org.apache.ignite.internal.util.nio.GridCommunicationClient) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with IpcOutOfSystemResourcesException

use of org.apache.ignite.internal.util.ipc.shmem.IpcOutOfSystemResourcesException in project ignite by apache.

the class HadoopIgfsIpcIo method start.

/**
 * Starts the IO.
 *
 * @throws IgniteCheckedException If failed to connect the endpoint.
 */
private void start() throws IgniteCheckedException {
    boolean success = false;
    try {
        endpoint = IpcEndpointFactory.connectEndpoint(endpointAddr, new GridLoggerProxy(new HadoopIgfsJclLogger(log), null, null, ""));
        out = new IgfsDataOutputStream(new BufferedOutputStream(endpoint.outputStream()));
        reader = new ReaderThread();
        // Required for Hadoop 2.x
        reader.setDaemon(true);
        reader.start();
        success = true;
    } catch (IgniteCheckedException e) {
        IpcOutOfSystemResourcesException resEx = e.getCause(IpcOutOfSystemResourcesException.class);
        if (resEx != null)
            throw new IgniteCheckedException(IpcSharedMemoryServerEndpoint.OUT_OF_RESOURCES_MSG, resEx);
        throw e;
    } finally {
        if (!success)
            stop();
    }
}
Also used : GridLoggerProxy(org.apache.ignite.internal.GridLoggerProxy) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IpcOutOfSystemResourcesException(org.apache.ignite.internal.util.ipc.shmem.IpcOutOfSystemResourcesException) IgfsDataOutputStream(org.apache.ignite.internal.igfs.common.IgfsDataOutputStream) BufferedOutputStream(java.io.BufferedOutputStream)

Aggregations

IgniteCheckedException (org.apache.ignite.IgniteCheckedException)2 IpcOutOfSystemResourcesException (org.apache.ignite.internal.util.ipc.shmem.IpcOutOfSystemResourcesException)2 BufferedOutputStream (java.io.BufferedOutputStream)1 ClusterNode (org.apache.ignite.cluster.ClusterNode)1 GridLoggerProxy (org.apache.ignite.internal.GridLoggerProxy)1 IgfsDataOutputStream (org.apache.ignite.internal.igfs.common.IgfsDataOutputStream)1 GridCommunicationClient (org.apache.ignite.internal.util.nio.GridCommunicationClient)1 Nullable (org.jetbrains.annotations.Nullable)1