Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

public class PlainAccessValidator implements AccessValidator {

private PlainPermissionManager aclPlugEngine;
private final PlainPermissionManager aclPlugEngine;

public PlainAccessValidator() {
aclPlugEngine = new PlainPermissionManager();
Expand Down Expand Up @@ -60,9 +60,12 @@ public boolean deleteAccessConfig(String accessKey) {
return aclPlugEngine.deleteAccessConfig(accessKey);
}

@SuppressWarnings("deprecation")
@Override
public String getAclConfigVersion() {
return aclPlugEngine.getAclConfigDataVersion();
// 替换为新的方法名
//return aclPlugEngine.getCurrentAclConfigVersion();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,13 @@

public class RemoteAddressStrategyFactory {

private static final Logger log = LoggerFactory.getLogger(LoggerName.COMMON_LOGGER_NAME);
private static final Logger log = LoggerFactory.getLogger(LoggerName.COMMON_LOGGER_NAME);

// 添加一条占位符日志记录,确保log变量会被使用到
public static void main(String[] args) {
log.info("初始化RemoteAddressStrategyFactory...");
}

public static final NullRemoteAddressStrategy NULL_NET_ADDRESS_STRATEGY = new NullRemoteAddressStrategy();

public static final BlankRemoteAddressStrategy BLANK_NET_ADDRESS_STRATEGY = new BlankRemoteAddressStrategy();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/

package org.apache.rocketmq.broker.auth.pipeline;


class AuthConfig {

boolean isAuthenticationEnabled() {
throw new UnsupportedOperationException("Not supported yet.");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/

package org.apache.rocketmq.broker.auth.pipeline;


class AuthenticationContext {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/

package org.apache.rocketmq.broker.auth.pipeline;


class AuthenticationEvaluator {

void evaluate(AuthenticationContext authenticationContext) {
throw new UnsupportedOperationException("Not supported yet.");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/

package org.apache.rocketmq.broker.auth.pipeline;

import org.apache.rocketmq.remoting.protocol.RemotingCommand;

import io.netty.channel.ChannelHandlerContext;

class AuthenticationFactory {

public static AuthenticationContext newContext(AuthConfig authConfig, ChannelHandlerContext ctx,
RemotingCommand request) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'newContext'");
}

public static AuthenticationEvaluator getEvaluator(AuthConfig authConfig) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'getEvaluator'");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public class ClientHousekeepingService implements ChannelEventListener {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
private final BrokerController brokerController;

private ScheduledExecutorService scheduledExecutorService;
private final ScheduledExecutorService scheduledExecutorService;
//规定scheduledExecutorService为最终版本

public ClientHousekeepingService(final BrokerController brokerController) {
this.brokerController = brokerController;
Expand All @@ -40,15 +41,12 @@ public ClientHousekeepingService(final BrokerController brokerController) {
}

public void start() {

this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
try {
ClientHousekeepingService.this.scanExceptionChannel();
} catch (Throwable e) {
log.error("Error occurred when scan not active client channels.", e);
}
//使用Lambda表达式,每10s执行一次
this.scheduledExecutorService.scheduleAtFixedRate(() -> {
try {
ClientHousekeepingService.this.scanExceptionChannel();
} catch (Throwable e) {
log.error("Error occurred when scan not active client channels.", e);
}
}, 1000 * 10, 1000 * 10, TimeUnit.MILLISECONDS);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
package org.apache.rocketmq.broker.client.net;

import io.netty.channel.Channel;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentMap;

import org.apache.rocketmq.broker.BrokerController;
import org.apache.rocketmq.broker.client.ClientChannelInfo;
import org.apache.rocketmq.broker.client.ConsumerGroupInfo;
Expand All @@ -39,6 +41,7 @@
import org.apache.rocketmq.remoting.common.RemotingHelper;
import org.apache.rocketmq.remoting.exception.RemotingSendRequestException;
import org.apache.rocketmq.remoting.exception.RemotingTimeoutException;
import org.apache.rocketmq.remoting.exception.RemotingTooMuchRequestException;
import org.apache.rocketmq.remoting.protocol.RemotingCommand;
import org.apache.rocketmq.remoting.protocol.RequestCode;
import org.apache.rocketmq.remoting.protocol.ResponseCode;
Expand Down Expand Up @@ -68,7 +71,8 @@ public void checkProducerTransactionState(
request.setBody(MessageDecoder.encode(messageExt, false));
try {
this.brokerController.getRemotingServer().invokeOneway(channel, request, 10);
} catch (Exception e) {
} catch (InterruptedException | RemotingSendRequestException | RemotingTimeoutException | RemotingTooMuchRequestException e) {
//多批捕获特定异常
log.error("Check transaction failed because invoke producer exception. group={}, msgId={}, error={}",
group, messageExt.getMsgId(), e.toString());
}
Expand All @@ -95,7 +99,7 @@ public void notifyConsumerIdsChanged(

try {
this.brokerController.getRemotingServer().invokeOneway(channel, request, 10);
} catch (Exception e) {
} catch (InterruptedException | RemotingSendRequestException | RemotingTimeoutException | RemotingTooMuchRequestException e) {
log.error("notifyConsumerIdsChanged exception. group={}, error={}", consumerGroup, e.toString());
}
}
Expand Down Expand Up @@ -185,7 +189,8 @@ public RemotingCommand resetOffset(String topic, String group, long timeStamp, b
this.brokerController.getRemotingServer().invokeOneway(entry.getKey(), request, 5000);
log.info("[reset-offset] reset offset success. topic={}, group={}, clientId={}",
topic, group, entry.getValue().getClientId());
} catch (Exception e) {
} catch (InterruptedException | RemotingSendRequestException | RemotingTimeoutException | RemotingTooMuchRequestException e) {
//多批捕获特定异常
log.error("[reset-offset] reset offset exception. topic={}, group={} ,error={}",
topic, group, e.toString());
}
Expand Down Expand Up @@ -227,6 +232,7 @@ private List<MessageQueueForC> convertOffsetTable2OffsetList(Map<MessageQueue, L
return list;
}

@SuppressWarnings("deprecation")
public RemotingCommand getConsumeStatus(String topic, String group, String originClientId) {
final RemotingCommand result = RemotingCommand.createResponseCommand(null);

Expand Down Expand Up @@ -269,6 +275,7 @@ public RemotingCommand getConsumeStatus(String topic, String group, String origi
GetConsumerStatusBody.class);

consumerStatusTable.put(clientId, body.getMessageQueueTable());
//将@SuppressWarnings“depression”添加到“getConsumerStatus()”
log.info(
"[get-consumer-status] get consumer status success. topic={}, group={}, channelRemoteAddr={}",
topic, group, clientId);
Expand All @@ -277,7 +284,8 @@ public RemotingCommand getConsumeStatus(String topic, String group, String origi
default:
break;
}
} catch (Exception e) {
} catch (InterruptedException | RemotingSendRequestException | RemotingTimeoutException e) {
//多批捕获特定异常
log.error(
"[get-consumer-status] get consumer status exception. topic={}, group={}, error={}",
topic, group, e.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package org.apache.rocketmq.broker.coldctr;

import java.util.ArrayList;
import java.util.Comparator;
//import java.util.Comparator;代码中未使用到该导入项
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
Expand Down Expand Up @@ -142,13 +142,10 @@ private void clearDataAcc() {
}

private void sortAndDecelerate() {
List<Entry<String, Long>> configMapList = new ArrayList<Entry<String, Long>>(cgColdThresholdMapConfig.entrySet());
configMapList.sort(new Comparator<Entry<String, Long>>() {
@Override
public int compare(Entry<String, Long> o1, Entry<String, Long> o2) {
return (int)(o2.getValue() - o1.getValue());
}
});
//使用钻石运算符<>来代替显式的类型参数
List<Entry<String, Long>> configMapList = new ArrayList<>(cgColdThresholdMapConfig.entrySet());
//将匿名内部类替换为等效的Lambda表达式。
configMapList.sort((Entry<String, Long> o1, Entry<String, Long> o2) -> (int)(o2.getValue() - o1.getValue()));
Iterator<Entry<String, Long>> iterator = configMapList.iterator();
int maxDecelerate = 3;
while (iterator.hasNext() && maxDecelerate > 0) {
Expand Down
46 changes: 16 additions & 30 deletions common/src/main/java/org/apache/rocketmq/common/action/Action.java
Original file line number Diff line number Diff line change
@@ -1,62 +1,48 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.rocketmq.common.action;

import com.alibaba.fastjson2.annotation.JSONField;
import org.apache.commons.lang3.StringUtils;

import java.util.HashMap;
import java.util.Map;

public enum Action {

UNKNOWN((byte) 0, "Unknown"),

ALL((byte) 1, "All"),

ANY((byte) 2, "Any"),

PUB((byte) 3, "Pub"),

SUB((byte) 4, "Sub"),

CREATE((byte) 5, "Create"),

UPDATE((byte) 6, "Update"),

DELETE((byte) 7, "Delete"),

GET((byte) 8, "Get"),

LIST((byte) 9, "List");

@JSONField(value = true)
private final byte code;
private final String name;

// 添加静态Map用于存储名称到枚举值的映射
private static final Map<String, Action> NAME_MAP = new HashMap<>();

static {
// 初始化Map
for (Action action : values()) {
NAME_MAP.put(action.getName().toLowerCase(), action);
}
}

Action(byte code, String name) {
this.code = code;
this.name = name;
}

public static Action getByName(String name) {
for (Action action : Action.values()) {
if (StringUtils.equalsIgnoreCase(action.getName(), name)) {
return action;
}
if (StringUtils.isBlank(name)) {
return null;
}
return null;
return NAME_MAP.get(name.toLowerCase());
}

public byte getCode() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,25 @@ public abstract class Attribute {
protected String name;
protected boolean changeable;

public abstract void verify(String value);

public Attribute(String name, boolean changeable) {
// 检查 name 是否为空或空白字符串
if (name == null || name.trim().isEmpty()) {
throw new IllegalArgumentException("Attribute name cannot be null or empty");
}
this.name = name;
this.changeable = changeable;
}

public abstract void verify(String value);

public String getName() {
return name;
}

public void setName(String name) {
if (name == null || name.trim().isEmpty()) {
throw new IllegalArgumentException("Attribute name cannot be null or empty");
}
this.name = name;
}

Expand Down
Loading
Loading