提交 5503cff5 编写于 作者: H hujie

tools acl

上级 ceaa64bb
...@@ -16,6 +16,9 @@ ...@@ -16,6 +16,9 @@
*/ */
package org.apache.rocketmq.tools.command; package org.apache.rocketmq.tools.command;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.joran.JoranConfigurator;
import ch.qos.logback.core.joran.spi.JoranException;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
...@@ -26,7 +29,6 @@ import java.util.ArrayList; ...@@ -26,7 +29,6 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Properties; import java.util.Properties;
import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Options; import org.apache.commons.cli.Options;
import org.apache.commons.cli.PosixParser; import org.apache.commons.cli.PosixParser;
...@@ -81,10 +83,6 @@ import org.apache.rocketmq.tools.command.topic.UpdateTopicPermSubCommand; ...@@ -81,10 +83,6 @@ import org.apache.rocketmq.tools.command.topic.UpdateTopicPermSubCommand;
import org.apache.rocketmq.tools.command.topic.UpdateTopicSubCommand; import org.apache.rocketmq.tools.command.topic.UpdateTopicSubCommand;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.joran.JoranConfigurator;
import ch.qos.logback.core.joran.spi.JoranException;
public class MQAdminStartup { public class MQAdminStartup {
protected static List<SubCommand> subCommandList = new ArrayList<SubCommand>(); protected static List<SubCommand> subCommandList = new ArrayList<SubCommand>();
...@@ -220,7 +218,7 @@ public class MQAdminStartup { ...@@ -220,7 +218,7 @@ public class MQAdminStartup {
private static void printHelp() { private static void printHelp() {
System.out.printf("The most commonly used mqadmin commands are:%n"); System.out.printf("The most commonly used mqadmin commands are:%n");
System.out.println("ROCKETMQ_HOME Add tools.properties to the %ROCKETMQ_HOME%/conf/ directory or add -account xxxx -password xxxx Join when executing a command"); System.out.printf("ROCKETMQ_HOME Add tools.properties to the %ROCKETMQ_HOME%/conf/ directory or add -account xxxx -password xxxx Join when executing a command");
for (SubCommand cmd : subCommandList) { for (SubCommand cmd : subCommandList) {
System.out.printf(" %-20s %s%n", cmd.commandName(), cmd.commandDesc()); System.out.printf(" %-20s %s%n", cmd.commandName(), cmd.commandDesc());
} }
...@@ -254,19 +252,19 @@ public class MQAdminStartup { ...@@ -254,19 +252,19 @@ public class MQAdminStartup {
} }
public static RPCHook getAclRPCHook(CommandLine commandLine) { public static RPCHook getAclRPCHook(CommandLine commandLine) {
String account=null ,password = null; String account = null, password = null;
if(commandLine.hasOption("account")) { if (commandLine.hasOption("account")) {
account = commandLine.getOptionValue("account"); account = commandLine.getOptionValue("account");
password = commandLine.getOptionValue("password"); password = commandLine.getOptionValue("password");
}else { } else {
String fileHome = System.getProperty(MixAll.ROCKETMQ_HOME_PROPERTY,System.getenv(MixAll.ROCKETMQ_HOME_ENV)); String fileHome = System.getProperty(MixAll.ROCKETMQ_HOME_PROPERTY, System.getenv(MixAll.ROCKETMQ_HOME_ENV));
File file = new File(fileHome+"/conf/tools.properties"); File file = new File(fileHome + "/conf/tools.properties");
if(!file.exists()) { if (!file.exists()) {
System.out.println("no find tools.properties , , Execution may fail without account andd password"); System.out.printf("no find tools.properties , , Execution may fail without account andd password");
System.out.println("ROCKETMQ_HOME Add tools.properties to the %ROCKETMQ_HOME%/conf/ directory or add -account xxxx -password xxxx Join when executing a command"); System.out.printf("ROCKETMQ_HOME Add tools.properties to the %ROCKETMQ_HOME%/conf/ directory or add -account xxxx -password xxxx Join when executing a command");
return null; return null;
} }
InputStream in=null; InputStream in = null;
try { try {
in = new BufferedInputStream(new FileInputStream(file)); in = new BufferedInputStream(new FileInputStream(file));
Properties properties = new Properties(); Properties properties = new Properties();
...@@ -277,8 +275,8 @@ public class MQAdminStartup { ...@@ -277,8 +275,8 @@ public class MQAdminStartup {
e.printStackTrace(); e.printStackTrace();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
}finally { } finally {
if(in != null) { if (in != null) {
try { try {
in.close(); in.close();
} catch (IOException e) { } catch (IOException e) {
...@@ -287,7 +285,7 @@ public class MQAdminStartup { ...@@ -287,7 +285,7 @@ public class MQAdminStartup {
} }
} }
} }
if(StringUtils.isNotBlank(account) && StringUtils.isNotBlank(password) ) { if (StringUtils.isNotBlank(account) && StringUtils.isNotBlank(password)) {
final String newAccount = account; final String newAccount = account;
final String newPassword = password; final String newPassword = password;
return new RPCHook() { return new RPCHook() {
...@@ -304,11 +302,12 @@ public class MQAdminStartup { ...@@ -304,11 +302,12 @@ public class MQAdminStartup {
} }
@Override @Override
public void doAfterResponse(String remoteAddr, RemotingCommand request, RemotingCommand response) {} public void doAfterResponse(String remoteAddr, RemotingCommand request, RemotingCommand response) {
}
}; };
} }
System.out.println("account andd password data incorrectness , Execution may fail without account andd password"); System.out.printf("account andd password data incorrectness , Execution may fail without account andd password");
System.out.println("ROCKETMQ_HOME Add tools.properties to the %ROCKETMQ_HOME%/conf/ directory or add -account xxxx -password xxxx Join when executing a command"); System.out.printf("ROCKETMQ_HOME Add tools.properties to the %ROCKETMQ_HOME%/conf/ directory or add -account xxxx -password xxxx Join when executing a command");
return null; return null;
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册