You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2022/09/15 03:25:34 UTC
[GitHub] [rocketmq] xdkxlk opened a new pull request, #5083: [ISSUE #5069] polish the startup of proxy; can specify parameters on the command line of proxy
xdkxlk opened a new pull request, #5083:
URL: https://github.com/apache/rocketmq/pull/5083
**Make sure set the target branch to `develop`**
## What is the purpose of the change
Nowadays, proxy can only be configured by configuration file, it is not convenient to use.
## Brief changelog
Proxy can config these parameters on the command line
- `-n` `--namesrvAddr`, the nameserver addr
- `-pc` `--proxyConfigPath`, the path of proxy config file
- `-pm` `--proxyMode`, proxy run in local or cluster mode
- `-bc` `--brokerConfigPath`, the path of broker config file when proxy run in local mode
Meanwhile, we can start local mode proxy with mqbroker like `sh bin/mqbroker -n 127.0.0.1:9876 -c /path/to/broker.properties --enable-proxy`, and shutdown by `sh bin/mqshutdown broker`
## Verifying this change
XXXX
Follow this checklist to help us incorporate your contribution quickly and easily. Notice, `it would be helpful if you could finish the following 5 checklist(the last one is not necessary)before request the community to review your PR`.
- [x] Make sure there is a [Github issue](https://github.com/apache/rocketmq/issues) filed for the change (usually before you start working on it). Trivial changes like typos do not require a Github issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
- [x] Format the pull request title like `[ISSUE #123] Fix UnknownException when host config not exist`. Each commit in the pull request should have a meaningful subject line and body.
- [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
- [x] Write necessary unit-test(over 80% coverage) to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add integration-test in [test module](https://github.com/apache/rocketmq/tree/master/test).
- [x] Run `mvn -B clean apache-rat:check findbugs:findbugs checkstyle:checkstyle` to make sure basic checks pass. Run `mvn clean install -DskipITs` to make sure unit-test pass. Run `mvn clean test-compile failsafe:integration-test` to make sure integration-test pass.
- [ ] If this contribution is large, please file an [Apache Individual Contributor License Agreement](http://www.apache.org/licenses/#clas).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [rocketmq] lollipopjin commented on a diff in pull request #5083: [ISSUE #5069] polish the startup of proxy; can specify parameters on the command line of proxy
Posted by GitBox <gi...@apache.org>.
lollipopjin commented on code in PR #5083:
URL: https://github.com/apache/rocketmq/pull/5083#discussion_r971661609
##########
proxy/src/main/java/org/apache/rocketmq/proxy/config/ProxyConfig.java:
##########
@@ -44,7 +45,7 @@ public class ProxyConfig implements ConfigFile {
private long printJstackInMillis = Duration.ofSeconds(60).toMillis();
private long printThreadPoolStatusInMillis = Duration.ofSeconds(3).toMillis();
- private String nameSrvAddr = "";
+ private String nameSrvAddr = System.getProperty(MixAll.NAMESRV_ADDR_PROPERTY, System.getenv(MixAll.NAMESRV_ADDR_ENV));
Review Comment:
rename nameSrvAddr to namesrvAddr, match the config in brokeConfig.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [rocketmq] codecov-commenter commented on pull request #5083: [ISSUE #5069] polish the startup of proxy; can specify parameters on the command line of proxy
Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #5083:
URL: https://github.com/apache/rocketmq/pull/5083#issuecomment-1247550275
# [Codecov](https://codecov.io/gh/apache/rocketmq/pull/5083?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#5083](https://codecov.io/gh/apache/rocketmq/pull/5083?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (7c47c90) into [develop](https://codecov.io/gh/apache/rocketmq/commit/b292012ad7ead9a1e9a15522a0cb8e6e40fa165d?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (b292012) will **increase** coverage by `0.05%`.
> The diff coverage is `72.85%`.
```diff
@@ Coverage Diff @@
## develop #5083 +/- ##
=============================================
+ Coverage 43.19% 43.25% +0.05%
- Complexity 7767 7784 +17
=============================================
Files 995 996 +1
Lines 69170 69225 +55
Branches 9154 9159 +5
=============================================
+ Hits 29879 29943 +64
+ Misses 35538 35526 -12
- Partials 3753 3756 +3
```
| [Impacted Files](https://codecov.io/gh/apache/rocketmq/pull/5083?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...rg/apache/rocketmq/proxy/config/Configuration.java](https://codecov.io/gh/apache/rocketmq/pull/5083/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHJveHkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL3Byb3h5L2NvbmZpZy9Db25maWd1cmF0aW9uLmphdmE=) | `71.42% <63.63%> (+19.57%)` | :arrow_up: |
| [...n/java/org/apache/rocketmq/proxy/ProxyStartup.java](https://codecov.io/gh/apache/rocketmq/pull/5083/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHJveHkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL3Byb3h5L1Byb3h5U3RhcnR1cC5qYXZh) | `33.87% <66.66%> (+33.87%)` | :arrow_up: |
| [...org/apache/rocketmq/proxy/CommandLineArgument.java](https://codecov.io/gh/apache/rocketmq/pull/5083/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHJveHkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL3Byb3h5L0NvbW1hbmRMaW5lQXJndW1lbnQuamF2YQ==) | `100.00% <100.00%> (ø)` | |
| [.../org/apache/rocketmq/proxy/config/ProxyConfig.java](https://codecov.io/gh/apache/rocketmq/pull/5083/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHJveHkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL3Byb3h5L2NvbmZpZy9Qcm94eUNvbmZpZy5qYXZh) | `49.74% <100.00%> (+0.77%)` | :arrow_up: |
| [...apache/rocketmq/broker/longpolling/PopRequest.java](https://codecov.io/gh/apache/rocketmq/pull/5083/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YnJva2VyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9icm9rZXIvbG9uZ3BvbGxpbmcvUG9wUmVxdWVzdC5qYXZh) | `31.03% <0.00%> (-13.80%)` | :arrow_down: |
| [...ache/rocketmq/common/stats/MomentStatsItemSet.java](https://codecov.io/gh/apache/rocketmq/pull/5083/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9jb21tb24vc3RhdHMvTW9tZW50U3RhdHNJdGVtU2V0LmphdmE=) | `39.13% <0.00%> (-4.35%)` | :arrow_down: |
| [.../apache/rocketmq/controller/ControllerManager.java](https://codecov.io/gh/apache/rocketmq/pull/5083/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29udHJvbGxlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcm9ja2V0bXEvY29udHJvbGxlci9Db250cm9sbGVyTWFuYWdlci5qYXZh) | `73.11% <0.00%> (-2.16%)` | :arrow_down: |
| [...mq/client/impl/consumer/RebalanceLitePullImpl.java](https://codecov.io/gh/apache/rocketmq/pull/5083/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2xpZW50L3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9jbGllbnQvaW1wbC9jb25zdW1lci9SZWJhbGFuY2VMaXRlUHVsbEltcGwuamF2YQ==) | `69.86% <0.00%> (-1.37%)` | :arrow_down: |
| [...a/org/apache/rocketmq/store/StoreStatsService.java](https://codecov.io/gh/apache/rocketmq/pull/5083/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3RvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL3N0b3JlL1N0b3JlU3RhdHNTZXJ2aWNlLmphdmE=) | `39.77% <0.00%> (-0.56%)` | :arrow_down: |
| [...he/rocketmq/client/trace/AsyncTraceDispatcher.java](https://codecov.io/gh/apache/rocketmq/pull/5083/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2xpZW50L3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9jbGllbnQvdHJhY2UvQXN5bmNUcmFjZURpc3BhdGNoZXIuamF2YQ==) | `82.85% <0.00%> (-0.48%)` | :arrow_down: |
| ... and [14 more](https://codecov.io/gh/apache/rocketmq/pull/5083/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [rocketmq] lollipopjin merged pull request #5083: [ISSUE #5069] polish the startup of proxy; can specify parameters on the command line of proxy
Posted by GitBox <gi...@apache.org>.
lollipopjin merged PR #5083:
URL: https://github.com/apache/rocketmq/pull/5083
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [rocketmq] Oliverwqcwrw commented on pull request #5083: [ISSUE #5069] polish the startup of proxy; can specify parameters on the command line of proxy
Posted by GitBox <gi...@apache.org>.
Oliverwqcwrw commented on PR #5083:
URL: https://github.com/apache/rocketmq/pull/5083#issuecomment-1248837053
linked #5069
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [rocketmq] xdkxlk commented on a diff in pull request #5083: [ISSUE #5069] polish the startup of proxy; can specify parameters on the command line of proxy
Posted by GitBox <gi...@apache.org>.
xdkxlk commented on code in PR #5083:
URL: https://github.com/apache/rocketmq/pull/5083#discussion_r972669257
##########
proxy/src/main/java/org/apache/rocketmq/proxy/config/ProxyConfig.java:
##########
@@ -44,7 +45,7 @@ public class ProxyConfig implements ConfigFile {
private long printJstackInMillis = Duration.ofSeconds(60).toMillis();
private long printThreadPoolStatusInMillis = Duration.ofSeconds(3).toMillis();
- private String nameSrvAddr = "";
+ private String nameSrvAddr = System.getProperty(MixAll.NAMESRV_ADDR_PROPERTY, System.getenv(MixAll.NAMESRV_ADDR_ENV));
Review Comment:
done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [rocketmq] lollipopjin commented on a diff in pull request #5083: [ISSUE #5069] polish the startup of proxy; can specify parameters on the command line of proxy
Posted by GitBox <gi...@apache.org>.
lollipopjin commented on code in PR #5083:
URL: https://github.com/apache/rocketmq/pull/5083#discussion_r972687135
##########
proxy/src/test/java/org/apache/rocketmq/proxy/ProxyStartupTest.java:
##########
@@ -0,0 +1,140 @@
+/*
+ * 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.
+ */
+
+package org.apache.rocketmq.proxy;
+
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import org.apache.rocketmq.client.log.ClientLogger;
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.proxy.config.Configuration;
+import org.apache.rocketmq.proxy.config.ConfigurationManager;
+import org.apache.rocketmq.proxy.config.ProxyConfig;
+import org.assertj.core.util.Strings;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.apache.rocketmq.proxy.config.ConfigurationManager.RMQ_PROXY_HOME;
+import static org.junit.Assert.assertEquals;
+
+public class ProxyStartupTest {
+
+ public static String mockProxyHome = "/mock/rmq/proxy/home";
+
+ @Before
+ public void before() throws Throwable {
+ URL mockProxyHomeURL = getClass().getClassLoader().getResource("rmq-proxy-home");
+ if (mockProxyHomeURL != null) {
+ mockProxyHome = mockProxyHomeURL.toURI().getPath();
+ }
+
+ if (!Strings.isNullOrEmpty(mockProxyHome)) {
+ System.setProperty(RMQ_PROXY_HOME, mockProxyHome);
+ }
+ }
+
+ @After
+ public void after() {
+ System.clearProperty(RMQ_PROXY_HOME);
+ System.clearProperty(MixAll.NAMESRV_ADDR_PROPERTY);
+ System.clearProperty(Configuration.CONFIG_PATH_PROPERTY);
+ System.clearProperty(ClientLogger.CLIENT_LOG_USESLF4J);
+ }
+
+ @Test
+ public void testParseAndInitCommandLineArgument() throws Exception {
+ Path configFilePath = Files.createTempFile("testParseAndInitCommandLineArgument", ".json");
+ String configData = "{}";
+ Files.write(configFilePath, configData.getBytes(StandardCharsets.UTF_8));
+
+ String brokerConfigPath = "brokerConfigPath";
+ String proxyConfigPath = configFilePath.toAbsolutePath().toString();
+ String proxyMode = "LOCAL";
+ String namesrvAddr = "namesrvAddr";
+ CommandLineArgument commandLineArgument = ProxyStartup.parseCommandLineArgument(new String[] {
+ "-bc", brokerConfigPath,
+ "-pc", proxyConfigPath,
+ "-pm", proxyMode,
+ "-n", namesrvAddr
+ });
+
+ assertEquals(brokerConfigPath, commandLineArgument.getBrokerConfigPath());
+ assertEquals(proxyConfigPath, commandLineArgument.getProxyConfigPath());
+ assertEquals(proxyMode, commandLineArgument.getProxyMode());
+ assertEquals(namesrvAddr, commandLineArgument.getNamesrvAddr());
+
+ ProxyStartup.initLogAndConfiguration(commandLineArgument);
+
+ ProxyConfig config = ConfigurationManager.getProxyConfig();
+ assertEquals(brokerConfigPath, config.getBrokerConfigPath());
+ assertEquals(proxyMode, config.getProxyMode());
+ assertEquals(namesrvAddr, config.getNamesrvAddr());
+ }
+
+ @Test
+ public void testLoadNameSrvAddrByProperty() throws Exception {
+ String namesrvAddr = "namesrvAddr";
+ System.setProperty(MixAll.NAMESRV_ADDR_PROPERTY, namesrvAddr);
+ CommandLineArgument commandLineArgument = ProxyStartup.parseCommandLineArgument(new String[] {});
+ ProxyStartup.initLogAndConfiguration(commandLineArgument);
+
+ ProxyConfig config = ConfigurationManager.getProxyConfig();
+ assertEquals(namesrvAddr, config.getNamesrvAddr());
+ }
+
+ @Test
+ public void testLoadNameSrvAddrByConfigFile() throws Exception {
+ String namesrvAddr = "namesrvAddr";
+ System.setProperty(MixAll.NAMESRV_ADDR_PROPERTY, "foo");
+ Path configFilePath = Files.createTempFile("testLoadNameSrvAddrByConfigFile", ".json");
+ String configData = "{\n" +
+ " \"nameSrvAddr\": \"namesrvAddr\"\n" +
+ "}";
+ Files.write(configFilePath, configData.getBytes(StandardCharsets.UTF_8));
+
+ CommandLineArgument commandLineArgument = ProxyStartup.parseCommandLineArgument(new String[] {
+ "-pc", configFilePath.toAbsolutePath().toString()
+ });
+ ProxyStartup.initLogAndConfiguration(commandLineArgument);
+
+ ProxyConfig config = ConfigurationManager.getProxyConfig();
+ assertEquals(namesrvAddr, config.getNamesrvAddr());
+ }
+
+ @Test
+ public void testLoadNameSrvAddrByCommandLine() throws Exception {
+ String namesrvAddr = "namesrvAddr";
+ System.setProperty(MixAll.NAMESRV_ADDR_PROPERTY, "foo");
+ Path configFilePath = Files.createTempFile("testLoadNameSrvAddrByConfigFile", ".json");
+ String configData = "{\n" +
+ " \"nameSrvAddr\": \"foo\"\n" +
+ "}";
+ Files.write(configFilePath, configData.getBytes(StandardCharsets.UTF_8));
+
+ CommandLineArgument commandLineArgument = ProxyStartup.parseCommandLineArgument(new String[] {
Review Comment:
Add a case to make sure it works with "-bc xx/broker.conf" arguments
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org