majialoong commented on code in PR #9787:
URL: https://github.com/apache/rocketmq/pull/9787#discussion_r2477115505


##########
broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java:
##########
@@ -3408,4 +3415,64 @@ private RemotingCommand 
transferPopToFsStore(ChannelHandlerContext ctx, Remoting
         }
         return response;
     }
+
+    private synchronized RemotingCommand 
switchTimerEngine(ChannelHandlerContext ctx, RemotingCommand request) {
+        final RemotingCommand response = 
RemotingCommand.createResponseCommand(null);
+        if 
(!this.brokerController.getMessageStoreConfig().isTimerWheelEnable()) {
+            LOGGER.info("switchTimerEngine error, broker timerWheelEnable is 
false");
+            response.setCode(ResponseCode.INVALID_PARAMETER);
+            response.setRemark("broker timerWheelEnable is false");
+            return response;
+        }
+        if (null == request.getExtFields()) {
+            LOGGER.info("switchTimerEngine extFields is null");
+            response.setCode(ResponseCode.INVALID_PARAMETER);
+            response.setRemark("param error, extFields is null");
+            return response;
+        }
+        String engineType = request.getExtFields().get(TIMER_ENGINE_TYPE);
+        if (StringUtils.isEmpty(engineType) || 
!MessageConst.TIMER_ENGINE_ROCKSDB_TIMELINE.equals(engineType) && 
!MessageConst.TIMER_ENGINE_FILE_TIME_WHEEL.equals(engineType)) {
+            response.setCode(ResponseCode.INVALID_PARAMETER);
+            response.setRemark("param error");
+            return response;
+        }
+        try {
+            Properties properties = new Properties();
+            boolean result = false;
+            if (MessageConst.TIMER_ENGINE_ROCKSDB_TIMELINE.equals(engineType)) 
{
+                if (this.brokerController.getTimerMessageRocksDBStore() == 
null) {
+                    response.setCode(ResponseCode.INVALID_PARAMETER);
+                    response.setRemark("timerUseRocksDB muse be configured 
true when broker start");
+                    return response;
+                }
+                result = 
this.brokerController.getTimerMessageRocksDBStore().restart();
+                if (result) {
+                    properties.put("timerStopEnqueue", 
Boolean.TRUE.toString());
+                    properties.put("timerUseRocksDB", Boolean.TRUE.toString());
+                    properties.put("timerRocksDBStopScan", 
Boolean.FALSE.toString());
+                }
+            } else {
+                result = 
this.brokerController.getTimerMessageStore().restart();
+                if (result) {
+                    properties.put("timerRocksDBStopScan", 
Boolean.TRUE.toString());
+                    properties.put("timerStopEnqueue", 
Boolean.FALSE.toString());
+                }
+            }
+            if (result) {
+                this.brokerController.getConfiguration().update(properties);
+                response.setCode(ResponseCode.SUCCESS);
+                response.setRemark("switch timer engine success");
+                LOGGER.info("switchTimerEngine success");
+            } else {
+                response.setCode(ResponseCode.SYSTEM_ERROR);
+                response.setRemark("switch timer engine error");
+                LOGGER.info("switchTimerEngine error");

Review Comment:
   Hello, @zk-drizzle . I'm just curious why all the logs here are INFO level, 
regardless of whether the restart succeeds or fails. 
   
   Shouldn't WARN or ERROR level logs be used to provide some warning 
information to the user when the restart fails?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to