Skip to content

Commit bfd6410

Browse files
committed
Merge branch 'refs/heads/develop' into dev-tofastjson2
2 parents 2569b68 + e6ec760 commit bfd6410

45 files changed

Lines changed: 235 additions & 259 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CONTRIBUTING.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
We are always very happy to have contributions, whether for trivial cleanups or big new features.
44
We want to have high quality, well documented codes for each programming language, as well as the surrounding [ecosystem](https://github.com/apache/rocketmq-externals) of integration tools that people use with RocketMQ.
55

6-
Nor is code the only way to contribute to the project. We strongly value documentation, integration with other project, and gladly accept improvements for these aspects.
6+
Nor is code the only way to contribute to the project. We strongly value documentation, integration with other projects, and gladly accept improvements for these aspects.
77

88
Recommend reading:
99
* [Contributors Tech Guide](http://www.apache.org/dev/contributors)
@@ -34,15 +34,15 @@ More details of squash can be found at [stackoverflow](https://stackoverflow.com
3434

3535
We are always interested in adding new contributors. What we look for are series of contributions, good taste and ongoing interest in the project. If you are interested in becoming a committer, please let one of the existing committers know and they can help you walk through the process.
3636

37-
Nowadays,we have several important contribution points:
37+
Nowadays, we have several important contribution points:
3838
#### Wiki & JavaDoc
3939
#### RocketMQ SDK(C++\.Net\Php\Python\Go\Node.js)
4040
#### RocketMQ Connectors
4141

42-
##### Prerequisite
43-
If you want to contribute the above listing points, you must abide our some prerequisites:
42+
##### Prerequisites
43+
If you want to contribute to the above listed points, you must abide by the following prerequisites:
4444

45-
###### Readability - API must have Javadoc, some very important methods also must have javadoc
46-
###### Testability - 80% above unit test coverage about main process
47-
###### Maintainability - Comply with our [checkstyle spec](style/rmq_checkstyle.xml), and at least 3 month update frequency
45+
###### Readability - API must have Javadoc, and some very important methods must also have Javadoc
46+
###### Testability - Above 80% unit test coverage for the main process
47+
###### Maintainability - Comply with our [checkstyle spec](style/rmq_checkstyle.xml), and at least a 3-month update frequency
4848
###### Deployability - We encourage you to deploy into [maven repository](http://search.maven.org/)

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ It offers a variety of features:
1616

1717
* Messaging patterns including publish/subscribe, request/reply and streaming
1818
* Financial grade transactional message
19-
* Built-in fault tolerance and high availability configuration options base on [DLedger Controller](docs/en/controller/quick_start.md)
20-
* Built-in message tracing capability, also support opentracing
19+
* Built-in fault tolerance and high availability configuration options based on [DLedger Controller](docs/en/controller/quick_start.md)
20+
* Built-in message tracing capability, also supports opentracing
2121
* Versatile big-data and streaming ecosystem integration
2222
* Message retroactivity by time or offset
2323
* Reliable FIFO and strict ordered messaging in the same queue
@@ -80,7 +80,7 @@ $ tail -f ~/logs/rocketmqlogs/namesrv.log
8080
The Name Server boot success...
8181
```
8282

83-
For Windows users, you need set environment variables first:
83+
For Windows users, you need to set environment variables first:
8484
- From the desktop, right click the Computer icon.
8585
- Choose Properties from the context menu.
8686
- Click the Advanced system settings link.
@@ -139,7 +139,7 @@ Before your operations, make sure that `kubectl` and related kubeconfig file ins
139139
$ git clone https://github.com/apache/rocketmq-operator
140140
$ cd rocketmq-operator && make deploy
141141

142-
### check whether CRDs is successfully installed
142+
### check whether CRDs are successfully installed
143143
$ kubectl get crd | grep rocketmq.apache.org
144144
brokers.rocketmq.apache.org 2022-05-12T09:23:18Z
145145
consoles.rocketmq.apache.org 2022-05-12T09:23:19Z
@@ -156,7 +156,7 @@ rocketmq-operator-6f65c77c49-8hwmj 1/1 Running 0 93s
156156
### create RocketMQ cluster resource
157157
$ cd example && kubectl create -f rocketmq_v1alpha1_rocketmq_cluster.yaml
158158

159-
### check whether cluster resources is running
159+
### check whether cluster resources are running
160160
$ kubectl get sts
161161
NAME READY AGE
162162
broker-0-master 1/1 107m
@@ -182,7 +182,7 @@ name-service 1/1 107m
182182
* [RocketMQ Dashboard](https://github.com/apache/rocketmq-dashboard): Operation and maintenance console of Apache RocketMQ.
183183
* [RocketMQ Connect](https://github.com/apache/rocketmq-connect): A tool for scalably and reliably streaming data between Apache RocketMQ and other systems.
184184
* [RocketMQ MQTT](https://github.com/apache/rocketmq-mqtt): A new MQTT protocol architecture model, based on which Apache RocketMQ can better support messages from terminals such as IoT devices and Mobile APP.
185-
* [RocketMQ EventBridge](https://github.com/apache/rocketmq-eventbridge): EventBridge make it easier to build a event-driven application.
185+
* [RocketMQ EventBridge](https://github.com/apache/rocketmq-eventbridge): EventBridge makes it easier to build an event-driven application.
186186
* [RocketMQ Incubating Community Projects](https://github.com/apache/rocketmq-externals): Incubator community projects of Apache RocketMQ, including [logappender](https://github.com/apache/rocketmq-externals/tree/master/logappender), [rocketmq-ansible](https://github.com/apache/rocketmq-externals/tree/master/rocketmq-ansible), [rocketmq-beats-integration](https://github.com/apache/rocketmq-externals/tree/master/rocketmq-beats-integration), [rocketmq-cloudevents-binding](https://github.com/apache/rocketmq-externals/tree/master/rocketmq-cloudevents-binding), etc.
187187
* [RocketMQ Site](https://github.com/apache/rocketmq-site): The repository for Apache RocketMQ website.
188188
* [RocketMQ E2E](https://github.com/apache/rocketmq-e2e): A project for testing Apache RocketMQ, including end-to-end, performance, compatibility tests.

auth/src/main/java/org/apache/rocketmq/auth/authentication/manager/AuthenticationMetadataManagerImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,14 +208,14 @@ private void handleException(Exception e, CompletableFuture<?> result) {
208208

209209
private AuthenticationMetadataProvider getAuthenticationMetadataProvider() {
210210
if (authenticationMetadataProvider == null) {
211-
throw new IllegalStateException("The authenticationMetadataProvider is not configured");
211+
throw new IllegalStateException("The authenticationMetadataProvider is not configured.");
212212
}
213213
return authenticationMetadataProvider;
214214
}
215215

216216
private AuthorizationMetadataProvider getAuthorizationMetadataProvider() {
217217
if (authorizationMetadataProvider == null) {
218-
throw new IllegalStateException("The authorizationMetadataProvider is not configured");
218+
throw new IllegalStateException("The authorizationMetadataProvider is not configured.");
219219
}
220220
return authorizationMetadataProvider;
221221
}

auth/src/main/java/org/apache/rocketmq/auth/authentication/strategy/AbstractAuthenticationStrategy.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
*/
1717
package org.apache.rocketmq.auth.authentication.strategy;
1818

19-
import java.util.ArrayList;
20-
import java.util.List;
19+
import java.util.HashSet;
20+
import java.util.Set;
2121
import java.util.function.Supplier;
2222
import org.apache.commons.lang3.StringUtils;
2323
import org.apache.rocketmq.auth.authentication.context.AuthenticationContext;
@@ -30,7 +30,7 @@
3030
public abstract class AbstractAuthenticationStrategy implements AuthenticationStrategy {
3131

3232
protected final AuthConfig authConfig;
33-
protected final List<String> authenticationWhitelist = new ArrayList<>();
33+
protected final Set<String> authenticationWhiteSet = new HashSet<>();
3434
protected final AuthenticationProvider<AuthenticationContext> authenticationProvider;
3535

3636
public AbstractAuthenticationStrategy(AuthConfig authConfig, Supplier<?> metadataService) {
@@ -42,7 +42,7 @@ public AbstractAuthenticationStrategy(AuthConfig authConfig, Supplier<?> metadat
4242
if (StringUtils.isNotBlank(authConfig.getAuthenticationWhitelist())) {
4343
String[] whitelist = StringUtils.split(authConfig.getAuthenticationWhitelist(), ",");
4444
for (String rpcCode : whitelist) {
45-
this.authenticationWhitelist.add(StringUtils.trim(rpcCode));
45+
this.authenticationWhiteSet.add(StringUtils.trim(rpcCode));
4646
}
4747
}
4848
}
@@ -57,7 +57,7 @@ protected void doEvaluate(AuthenticationContext context) {
5757
if (this.authenticationProvider == null) {
5858
return;
5959
}
60-
if (this.authenticationWhitelist.contains(context.getRpcCode())) {
60+
if (this.authenticationWhiteSet.contains(context.getRpcCode())) {
6161
return;
6262
}
6363
try {

auth/src/main/java/org/apache/rocketmq/auth/authorization/manager/AuthorizationMetadataManagerImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,15 +269,15 @@ private <T> CompletableFuture<T> handleException(Exception e) {
269269
}
270270

271271
private AuthenticationMetadataProvider getAuthenticationMetadataProvider() {
272-
if (authorizationMetadataProvider == null) {
272+
if (authenticationMetadataProvider == null) {
273273
throw new IllegalStateException("The authenticationMetadataProvider is not configured.");
274274
}
275275
return authenticationMetadataProvider;
276276
}
277277

278278
private AuthorizationMetadataProvider getAuthorizationMetadataProvider() {
279-
if (authenticationMetadataProvider == null) {
280-
throw new IllegalStateException("The authenticationMetadataProvider is not configured.");
279+
if (authorizationMetadataProvider == null) {
280+
throw new IllegalStateException("The authorizationMetadataProvider is not configured.");
281281
}
282282
return authorizationMetadataProvider;
283283
}

auth/src/main/java/org/apache/rocketmq/auth/authorization/provider/LocalAuthorizationMetadataProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public CompletableFuture<List<Acl>> listAcl(String subjectFilter, String resourc
148148
if (CollectionUtils.isEmpty(entries)) {
149149
continue;
150150
}
151-
if (StringUtils.isNotBlank(resourceFilter) && !subjectKey.contains(resourceFilter)) {
151+
if (StringUtils.isNotBlank(resourceFilter)) {
152152
entries.removeIf(entry -> !entry.toResourceStr().contains(resourceFilter));
153153
}
154154
if (CollectionUtils.isEmpty(entries)) {

auth/src/test/java/org/apache/rocketmq/auth/authorization/manager/AuthorizationMetadataManagerTest.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.apache.rocketmq.auth.authorization.factory.AuthorizationFactory;
2929
import org.apache.rocketmq.auth.authorization.model.Acl;
3030
import org.apache.rocketmq.auth.authorization.model.Policy;
31+
import org.apache.rocketmq.auth.authorization.model.PolicyEntry;
3132
import org.apache.rocketmq.auth.authorization.model.Resource;
3233
import org.apache.rocketmq.auth.config.AuthConfig;
3334
import org.apache.rocketmq.auth.helper.AuthTestHelper;
@@ -220,6 +221,10 @@ public void listAcl() {
220221
"192.168.0.0/24,10.10.0.0/24", Decision.ALLOW);
221222
this.authorizationMetadataManager.createAcl(acl2).join();
222223

224+
Acl acl3 = AuthTestHelper.buildAcl("User:test-2", "Topic:acl-2,Group:acl-2", "PUB,SUB",
225+
"192.168.0.0/24,10.10.0.0/24", Decision.ALLOW);
226+
this.authorizationMetadataManager.createAcl(acl3).join();
227+
223228
List<Acl> acls1 = this.authorizationMetadataManager.listAcl(null, null).join();
224229
Assert.assertEquals(acls1.size(), 2);
225230

@@ -235,13 +240,21 @@ public void listAcl() {
235240

236241
List<Acl> acls5 = this.authorizationMetadataManager.listAcl(null, "test-1").join();
237242
Assert.assertEquals(acls5.size(), 1);
238-
Assert.assertEquals(acls4.get(0).getPolicy(PolicyType.CUSTOM).getEntries().size(), 1);
243+
Assert.assertEquals(acls5.get(0).getPolicy(PolicyType.CUSTOM).getEntries().size(), 2);
239244

240245
List<Acl> acls6 = this.authorizationMetadataManager.listAcl("User:abc", null).join();
241246
Assert.assertTrue(CollectionUtils.isEmpty(acls6));
242247

243248
List<Acl> acls7 = this.authorizationMetadataManager.listAcl(null, "Topic:abc").join();
244249
Assert.assertTrue(CollectionUtils.isEmpty(acls7));
250+
251+
List<Acl> acls8 = this.authorizationMetadataManager.listAcl("test-2", "test-2").join();
252+
Assert.assertEquals(acls8.size(), 1);
253+
List<PolicyEntry> policyEntries = acls8.get(0).getPolicy(PolicyType.CUSTOM).getEntries();
254+
Assert.assertEquals(policyEntries.size(), 2);
255+
for (PolicyEntry policyEntry : policyEntries) {
256+
Assert.assertTrue(policyEntry.toResourceStr().contains("test-2"));
257+
}
245258
}
246259

247260
private void clearAllUsers() {

broker/src/main/java/org/apache/rocketmq/broker/BrokerStartup.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ public static ConfigContext configFileToConfigContext(String filePath) throws Ex
124124
NettyClientConfig nettyClientConfig = new NettyClientConfig();
125125
MessageStoreConfig messageStoreConfig = new MessageStoreConfig();
126126
AuthConfig authConfig = new AuthConfig();
127+
128+
nettyServerConfig.setListenPort(10911);
129+
messageStoreConfig.setHaListenPort(0);
130+
127131
Properties properties = new Properties();
128132
if (StringUtils.isNotBlank(filePath)) {
129133
systemConfigFileHelper.setFile(filePath);
@@ -161,9 +165,6 @@ public static BrokerController buildBrokerController(ConfigContext configContext
161165
AuthConfig authConfig = configContext.getAuthConfig();
162166
Properties properties = configContext.getProperties();
163167

164-
nettyServerConfig.setListenPort(10911);
165-
configContext.getMessageStoreConfig().setHaListenPort(0);
166-
167168
if (null == brokerConfig.getRocketmqHome()) {
168169
System.out.printf("Please set the %s variable in your environment " +
169170
"to match the location of the RocketMQ installation", MixAll.ROCKETMQ_HOME_ENV);

broker/src/main/java/org/apache/rocketmq/broker/processor/SendMessageProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ public RemotingCommand sendMessage(final ChannelHandlerContext ctx,
356356
}
357357
handlePutMessageResult(putMessageResult, response, request, msgInner, responseHeader, sendMessageContext, ctx, queueIdInt, beginTimeMillis, mappingContext, BrokerMetricsManager.getMessageType(requestHeader));
358358
// record the transaction metrics
359-
if (putMessageResult.getPutMessageStatus() == PutMessageStatus.PUT_OK && putMessageResult.getAppendMessageResult().isOk()) {
359+
if (sendTransactionPrepareMessage && putMessageResult.getPutMessageStatus() == PutMessageStatus.PUT_OK && putMessageResult.getAppendMessageResult().isOk()) {
360360
this.brokerController.getTransactionalMessageService().getTransactionMetrics().addAndGet(msgInner.getProperty(MessageConst.PROPERTY_REAL_TOPIC), 1);
361361
}
362362
sendMessageCallback.onComplete(sendMessageContext, response);

broker/src/test/java/org/apache/rocketmq/broker/config/v2/ConsumerOffsetManagerV2Test.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import org.apache.rocketmq.store.config.MessageStoreConfig;
2727
import org.junit.After;
2828
import org.junit.Assert;
29-
import org.junit.Assume;
3029
import org.junit.Before;
3130
import org.junit.Rule;
3231
import org.junit.Test;
@@ -60,7 +59,6 @@ public void cleanUp() {
6059

6160
@Before
6261
public void setUp() throws IOException {
63-
Assume.assumeFalse(MixAll.isMac());
6462
BrokerConfig brokerConfig = new BrokerConfig();
6563
Mockito.doReturn(brokerConfig).when(controller).getBrokerConfig();
6664

@@ -77,7 +75,6 @@ public void setUp() throws IOException {
7775
*/
7876
@Test
7977
public void testCommitOffset_Standard() {
80-
Assume.assumeFalse(MixAll.isMac());
8178
Assert.assertTrue(consumerOffsetManagerV2.load());
8279

8380
String clientHost = "localhost";
@@ -104,7 +101,6 @@ public void testCommitOffset_Standard() {
104101
*/
105102
@Test
106103
public void testCommitOffset_LMQ() {
107-
Assume.assumeFalse(MixAll.isMac());
108104
Assert.assertTrue(consumerOffsetManagerV2.load());
109105

110106
String clientHost = "localhost";
@@ -130,7 +126,6 @@ public void testCommitOffset_LMQ() {
130126
*/
131127
@Test
132128
public void testCommitPullOffset_LMQ() {
133-
Assume.assumeFalse(MixAll.isMac());
134129
Assert.assertTrue(consumerOffsetManagerV2.load());
135130

136131
String clientHost = "localhost";
@@ -155,7 +150,6 @@ public void testCommitPullOffset_LMQ() {
155150
*/
156151
@Test
157152
public void testRemoveByTopicAtGroup() {
158-
Assume.assumeFalse(MixAll.isMac());
159153
Assert.assertTrue(consumerOffsetManagerV2.load());
160154

161155
String clientHost = "localhost";
@@ -188,7 +182,6 @@ public void testRemoveByTopicAtGroup() {
188182
*/
189183
@Test
190184
public void testRemoveByGroup() {
191-
Assume.assumeFalse(MixAll.isMac());
192185
Assert.assertTrue(consumerOffsetManagerV2.load());
193186

194187
String clientHost = "localhost";

0 commit comments

Comments
 (0)