public ServerBuilder syncBufs(boolean syncBufs) { netParams.syncBufs(syncBufs); return this; }
public TCPClientBuilder syncBufs(boolean syncBufs) { netParams.syncBufs(syncBufs); return this; }
private void openSocket() throws IOException { U.notNull(net.protocol(), "protocol"); U.notNull(net.helperClass(), "helperClass"); String blockingInfo = net.blockingAccept() ? "blocking" : "non-blocking"; Log.debug("Initializing server", "address", net.address(), "port", net.port(), "sync", net.syncBufs(), "accept", blockingInfo); serverSocketChannel = ServerSocketChannel.open(); if ((serverSocketChannel.isOpen()) && (selector.isOpen())) { serverSocketChannel.configureBlocking(net.blockingAccept()); ServerSocket socket = serverSocketChannel.socket(); Log.info("!Starting server", "!address", net.address(), "!port", net.port(), "I/O workers", net.workers(), "sync", net.syncBufs(), "accept", blockingInfo); InetSocketAddress addr = new InetSocketAddress(net.address(), net.port()); socket.setReceiveBufferSize(16 * 1024); socket.setReuseAddress(true); socket.bind(addr, MAX_PENDING_CONNECTIONS); Log.debug("Opened server socket", "address", addr); if (!net.blockingAccept()) { Log.debug("Registering accept selector"); serverSocketChannel.register(selector, SelectionKey.OP_ACCEPT); } initWorkers(); } else { throw U.rte("Cannot open socket!"); } }
public ExtendedWorker(String name, RapidoidHelper helper, NetworkingParams net, SSLContext sslContext) { super(name); this.bufSize = net.bufSizeKB() * 1024; this.noDelay = net.noDelay(); this.bufs = new BufGroup(bufSize, net.syncBufs()); this.bufSizeLimit = 1024L * Conf.NET.entry("bufSizeLimit").or(1024); // in KB this.serverProtocol = net.protocol(); this.helper = helper; this.sslContext = sslContext; this.maxPipeline = net.maxPipeline(); final int queueSize = ConfigUtil.micro() ? 1000 : 1000000; final int growFactor = ConfigUtil.micro() ? 2 : 10; this.restarting = new ArrayBlockingQueue<>(queueSize); this.connecting = new ArrayBlockingQueue<>(queueSize); this.connected = new ArrayBlockingQueue<>(queueSize); this.done = new SimpleList<>(queueSize / 10, growFactor); this.dataIn = Insights.stats(name + ":datain"); this.dataOut = Insights.stats(name + ":dataout"); connections = Pools.create("connections", () -> newConnection(false), 100000); if (idleConnectionsCrawler != null) { idleConnectionsCrawler.register(allConnections); } }
public RapidoidWorker(String name, final RapidoidHelper helper, NetworkingParams net, SSLContext sslContext) { super(name); this.bufSize = net.bufSizeKB() * 1024; this.noDelay = net.noDelay(); this.bufs = new BufGroup(bufSize, net.syncBufs()); this.serverProtocol = net.protocol(); this.helper = helper; this.sslContext = sslContext; this.maxPipeline = net.maxPipeline(); final int queueSize = ConfigUtil.micro() ? 1000 : 1000000; final int growFactor = ConfigUtil.micro() ? 2 : 10; this.connected = new ArrayBlockingQueue<>(queueSize); this.done = new SimpleList<>(queueSize / 10, growFactor); connections = Pools.create("connections", () -> newConnection(false), 100000); if (idleConnectionsCrawler != null) { idleConnectionsCrawler.register(allConnections); } }