use of org.apache.rocketmq.common.BrokerConfig in project rocketmq by apache.
the class CommitLogDispatcherCalcBitMapTest method testDispatch_filterDataIllegal.
@Test
public void testDispatch_filterDataIllegal() {
BrokerConfig brokerConfig = new BrokerConfig();
brokerConfig.setEnableCalcFilterBitMap(true);
ConsumerFilterManager filterManager = new ConsumerFilterManager();
filterManager.register("topic0", "CID_0", "a is not null and a >= 5", ExpressionType.SQL92, System.currentTimeMillis());
filterManager.register("topic0", "CID_1", "a is not null and a >= 15", ExpressionType.SQL92, System.currentTimeMillis());
ConsumerFilterData nullExpression = filterManager.get("topic0", "CID_0");
nullExpression.setExpression(null);
nullExpression.setCompiledExpression(null);
ConsumerFilterData nullBloomData = filterManager.get("topic0", "CID_1");
nullBloomData.setBloomFilterData(null);
CommitLogDispatcherCalcBitMap calcBitMap = new CommitLogDispatcherCalcBitMap(brokerConfig, filterManager);
for (int i = 0; i < 1; i++) {
Map<String, String> properties = new HashMap<String, String>(4);
properties.put("a", String.valueOf(i * 10 + 5));
String topic = "topic" + i;
DispatchRequest dispatchRequest = new DispatchRequest(topic, 0, i * 100 + 123, 100, (long) ("tags" + i).hashCode(), System.currentTimeMillis(), i, null, UUID.randomUUID().toString(), 0, 0, properties);
calcBitMap.dispatch(dispatchRequest);
assertThat(dispatchRequest.getBitMap()).isNotNull();
BitsArray bitsArray = BitsArray.create(dispatchRequest.getBitMap(), filterManager.getBloomFilter().getM());
for (int j = 0; j < bitsArray.bitLength(); j++) {
assertThat(bitsArray.getBit(j)).isFalse();
}
}
}
use of org.apache.rocketmq.common.BrokerConfig in project rocketmq-externals by apache.
the class IntegrationTestBase method createAndStartBroker.
public static BrokerController createAndStartBroker(String nsAddr) {
String baseDir = createBaseDir();
BrokerConfig brokerConfig = new BrokerConfig();
NettyServerConfig nettyServerConfig = new NettyServerConfig();
NettyClientConfig nettyClientConfig = new NettyClientConfig();
MessageStoreConfig storeConfig = new MessageStoreConfig();
brokerConfig.setBrokerName(BROKER_NAME_PREFIX + BROKER_INDEX.getAndIncrement());
brokerConfig.setBrokerIP1("127.0.0.1");
brokerConfig.setNamesrvAddr(nsAddr);
brokerConfig.setEnablePropertyFilter(true);
storeConfig.setStorePathRootDir(baseDir);
storeConfig.setStorePathCommitLog(baseDir + SEP + "commitlog");
storeConfig.setHaListenPort(8000 + random.nextInt(1000));
storeConfig.setMapedFileSizeCommitLog(COMMIT_LOG_SIZE);
storeConfig.setMaxIndexNum(INDEX_NUM);
storeConfig.setMaxHashSlotNum(INDEX_NUM * 4);
nettyServerConfig.setListenPort(10000 + random.nextInt(1000));
BrokerController brokerController = new BrokerController(brokerConfig, nettyServerConfig, nettyClientConfig, storeConfig);
try {
Assert.assertTrue(brokerController.initialize());
logger.info("Broker Start name:{} addr:{}", brokerConfig.getBrokerName(), brokerController.getBrokerAddr());
brokerController.start();
} catch (Exception e) {
logger.info("Broker start failed");
System.exit(1);
}
BROKER_CONTROLLERS.add(brokerController);
return brokerController;
}
use of org.apache.rocketmq.common.BrokerConfig in project rocketmq-externals by apache.
the class RocketMQServerMock method startBroker.
private void startBroker() throws Exception {
System.setProperty(RemotingCommand.REMOTING_VERSION_KEY, Integer.toString(MQVersion.CURRENT_VERSION));
BrokerConfig brokerConfig = new BrokerConfig();
brokerConfig.setNamesrvAddr(nameserverAddr);
brokerConfig.setBrokerId(MixAll.MASTER_ID);
NettyServerConfig nettyServerConfig = new NettyServerConfig();
nettyServerConfig.setListenPort(10911);
NettyClientConfig nettyClientConfig = new NettyClientConfig();
MessageStoreConfig messageStoreConfig = new MessageStoreConfig();
brokerController = new BrokerController(brokerConfig, nettyServerConfig, nettyClientConfig, messageStoreConfig);
boolean initResult = brokerController.initialize();
if (!initResult) {
brokerController.shutdown();
throw new Exception("Broker init failure!");
}
brokerController.start();
}
use of org.apache.rocketmq.common.BrokerConfig in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.
the class AbstractTestCase method startBroker.
/**
* Start rocketmq broker service
* @throws Exception
*/
private static void startBroker() throws Exception {
System.setProperty(RemotingCommand.REMOTING_VERSION_KEY, Integer.toString(MQVersion.CURRENT_VERSION));
BrokerConfig brokerConfig = new BrokerConfig();
brokerConfig.setNamesrvAddr(nameServer);
brokerConfig.setBrokerId(MixAll.MASTER_ID);
NettyServerConfig nettyServerConfig = new NettyServerConfig();
nettyServerConfig.setListenPort(10911);
NettyClientConfig nettyClientConfig = new NettyClientConfig();
MessageStoreConfig messageStoreConfig = new MessageStoreConfig();
brokerController = new BrokerController(brokerConfig, nettyServerConfig, nettyClientConfig, messageStoreConfig);
boolean initResult = brokerController.initialize();
if (!initResult) {
brokerController.shutdown();
throw new Exception();
}
brokerController.start();
}
use of org.apache.rocketmq.common.BrokerConfig in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.
the class DefaultMessageStoreTest method testWriteAndRead.
@Test
public void testWriteAndRead() throws Exception {
long totalMsgs = 100;
QUEUE_TOTAL = 1;
MessageBody = StoreMessage.getBytes();
MessageStoreConfig messageStoreConfig = new MessageStoreConfig();
messageStoreConfig.setMapedFileSizeCommitLog(1024 * 8);
messageStoreConfig.setMapedFileSizeConsumeQueue(1024 * 4);
messageStoreConfig.setMaxHashSlotNum(100);
messageStoreConfig.setMaxIndexNum(100 * 10);
MessageStore master = new DefaultMessageStore(messageStoreConfig, null, new MyMessageArrivingListener(), new BrokerConfig());
boolean load = master.load();
assertTrue(load);
master.start();
try {
for (long i = 0; i < totalMsgs; i++) {
master.putMessage(buildMessage());
}
for (long i = 0; i < totalMsgs; i++) {
GetMessageResult result = master.getMessage("GROUP_A", "TOPIC_A", 0, i, 1024 * 1024, null);
assertThat(result).isNotNull();
result.release();
}
} finally {
master.shutdown();
master.destroy();
}
}
Aggregations