提交 da09320d 编写于 作者: H hujie

clean Attention: delete line 37 of the MixAllTest.java

上级 f2dcde94
...@@ -18,32 +18,32 @@ package org.apache.rocketmq.acl.plug; ...@@ -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.AclPlugEngine;
import org.apache.rocketmq.acl.plug.engine.PlainAclPlugEngine; 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; import org.apache.rocketmq.acl.plug.exception.AclPlugRuntimeException;
public class AclPlugController { public class AclPlugController {
private ControllerParametersEntity controllerParametersEntity; private ControllerParameters controllerParameters;
private AclPlugEngine aclPlugEngine; private AclPlugEngine aclPlugEngine;
private AclRemotingServer aclRemotingServer; private AclRemotingService aclRemotingService;
private boolean startSucceed = false; private boolean startSucceed = false;
public AclPlugController(ControllerParametersEntity controllerParametersEntity) throws AclPlugRuntimeException { public AclPlugController(ControllerParameters controllerParameters) throws AclPlugRuntimeException {
try { try {
this.controllerParametersEntity = controllerParametersEntity; this.controllerParameters = controllerParameters;
aclPlugEngine = new PlainAclPlugEngine(controllerParametersEntity); aclPlugEngine = new PlainAclPlugEngine(controllerParameters);
aclRemotingServer = new DefaultAclRemotingServerImpl(aclPlugEngine); aclRemotingService = new DefaultAclRemotingServiceImpl(aclPlugEngine);
this.startSucceed = true; this.startSucceed = true;
} catch (Exception e) { } 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() { public AclRemotingService getAclRemotingService() {
return this.aclRemotingServer; return this.aclRemotingService;
} }
public void doChannelCloseEvent(String remoteAddr) { public void doChannelCloseEvent(String remoteAddr) {
......
...@@ -19,7 +19,7 @@ package org.apache.rocketmq.acl.plug; ...@@ -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.AccessControl;
import org.apache.rocketmq.acl.plug.entity.AuthenticationResult; import org.apache.rocketmq.acl.plug.entity.AuthenticationResult;
public interface AclRemotingServer { public interface AclRemotingService {
public AuthenticationResult check(AccessControl accessControl); public AuthenticationResult check(AccessControl accessControl);
......
...@@ -21,11 +21,11 @@ import org.apache.rocketmq.acl.plug.entity.AccessControl; ...@@ -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.entity.AuthenticationResult;
import org.apache.rocketmq.acl.plug.exception.AclPlugRuntimeException; import org.apache.rocketmq.acl.plug.exception.AclPlugRuntimeException;
public class DefaultAclRemotingServerImpl implements AclRemotingServer { public class DefaultAclRemotingServiceImpl implements AclRemotingService {
private AclPlugEngine aclPlugEngine; private AclPlugEngine aclPlugEngine;
public DefaultAclRemotingServerImpl(AclPlugEngine aclPlugEngine) { public DefaultAclRemotingServiceImpl(AclPlugEngine aclPlugEngine) {
this.aclPlugEngine = aclPlugEngine; this.aclPlugEngine = aclPlugEngine;
} }
......
...@@ -25,7 +25,7 @@ import org.apache.rocketmq.acl.plug.entity.AccessControl; ...@@ -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.AuthenticationInfo;
import org.apache.rocketmq.acl.plug.entity.AuthenticationResult; import org.apache.rocketmq.acl.plug.entity.AuthenticationResult;
import org.apache.rocketmq.acl.plug.entity.BorkerAccessControlTransport; 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.exception.AclPlugRuntimeException;
import org.apache.rocketmq.acl.plug.strategy.NetaddressStrategy; import org.apache.rocketmq.acl.plug.strategy.NetaddressStrategy;
import org.apache.rocketmq.acl.plug.strategy.NetaddressStrategyFactory; import org.apache.rocketmq.acl.plug.strategy.NetaddressStrategyFactory;
...@@ -36,16 +36,16 @@ import org.apache.rocketmq.logging.InternalLoggerFactory; ...@@ -36,16 +36,16 @@ import org.apache.rocketmq.logging.InternalLoggerFactory;
public abstract class AuthenticationInfoManagementAclPlugEngine implements AclPlugEngine { public abstract class AuthenticationInfoManagementAclPlugEngine implements AclPlugEngine {
private static final InternalLogger log = InternalLoggerFactory.getLogger(LoggerName.ACL_PLUG_LOGGER_NAME); private static final InternalLogger log = InternalLoggerFactory.getLogger(LoggerName.ACL_PLUG_LOGGER_NAME);
ControllerParametersEntity controllerParametersEntity; ControllerParameters controllerParameters;
private Map<String/** account **/, Map<String/** netaddress **/, AuthenticationInfo>> accessControlMap = new HashMap<>(); private Map<String/** account **/, Map<String/** netaddress **/, AuthenticationInfo>> accessControlMap = new HashMap<>();
private AuthenticationInfo authenticationInfo; private AuthenticationInfo authenticationInfo;
private NetaddressStrategyFactory netaddressStrategyFactory = new NetaddressStrategyFactory(); private NetaddressStrategyFactory netaddressStrategyFactory = new NetaddressStrategyFactory();
private AccessContralAnalysis accessContralAnalysis = new AccessContralAnalysis(); private AccessContralAnalysis accessContralAnalysis = new AccessContralAnalysis();
private Authentication authentication = new Authentication(); private Authentication authentication = new Authentication();
public AuthenticationInfoManagementAclPlugEngine(ControllerParametersEntity controllerParametersEntity) { public AuthenticationInfoManagementAclPlugEngine(ControllerParameters controllerParameters) {
this.controllerParametersEntity = controllerParametersEntity; this.controllerParameters = controllerParameters;
accessContralAnalysis.analysisClass(controllerParametersEntity.getAccessContralAnalysisClass()); accessContralAnalysis.analysisClass(controllerParameters.getAccessContralAnalysisClass());
} }
public void setAccessControl(AccessControl accessControl) throws AclPlugRuntimeException { public void setAccessControl(AccessControl accessControl) throws AclPlugRuntimeException {
......
...@@ -21,15 +21,15 @@ import java.util.concurrent.ConcurrentHashMap; ...@@ -21,15 +21,15 @@ import java.util.concurrent.ConcurrentHashMap;
import org.apache.rocketmq.acl.plug.entity.AccessControl; import org.apache.rocketmq.acl.plug.entity.AccessControl;
import org.apache.rocketmq.acl.plug.entity.AuthenticationInfo; import org.apache.rocketmq.acl.plug.entity.AuthenticationInfo;
import org.apache.rocketmq.acl.plug.entity.AuthenticationResult; 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; import org.apache.rocketmq.acl.plug.entity.LoginInfo;
public abstract class LoginInfoAclPlugEngine extends AuthenticationInfoManagementAclPlugEngine { public abstract class LoginInfoAclPlugEngine extends AuthenticationInfoManagementAclPlugEngine {
private Map<String, LoginInfo> loginInfoMap = new ConcurrentHashMap<>(); private Map<String, LoginInfo> loginInfoMap = new ConcurrentHashMap<>();
public LoginInfoAclPlugEngine(ControllerParametersEntity controllerParametersEntity) { public LoginInfoAclPlugEngine(ControllerParameters controllerParameters) {
super(controllerParametersEntity); super(controllerParameters);
} }
public LoginInfo getLoginInfo(AccessControl accessControl) { public LoginInfo getLoginInfo(AccessControl accessControl) {
......
...@@ -20,20 +20,20 @@ import java.io.File; ...@@ -20,20 +20,20 @@ import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import org.apache.rocketmq.acl.plug.entity.BorkerAccessControlTransport; 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.exception.AclPlugRuntimeException;
import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.Yaml;
public class PlainAclPlugEngine extends LoginInfoAclPlugEngine { public class PlainAclPlugEngine extends LoginInfoAclPlugEngine {
public PlainAclPlugEngine( public PlainAclPlugEngine(
ControllerParametersEntity controllerParametersEntity) throws AclPlugRuntimeException { ControllerParameters controllerParameters) throws AclPlugRuntimeException {
super(controllerParametersEntity); super(controllerParameters);
init(); init();
} }
void init() throws AclPlugRuntimeException { void init() throws AclPlugRuntimeException {
String filePath = controllerParametersEntity.getFileHome() + "/conf/transport.yml"; String filePath = controllerParameters.getFileHome() + "/conf/transport.yml";
Yaml ymal = new Yaml(); Yaml ymal = new Yaml();
FileInputStream fis = null; FileInputStream fis = null;
BorkerAccessControlTransport transport; BorkerAccessControlTransport transport;
......
...@@ -18,7 +18,7 @@ package org.apache.rocketmq.acl.plug.entity; ...@@ -18,7 +18,7 @@ package org.apache.rocketmq.acl.plug.entity;
import org.apache.rocketmq.common.protocol.RequestCode; import org.apache.rocketmq.common.protocol.RequestCode;
public class ControllerParametersEntity { public class ControllerParameters {
private String fileHome; private String fileHome;
......
...@@ -28,7 +28,7 @@ import org.apache.rocketmq.acl.plug.entity.AuthenticationInfo; ...@@ -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.AuthenticationResult;
import org.apache.rocketmq.acl.plug.entity.BorkerAccessControl; import org.apache.rocketmq.acl.plug.entity.BorkerAccessControl;
import org.apache.rocketmq.acl.plug.entity.BorkerAccessControlTransport; 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.entity.LoginInfo;
import org.apache.rocketmq.acl.plug.exception.AclPlugRuntimeException; import org.apache.rocketmq.acl.plug.exception.AclPlugRuntimeException;
import org.apache.rocketmq.common.MixAll; import org.apache.rocketmq.common.MixAll;
...@@ -61,7 +61,7 @@ public class PlainAclPlugEngineTest { ...@@ -61,7 +61,7 @@ public class PlainAclPlugEngineTest {
FileInputStream fis = new FileInputStream(new File(filePath)); FileInputStream fis = new FileInputStream(new File(filePath));
transport = ymal.loadAs(fis, BorkerAccessControlTransport.class); transport = ymal.loadAs(fis, BorkerAccessControlTransport.class);
ControllerParametersEntity controllerParametersEntity = new ControllerParametersEntity(); ControllerParameters controllerParametersEntity = new ControllerParameters();
controllerParametersEntity.setFileHome(home); controllerParametersEntity.setFileHome(home);
plainAclPlugEngine = new PlainAclPlugEngine(controllerParametersEntity); plainAclPlugEngine = new PlainAclPlugEngine(controllerParametersEntity);
...@@ -108,7 +108,7 @@ public class PlainAclPlugEngineTest { ...@@ -108,7 +108,7 @@ public class PlainAclPlugEngineTest {
@Test(expected = AclPlugRuntimeException.class) @Test(expected = AclPlugRuntimeException.class)
public void testPlainAclPlugEngineInit() { public void testPlainAclPlugEngineInit() {
ControllerParametersEntity controllerParametersEntity = new ControllerParametersEntity(); ControllerParameters controllerParametersEntity = new ControllerParameters();
new PlainAclPlugEngine(controllerParametersEntity); new PlainAclPlugEngine(controllerParametersEntity);
} }
......
...@@ -32,12 +32,11 @@ import java.util.concurrent.LinkedBlockingQueue; ...@@ -32,12 +32,11 @@ import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.rocketmq.acl.plug.AclPlugController; 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.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.ClientHousekeepingService;
import org.apache.rocketmq.broker.client.ConsumerIdsChangeListener; import org.apache.rocketmq.broker.client.ConsumerIdsChangeListener;
import org.apache.rocketmq.broker.client.ConsumerManager; import org.apache.rocketmq.broker.client.ConsumerManager;
...@@ -503,14 +502,14 @@ public class BrokerController { ...@@ -503,14 +502,14 @@ public class BrokerController {
log.info("Default does not start acl plug"); log.info("Default does not start acl plug");
return; return;
} }
ControllerParametersEntity controllerParametersEntity = new ControllerParametersEntity(); ControllerParameters controllerParameters = new ControllerParameters();
controllerParametersEntity.setFileHome(brokerConfig.getRocketmqHome()); controllerParameters.setFileHome(brokerConfig.getRocketmqHome());
aclPlugController = new AclPlugController(controllerParametersEntity); aclPlugController = new AclPlugController(controllerParameters);
if (!aclPlugController.isStartSucceed()) { if (!aclPlugController.isStartSucceed()) {
log.error("start acl plug failure"); log.error("start acl plug failure");
return; return;
} }
final AclRemotingServer aclRemotingServe = aclPlugController.getAclRemotingServer(); final AclRemotingService aclRemotingService = aclPlugController.getAclRemotingService();
this.registerServerRPCHook(new RPCHook() { this.registerServerRPCHook(new RPCHook() {
@Override @Override
...@@ -525,7 +524,7 @@ public class BrokerController { ...@@ -525,7 +524,7 @@ public class BrokerController {
accessControl.setNetaddress(StringUtils.split(remoteAddr, ":")[0]); accessControl.setNetaddress(StringUtils.split(remoteAddr, ":")[0]);
accessControl.setTopic(extFields.get("topic")); accessControl.setTopic(extFields.get("topic"));
} }
aclRemotingServe.check(accessControl); aclRemotingService.check(accessControl);
} }
@Override @Override
......
...@@ -17,14 +17,13 @@ ...@@ -17,14 +17,13 @@
package org.apache.rocketmq.common; package org.apache.rocketmq.common;
import org.junit.Test;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.net.InetAddress; import java.net.InetAddress;
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
...@@ -34,7 +33,7 @@ public class MixAllTest { ...@@ -34,7 +33,7 @@ public class MixAllTest {
List<String> localInetAddress = MixAll.getLocalInetAddress(); List<String> localInetAddress = MixAll.getLocalInetAddress();
String local = InetAddress.getLocalHost().getHostAddress(); String local = InetAddress.getLocalHost().getHostAddress();
assertThat(localInetAddress).contains("127.0.0.1"); assertThat(localInetAddress).contains("127.0.0.1");
assertThat(localInetAddress).contains(local);
} }
@Test @Test
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册