Java Code Examples for org.apache.rocketmq.remoting.netty.NettyServerConfig#setServerWorkerThreads()
The following examples show how to use
org.apache.rocketmq.remoting.netty.NettyServerConfig#setServerWorkerThreads() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FiltersrvStartup.java From DDMQ with Apache License 2.0 | 4 votes |
public static FiltersrvController createController(String[] args) { System.setProperty(RemotingCommand.REMOTING_VERSION_KEY, Integer.toString(MQVersion.CURRENT_VERSION)); if (null == System.getProperty(NettySystemConfig.COM_ROCKETMQ_REMOTING_SOCKET_SNDBUF_SIZE)) { NettySystemConfig.socketSndbufSize = 65535; } if (null == System.getProperty(NettySystemConfig.COM_ROCKETMQ_REMOTING_SOCKET_RCVBUF_SIZE)) { NettySystemConfig.socketRcvbufSize = 1024; } try { Options options = ServerUtil.buildCommandlineOptions(new Options()); final CommandLine commandLine = ServerUtil.parseCmdLine("mqfiltersrv", args, buildCommandlineOptions(options), new PosixParser()); if (null == commandLine) { System.exit(-1); return null; } final FiltersrvConfig filtersrvConfig = new FiltersrvConfig(); final NettyServerConfig nettyServerConfig = new NettyServerConfig(); if (commandLine.hasOption('c')) { String file = commandLine.getOptionValue('c'); if (file != null) { InputStream in = new BufferedInputStream(new FileInputStream(file)); Properties properties = new Properties(); properties.load(in); MixAll.properties2Object(properties, filtersrvConfig); System.out.printf("load config properties file OK, %s%n", file); in.close(); String port = properties.getProperty("listenPort"); if (port != null) { filtersrvConfig.setConnectWhichBroker(String.format("127.0.0.1:%s", port)); } } } nettyServerConfig.setListenPort(0); nettyServerConfig.setServerAsyncSemaphoreValue(filtersrvConfig.getFsServerAsyncSemaphoreValue()); nettyServerConfig.setServerCallbackExecutorThreads(filtersrvConfig .getFsServerCallbackExecutorThreads()); nettyServerConfig.setServerWorkerThreads(filtersrvConfig.getFsServerWorkerThreads()); if (commandLine.hasOption('p')) { MixAll.printObjectProperties(null, filtersrvConfig); MixAll.printObjectProperties(null, nettyServerConfig); System.exit(0); } MixAll.properties2Object(ServerUtil.commandLine2Properties(commandLine), filtersrvConfig); if (null == filtersrvConfig.getRocketmqHome()) { System.out.printf("Please set the %s variable in your environment to match the location of the RocketMQ installation%n", MixAll.ROCKETMQ_HOME_ENV); System.exit(-2); } LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); JoranConfigurator configurator = new JoranConfigurator(); configurator.setContext(lc); lc.reset(); configurator.doConfigure(filtersrvConfig.getRocketmqHome() + "/conf/logback_filtersrv.xml"); log = LoggerFactory.getLogger(LoggerName.FILTERSRV_LOGGER_NAME); final FiltersrvController controller = new FiltersrvController(filtersrvConfig, nettyServerConfig); boolean initResult = controller.initialize(); if (!initResult) { controller.shutdown(); System.exit(-3); } Runtime.getRuntime().addShutdownHook(new ShutdownHookThread(log, new Callable<Void>() { @Override public Void call() throws Exception { controller.shutdown(); return null; } })); return controller; } catch (Throwable e) { e.printStackTrace(); System.exit(-1); } return null; }
Example 2
Source File: FiltersrvStartup.java From rocketmq with Apache License 2.0 | 4 votes |
public static FiltersrvController createController(String[] args) { System.setProperty(RemotingCommand.REMOTING_VERSION_KEY, Integer.toString(MQVersion.CURRENT_VERSION)); if (null == System.getProperty(NettySystemConfig.COM_ROCKETMQ_REMOTING_SOCKET_SNDBUF_SIZE)) { NettySystemConfig.socketSndbufSize = 65535; } if (null == System.getProperty(NettySystemConfig.COM_ROCKETMQ_REMOTING_SOCKET_RCVBUF_SIZE)) { NettySystemConfig.socketRcvbufSize = 1024; } try { Options options = ServerUtil.buildCommandlineOptions(new Options()); final CommandLine commandLine = ServerUtil.parseCmdLine("mqfiltersrv", args, buildCommandlineOptions(options), new PosixParser()); if (null == commandLine) { System.exit(-1); return null; } final FiltersrvConfig filtersrvConfig = new FiltersrvConfig(); final NettyServerConfig nettyServerConfig = new NettyServerConfig(); if (commandLine.hasOption('c')) { String file = commandLine.getOptionValue('c'); if (file != null) { InputStream in = new BufferedInputStream(new FileInputStream(file)); Properties properties = new Properties(); properties.load(in); MixAll.properties2Object(properties, filtersrvConfig); System.out.printf("load config properties file OK, " + file + "%n"); in.close(); String port = properties.getProperty("listenPort"); if (port != null) { filtersrvConfig.setConnectWhichBroker(String.format("127.0.0.1:%s", port)); } } } nettyServerConfig.setListenPort(0); nettyServerConfig.setServerAsyncSemaphoreValue(filtersrvConfig.getFsServerAsyncSemaphoreValue()); nettyServerConfig.setServerCallbackExecutorThreads(filtersrvConfig .getFsServerCallbackExecutorThreads()); nettyServerConfig.setServerWorkerThreads(filtersrvConfig.getFsServerWorkerThreads()); if (commandLine.hasOption('p')) { MixAll.printObjectProperties(null, filtersrvConfig); MixAll.printObjectProperties(null, nettyServerConfig); System.exit(0); } MixAll.properties2Object(ServerUtil.commandLine2Properties(commandLine), filtersrvConfig); if (null == filtersrvConfig.getRocketmqHome()) { System.out.printf("Please set the " + MixAll.ROCKETMQ_HOME_ENV + " variable in your environment to match the location of the RocketMQ installation%n"); System.exit(-2); } LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); JoranConfigurator configurator = new JoranConfigurator(); configurator.setContext(lc); lc.reset(); configurator.doConfigure(filtersrvConfig.getRocketmqHome() + "/conf/logback_filtersrv.xml"); log = LoggerFactory.getLogger(LoggerName.FILTERSRV_LOGGER_NAME); final FiltersrvController controller = new FiltersrvController(filtersrvConfig, nettyServerConfig); boolean initResult = controller.initialize(); if (!initResult) { controller.shutdown(); System.exit(-3); } Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { private volatile boolean hasShutdown = false; private AtomicInteger shutdownTimes = new AtomicInteger(0); @Override public void run() { synchronized (this) { log.info("shutdown hook was invoked, " + this.shutdownTimes.incrementAndGet()); if (!this.hasShutdown) { this.hasShutdown = true; long begineTime = System.currentTimeMillis(); controller.shutdown(); long consumingTimeTotal = System.currentTimeMillis() - begineTime; log.info("shutdown hook over, consuming time total(ms): " + consumingTimeTotal); } } } }, "ShutdownHook")); return controller; } catch (Throwable e) { e.printStackTrace(); System.exit(-1); } return null; }
Example 3
Source File: FiltersrvStartup.java From DDMQ with Apache License 2.0 | 4 votes |
public static FiltersrvController createController(String[] args) { System.setProperty(RemotingCommand.REMOTING_VERSION_KEY, Integer.toString(MQVersion.CURRENT_VERSION)); if (null == System.getProperty(NettySystemConfig.COM_ROCKETMQ_REMOTING_SOCKET_SNDBUF_SIZE)) { NettySystemConfig.socketSndbufSize = 65535; } if (null == System.getProperty(NettySystemConfig.COM_ROCKETMQ_REMOTING_SOCKET_RCVBUF_SIZE)) { NettySystemConfig.socketRcvbufSize = 1024; } try { Options options = ServerUtil.buildCommandlineOptions(new Options()); final CommandLine commandLine = ServerUtil.parseCmdLine("mqfiltersrv", args, buildCommandlineOptions(options), new PosixParser()); if (null == commandLine) { System.exit(-1); return null; } final FiltersrvConfig filtersrvConfig = new FiltersrvConfig(); final NettyServerConfig nettyServerConfig = new NettyServerConfig(); if (commandLine.hasOption('c')) { String file = commandLine.getOptionValue('c'); if (file != null) { InputStream in = new BufferedInputStream(new FileInputStream(file)); Properties properties = new Properties(); properties.load(in); MixAll.properties2Object(properties, filtersrvConfig); System.out.printf("load config properties file OK, %s%n", file); in.close(); String port = properties.getProperty("listenPort"); if (port != null) { filtersrvConfig.setConnectWhichBroker(String.format("127.0.0.1:%s", port)); } } } nettyServerConfig.setListenPort(0); nettyServerConfig.setServerAsyncSemaphoreValue(filtersrvConfig.getFsServerAsyncSemaphoreValue()); nettyServerConfig.setServerCallbackExecutorThreads(filtersrvConfig .getFsServerCallbackExecutorThreads()); nettyServerConfig.setServerWorkerThreads(filtersrvConfig.getFsServerWorkerThreads()); if (commandLine.hasOption('p')) { MixAll.printObjectProperties(null, filtersrvConfig); MixAll.printObjectProperties(null, nettyServerConfig); System.exit(0); } MixAll.properties2Object(ServerUtil.commandLine2Properties(commandLine), filtersrvConfig); if (null == filtersrvConfig.getRocketmqHome()) { System.out.printf("Please set the %s variable in your environment to match the location of the RocketMQ installation%n", MixAll.ROCKETMQ_HOME_ENV); System.exit(-2); } LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); JoranConfigurator configurator = new JoranConfigurator(); configurator.setContext(lc); lc.reset(); configurator.doConfigure(filtersrvConfig.getRocketmqHome() + "/conf/logback_filtersrv.xml"); log = LoggerFactory.getLogger(LoggerName.FILTERSRV_LOGGER_NAME); final FiltersrvController controller = new FiltersrvController(filtersrvConfig, nettyServerConfig); boolean initResult = controller.initialize(); if (!initResult) { controller.shutdown(); System.exit(-3); } Runtime.getRuntime().addShutdownHook(new ShutdownHookThread(log, new Callable<Void>() { @Override public Void call() throws Exception { controller.shutdown(); return null; } })); return controller; } catch (Throwable e) { e.printStackTrace(); System.exit(-1); } return null; }
Example 4
Source File: FiltersrvStartup.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 4 votes |
public static FiltersrvController createController(String[] args) { System.setProperty(RemotingCommand.REMOTING_VERSION_KEY, Integer.toString(MQVersion.CURRENT_VERSION)); if (null == System.getProperty(NettySystemConfig.COM_ROCKETMQ_REMOTING_SOCKET_SNDBUF_SIZE)) { NettySystemConfig.socketSndbufSize = 65535; } if (null == System.getProperty(NettySystemConfig.COM_ROCKETMQ_REMOTING_SOCKET_RCVBUF_SIZE)) { NettySystemConfig.socketRcvbufSize = 1024; } try { Options options = ServerUtil.buildCommandlineOptions(new Options()); final CommandLine commandLine = ServerUtil.parseCmdLine("mqfiltersrv", args, buildCommandlineOptions(options), new PosixParser()); if (null == commandLine) { System.exit(-1); return null; } final FiltersrvConfig filtersrvConfig = new FiltersrvConfig(); final NettyServerConfig nettyServerConfig = new NettyServerConfig(); if (commandLine.hasOption('c')) { String file = commandLine.getOptionValue('c'); if (file != null) { InputStream in = new BufferedInputStream(new FileInputStream(file)); Properties properties = new Properties(); properties.load(in); MixAll.properties2Object(properties, filtersrvConfig); System.out.printf("load config properties file OK, " + file + "%n"); in.close(); String port = properties.getProperty("listenPort"); if (port != null) { filtersrvConfig.setConnectWhichBroker(String.format("127.0.0.1:%s", port)); } } } nettyServerConfig.setListenPort(0); nettyServerConfig.setServerAsyncSemaphoreValue(filtersrvConfig.getFsServerAsyncSemaphoreValue()); nettyServerConfig.setServerCallbackExecutorThreads(filtersrvConfig .getFsServerCallbackExecutorThreads()); nettyServerConfig.setServerWorkerThreads(filtersrvConfig.getFsServerWorkerThreads()); if (commandLine.hasOption('p')) { MixAll.printObjectProperties(null, filtersrvConfig); MixAll.printObjectProperties(null, nettyServerConfig); System.exit(0); } MixAll.properties2Object(ServerUtil.commandLine2Properties(commandLine), filtersrvConfig); if (null == filtersrvConfig.getRocketmqHome()) { System.out.printf("Please set the " + MixAll.ROCKETMQ_HOME_ENV + " variable in your environment to match the location of the RocketMQ installation%n"); System.exit(-2); } LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); JoranConfigurator configurator = new JoranConfigurator(); configurator.setContext(lc); lc.reset(); configurator.doConfigure(filtersrvConfig.getRocketmqHome() + "/conf/logback_filtersrv.xml"); log = LoggerFactory.getLogger(LoggerName.FILTERSRV_LOGGER_NAME); final FiltersrvController controller = new FiltersrvController(filtersrvConfig, nettyServerConfig); boolean initResult = controller.initialize(); if (!initResult) { controller.shutdown(); System.exit(-3); } Runtime.getRuntime().addShutdownHook(new ShutdownHookThread(log, new Callable<Void>() { @Override public Void call() throws Exception { controller.shutdown(); return null; } })); return controller; } catch (Throwable e) { e.printStackTrace(); System.exit(-1); } return null; }
Example 5
Source File: FiltersrvStartup.java From rocketmq_trans_message with Apache License 2.0 | 4 votes |
public static FiltersrvController createController(String[] args) { System.setProperty(RemotingCommand.REMOTING_VERSION_KEY, Integer.toString(MQVersion.CURRENT_VERSION)); if (null == System.getProperty(NettySystemConfig.COM_ROCKETMQ_REMOTING_SOCKET_SNDBUF_SIZE)) { NettySystemConfig.socketSndbufSize = 65535; } if (null == System.getProperty(NettySystemConfig.COM_ROCKETMQ_REMOTING_SOCKET_RCVBUF_SIZE)) { NettySystemConfig.socketRcvbufSize = 1024; } try { Options options = ServerUtil.buildCommandlineOptions(new Options()); final CommandLine commandLine = ServerUtil.parseCmdLine("mqfiltersrv", args, buildCommandlineOptions(options), new PosixParser()); if (null == commandLine) { System.exit(-1); return null; } final FiltersrvConfig filtersrvConfig = new FiltersrvConfig(); final NettyServerConfig nettyServerConfig = new NettyServerConfig(); if (commandLine.hasOption('c')) { String file = commandLine.getOptionValue('c'); if (file != null) { InputStream in = new BufferedInputStream(new FileInputStream(file)); Properties properties = new Properties(); properties.load(in); MixAll.properties2Object(properties, filtersrvConfig); System.out.printf("load config properties file OK, " + file + "%n"); in.close(); String port = properties.getProperty("listenPort"); if (port != null) { filtersrvConfig.setConnectWhichBroker(String.format("127.0.0.1:%s", port)); } } } nettyServerConfig.setListenPort(0); nettyServerConfig.setServerAsyncSemaphoreValue(filtersrvConfig.getFsServerAsyncSemaphoreValue()); nettyServerConfig.setServerCallbackExecutorThreads(filtersrvConfig .getFsServerCallbackExecutorThreads()); nettyServerConfig.setServerWorkerThreads(filtersrvConfig.getFsServerWorkerThreads()); if (commandLine.hasOption('p')) { MixAll.printObjectProperties(null, filtersrvConfig); MixAll.printObjectProperties(null, nettyServerConfig); System.exit(0); } MixAll.properties2Object(ServerUtil.commandLine2Properties(commandLine), filtersrvConfig); if (null == filtersrvConfig.getRocketmqHome()) { System.out.printf("Please set the " + MixAll.ROCKETMQ_HOME_ENV + " variable in your environment to match the location of the RocketMQ installation%n"); System.exit(-2); } LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); JoranConfigurator configurator = new JoranConfigurator(); configurator.setContext(lc); lc.reset(); configurator.doConfigure(filtersrvConfig.getRocketmqHome() + "/conf/logback_filtersrv.xml"); log = LoggerFactory.getLogger(LoggerName.FILTERSRV_LOGGER_NAME); final FiltersrvController controller = new FiltersrvController(filtersrvConfig, nettyServerConfig); boolean initResult = controller.initialize(); if (!initResult) { controller.shutdown(); System.exit(-3); } Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { private volatile boolean hasShutdown = false; private AtomicInteger shutdownTimes = new AtomicInteger(0); @Override public void run() { synchronized (this) { log.info("shutdown hook was invoked, " + this.shutdownTimes.incrementAndGet()); if (!this.hasShutdown) { this.hasShutdown = true; long begineTime = System.currentTimeMillis(); controller.shutdown(); long consumingTimeTotal = System.currentTimeMillis() - begineTime; log.info("shutdown hook over, consuming time total(ms): " + consumingTimeTotal); } } } }, "ShutdownHook")); return controller; } catch (Throwable e) { e.printStackTrace(); System.exit(-1); } return null; }