RocketMQ高手之路系列之三:RocketMQ之路由中心

public static NamesrvController main0(String[] args) {

try {

//创建NamesrvController

NamesrvController controller = createNamesrvController(args);

//启动NamesrvController

start(controller);

String tip = “The Name Server boot success. serializeType=” + RemotingCommand.getSerializeTypeConfigInThisServer();

log.info(tip);

System.out.printf(“%s%n”, tip);

return controller;

} catch (Throwable e) {

e.printStackTrace();

System.exit(-1);

}

return null;

}

创建NamesrvController 实例,源码如下所示:

public static NamesrvController createNamesrvController(String[] args) throws IOException, JoranException {

System.setProperty(RemotingCommand.REMOTING_VERSION_KEY, Integer.toString(MQVersion.CURRENT_VERSION));

//PackageConflictDetect.detectFastjson();

//读取启动参数

Options options = ServerUtil.buildCommandlineOptions(new Options());

commandLine = ServerUtil.parseCmdLine(“mqnamesrv”, args, buildCommandlineOptions(options), new PosixParser());

if (null == commandLine) {

System.exit(-1);

return null;

}

//NamesrvConfig为NameServer配置,NettyServerConfig为Netty配置,用来构造NamesrvController

final NamesrvConfig namesrvConfig = new NamesrvConfig();

final NettyServerConfig nettyServerConfig = new NettyServerConfig();

nettyServerConfig.setListenPort(9876);

if (commandLine.hasOption(‘c’)) {

String file = commandLine.getOptionValue(‘c’);

if (file != null) {

InputStream in = new BufferedInputStream(new FileInputStream(file));

properties = new Properties();

properties.load(in);

MixAll.properties2Object(properties, namesrvConfig);

MixAll.properties2Object(properties, nettyServerConfig);

namesrvConfig.setConfigStorePath(file);

System.out.printf(“load config properties file OK, %s%n”, file);

in.close();

}

}

if (commandLine.hasOption(‘p’)) {

InternalLogger console = InternalLoggerFactory.getLogger(LoggerName.NAMESRV_CONSOLE_NAME);

MixAll.printObjectProperties(console, namesrvConfig);

MixAll.printObjectProperties(console, nettyServerConfig);

System.exit(0);

}

MixAll.properties2Object(ServerUtil.commandLine2Properties(commandLine), namesrvConfig);

if (null == namesrvConfig.getRocketmqHome()) {

System.out.printf(“Please set the %s variable in your environment to match the location of the RocketMQ installation%n”, MixAll.ROCKETMQ_HOME_ENV);

System.exit(-2);

}

LoggerContext lc =

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值