本文整理汇总了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;
}
开发者ID:didapinchegit,项目名称:rocket-console,代码行数:20,代码来源:TopicServiceImpl.java
示例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);
}
开发者ID:medusar,项目名称:rocketmq-commet,代码行数:18,代码来源:DeleteTopicSubCommand.java
示例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;
}
开发者ID:LXLun,项目名称:RocketMQMonitor,代码行数:40,代码来源:ConsumerService.java
示例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;
}
开发者ID:LXLun,项目名称:RocketMQMonitor,代码行数:36,代码来源:BrokerService.java
示例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();
}
}
开发者ID:diwayou,项目名称:rocketmq-all-trans,代码行数:37,代码来源:DeleteTopicSubCommand.java
示例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();
}
}
开发者ID:diwayou,项目名称:rocketmq-all-trans,代码行数:43,代码来源:DeleteSubscriptionGroupCommand.java
注:本文中的com.alibaba.rocketmq.tools.command.CommandUtil类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论