本文整理汇总了Java中com.alibaba.rocketmq.tools.command.CommandUtil类的典型用法代码示例。如果您正苦于以下问题:Java CommandUtil类的具体用法?Java CommandUtil怎么用?Java CommandUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommandUtil类属于com.alibaba.rocketmq.tools.command包,在下文中一共展示了CommandUtil类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deleteTopic
import com.alibaba.rocketmq.tools.command.CommandUtil; //导入依赖的package包/类
@Override
public boolean deleteTopic(String topic, String clusterName) {
try {
if(StringUtils.isBlank(clusterName)){
return deleteTopic(topic);
}
Set<String> masterSet = CommandUtil.fetchMasterAddrByClusterName(mqAdminExt, clusterName);
mqAdminExt.deleteTopicInBroker(masterSet, topic);
Set<String> nameServerSet = null;
if (StringUtils.isNotBlank(configureInitializer.getNameSrvAddr())) {
String[] ns = configureInitializer.getNameSrvAddr().split(";");
nameServerSet = new HashSet<String>(Arrays.asList(ns));
}
mqAdminExt.deleteTopicInNameServer(nameServerSet, topic);
} catch (Exception err) {
throw Throwables.propagate(err);
}
return true;
}
示例2: deleteTopic
import com.alibaba.rocketmq.tools.command.CommandUtil; //导入依赖的package包/类
public static void deleteTopic(final DefaultMQAdminExt adminExt,//
final String clusterName,//
final String topic//
) throws InterruptedException, MQBrokerException, RemotingException, MQClientException {
Set<String> masterSet = CommandUtil.fetchMasterAddrByClusterName(adminExt, clusterName);
adminExt.deleteTopicInBroker(masterSet, topic);
System.out.printf("delete topic [%s] from cluster [%s] success.\n", topic, clusterName);
Set<String> nameServerSet = null;
if (adminExt.getNamesrvAddr() != null) {
String[] ns = adminExt.getNamesrvAddr().trim().split(";");
nameServerSet = new HashSet(Arrays.asList(ns));
}
adminExt.deleteTopicInNameServer(nameServerSet, topic);
System.out.printf("delete topic [%s] from NameServer success.\n", topic);
}
示例3: deleteSubGroup
import com.alibaba.rocketmq.tools.command.CommandUtil; //导入依赖的package包/类
@CmdTrace(cmdClazz = DeleteSubscriptionGroupCommand.class)
public boolean deleteSubGroup(String groupName, String brokerAddr, String clusterName) throws Throwable {
Throwable t = null;
DefaultMQAdminExt adminExt = getDefaultMQAdminExt();
try {
if (isNotBlank(brokerAddr)) {
adminExt.start();
adminExt.deleteSubscriptionGroup(brokerAddr, groupName);
// System.out.printf("delete subscription group [%s] from broker [%s] success.\n",
// groupName,addr);
return true;
}
else if (isNotBlank(clusterName)) {
adminExt.start();
Set<String> masterSet = CommandUtil.fetchMasterAddrByClusterName(adminExt, clusterName);
for (String master : masterSet) {
adminExt.deleteSubscriptionGroup(master, groupName);
// System.out.printf(
// "delete subscription group [%s] from broker [%s] in cluster [%s] success.\n",
// groupName, master, clusterName);
}
return true;
}
else {
throw new IllegalStateException("brokerAddr or clusterName can not be all blank");
}
}
catch (Throwable e) {
logger.error(e.getMessage(), e);
t = e;
}
finally {
shutdownDefaultMQAdminExt(adminExt);
}
throw t;
}
示例4: updateBrokerConfig
import com.alibaba.rocketmq.tools.command.CommandUtil; //导入依赖的package包/类
@CmdTrace(cmdClazz = UpdateBrokerConfigSubCommand.class)
public boolean updateBrokerConfig(String brokerAddr, String clusterName, String key, String value)
throws Throwable {
Throwable t = null;
DefaultMQAdminExt defaultMQAdminExt = getDefaultMQAdminExt();
try {
Properties properties = new Properties();
properties.put(key, value);
if (StringUtils.isNotBlank(brokerAddr)) {
defaultMQAdminExt.start();
defaultMQAdminExt.updateBrokerConfig(brokerAddr, properties);
return true;
}
else if (StringUtils.isNotBlank(clusterName)) {
defaultMQAdminExt.start();
Set<String> masterSet =
CommandUtil.fetchMasterAddrByClusterName(defaultMQAdminExt, clusterName);
for (String tempBrokerAddr : masterSet) {
defaultMQAdminExt.updateBrokerConfig(tempBrokerAddr, properties);
}
return true;
}
else {
throw new IllegalStateException("brokerAddr or clusterName can not be all blank");
}
}
catch (Throwable e) {
logger.error(e.getMessage(), e);
t = e;
}
finally {
shutdownDefaultMQAdminExt(defaultMQAdminExt);
}
throw t;
}
示例5: execute
import com.alibaba.rocketmq.tools.command.CommandUtil; //导入依赖的package包/类
@Override
public void execute(CommandLine commandLine, Options options) {
DefaultMQAdminExt adminExt = new DefaultMQAdminExt();
adminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
try {
String topic = commandLine.getOptionValue('t').trim();
if (commandLine.hasOption('c')) {
String clusterName = commandLine.getOptionValue('c').trim();
adminExt.start();
// 删除 broker 上的 topic 信息
Set<String> masterSet = CommandUtil.fetchMasterAddrByClusterName(adminExt, clusterName);
adminExt.deleteTopicInBroker(masterSet, topic);
System.out.printf("delete topic [%s] from cluster [%s] success.\n", topic, clusterName);
// 删除 NameServer 上的 topic 信息
Set<String> nameServerSet = null;
if (commandLine.hasOption('n')) {
String[] ns = commandLine.getOptionValue('n').trim().split(";");
nameServerSet = new HashSet(Arrays.asList(ns));
}
adminExt.deleteTopicInNameServer(nameServerSet, topic);
System.out.printf("delete topic [%s] from NameServer success.\n", topic);
return;
}
MixAll.printCommandLineHelp("mqadmin " + this.commandName(), options);
}
catch (Exception e) {
e.printStackTrace();
}
finally {
adminExt.shutdown();
}
}
示例6: execute
import com.alibaba.rocketmq.tools.command.CommandUtil; //导入依赖的package包/类
@Override
public void execute(CommandLine commandLine, Options options) {
DefaultMQAdminExt adminExt = new DefaultMQAdminExt();
adminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
try {
// groupName
String groupName = commandLine.getOptionValue('g').trim();
if (commandLine.hasOption('b')) {
String addr = commandLine.getOptionValue('b').trim();
adminExt.start();
adminExt.deleteSubscriptionGroup(addr, groupName);
System.out.printf("delete subscription group [%s] from broker [%s] success.\n", groupName,
addr);
return;
}
else if (commandLine.hasOption('c')) {
String clusterName = commandLine.getOptionValue('c').trim();
adminExt.start();
Set<String> masterSet = CommandUtil.fetchMasterAddrByClusterName(adminExt, clusterName);
for (String master : masterSet) {
adminExt.deleteSubscriptionGroup(master, groupName);
System.out.printf(
"delete subscription group [%s] from broker [%s] in cluster [%s] success.\n",
groupName, master, clusterName);
}
return;
}
MixAll.printCommandLineHelp("mqadmin " + this.commandName(), options);
}
catch (Exception e) {
e.printStackTrace();
}
finally {
adminExt.shutdown();
}
}