org.apache.rocketmq.remoting.netty.NettyRemotingServer Java Examples
The following examples show how to use
org.apache.rocketmq.remoting.netty.NettyRemotingServer.
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: RemotingServerTest.java From DDMQ with Apache License 2.0 | 6 votes |
public static RemotingServer createRemotingServer() throws InterruptedException { NettyServerConfig config = new NettyServerConfig(); RemotingServer remotingServer = new NettyRemotingServer(config); remotingServer.registerProcessor(0, new NettyRequestProcessor() { @Override public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) { request.setRemark("Hi " + ctx.channel().remoteAddress()); return request; } @Override public boolean rejectRequest() { return false; } }, Executors.newCachedThreadPool()); remotingServer.start(); return remotingServer; }
Example #2
Source File: TlsTest.java From rocketmq with Apache License 2.0 | 6 votes |
@Test public void reloadSslContextForServer() throws Exception { requestThenAssertResponse(); //Use new cert and private key tlsClientKeyPath = getCertsPath("badClient.key"); tlsClientCertPath = getCertsPath("badClient.pem"); ((NettyRemotingServer) remotingServer).loadSslContext(); //Request Again requestThenAssertResponse(); //Start another client NettyClientConfig clientConfig = new NettyClientConfig(); clientConfig.setUseTLS(true); RemotingClient remotingClient = RemotingServerTest.createRemotingClient(clientConfig); requestThenAssertResponse(remotingClient); }
Example #3
Source File: RemotingServerTest.java From rocketmq-4.3.0 with Apache License 2.0 | 6 votes |
public static RemotingServer createRemotingServer() throws InterruptedException { NettyServerConfig config = new NettyServerConfig(); RemotingServer remotingServer = new NettyRemotingServer(config); remotingServer.registerProcessor(0, new NettyRequestProcessor() { @Override public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) { request.setRemark("Hi " + ctx.channel().remoteAddress()); return request; } @Override public boolean rejectRequest() { return false; } }, Executors.newCachedThreadPool()); remotingServer.start(); return remotingServer; }
Example #4
Source File: TlsTest.java From rocketmq-4.3.0 with Apache License 2.0 | 6 votes |
@Test public void reloadSslContextForServer() throws Exception { requestThenAssertResponse(); //Use new cert and private key tlsClientKeyPath = getCertsPath("badClient.key"); tlsClientCertPath = getCertsPath("badClient.pem"); ((NettyRemotingServer) remotingServer).loadSslContext(); //Request Again requestThenAssertResponse(); //Start another client NettyClientConfig clientConfig = new NettyClientConfig(); clientConfig.setUseTLS(true); RemotingClient remotingClient = RemotingServerTest.createRemotingClient(clientConfig); requestThenAssertResponse(remotingClient); }
Example #5
Source File: RemotingServerTest.java From rocketmq-read with Apache License 2.0 | 6 votes |
public static RemotingServer createRemotingServer() throws InterruptedException { NettyServerConfig config = new NettyServerConfig(); RemotingServer remotingServer = new NettyRemotingServer(config); remotingServer.registerProcessor(0, new NettyRequestProcessor() { @Override public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) { request.setRemark("Hi " + ctx.channel().remoteAddress()); return request; } @Override public boolean rejectRequest() { return false; } }, Executors.newCachedThreadPool()); remotingServer.start(); return remotingServer; }
Example #6
Source File: TlsTest.java From rocketmq-read with Apache License 2.0 | 6 votes |
@Test public void reloadSslContextForServer() throws Exception { requestThenAssertResponse(); //Use new cert and private key tlsClientKeyPath = getCertsPath("badClient.key"); tlsClientCertPath = getCertsPath("badClient.pem"); ((NettyRemotingServer) remotingServer).loadSslContext(); //Request Again requestThenAssertResponse(); //Start another client NettyClientConfig clientConfig = new NettyClientConfig(); clientConfig.setUseTLS(true); RemotingClient remotingClient = RemotingServerTest.createRemotingClient(clientConfig); requestThenAssertResponse(remotingClient); }
Example #7
Source File: RemotingServerTest.java From rocketmq with Apache License 2.0 | 6 votes |
public static RemotingServer createRemotingServer() throws InterruptedException { NettyServerConfig config = new NettyServerConfig(); RemotingServer remotingServer = new NettyRemotingServer(config); remotingServer.registerProcessor(0, new NettyRequestProcessor() { @Override public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) { request.setRemark("Hi " + ctx.channel().remoteAddress()); return request; } @Override public boolean rejectRequest() { return false; } }, Executors.newCachedThreadPool()); remotingServer.start(); return remotingServer; }
Example #8
Source File: RemotingServerTest.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 6 votes |
public static RemotingServer createRemotingServer() throws InterruptedException { NettyServerConfig config = new NettyServerConfig(); RemotingServer remotingServer = new NettyRemotingServer(config); remotingServer.registerProcessor(0, new NettyRequestProcessor() { @Override public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) { request.setRemark("Hi " + ctx.channel().remoteAddress()); return request; } @Override public boolean rejectRequest() { return false; } }, Executors.newCachedThreadPool()); remotingServer.start(); return remotingServer; }
Example #9
Source File: RemotingServerTest.java From DDMQ with Apache License 2.0 | 6 votes |
public static RemotingServer createRemotingServer() throws InterruptedException { NettyServerConfig config = new NettyServerConfig(); RemotingServer remotingServer = new NettyRemotingServer(config); remotingServer.registerProcessor(0, new NettyRequestProcessor() { @Override public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) { request.setRemark("Hi " + ctx.channel().remoteAddress()); return request; } @Override public boolean rejectRequest() { return false; } }, Executors.newCachedThreadPool()); remotingServer.start(); return remotingServer; }
Example #10
Source File: FiltersrvController.java From DDMQ with Apache License 2.0 | 5 votes |
public boolean initialize() { MixAll.printObjectProperties(log, this.filtersrvConfig); this.remotingServer = new NettyRemotingServer(this.nettyServerConfig); this.remotingExecutor = Executors.newFixedThreadPool(nettyServerConfig.getServerWorkerThreads(), new ThreadFactoryImpl("RemotingExecutorThread_")); this.registerProcessor(); this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() { @Override public void run() { FiltersrvController.this.registerFilterServerToBroker(); } }, 3, 10, TimeUnit.SECONDS); this.defaultMQPullConsumer.setBrokerSuspendMaxTimeMillis(this.defaultMQPullConsumer .getBrokerSuspendMaxTimeMillis() - 1000); this.defaultMQPullConsumer.setConsumerTimeoutMillisWhenSuspend(this.defaultMQPullConsumer .getConsumerTimeoutMillisWhenSuspend() - 1000); this.defaultMQPullConsumer.setNamesrvAddr(this.filtersrvConfig.getNamesrvAddr()); this.defaultMQPullConsumer.setInstanceName(String.valueOf(UtilAll.getPid())); return true; }
Example #11
Source File: NamesrvController.java From rocketmq_trans_message with Apache License 2.0 | 5 votes |
public boolean initialize() { this.kvConfigManager.load(); this.remotingServer = new NettyRemotingServer(this.nettyServerConfig, this.brokerHousekeepingService); this.remotingExecutor = Executors.newFixedThreadPool(nettyServerConfig.getServerWorkerThreads(), new ThreadFactoryImpl("RemotingExecutorThread_")); this.registerProcessor(); this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() { @Override public void run() { NamesrvController.this.routeInfoManager.scanNotActiveBroker(); } }, 5, 10, TimeUnit.SECONDS); this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() { @Override public void run() { NamesrvController.this.kvConfigManager.printAllPeriodically(); } }, 1, 10, TimeUnit.MINUTES); return true; }
Example #12
Source File: FiltersrvController.java From rocketmq_trans_message with Apache License 2.0 | 5 votes |
public boolean initialize() { MixAll.printObjectProperties(log, this.filtersrvConfig); this.remotingServer = new NettyRemotingServer(this.nettyServerConfig); this.remotingExecutor = Executors.newFixedThreadPool(nettyServerConfig.getServerWorkerThreads(), new ThreadFactoryImpl("RemotingExecutorThread_")); this.registerProcessor(); this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() { @Override public void run() { FiltersrvController.this.registerFilterServerToBroker(); } }, 3, 10, TimeUnit.SECONDS); this.defaultMQPullConsumer.setBrokerSuspendMaxTimeMillis(this.defaultMQPullConsumer .getBrokerSuspendMaxTimeMillis() - 1000); this.defaultMQPullConsumer.setConsumerTimeoutMillisWhenSuspend(this.defaultMQPullConsumer .getConsumerTimeoutMillisWhenSuspend() - 1000); this.defaultMQPullConsumer.setNamesrvAddr(this.filtersrvConfig.getNamesrvAddr()); this.defaultMQPullConsumer.setInstanceName(String.valueOf(UtilAll.getPid())); return true; }
Example #13
Source File: NamesrvController.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 5 votes |
public boolean initialize() { // 加载KV配置 this.kvConfigManager.load(); // 初始化通信层 this.remotingServer = new NettyRemotingServer(this.nettyServerConfig, this.brokerHousekeepingService); //brokerHousekeepingService 接收Broker连接事件 // 初始化固定线程池 this.remotingExecutor = Executors.newFixedThreadPool(nettyServerConfig.getServerWorkerThreads(), new ThreadFactoryImpl("RemotingExecutorThread_")); //注册接收到请求之后具体的处理 this.registerProcessor(); // 增加定时任务 this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() { @Override public void run() { NamesrvController.this.routeInfoManager.scanNotActiveBroker(); } }, 5, 10, TimeUnit.SECONDS); //每隔10s扫描broker,维护当前存活的Broker信息 this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() { @Override public void run() { NamesrvController.this.kvConfigManager.printAllPeriodically(); } }, 1, 10, TimeUnit.MINUTES); //每隔10s打印KVConfig信息。 return true; }
Example #14
Source File: FiltersrvController.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 5 votes |
public boolean initialize() { MixAll.printObjectProperties(log, this.filtersrvConfig); this.remotingServer = new NettyRemotingServer(this.nettyServerConfig); this.remotingExecutor = Executors.newFixedThreadPool(nettyServerConfig.getServerWorkerThreads(), new ThreadFactoryImpl("RemotingExecutorThread_")); this.registerProcessor(); this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() { @Override public void run() { FiltersrvController.this.registerFilterServerToBroker(); } }, 3, 10, TimeUnit.SECONDS); this.defaultMQPullConsumer.setBrokerSuspendMaxTimeMillis(this.defaultMQPullConsumer .getBrokerSuspendMaxTimeMillis() - 1000); this.defaultMQPullConsumer.setConsumerTimeoutMillisWhenSuspend(this.defaultMQPullConsumer .getConsumerTimeoutMillisWhenSuspend() - 1000); this.defaultMQPullConsumer.setNamesrvAddr(this.filtersrvConfig.getNamesrvAddr()); this.defaultMQPullConsumer.setInstanceName(String.valueOf(UtilAll.getPid())); return true; }
Example #15
Source File: NamesrvController.java From DDMQ with Apache License 2.0 | 5 votes |
public boolean initialize() { if (namesrvConfig.isRoleSwitchEnable()) { haManager = new HAManager(this); } routeInfoManager.setHaManager(haManager); this.kvConfigManager.load(); this.remotingServer = new NettyRemotingServer(this.nettyServerConfig, this.brokerHousekeepingService); this.remotingExecutor = Executors.newFixedThreadPool(nettyServerConfig.getServerWorkerThreads(), new ThreadFactoryImpl("RemotingExecutorThread_")); this.registerProcessor(); this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() { @Override public void run() { NamesrvController.this.routeInfoManager.scanNotActiveBroker(); } }, 5, 10, TimeUnit.SECONDS); this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() { @Override public void run() { NamesrvController.this.kvConfigManager.printAllPeriodically(); } }, 1, 10, TimeUnit.MINUTES); return true; }
Example #16
Source File: FiltersrvController.java From DDMQ with Apache License 2.0 | 5 votes |
public boolean initialize() { MixAll.printObjectProperties(log, this.filtersrvConfig); this.remotingServer = new NettyRemotingServer(this.nettyServerConfig); this.remotingExecutor = Executors.newFixedThreadPool(nettyServerConfig.getServerWorkerThreads(), new ThreadFactoryImpl("RemotingExecutorThread_")); this.registerProcessor(); this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() { @Override public void run() { FiltersrvController.this.registerFilterServerToBroker(); } }, 3, 10, TimeUnit.SECONDS); this.defaultMQPullConsumer.setBrokerSuspendMaxTimeMillis(this.defaultMQPullConsumer .getBrokerSuspendMaxTimeMillis() - 1000); this.defaultMQPullConsumer.setConsumerTimeoutMillisWhenSuspend(this.defaultMQPullConsumer .getConsumerTimeoutMillisWhenSuspend() - 1000); this.defaultMQPullConsumer.setNamesrvAddr(this.filtersrvConfig.getNamesrvAddr()); this.defaultMQPullConsumer.setInstanceName(String.valueOf(UtilAll.getPid())); return true; }
Example #17
Source File: NamesrvController.java From rocketmq with Apache License 2.0 | 5 votes |
/** * @return */ public boolean initialize() { this.kvConfigManager.load(); this.remotingServer = new NettyRemotingServer(this.nettyServerConfig, this.brokerHousekeepingService); this.remotingExecutor = Executors.newFixedThreadPool(nettyServerConfig.getServerWorkerThreads(), new ThreadFactoryImpl("RemotingExecutorThread_")); this.registerProcessor(); //启动内部扫描失效Broker的定时任务,5S后执行第一次,每次间隔10S this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() { @Override public void run() { NamesrvController.this.routeInfoManager.scanNotActiveBroker(); } }, 5, 10, TimeUnit.SECONDS); //定期打印配置信息,每10分钟一次 this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() { @Override public void run() { NamesrvController.this.kvConfigManager.printAllPeriodically(); } }, 1, 10, TimeUnit.MINUTES); return true; }
Example #18
Source File: FiltersrvController.java From rocketmq with Apache License 2.0 | 5 votes |
public boolean initialize() { MixAll.printObjectProperties(log, this.filtersrvConfig); this.remotingServer = new NettyRemotingServer(this.nettyServerConfig); this.remotingExecutor = Executors.newFixedThreadPool(nettyServerConfig.getServerWorkerThreads(), new ThreadFactoryImpl("RemotingExecutorThread_")); this.registerProcessor(); // 固定间隔注册到Broker this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() { @Override public void run() { FiltersrvController.this.registerFilterServerToBroker(); } }, 15, 10, TimeUnit.SECONDS); // TODO edit by 芋艿:initialDelay时间太短,可能导致初始化失败。从3=》15 this.defaultMQPullConsumer.setBrokerSuspendMaxTimeMillis(this.defaultMQPullConsumer .getBrokerSuspendMaxTimeMillis() - 1000); this.defaultMQPullConsumer.setConsumerTimeoutMillisWhenSuspend(this.defaultMQPullConsumer .getConsumerTimeoutMillisWhenSuspend() - 1000); this.defaultMQPullConsumer.setNamesrvAddr(this.filtersrvConfig.getNamesrvAddr()); this.defaultMQPullConsumer.setInstanceName(String.valueOf(UtilAll.getPid())); return true; }
Example #19
Source File: DLedgerRpcNettyService.java From openmessaging-storage-dledger with Apache License 2.0 | 5 votes |
public DLedgerRpcNettyService(DLedgerServer dLedgerServer) { this.dLedgerServer = dLedgerServer; this.memberState = dLedgerServer.getMemberState(); NettyRequestProcessor protocolProcessor = new NettyRequestProcessor() { @Override public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) throws Exception { return DLedgerRpcNettyService.this.processRequest(ctx, request); } @Override public boolean rejectRequest() { return false; } }; //start the remoting server NettyServerConfig nettyServerConfig = new NettyServerConfig(); nettyServerConfig.setListenPort(Integer.valueOf(memberState.getSelfAddr().split(":")[1])); this.remotingServer = new NettyRemotingServer(nettyServerConfig, null); this.remotingServer.registerProcessor(DLedgerRequestCode.METADATA.getCode(), protocolProcessor, null); this.remotingServer.registerProcessor(DLedgerRequestCode.APPEND.getCode(), protocolProcessor, null); this.remotingServer.registerProcessor(DLedgerRequestCode.GET.getCode(), protocolProcessor, null); this.remotingServer.registerProcessor(DLedgerRequestCode.PULL.getCode(), protocolProcessor, null); this.remotingServer.registerProcessor(DLedgerRequestCode.PUSH.getCode(), protocolProcessor, null); this.remotingServer.registerProcessor(DLedgerRequestCode.VOTE.getCode(), protocolProcessor, null); this.remotingServer.registerProcessor(DLedgerRequestCode.HEART_BEAT.getCode(), protocolProcessor, null); this.remotingServer.registerProcessor(DLedgerRequestCode.LEADERSHIP_TRANSFER.getCode(), protocolProcessor, null); //start the remoting client this.remotingClient = new NettyRemotingClient(new NettyClientConfig(), null); }
Example #20
Source File: NamesrvController.java From DDMQ with Apache License 2.0 | 5 votes |
public boolean initialize() { if (namesrvConfig.isRoleSwitchEnable()) { haManager = new HAManager(this); } routeInfoManager.setHaManager(haManager); this.kvConfigManager.load(); this.remotingServer = new NettyRemotingServer(this.nettyServerConfig, this.brokerHousekeepingService); this.remotingExecutor = Executors.newFixedThreadPool(nettyServerConfig.getServerWorkerThreads(), new ThreadFactoryImpl("RemotingExecutorThread_")); this.registerProcessor(); this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() { @Override public void run() { NamesrvController.this.routeInfoManager.scanNotActiveBroker(); } }, 5, 10, TimeUnit.SECONDS); this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() { @Override public void run() { NamesrvController.this.kvConfigManager.printAllPeriodically(); } }, 1, 10, TimeUnit.MINUTES); return true; }
Example #21
Source File: NamesrvController.java From rocketmq-read with Apache License 2.0 | 4 votes |
/** * NameServerController的初始化函数 * @return ; */ public boolean initialize() { /* * load kvconfigManager */ this.kvConfigManager.load(); //实例化通信层Server this.remotingServer = new NettyRemotingServer(this.nettyServerConfig, this.brokerHousekeepingService); //实例化通信层线程池 this.remotingExecutor = Executors.newFixedThreadPool(nettyServerConfig.getServerWorkerThreads(), new ThreadFactoryImpl("RemotingExecutorThread_")); //注册Processor this.registerProcessor(); //定时扫描不活跃的Broker this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() { @Override public void run() { NamesrvController.this.routeInfoManager.scanNotActiveBroker(); } }, 5, 10, TimeUnit.SECONDS); //定时扫描KVconfigManager this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() { @Override public void run() { NamesrvController.this.kvConfigManager.printAllPeriodically(); } }, 1, 10, TimeUnit.MINUTES); //TSL相关,就是监听到tsl证书更新了,触发 NettyRemotingServer.loadSslContext() 代码; if (TlsSystemConfig.tlsMode != TlsMode.DISABLED) { // Register a listener to reload SslContext try { fileWatchService = new FileWatchService( new String[] { TlsSystemConfig.tlsServerCertPath, TlsSystemConfig.tlsServerKeyPath, TlsSystemConfig.tlsServerTrustCertPath }, new FileWatchService.Listener() { boolean certChanged, keyChanged = false; @Override public void onChanged(String path) { if (path.equals(TlsSystemConfig.tlsServerTrustCertPath)) { log.info("The trust certificate changed, reload the ssl context"); reloadServerSslContext(); } if (path.equals(TlsSystemConfig.tlsServerCertPath)) { certChanged = true; } if (path.equals(TlsSystemConfig.tlsServerKeyPath)) { keyChanged = true; } if (certChanged && keyChanged) { log.info("The certificate and private key changed, reload the ssl context"); certChanged = keyChanged = false; reloadServerSslContext(); } } private void reloadServerSslContext() { ((NettyRemotingServer) remotingServer).loadSslContext(); } }); } catch (Exception e) { log.warn("FileWatchService created error, can't load the certificate dynamically"); } } return true; }
Example #22
Source File: NamesrvController.java From rocketmq-4.3.0 with Apache License 2.0 | 4 votes |
public boolean initialize() { // 加载配置 =》 this.kvConfigManager.load(); // 初始化netty server =》 this.remotingServer = new NettyRemotingServer(this.nettyServerConfig, this.brokerHousekeepingService); // 初始化netty执行器 8个线程 this.remotingExecutor = Executors.newFixedThreadPool(nettyServerConfig.getServerWorkerThreads(), new ThreadFactoryImpl("RemotingExecutorThread_")); // 注册处理器 =》 this.registerProcessor(); this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() { @Override public void run() { // 扫描非活动的broker NamesrvController.this.routeInfoManager.scanNotActiveBroker(); } }, 5, 10, TimeUnit.SECONDS); this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() { @Override public void run() { NamesrvController.this.kvConfigManager.printAllPeriodically(); } }, 1, 10, TimeUnit.MINUTES); if (TlsSystemConfig.tlsMode != TlsMode.DISABLED) { // Register a listener to reload SslContext try { fileWatchService = new FileWatchService( new String[] { TlsSystemConfig.tlsServerCertPath, TlsSystemConfig.tlsServerKeyPath, TlsSystemConfig.tlsServerTrustCertPath }, new FileWatchService.Listener() { boolean certChanged, keyChanged = false; @Override public void onChanged(String path) { if (path.equals(TlsSystemConfig.tlsServerTrustCertPath)) { log.info("The trust certificate changed, reload the ssl context"); reloadServerSslContext(); } if (path.equals(TlsSystemConfig.tlsServerCertPath)) { certChanged = true; } if (path.equals(TlsSystemConfig.tlsServerKeyPath)) { keyChanged = true; } if (certChanged && keyChanged) { log.info("The certificate and private key changed, reload the ssl context"); certChanged = keyChanged = false; reloadServerSslContext(); } } private void reloadServerSslContext() { ((NettyRemotingServer) remotingServer).loadSslContext(); } }); } catch (Exception e) { log.warn("FileWatchService created error, can't load the certificate dynamically"); } } return true; }
Example #23
Source File: NamesrvController.java From rocketmq with Apache License 2.0 | 4 votes |
public boolean initialize() { this.kvConfigManager.load(); this.remotingServer = new NettyRemotingServer(this.nettyServerConfig, this.brokerHousekeepingService); this.remotingExecutor = Executors.newFixedThreadPool(nettyServerConfig.getServerWorkerThreads(), new ThreadFactoryImpl("RemotingExecutorThread_")); this.registerProcessor(); this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() { @Override public void run() { NamesrvController.this.routeInfoManager.scanNotActiveBroker(); } }, 5, 10, TimeUnit.SECONDS); this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() { @Override public void run() { NamesrvController.this.kvConfigManager.printAllPeriodically(); } }, 1, 10, TimeUnit.MINUTES); if (TlsSystemConfig.tlsMode != TlsMode.DISABLED) { // Register a listener to reload SslContext try { fileWatchService = new FileWatchService( new String[] { TlsSystemConfig.tlsServerCertPath, TlsSystemConfig.tlsServerKeyPath, TlsSystemConfig.tlsServerTrustCertPath }, new FileWatchService.Listener() { boolean certChanged, keyChanged = false; @Override public void onChanged(String path) { if (path.equals(TlsSystemConfig.tlsServerTrustCertPath)) { log.info("The trust certificate changed, reload the ssl context"); reloadServerSslContext(); } if (path.equals(TlsSystemConfig.tlsServerCertPath)) { certChanged = true; } if (path.equals(TlsSystemConfig.tlsServerKeyPath)) { keyChanged = true; } if (certChanged && keyChanged) { log.info("The certificate and private key changed, reload the ssl context"); certChanged = keyChanged = false; reloadServerSslContext(); } } private void reloadServerSslContext() { ((NettyRemotingServer) remotingServer).loadSslContext(); } }); } catch (Exception e) { log.warn("FileWatchService created error, can't load the certificate dynamically"); } } return true; }