Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加对properties文件的支持: ali-sentinel.properties #72

Closed
wants to merge 6 commits into from

Conversation

VanXD
Copy link

@VanXD VanXD commented Aug 17, 2018

Describe what this PR does / why we need it

更方便的对sentinel进行配置.
Convenient to write configuration.

Does this pull request fix one issue?

Fixes #64

Describe how you did it

  1. 兼容了原来的模式, 从JVM上加载相应的参数.
  2. 如果JVM上没有配置project.name,则使用默认的文件名"ali-sentinel.properties"进行加载.

  1. Compatible with old version.
  2. If project.name is not configured on the JVM, it is loaded with the default filename "ali-sentinel.properties".

Describe how to verify it

在resources文件夹下创建"ali-sentinel.properties"文件.并且在其中书写配置.
create file in resources dir, and write your configuration.

Special notes for reviews

no

@CLAassistant
Copy link

CLAassistant commented Aug 17, 2018

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ TragedyXD
❌ VanXD


VanXD seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@sczyh30 sczyh30 added the to-review To review label Aug 17, 2018
@codecov-io
Copy link

codecov-io commented Aug 17, 2018

Codecov Report

Merging #72 into master will increase coverage by 11.07%.
The diff coverage is 49.05%.

Impacted file tree graph

@@              Coverage Diff              @@
##             master      #72       +/-   ##
=============================================
+ Coverage     41.71%   52.79%   +11.07%     
+ Complexity     1376      911      -465     
=============================================
  Files           304      150      -154     
  Lines          8764     5097     -3667     
  Branches       1182      733      -449     
=============================================
- Hits           3656     2691      -965     
+ Misses         4662     2083     -2579     
+ Partials        446      323      -123
Impacted Files Coverage Δ Complexity Δ
...ava/com/alibaba/csp/sentinel/util/AppNameUtil.java 88.88% <100%> (+45.41%) 4 <2> (-1) ⬇️
...ava/com/alibaba/csp/sentinel/util/ClassHelper.java 44.44% <44.44%> (ø) 4 <4> (?)
...om/alibaba/csp/sentinel/config/SentinelConfig.java 59.13% <51.02%> (+7.52%) 15 <3> (+1) ⬆️
...ain/java/com/alibaba/csp/sentinel/util/IdUtil.java 0% <0%> (-100%) 0% <0%> (-6%)
.../sentinel/adapter/dubbo/DubboAppContextFilter.java 0% <0%> (-100%) 0% <0%> (-3%)
...sp/sentinel/adapter/dubbo/AbstractDubboFilter.java 0% <0%> (-100%) 0% <0%> (-4%)
...alibaba/csp/sentinel/adapter/dubbo/DubboUtils.java 0% <0%> (-66.67%) 0% <0%> (-2%)
...nel/adapter/dubbo/SentinelDubboProviderFilter.java 0% <0%> (-64%) 0% <0%> (-2%)
...nel/adapter/dubbo/SentinelDubboConsumerFilter.java 0% <0%> (-57.15%) 0% <0%> (-2%)
...ntinel/slots/block/flow/param/ParameterMetric.java 23.33% <0%> (-51.67%) 7% <0%> (-22%)
... and 270 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 062385f...d4c9840. Read the comment docs.

@VanXD
Copy link
Author

VanXD commented Aug 22, 2018

这个license/cla Pending就没法解决了么。。我已经去details里签署过了。

@sczyh30
Copy link
Member

sczyh30 commented Aug 22, 2018

请查看对应 GitHub 账号是否正确,包括产生的提交记录的 email 需要与当前 GitHub 账号一致。貌似你的提交记录里 email 和当前账号不对应。

===

Please make sure that the email of your commits matches the email of your GitHub account.

@TragedyXD
Copy link

非常感谢, 我换了帐号过来.

@@ -34,6 +34,7 @@
*/
public class SentinelConfig {

private static final String DEFAULT_PROPERTIES_NAME = "ali-sentinel";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sentinel is better

import java.net.URL;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;

/**
* The universal config of Courier. The config is retrieved from
* {@code ${user.home}/logs/csp/${appName}.properties} by default.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

classpath is better.

@kimmking
Copy link
Contributor

add some tests

@TragedyXD
Copy link

add some tests

参考了dubbo那边对config进行的测试

===

reference config tests from dubbo.

@@ -60,34 +60,15 @@ private AppNameUtil() {
RecordLog.info("App name resolved: " + appName);
}

/**
* resolve app name from jvm options
*/
public static void resolveAppName() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to consider the case when project.name is absent both in system property and configuration file, so we have to provide a default parsed appName rather than empty.

@@ -93,6 +98,7 @@ private static void loadProps() {
RecordLog.info("[SentinelConfig] JVM parameter overrides {0}: {1} -> {2}", configKey, configValueOld, configValue);
}
}
AppNameUtil.setAppName(SentinelConfig.getConfig(AppNameUtil.APP_NAME));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to consider what if the appName from SentinelConfig is invalid (null or empty)?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

您的两个问题都是关于appName不合法, 在dubbo里dubbo.application.name是必填项, 不配置启动会异常.
如果我们这里需要一个默认值的话, 那或许我可以在resolveAppName()中改为解析不到project.name就设置成"sentinel".
综合你们的考虑看需要怎么改呢, 因为这里主要目的是为了加载配置文件.

@sentinel-bot
Copy link
Collaborator

Ping @VanXD . Conflict happens after merging a previous commit. Please rebase the branch against master and push it back again. Thanks a lot.

@sentinel-bot sentinel-bot added the merge-conflict Category prs with merge conflict. label Jan 18, 2019
@sczyh30 sczyh30 added the area/configuration Issues or PRs related to configurations of Sentinel label Apr 11, 2019
@pouchrobot
Copy link

ping @VanXD
Conflict happens after merging a previous commit.
Please rebase the branch against master and push it back again. Thanks a lot.

@sczyh30
Copy link
Member

sczyh30 commented Jul 8, 2019

Resolved via #804. Anyway thanks for nice work!

@sczyh30 sczyh30 closed this Jul 8, 2019
@sczyh30 sczyh30 removed the to-review To review label Jul 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/configuration Issues or PRs related to configurations of Sentinel merge-conflict Category prs with merge conflict.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

properties加载建议?
8 participants