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

[SCB-636] change config mapping machanism #745

Merged
merged 6 commits into from
Jun 11, 2018

Conversation

jeho0815
Copy link
Contributor

@jeho0815 jeho0815 commented Jun 2, 2018

Follow this checklist to help us incorporate your contribution quickly and easily:

  • Make sure there is a JIRA issue filed for the change (usually before you start working on it). Trivial changes like typos do not require a JIRA issue. Your pull request should address just this issue, without pulling in other changes.
  • Each commit in the pull request should have a meaningful subject line and body.
  • Format the pull request title like [SCB-XXX] Fixes bug in ApproximateQuantiles, where you replace SCB-XXX with the appropriate JIRA issue.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Run mvn clean install to make sure basic checks pass. A more thorough check will be performed on your pull request automatically.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

@coveralls
Copy link

coveralls commented Jun 2, 2018

Coverage Status

Coverage decreased (-0.03%) to 87.467% when pulling a0f670b on jeho0815:Branch_master_SCB-636 into 517a9ff on apache:master.

@wujimin
Copy link
Contributor

wujimin commented Jun 4, 2018

try to write config mapping in CSE, not add logic in ServiceComb

*
* To adapte different Platforms
*/
public interface PlatformAdaptor {
Copy link
Contributor

@liubao68 liubao68 Jun 4, 2018

Choose a reason for hiding this comment

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

  1. Maybe we can have a more specific name, e.g. ConfigCenterAddressFinder
  2. This implementation has coupled config module with config center module & service center module. It's not very good. I think this is config center, service center specific features. Or you need also to implement config-apollo and other modules
  3. If you are using SPI, it's better to add an getOrder method and can resolve conflicts easier. And add a param or new method to distinguish the usage of the address, e.g. for config center, service center or apollo

@jeho0815 jeho0815 changed the title [SCB-636] provider a adaptor to aotomatic acquire different PaaS's EL… [SCB-636] change config mapping machanism Jun 4, 2018
configMap.putAll(YAMLUtil.yaml2Properties(url.openStream()));
}
} catch (IOException e) {
e.printStackTrace();
Copy link
Contributor

Choose a reason for hiding this comment

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

e.print?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i'm sorry~, will change

## limitations under the License.
## ---------------------------------------------------------------------------

cse:
Copy link
Member

Choose a reason for hiding this comment

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

We are supposed to use servicecomb instead of cse here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

## limitations under the License.
## ---------------------------------------------------------------------------

servicecomb:
Copy link
Contributor

Choose a reason for hiding this comment

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

mapping "a" to "b" is

a: b

not

b: a

Copy link
Contributor Author

Choose a reason for hiding this comment

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

accept

private static void duplicateServiceCombConfigToCseAtFront(ConcurrentCompositeConfiguration compositeConfiguration,
AbstractConfiguration source,
String sourceName) {
duplicateServiceCombConfigToCse(source);
Copy link
Contributor

Choose a reason for hiding this comment

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

duplicateServiceCombConfigToCse has already addConfiguration, and here addConfigurationAtFront again, is it necessary to add it twice?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

mapping
ENV: servicecomb.abc
we can use cse.abc to get the value

urlList.add(urls.nextElement());
}
for (URL url : urlList) {
configMap.putAll(YAMLUtil.yaml2Properties(url.openStream()));
Copy link
Contributor

@liubao68 liubao68 Jun 6, 2018

Choose a reason for hiding this comment

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

From YAMLUtil.yaml2Properties docs, it's not mentioned if close the stream. Close the stream if necessary or add a api docs that will close internally.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

snake yaml's demo and document don't require to close the stream. but we close the stream maybe more safely

Copy link
Contributor

Choose a reason for hiding this comment

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

"snake yaml's demo and document don't require to close the stream"
it's not a good idea to work in this way.

1.YAMLUtil.yaml2Properties is our code
2.if you are not sure if "yaml.loadAll" will close stream, it's better to read the source code, not guess

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, i have read the source, i don't find no code to close the stream, but their demo code do not close the stream. Today i write a demo, if i do not close the stream , the stream will be leak.
image
so add an api document to explain this.

@wujimin
Copy link
Contributor

wujimin commented Jun 7, 2018

too many commits.
1.change last commit, you can use "amend last commit"
2.change not last commit, you can use "rebase"

it's better to make every commit meaningful

old: A->B just add a new key/value => B/A's value, A has config in microserivce.yaml
new: A->B add a new key/value => A/B's value, B can read from Env/Properties/microservice.yaml, and support multi key map,
     A1: B
     A2: B
delete the removed config property
code reivew, change the e.printStackTrace() to log and remove the unused code
change the cse to servicecomb
change mapping A->B, support one to multi keys
A:
  - B1
  - B2
codereview, safe close the steam
@jeho0815 jeho0815 closed this Jun 8, 2018
@jeho0815 jeho0815 reopened this Jun 8, 2018
@liubao68 liubao68 merged commit 2d7623a into apache:master Jun 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants