diff --git a/acl-plug/src/main/java/org/apache/rocketmq/acl/plug/AclPlugController.java b/acl-plug/src/main/java/org/apache/rocketmq/acl/plug/AclPlugController.java index c32ec73331adc6f6d39f08bdbc6ca7139e007c04..c61e122b1e569966f942ef088db9fedf1eefbc70 100644 --- a/acl-plug/src/main/java/org/apache/rocketmq/acl/plug/AclPlugController.java +++ b/acl-plug/src/main/java/org/apache/rocketmq/acl/plug/AclPlugController.java @@ -18,32 +18,32 @@ package org.apache.rocketmq.acl.plug; import org.apache.rocketmq.acl.plug.engine.AclPlugEngine; import org.apache.rocketmq.acl.plug.engine.PlainAclPlugEngine; -import org.apache.rocketmq.acl.plug.entity.ControllerParametersEntity; +import org.apache.rocketmq.acl.plug.entity.ControllerParameters; import org.apache.rocketmq.acl.plug.exception.AclPlugRuntimeException; public class AclPlugController { - private ControllerParametersEntity controllerParametersEntity; + private ControllerParameters controllerParameters; private AclPlugEngine aclPlugEngine; - private AclRemotingServer aclRemotingServer; + private AclRemotingService aclRemotingService; private boolean startSucceed = false; - public AclPlugController(ControllerParametersEntity controllerParametersEntity) throws AclPlugRuntimeException { + public AclPlugController(ControllerParameters controllerParameters) throws AclPlugRuntimeException { try { - this.controllerParametersEntity = controllerParametersEntity; - aclPlugEngine = new PlainAclPlugEngine(controllerParametersEntity); - aclRemotingServer = new DefaultAclRemotingServerImpl(aclPlugEngine); + this.controllerParameters = controllerParameters; + aclPlugEngine = new PlainAclPlugEngine(controllerParameters); + aclRemotingService = new DefaultAclRemotingServiceImpl(aclPlugEngine); this.startSucceed = true; } catch (Exception e) { - throw new AclPlugRuntimeException(String.format("Start the abnormal , Launch parameters is %s", this.controllerParametersEntity.toString()), e); + throw new AclPlugRuntimeException(String.format("Start the abnormal , Launch parameters is %s", this.controllerParameters.toString()), e); } } - public AclRemotingServer getAclRemotingServer() { - return this.aclRemotingServer; + public AclRemotingService getAclRemotingService() { + return this.aclRemotingService; } public void doChannelCloseEvent(String remoteAddr) { diff --git a/acl-plug/src/main/java/org/apache/rocketmq/acl/plug/AclRemotingServer.java b/acl-plug/src/main/java/org/apache/rocketmq/acl/plug/AclRemotingService.java similarity index 96% rename from acl-plug/src/main/java/org/apache/rocketmq/acl/plug/AclRemotingServer.java rename to acl-plug/src/main/java/org/apache/rocketmq/acl/plug/AclRemotingService.java index ded9f80c1e6899d7cf0a57e63faa41e89b2cc4b3..c651a5d99f8153fa556bc192d4eb8c77b225f721 100644 --- a/acl-plug/src/main/java/org/apache/rocketmq/acl/plug/AclRemotingServer.java +++ b/acl-plug/src/main/java/org/apache/rocketmq/acl/plug/AclRemotingService.java @@ -19,7 +19,7 @@ package org.apache.rocketmq.acl.plug; import org.apache.rocketmq.acl.plug.entity.AccessControl; import org.apache.rocketmq.acl.plug.entity.AuthenticationResult; -public interface AclRemotingServer { +public interface AclRemotingService { public AuthenticationResult check(AccessControl accessControl); diff --git a/acl-plug/src/main/java/org/apache/rocketmq/acl/plug/DefaultAclRemotingServerImpl.java b/acl-plug/src/main/java/org/apache/rocketmq/acl/plug/DefaultAclRemotingServiceImpl.java similarity index 93% rename from acl-plug/src/main/java/org/apache/rocketmq/acl/plug/DefaultAclRemotingServerImpl.java rename to acl-plug/src/main/java/org/apache/rocketmq/acl/plug/DefaultAclRemotingServiceImpl.java index 4ea14b48806b50dccac6b80b47773906ec060848..240c9a24e897913b488d6b33d2b727795d0c1289 100644 --- a/acl-plug/src/main/java/org/apache/rocketmq/acl/plug/DefaultAclRemotingServerImpl.java +++ b/acl-plug/src/main/java/org/apache/rocketmq/acl/plug/DefaultAclRemotingServiceImpl.java @@ -21,11 +21,11 @@ import org.apache.rocketmq.acl.plug.entity.AccessControl; import org.apache.rocketmq.acl.plug.entity.AuthenticationResult; import org.apache.rocketmq.acl.plug.exception.AclPlugRuntimeException; -public class DefaultAclRemotingServerImpl implements AclRemotingServer { +public class DefaultAclRemotingServiceImpl implements AclRemotingService { private AclPlugEngine aclPlugEngine; - public DefaultAclRemotingServerImpl(AclPlugEngine aclPlugEngine) { + public DefaultAclRemotingServiceImpl(AclPlugEngine aclPlugEngine) { this.aclPlugEngine = aclPlugEngine; } diff --git a/acl-plug/src/main/java/org/apache/rocketmq/acl/plug/engine/AuthenticationInfoManagementAclPlugEngine.java b/acl-plug/src/main/java/org/apache/rocketmq/acl/plug/engine/AuthenticationInfoManagementAclPlugEngine.java index a6c73930aea8863355d678c4b1a4c2f036dabd61..44b5245ae55b7c4997d53f69873f4256a0499dd7 100644 --- a/acl-plug/src/main/java/org/apache/rocketmq/acl/plug/engine/AuthenticationInfoManagementAclPlugEngine.java +++ b/acl-plug/src/main/java/org/apache/rocketmq/acl/plug/engine/AuthenticationInfoManagementAclPlugEngine.java @@ -25,7 +25,7 @@ import org.apache.rocketmq.acl.plug.entity.AccessControl; import org.apache.rocketmq.acl.plug.entity.AuthenticationInfo; import org.apache.rocketmq.acl.plug.entity.AuthenticationResult; import org.apache.rocketmq.acl.plug.entity.BorkerAccessControlTransport; -import org.apache.rocketmq.acl.plug.entity.ControllerParametersEntity; +import org.apache.rocketmq.acl.plug.entity.ControllerParameters; import org.apache.rocketmq.acl.plug.exception.AclPlugRuntimeException; import org.apache.rocketmq.acl.plug.strategy.NetaddressStrategy; import org.apache.rocketmq.acl.plug.strategy.NetaddressStrategyFactory; @@ -36,16 +36,16 @@ import org.apache.rocketmq.logging.InternalLoggerFactory; public abstract class AuthenticationInfoManagementAclPlugEngine implements AclPlugEngine { private static final InternalLogger log = InternalLoggerFactory.getLogger(LoggerName.ACL_PLUG_LOGGER_NAME); - ControllerParametersEntity controllerParametersEntity; + ControllerParameters controllerParameters; private Map> accessControlMap = new HashMap<>(); private AuthenticationInfo authenticationInfo; private NetaddressStrategyFactory netaddressStrategyFactory = new NetaddressStrategyFactory(); private AccessContralAnalysis accessContralAnalysis = new AccessContralAnalysis(); private Authentication authentication = new Authentication(); - public AuthenticationInfoManagementAclPlugEngine(ControllerParametersEntity controllerParametersEntity) { - this.controllerParametersEntity = controllerParametersEntity; - accessContralAnalysis.analysisClass(controllerParametersEntity.getAccessContralAnalysisClass()); + public AuthenticationInfoManagementAclPlugEngine(ControllerParameters controllerParameters) { + this.controllerParameters = controllerParameters; + accessContralAnalysis.analysisClass(controllerParameters.getAccessContralAnalysisClass()); } public void setAccessControl(AccessControl accessControl) throws AclPlugRuntimeException { diff --git a/acl-plug/src/main/java/org/apache/rocketmq/acl/plug/engine/LoginInfoAclPlugEngine.java b/acl-plug/src/main/java/org/apache/rocketmq/acl/plug/engine/LoginInfoAclPlugEngine.java index 4ce9f6a42715fd36d2aa7235ac27fffabc0bf7df..e8dc59c422a2cc9e5d1821fc10e1f86462561d1f 100644 --- a/acl-plug/src/main/java/org/apache/rocketmq/acl/plug/engine/LoginInfoAclPlugEngine.java +++ b/acl-plug/src/main/java/org/apache/rocketmq/acl/plug/engine/LoginInfoAclPlugEngine.java @@ -21,15 +21,15 @@ import java.util.concurrent.ConcurrentHashMap; import org.apache.rocketmq.acl.plug.entity.AccessControl; import org.apache.rocketmq.acl.plug.entity.AuthenticationInfo; import org.apache.rocketmq.acl.plug.entity.AuthenticationResult; -import org.apache.rocketmq.acl.plug.entity.ControllerParametersEntity; +import org.apache.rocketmq.acl.plug.entity.ControllerParameters; import org.apache.rocketmq.acl.plug.entity.LoginInfo; public abstract class LoginInfoAclPlugEngine extends AuthenticationInfoManagementAclPlugEngine { private Map loginInfoMap = new ConcurrentHashMap<>(); - public LoginInfoAclPlugEngine(ControllerParametersEntity controllerParametersEntity) { - super(controllerParametersEntity); + public LoginInfoAclPlugEngine(ControllerParameters controllerParameters) { + super(controllerParameters); } public LoginInfo getLoginInfo(AccessControl accessControl) { diff --git a/acl-plug/src/main/java/org/apache/rocketmq/acl/plug/engine/PlainAclPlugEngine.java b/acl-plug/src/main/java/org/apache/rocketmq/acl/plug/engine/PlainAclPlugEngine.java index 2917e72390e042ceb2a4d836d776778de84163e1..01fdba84648cb59703b2e94b55e27f30da00adf0 100644 --- a/acl-plug/src/main/java/org/apache/rocketmq/acl/plug/engine/PlainAclPlugEngine.java +++ b/acl-plug/src/main/java/org/apache/rocketmq/acl/plug/engine/PlainAclPlugEngine.java @@ -20,20 +20,20 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import org.apache.rocketmq.acl.plug.entity.BorkerAccessControlTransport; -import org.apache.rocketmq.acl.plug.entity.ControllerParametersEntity; +import org.apache.rocketmq.acl.plug.entity.ControllerParameters; import org.apache.rocketmq.acl.plug.exception.AclPlugRuntimeException; import org.yaml.snakeyaml.Yaml; public class PlainAclPlugEngine extends LoginInfoAclPlugEngine { public PlainAclPlugEngine( - ControllerParametersEntity controllerParametersEntity) throws AclPlugRuntimeException { - super(controllerParametersEntity); + ControllerParameters controllerParameters) throws AclPlugRuntimeException { + super(controllerParameters); init(); } void init() throws AclPlugRuntimeException { - String filePath = controllerParametersEntity.getFileHome() + "/conf/transport.yml"; + String filePath = controllerParameters.getFileHome() + "/conf/transport.yml"; Yaml ymal = new Yaml(); FileInputStream fis = null; BorkerAccessControlTransport transport; diff --git a/acl-plug/src/main/java/org/apache/rocketmq/acl/plug/entity/ControllerParametersEntity.java b/acl-plug/src/main/java/org/apache/rocketmq/acl/plug/entity/ControllerParameters.java similarity index 97% rename from acl-plug/src/main/java/org/apache/rocketmq/acl/plug/entity/ControllerParametersEntity.java rename to acl-plug/src/main/java/org/apache/rocketmq/acl/plug/entity/ControllerParameters.java index fe781e0e2ef92487e6f73956a201bf52db4c7ae9..708bcbeb9153c194a2c95dca8d1aec16913a135f 100644 --- a/acl-plug/src/main/java/org/apache/rocketmq/acl/plug/entity/ControllerParametersEntity.java +++ b/acl-plug/src/main/java/org/apache/rocketmq/acl/plug/entity/ControllerParameters.java @@ -18,7 +18,7 @@ package org.apache.rocketmq.acl.plug.entity; import org.apache.rocketmq.common.protocol.RequestCode; -public class ControllerParametersEntity { +public class ControllerParameters { private String fileHome; diff --git a/acl-plug/src/test/java/org/apache/rocketmq/acl/plug/engine/PlainAclPlugEngineTest.java b/acl-plug/src/test/java/org/apache/rocketmq/acl/plug/engine/PlainAclPlugEngineTest.java index 45755a0e11c19d6fecfc37f486b5a5cce710b79c..618c87e49d8ddff15a4a44656ce8718e452ad19e 100644 --- a/acl-plug/src/test/java/org/apache/rocketmq/acl/plug/engine/PlainAclPlugEngineTest.java +++ b/acl-plug/src/test/java/org/apache/rocketmq/acl/plug/engine/PlainAclPlugEngineTest.java @@ -28,7 +28,7 @@ import org.apache.rocketmq.acl.plug.entity.AuthenticationInfo; import org.apache.rocketmq.acl.plug.entity.AuthenticationResult; import org.apache.rocketmq.acl.plug.entity.BorkerAccessControl; import org.apache.rocketmq.acl.plug.entity.BorkerAccessControlTransport; -import org.apache.rocketmq.acl.plug.entity.ControllerParametersEntity; +import org.apache.rocketmq.acl.plug.entity.ControllerParameters; import org.apache.rocketmq.acl.plug.entity.LoginInfo; import org.apache.rocketmq.acl.plug.exception.AclPlugRuntimeException; import org.apache.rocketmq.common.MixAll; @@ -61,7 +61,7 @@ public class PlainAclPlugEngineTest { FileInputStream fis = new FileInputStream(new File(filePath)); transport = ymal.loadAs(fis, BorkerAccessControlTransport.class); - ControllerParametersEntity controllerParametersEntity = new ControllerParametersEntity(); + ControllerParameters controllerParametersEntity = new ControllerParameters(); controllerParametersEntity.setFileHome(home); plainAclPlugEngine = new PlainAclPlugEngine(controllerParametersEntity); @@ -108,7 +108,7 @@ public class PlainAclPlugEngineTest { @Test(expected = AclPlugRuntimeException.class) public void testPlainAclPlugEngineInit() { - ControllerParametersEntity controllerParametersEntity = new ControllerParametersEntity(); + ControllerParameters controllerParametersEntity = new ControllerParameters(); new PlainAclPlugEngine(controllerParametersEntity); } diff --git a/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java b/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java index e7e8097f2df3a5d34794abd8ae15cf5d8954a41c..c30d1f33e1caee28f7c3c074be459acf210f71d4 100644 --- a/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java +++ b/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java @@ -32,12 +32,11 @@ import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; - import org.apache.commons.lang3.StringUtils; import org.apache.rocketmq.acl.plug.AclPlugController; -import org.apache.rocketmq.acl.plug.AclRemotingServer; +import org.apache.rocketmq.acl.plug.AclRemotingService; import org.apache.rocketmq.acl.plug.entity.AccessControl; -import org.apache.rocketmq.acl.plug.entity.ControllerParametersEntity; +import org.apache.rocketmq.acl.plug.entity.ControllerParameters; import org.apache.rocketmq.broker.client.ClientHousekeepingService; import org.apache.rocketmq.broker.client.ConsumerIdsChangeListener; import org.apache.rocketmq.broker.client.ConsumerManager; @@ -503,14 +502,14 @@ public class BrokerController { log.info("Default does not start acl plug"); return; } - ControllerParametersEntity controllerParametersEntity = new ControllerParametersEntity(); - controllerParametersEntity.setFileHome(brokerConfig.getRocketmqHome()); - aclPlugController = new AclPlugController(controllerParametersEntity); + ControllerParameters controllerParameters = new ControllerParameters(); + controllerParameters.setFileHome(brokerConfig.getRocketmqHome()); + aclPlugController = new AclPlugController(controllerParameters); if (!aclPlugController.isStartSucceed()) { log.error("start acl plug failure"); return; } - final AclRemotingServer aclRemotingServe = aclPlugController.getAclRemotingServer(); + final AclRemotingService aclRemotingService = aclPlugController.getAclRemotingService(); this.registerServerRPCHook(new RPCHook() { @Override @@ -525,7 +524,7 @@ public class BrokerController { accessControl.setNetaddress(StringUtils.split(remoteAddr, ":")[0]); accessControl.setTopic(extFields.get("topic")); } - aclRemotingServe.check(accessControl); + aclRemotingService.check(accessControl); } @Override diff --git a/common/src/test/java/org/apache/rocketmq/common/MixAllTest.java b/common/src/test/java/org/apache/rocketmq/common/MixAllTest.java index 3f0487202f04c13485ea165280c3f71583e52efa..9110517fa530a7a2a42c24637be9c9b9826b70ab 100644 --- a/common/src/test/java/org/apache/rocketmq/common/MixAllTest.java +++ b/common/src/test/java/org/apache/rocketmq/common/MixAllTest.java @@ -17,14 +17,13 @@ package org.apache.rocketmq.common; -import org.junit.Test; - import java.io.File; import java.io.IOException; import java.io.PrintWriter; import java.net.InetAddress; import java.util.List; import java.util.concurrent.atomic.AtomicLong; +import org.junit.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -34,7 +33,7 @@ public class MixAllTest { List localInetAddress = MixAll.getLocalInetAddress(); String local = InetAddress.getLocalHost().getHostAddress(); assertThat(localInetAddress).contains("127.0.0.1"); - assertThat(localInetAddress).contains(local); + } @Test