use of io.aeron.driver.exceptions.ConfigurationException in project Aeron by real-logic.
the class MediaDriver method validateSufficientSocketBufferLengths.
private static void validateSufficientSocketBufferLengths(final Context ctx) {
try (DatagramChannel probe = DatagramChannel.open()) {
final int defaultSoSndBuf = probe.getOption(StandardSocketOptions.SO_SNDBUF);
probe.setOption(StandardSocketOptions.SO_SNDBUF, Integer.MAX_VALUE);
final int maxSoSndBuf = probe.getOption(StandardSocketOptions.SO_SNDBUF);
if (maxSoSndBuf < SOCKET_SNDBUF_LENGTH) {
System.err.format("WARNING: Could not get desired SO_SNDBUF, adjust OS buffer to match %s: attempted=%d, actual=%d%n", SOCKET_SNDBUF_LENGTH_PROP_NAME, SOCKET_SNDBUF_LENGTH, maxSoSndBuf);
}
probe.setOption(StandardSocketOptions.SO_RCVBUF, Integer.MAX_VALUE);
final int maxSoRcvBuf = probe.getOption(StandardSocketOptions.SO_RCVBUF);
if (maxSoRcvBuf < SOCKET_RCVBUF_LENGTH) {
System.err.format("WARNING: Could not get desired SO_RCVBUF, adjust OS buffer to match %s: attempted=%d, actual=%d%n", SOCKET_RCVBUF_LENGTH_PROP_NAME, SOCKET_RCVBUF_LENGTH, maxSoRcvBuf);
}
final int soSndBuf = 0 == SOCKET_SNDBUF_LENGTH ? defaultSoSndBuf : SOCKET_SNDBUF_LENGTH;
if (ctx.mtuLength() > soSndBuf) {
throw new ConfigurationException(String.format("MTU greater than socket SO_SNDBUF, adjust %s to match MTU: mtuLength=%d, SO_SNDBUF=%d", SOCKET_SNDBUF_LENGTH_PROP_NAME, ctx.mtuLength(), soSndBuf));
}
} catch (final IOException ex) {
throw new RuntimeException(String.format("probe socket: %s", ex.toString()), ex);
}
}
use of io.aeron.driver.exceptions.ConfigurationException in project aeron by real-logic.
the class Configuration method validateSocketBufferLengths.
/**
* Validate that the socket buffer lengths are sufficient for the media driver configuration.
*
* @param ctx to be validated.
*/
static void validateSocketBufferLengths(final MediaDriver.Context ctx) {
try (DatagramChannel probe = DatagramChannel.open()) {
final int defaultSoSndBuf = probe.getOption(StandardSocketOptions.SO_SNDBUF);
probe.setOption(StandardSocketOptions.SO_SNDBUF, Integer.MAX_VALUE);
final int maxSoSndBuf = probe.getOption(StandardSocketOptions.SO_SNDBUF);
if (maxSoSndBuf < SOCKET_SNDBUF_LENGTH) {
System.err.format("WARNING: Could not get desired SO_SNDBUF, adjust OS to allow %s: attempted=%d, actual=%d%n", SOCKET_SNDBUF_LENGTH_PROP_NAME, SOCKET_SNDBUF_LENGTH, maxSoSndBuf);
}
probe.setOption(StandardSocketOptions.SO_RCVBUF, Integer.MAX_VALUE);
final int maxSoRcvBuf = probe.getOption(StandardSocketOptions.SO_RCVBUF);
if (maxSoRcvBuf < SOCKET_RCVBUF_LENGTH) {
System.err.format("WARNING: Could not get desired SO_RCVBUF, adjust OS to allow %s: attempted=%d, actual=%d%n", SOCKET_RCVBUF_LENGTH_PROP_NAME, SOCKET_RCVBUF_LENGTH, maxSoRcvBuf);
}
final int soSndBuf = 0 == SOCKET_SNDBUF_LENGTH ? defaultSoSndBuf : SOCKET_SNDBUF_LENGTH;
if (ctx.mtuLength() > soSndBuf) {
throw new ConfigurationException(String.format("MTU greater than socket SO_SNDBUF, adjust %s to match MTU: mtuLength=%d, SO_SNDBUF=%d", SOCKET_SNDBUF_LENGTH_PROP_NAME, ctx.mtuLength(), soSndBuf));
}
if (ctx.initialWindowLength() > maxSoRcvBuf) {
throw new ConfigurationException("Window length greater than socket SO_RCVBUF, increase '" + Configuration.INITIAL_WINDOW_LENGTH_PROP_NAME + "' to match window: windowLength=" + ctx.initialWindowLength() + ", SO_RCVBUF=" + maxSoRcvBuf);
}
} catch (final IOException ex) {
throw new RuntimeException("probe socket: " + ex.toString(), ex);
}
}
Aggregations