Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions conf/broker.conf
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,8 @@ deleteWhen=04
fileReservedTime=48
brokerRole=ASYNC_MASTER
flushDiskType=ASYNC_FLUSH

# rocketMQ broker port config
# you can change it at here, and it will take effect at next start-up.
# default port is 10911
port=10911
19 changes: 19 additions & 0 deletions conf/namesrv.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# rocketMQ nameserver port config
# you can change it at here, and it will take effect at next start-up.
# default port is 9876
port=9876
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ public static BrokerController createBrokerController(String[] args) {
final BrokerConfig brokerConfig = new BrokerConfig();
final NettyServerConfig nettyServerConfig = new NettyServerConfig();
final NettyClientConfig nettyClientConfig = new NettyClientConfig();
nettyServerConfig.setListenPort(10911);
final MessageStoreConfig messageStoreConfig = new MessageStoreConfig();

if (BrokerRole.SLAVE == messageStoreConfig.getBrokerRole()) {
Expand All @@ -122,24 +121,30 @@ public static BrokerController createBrokerController(String[] args) {
System.exit(0);
}

if (commandLine.hasOption('c')) {
String file = commandLine.getOptionValue('c');
if (file != null) {
configFile = file;
InputStream in = new BufferedInputStream(new FileInputStream(file));
properties = new Properties();
properties.load(in);

parsePropertie2SystemEnv(properties);
MixAll.properties2Object(properties, brokerConfig);
MixAll.properties2Object(properties, nettyServerConfig);
MixAll.properties2Object(properties, nettyClientConfig);
MixAll.properties2Object(properties, messageStoreConfig);

BrokerPathConfigHelper.setBrokerConfigPath(file);
in.close();
}
String file = null;
if (commandLine.hasOption('c'))
file = commandLine.getOptionValue('c');
else
file = brokerConfig.getRocketmqHome() + "/conf/namesrv.conf";

if (file != null) {
configFile = file;
InputStream in = new BufferedInputStream(new FileInputStream(file));
properties = new Properties();
properties.load(in);

parsePropertie2SystemEnv(properties);
MixAll.properties2Object(properties, brokerConfig);
MixAll.properties2Object(properties, nettyServerConfig);
MixAll.properties2Object(properties, nettyClientConfig);
MixAll.properties2Object(properties, messageStoreConfig);

BrokerPathConfigHelper.setBrokerConfigPath(file);
in.close();
}else{
System.out.print("load config properties file failed, please make sure that the file: " + file + " is readable%n");
}
nettyServerConfig.setListenPort(brokerConfig.getPort());

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

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.alibaba.rocketmq.broker;

import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* @author nottyjay
* @date 2016/12/25
*/
public class NameServerConnectorTest {

private static final Logger LOG = LoggerFactory.getLogger(BrokerControllerTest.class);

@Test
public void testConnectorWithDefaultPort() throws Exception {
BrokerStartup.start(BrokerStartup.createBrokerController(new String[]{"-n", "localhost:9876"}));
Thread.sleep(6000);
BrokerStartup.createBrokerController(new String[]{"-c"});
}

@Test
public void testConnectorWithOtherPort() throws Exception {
BrokerStartup.start(BrokerStartup.createBrokerController(new String[]{"-n", "localhost:12345"}));
Thread.sleep(6000);
BrokerStartup.createBrokerController(new String[]{"-c"});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -598,14 +598,6 @@ private void checkConfig() throws MQClientException {
// check consumerGroup
Validators.checkGroup(this.defaultMQPullConsumer.getConsumerGroup());

// consumerGroup
if (null == this.defaultMQPullConsumer.getConsumerGroup()) {
throw new MQClientException(
"consumerGroup is null" //
+ FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL), //
null);
}

// consumerGroup
if (this.defaultMQPullConsumer.getConsumerGroup().equals(MixAll.DEFAULT_CONSUMER_GROUP)) {
throw new MQClientException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class BrokerConfig {
@ImportantField
private long brokerId = MixAll.MASTER_ID;
private int brokerPermission = PermName.PERM_READ | PermName.PERM_WRITE;
private int port = 10911;
private int defaultTopicQueueNums = 8;
@ImportantField
private boolean autoCreateTopicEnable = true;
Expand Down Expand Up @@ -263,6 +264,13 @@ public void setBrokerClusterName(String brokerClusterName) {
this.brokerClusterName = brokerClusterName;
}

public int getPort() {
return port;
}

public void setPort(int port) {
this.port = port;
}

public String getBrokerIP1() {
return brokerIP1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public class NamesrvConfig {
private boolean clusterTest = false;
private boolean orderMessageEnable = false;

private int port = 9876;

public boolean isOrderMessageEnable() {
return orderMessageEnable;
}
Expand Down Expand Up @@ -97,4 +99,12 @@ public String getConfigStorePath() {
public void setConfigStorePath(final String configStorePath) {
this.configStorePath = configStorePath;
}

public int getPort() {
return port;
}

public void setPort(int port) {
this.port = port;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,22 +79,28 @@ public static NamesrvController main0(String[] args) {

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, " + file + "%n");
in.close();
}

String file = null;
if (commandLine.hasOption('c'))
file = commandLine.getOptionValue('c');
else
file = namesrvConfig.getRocketmqHome() + "/conf/namesrv.conf";

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, " + file + "%n");
in.close();
}else{
System.out.print("load config properties file failed, please make sure that the file: " + file + " is readable%n");
}
nettyServerConfig.setListenPort(namesrvConfig.getPort());


if (commandLine.hasOption('p')) {
Expand Down