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();
}
}
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();
}
}
Aggregations