private Channel bind() throws InterruptedException { ServerBootstrap b = new ServerBootstrap(); b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class) .childOption(ChannelOption.RCVBUF_ALLOCATOR, new FixedRecvByteBufAllocator(RECEIVE_BUFFER_SIZE)) .childOption(ChannelOption.AUTO_READ, Boolean.FALSE) .childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT) .childOption(ChannelOption.WRITE_BUFFER_WATER_MARK, WRITE_BUFFER_WATER_MARK) .handler(new LoggingHandler(LogLevel.DEBUG)).childHandler(getChannelInitializer()); Channel newChannel = b.bind(port).sync().channel(); newChannel.closeFuture().addListener(f -> { // This listener is invoked from within a netty IO thread. Hence, we can never block it // For simplicity, we will submit the recovery task to a different thread synchronized (lock) { if (state != STARTED) { return; } LOGGER.log(Level.WARN, "{} has stopped unexpectedly. Starting server recovery", this); MXHelper.logFileDescriptors(); triggerRecovery(); } }); return newChannel; }
public static void logFileDescriptors() { try { if (supportOpenFileCount()) { LOGGER.log(Level.WARN, "Number of open files by this process is {}. Max number of allowed open files is {} ", MXHelper::getCurrentOpenFileCount, MXHelper::getMaxOpenFileCount); } } catch (Throwable th) { // NOSONAR: diagnostic code shouldn't cause server failure LOGGER.log(Level.WARN, "Failed getting the count of open files", th); } }
o.putPOJO("classpath", toPathElements(runtimeMXBean.getClassPath())); o.putPOJO("library_path", toPathElements(runtimeMXBean.getLibraryPath())); o.putPOJO("boot_classpath", toPathElements(MXHelper.getBootClassPath())); o.putPOJO("input_arguments", runtimeMXBean.getInputArguments()); o.putPOJO("system_properties", runtimeMXBean.getSystemProperties());
public NodeRegistration(InetSocketAddress ncAddress, String nodeId, NCConfig ncConfig, NetworkAddress dataPort, NetworkAddress resultPort, HeartbeatSchema hbSchema, NetworkAddress messagingPort, NodeCapacity capacity) { this.ncAddress = ncAddress; this.nodeId = nodeId; this.ncConfig = ncConfig; this.dataPort = dataPort; this.resultPort = resultPort; this.hbSchema = hbSchema; this.messagingPort = messagingPort; this.capacity = capacity; this.osName = osMXBean.getName(); this.arch = osMXBean.getArch(); this.osVersion = osMXBean.getVersion(); this.nProcessors = osMXBean.getAvailableProcessors(); this.vmName = runtimeMXBean.getVmName(); this.vmVersion = runtimeMXBean.getVmVersion(); this.vmVendor = runtimeMXBean.getVmVendor(); this.classpath = runtimeMXBean.getClassPath(); this.libraryPath = runtimeMXBean.getLibraryPath(); this.bootClasspath = MXHelper.getBootClassPath(); this.inputArguments = runtimeMXBean.getInputArguments(); this.systemProperties = runtimeMXBean.getSystemProperties(); this.pid = PidHelper.getPid(); }