本文整理汇总了Java中com.alibaba.rocketmq.common.namesrv.NamesrvUtil类的典型用法代码示例。如果您正苦于以下问题:Java NamesrvUtil类的具体用法?Java NamesrvUtil怎么用?Java NamesrvUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NamesrvUtil类属于com.alibaba.rocketmq.common.namesrv包,在下文中一共展示了NamesrvUtil类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRouteInfoByTopic
import com.alibaba.rocketmq.common.namesrv.NamesrvUtil; //导入依赖的package包/类
public RemotingCommand getRouteInfoByTopic(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final GetRouteInfoRequestHeader requestHeader =
(GetRouteInfoRequestHeader) request.decodeCommandCustomHeader(GetRouteInfoRequestHeader.class);
TopicRouteData topicRouteData = this.namesrvController.getRouteInfoManager().pickupTopicRouteData(requestHeader.getTopic());
if (topicRouteData != null) {
String orderTopicConf =
this.namesrvController.getKvConfigManager().getKVConfig(NamesrvUtil.NAMESPACE_ORDER_TOPIC_CONFIG,
requestHeader.getTopic());
topicRouteData.setOrderTopicConf(orderTopicConf);
byte[] content = topicRouteData.encode();
response.setBody(content);
response.setCode(ResponseCode.SUCCESS);
response.setRemark(null);
return response;
}
response.setCode(ResponseCode.TOPIC_NOT_EXIST);
response.setRemark("No topic route info in name server for the topic: " + requestHeader.getTopic()
+ FAQUrl.suggestTodo(FAQUrl.APPLY_TOPIC_URL));
return response;
}
示例2: getRouteInfoByTopic
import com.alibaba.rocketmq.common.namesrv.NamesrvUtil; //导入依赖的package包/类
/**
* 获取指定Topic的路由信息
*
* @param ctx
* @param request
* @return
* @throws RemotingCommandException
*/
public RemotingCommand getRouteInfoByTopic(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final GetRouteInfoRequestHeader requestHeader =
(GetRouteInfoRequestHeader) request.decodeCommandCustomHeader(GetRouteInfoRequestHeader.class);
TopicRouteData topicRouteData = this.namesrvController.getRouteInfoManager().pickupTopicRouteData(requestHeader.getTopic());
if (topicRouteData != null) {
String orderTopicConf = this.namesrvController.getKvConfigManager().getKVConfig(NamesrvUtil.NAMESPACE_ORDER_TOPIC_CONFIG,requestHeader.getTopic());
topicRouteData.setOrderTopicConf(orderTopicConf);
byte[] content = topicRouteData.encode();
response.setBody(content);
response.setCode(ResponseCode.SUCCESS);
response.setRemark(null);
return response;
}
response.setCode(ResponseCode.TOPIC_NOT_EXIST);
response.setRemark("No topic route info in name server for the topic: " + requestHeader.getTopic()
+ FAQUrl.suggestTodo(FAQUrl.APPLY_TOPIC_URL));
return response;
}
示例3: updateProjectGroup
import com.alibaba.rocketmq.common.namesrv.NamesrvUtil; //导入依赖的package包/类
@CmdTrace(cmdClazz = UpdateProjectGroupCommand.class)
public boolean updateProjectGroup(String ip, String project) throws Throwable {
Throwable t = null;
DefaultMQAdminExt defaultMQAdminExt = getDefaultMQAdminExt();
String namespace = NamesrvUtil.NAMESPACE_PROJECT_CONFIG;
try {
defaultMQAdminExt.start();
defaultMQAdminExt.createAndUpdateKvConfig(namespace, ip, project);
return true;
}
catch (Throwable e) {
logger.error(e.getMessage(), e);
t = e;
}
finally {
shutdownDefaultMQAdminExt(defaultMQAdminExt);
}
throw t;
}
示例4: execute
import com.alibaba.rocketmq.common.namesrv.NamesrvUtil; //导入依赖的package包/类
@Override
public void execute(CommandLine commandLine, Options options) {
DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt();
defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
try {
String namespace = NamesrvUtil.NAMESPACE_PROJECT_CONFIG;
String ip = commandLine.getOptionValue('i').trim();
String project = commandLine.getOptionValue('p').trim();
defaultMQAdminExt.start();
defaultMQAdminExt.createAndUpdateKvConfig(namespace, ip, project);
System.out.printf("create or update kv config to namespace success.\n");
return;
}
catch (Exception e) {
e.printStackTrace();
}
finally {
defaultMQAdminExt.shutdown();
}
}
示例5: registerBrokerWithFilterServer
import com.alibaba.rocketmq.common.namesrv.NamesrvUtil; //导入依赖的package包/类
public RemotingCommand registerBrokerWithFilterServer(ChannelHandlerContext ctx, RemotingCommand request)
throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(RegisterBrokerResponseHeader.class);
final RegisterBrokerResponseHeader responseHeader = (RegisterBrokerResponseHeader) response.readCustomHeader();
final RegisterBrokerRequestHeader requestHeader =
(RegisterBrokerRequestHeader) request.decodeCommandCustomHeader(RegisterBrokerRequestHeader.class);
RegisterBrokerBody registerBrokerBody = new RegisterBrokerBody();
if (request.getBody() != null) {
registerBrokerBody = RegisterBrokerBody.decode(request.getBody(), RegisterBrokerBody.class);
}
else {
registerBrokerBody.getTopicConfigSerializeWrapper().getDataVersion().setCounter(new AtomicLong(0));
registerBrokerBody.getTopicConfigSerializeWrapper().getDataVersion().setTimestatmp(0);
}
RegisterBrokerResult result = this.namesrvController.getRouteInfoManager().registerBroker(//
requestHeader.getClusterName(), // 1
requestHeader.getBrokerAddr(), // 2
requestHeader.getBrokerName(), // 3
requestHeader.getBrokerId(), // 4
requestHeader.getHaServerAddr(),// 5
registerBrokerBody.getTopicConfigSerializeWrapper(), // 6
registerBrokerBody.getFilterServerList(),//
ctx.channel()// 7
);
responseHeader.setHaServerAddr(result.getHaServerAddr());
responseHeader.setMasterAddr(result.getMasterAddr());
byte[] jsonValue = this.namesrvController.getKvConfigManager().getKVListByNamespace(NamesrvUtil.NAMESPACE_ORDER_TOPIC_CONFIG);
response.setBody(jsonValue);
response.setCode(ResponseCode.SUCCESS);
response.setRemark(null);
return response;
}
示例6: getRouteInfoByTopic
import com.alibaba.rocketmq.common.namesrv.NamesrvUtil; //导入依赖的package包/类
@Override
public RemotingCommand getRouteInfoByTopic(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final GetRouteInfoRequestHeader requestHeader =
(GetRouteInfoRequestHeader) request.decodeCommandCustomHeader(GetRouteInfoRequestHeader.class);
TopicRouteData topicRouteData = this.namesrvController.getRouteInfoManager().pickupTopicRouteData(requestHeader.getTopic());
if (topicRouteData != null) {
String orderTopicConf =
this.namesrvController.getKvConfigManager().getKVConfig(NamesrvUtil.NAMESPACE_ORDER_TOPIC_CONFIG,
requestHeader.getTopic());
topicRouteData.setOrderTopicConf(orderTopicConf);
}
else {
try {
topicRouteData = adminExt.examineTopicRouteInfo(requestHeader.getTopic());
}
catch (Exception e) {
log.info("get route info by topic from product environment failed. envName={},", productEnvName);
}
}
if (topicRouteData != null) {
byte[] content = topicRouteData.encode();
response.setBody(content);
response.setCode(ResponseCode.SUCCESS);
response.setRemark(null);
return response;
}
response.setCode(ResponseCode.TOPIC_NOT_EXIST);
response.setRemark("No topic route info in name server for the topic: " + requestHeader.getTopic()
+ FAQUrl.suggestTodo(FAQUrl.APPLY_TOPIC_URL));
return response;
}
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:36,代码来源:ClusterTestRequestProcessor.java
示例7: deleteProjectGroup
import com.alibaba.rocketmq.common.namesrv.NamesrvUtil; //导入依赖的package包/类
@CmdTrace(cmdClazz = DeleteProjectGroupCommand.class)
public boolean deleteProjectGroup(String ip, String project) throws Throwable {
Throwable t = null;
DefaultMQAdminExt defaultMQAdminExt = getDefaultMQAdminExt();
String namespace = NamesrvUtil.NAMESPACE_PROJECT_CONFIG;
try {
if (StringUtils.isNotBlank(ip)) {
defaultMQAdminExt.start();
defaultMQAdminExt.deleteKvConfig(namespace, ip);
return true;
}
else if (StringUtils.isNotBlank(project)) {
defaultMQAdminExt.start();
defaultMQAdminExt.deleteIpsByProjectGroup(project);
return true;
}
else {
throw new IllegalStateException("project or ip can not be all blank!");
}
}
catch (Throwable e) {
logger.error(e.getMessage(), e);
t = e;
}
finally {
shutdownDefaultMQAdminExt(defaultMQAdminExt);
}
throw t;
}
示例8: getRouteInfoByTopic
import com.alibaba.rocketmq.common.namesrv.NamesrvUtil; //导入依赖的package包/类
public RemotingCommand getRouteInfoByTopic(ChannelHandlerContext ctx, RemotingCommand request)
throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final GetRouteInfoRequestHeader requestHeader =
(GetRouteInfoRequestHeader) request
.decodeCommandCustomHeader(GetRouteInfoRequestHeader.class);
TopicRouteData topicRouteData =
this.namesrvController.getRouteInfoManager().pickupTopicRouteData(requestHeader.getTopic());
if (topicRouteData != null) {
String orderTopicConf =
this.namesrvController.getKvConfigManager().getKVConfig(
NamesrvUtil.NAMESPACE_ORDER_TOPIC_CONFIG, requestHeader.getTopic());
topicRouteData.setOrderTopicConf(orderTopicConf);
byte[] content = topicRouteData.encode();
response.setBody(content);
response.setCode(ResponseCode.SUCCESS);
response.setRemark(null);
return response;
}
response.setCode(ResponseCode.TOPIC_NOT_EXIST);
response.setRemark("No topic route info in name server for the topic: " + requestHeader.getTopic()
+ FAQUrl.suggestTodo(FAQUrl.APPLY_TOPIC_URL));
return response;
}
示例9: execute
import com.alibaba.rocketmq.common.namesrv.NamesrvUtil; //导入依赖的package包/类
@Override
public void execute(CommandLine commandLine, Options options) {
DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt();
defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
try {
String namespace = NamesrvUtil.NAMESPACE_PROJECT_CONFIG;
if (commandLine.hasOption("i")) {
String ip = commandLine.getOptionValue('i').trim();
defaultMQAdminExt.start();
defaultMQAdminExt.deleteKvConfig(namespace, ip);
System.out.printf("delete project group from namespace by server ip success.\n");
}
else if (commandLine.hasOption("p")) {
String project = commandLine.getOptionValue('p').trim();
defaultMQAdminExt.start();
defaultMQAdminExt.deleteIpsByProjectGroup(project);
System.out.printf("delete all server ip from namespace by project group success.\n");
}
else {
MixAll.printCommandLineHelp("mqadmin " + this.commandName(), options);
}
}
catch (Exception e) {
e.printStackTrace();
}
finally {
defaultMQAdminExt.shutdown();
}
}
示例10: getRouteInfoByTopic
import com.alibaba.rocketmq.common.namesrv.NamesrvUtil; //导入依赖的package包/类
public RemotingCommand getRouteInfoByTopic(ChannelHandlerContext ctx, RemotingCommand request)
throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final GetRouteInfoRequestHeader requestHeader =
(GetRouteInfoRequestHeader) request
.decodeCommandCustomHeader(GetRouteInfoRequestHeader.class);
TopicRouteData topicRouteData =
this.namesrvController.getRouteInfoManager().pickupTopicRouteData(requestHeader.getTopic());
if (topicRouteData != null) {
String orderTopicConf =
this.namesrvController.getKvConfigManager().getKVConfig(
NamesrvUtil.NAMESPACE_ORDER_TOPIC_CONFIG, requestHeader.getTopic());
topicRouteData.setOrderTopicConf(orderTopicConf);
byte[] content = topicRouteData.encode();
response.setBody(content);
response.setCode(ResponseCode.SUCCESS_VALUE);
response.setRemark(null);
return response;
}
response.setCode(MQResponseCode.TOPIC_NOT_EXIST_VALUE);
response.setRemark("No topic route info in name server for the topic: " + requestHeader.getTopic()
+ FAQUrl.suggestTodo(FAQUrl.APPLY_TOPIC_URL));
return response;
}
示例11: registerBrokerWithFilterServer
import com.alibaba.rocketmq.common.namesrv.NamesrvUtil; //导入依赖的package包/类
/**
* Broker注册
*
* @param ctx
* @param request
* @return
* @throws RemotingCommandException
*/
public RemotingCommand registerBrokerWithFilterServer(ChannelHandlerContext ctx, RemotingCommand request)
throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(RegisterBrokerResponseHeader.class);
final RegisterBrokerResponseHeader responseHeader = (RegisterBrokerResponseHeader) response.readCustomHeader();
final RegisterBrokerRequestHeader requestHeader =
(RegisterBrokerRequestHeader) request.decodeCommandCustomHeader(RegisterBrokerRequestHeader.class);
RegisterBrokerBody registerBrokerBody = new RegisterBrokerBody();
if (request.getBody() != null) {
registerBrokerBody = RegisterBrokerBody.decode(request.getBody(), RegisterBrokerBody.class);
} else {
registerBrokerBody.getTopicConfigSerializeWrapper().getDataVersion().setCounter(new AtomicLong(0));
registerBrokerBody.getTopicConfigSerializeWrapper().getDataVersion().setTimestatmp(0);
}
/**
* 更新RouteInfo
*/
RegisterBrokerResult result = this.namesrvController.getRouteInfoManager().registerBroker(//
requestHeader.getClusterName(), // 1
requestHeader.getBrokerAddr(), // 2
requestHeader.getBrokerName(), // 3
requestHeader.getBrokerId(), // 4
requestHeader.getHaServerAddr(),// 5
registerBrokerBody.getTopicConfigSerializeWrapper(), // 6
registerBrokerBody.getFilterServerList(),//
ctx.channel()// 7
);
responseHeader.setHaServerAddr(result.getHaServerAddr());
responseHeader.setMasterAddr(result.getMasterAddr());
byte[] jsonValue = this.namesrvController.getKvConfigManager().getKVListByNamespace(NamesrvUtil.NAMESPACE_ORDER_TOPIC_CONFIG);
response.setBody(jsonValue);
response.setCode(ResponseCode.SUCCESS);
response.setRemark(null);
return response;
}
示例12: getProjectGroupByIp
import com.alibaba.rocketmq.common.namesrv.NamesrvUtil; //导入依赖的package包/类
/**
* Name Server: 通过 server ip 获取 project 信息
*/
public String getProjectGroupByIp(String ip, final long timeoutMillis) throws RemotingException,
MQClientException, InterruptedException {
return getKVConfigValue(NamesrvUtil.NAMESPACE_PROJECT_CONFIG, ip, timeoutMillis);
}
示例13: getIpsByProjectGroup
import com.alibaba.rocketmq.common.namesrv.NamesrvUtil; //导入依赖的package包/类
@Override
public String getIpsByProjectGroup(String projectGroup) throws RemotingException, MQBrokerException,
InterruptedException, MQClientException {
String namespace = NamesrvUtil.NAMESPACE_PROJECT_CONFIG;
return this.mQClientFactory.getMQClientAPIImpl().getKVConfigByValue(namespace, projectGroup, 3000);
}
示例14: deleteIpsByProjectGroup
import com.alibaba.rocketmq.common.namesrv.NamesrvUtil; //导入依赖的package包/类
@Override
public void deleteIpsByProjectGroup(String projectGroup) throws RemotingException, MQBrokerException,
InterruptedException, MQClientException {
String namespace = NamesrvUtil.NAMESPACE_PROJECT_CONFIG;
this.mQClientFactory.getMQClientAPIImpl().deleteKVConfigByValue(namespace, projectGroup, 3000);
}