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

I9 config snapshot #62

Merged
merged 22 commits into from
May 17, 2018
Merged

I9 config snapshot #62

merged 22 commits into from
May 17, 2018

Conversation

struberg
Copy link
Contributor

@struberg struberg commented May 3, 2018

This adresses #9, #8 and #57

struberg added 11 commits April 18, 2018 13:09
We will probably introduce another way to get notified later on.
This code got originally developed on 2018-04-04 in Apache DeltaSpike by
Mark Struberg, Manfred Huber, Alex Falb, Gerhard Petracek and Romain Manni-Bucau
based on the problem analysis discussions between Mark Struberg and
Tomas Langer (tomas-langer) who also did reviews and gave important feedback.
…eparate discussion

As agreed in the last EG meeting I gonna split out this feature into a separate
ticket (eclipse#63).
Using the same attributes in different TCK tests
but with different values leads to random behaviour of the
whole TCK suite.
@struberg
Copy link
Contributor Author

struberg commented May 8, 2018

Hi!

I've removed the onValueChange callback as discussed in our last EG meeting.

Copy link
Contributor

@tomas-langer tomas-langer left a comment

Choose a reason for hiding this comment

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

There are a few things that should be fixed before merging.

* Returns the actual key which led to successful resolution and corresponds to the resolved value. This applies
* only when {@link #withLookupChain(String...)} is used.
* Returns the actual key which led to successful resolution and corresponds to the resolved value.
* This is mostly useful when {@link #withLookupChain(String...)} or {@link #evaluateVariables(boolean)} is used.
* Otherwise the resolved key should always be equal to the original key.
* This method is provided for cases, when arameterized resolution is
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: probably should be "parametrized".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually evaluateVariables does not have any impact at all the more I think about it.
evaluateVariable works on the value. It is a post processing of the value. But it doesn't affect the key at all. Gonna remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just wondered whether we should remove getResolvedKey at all?
It only gives you the value from the last 'successful' resolve. And if this happens in parallel rather quickly you might end up with glitches from another thread.
Of course this will only happen if the underlying config changes, otherwise it will be idempotent anyway.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, the usability is questionable - why would I need this information in my business logic?
Though there may be some troubleshooting use cases (e.g. debugging this information).
I don't have a strong opinion on this one, so choose ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, would be clever to log it out in case of onChange - If only we would not just have ditched that ;)

* Returns the actual key which led to successful resolution and corresponds to the resolved value. This applies
* only when {@link #withLookupChain(String...)} is used.
* Returns the actual key which led to successful resolution and corresponds to the resolved value.
* This is mostly useful when {@link #withLookupChain(String...)} or {@link #evaluateVariables(boolean)} is used.
Copy link
Contributor

Choose a reason for hiding this comment

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

What if this key is based on multiple variables? Which one is the "resolved one"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The last effective String.
So if you have cfg.access("myconfigkey").withLookupChain("${app.projectstage}")
and app.projectstage resolves to 'Prodution' you might end up with 'myconfigkey.Production'

int i2 = vals.get(DynamicChangeConfigSource.TEST_ATTRIBUTE);
assertTrue(i2 > i1);
public void testValueInvalidationOnConfigChange() throws Exception {
ConfigValue<Integer> valCfg = config.access(DynamicChangeConfigSource.TEST_ATTRIBUTE)
Copy link
Contributor

Choose a reason for hiding this comment

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

I considered this to be optional approach by the implementor. This behavior should not be tested - the implementation may decide not to refresh the value until the cache for is expired.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, the intention is to define that it must expire the cache if the Config gets notified about a change by the ConfigSource. Do you really think we should not mandate this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes I think so. This does not stand in the way of portability. We can mention that the implementation should refresh the value, though I still don't see this as a must.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But not defining this as mandatory feature renders ConfigSource#setOnAttributeChange useless on implementations not supporting it.
So I'd rather tighten it instead of removing.

Copy link
Member

Choose a reason for hiding this comment

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

We need to find a way to test this. Otherwise, how to mandate implementor implement this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There should be a test for it already. It sets a cacheFor to 15 minutes, then loads the values. Then the ConfigSource changes a value via the TCK test and fires the attributeChanged to the Config. And then the test reads the value again and verifies that the new value is picked up immediately.

@struberg
Copy link
Contributor Author

Oki so in summary? Looks fine @tomas-langer? In which case I suggest we apply it now and refine it all together.

@tomas-langer
Copy link
Contributor

LGTM, I would go through the must/should decision during our meeting next week (as this is to be decided in the spec - and TCK can be changed accordingly if we decide against your approach).

Copy link
Member

@Emily-Jiang Emily-Jiang left a comment

Choose a reason for hiding this comment

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

TCKs to be added for

  1. useConverter
  2. getKey
  3. getResolvedKey
  4. getValue(ConfigSnapShot)

*/
ConfigValue<String> access(String key);
ConfigValue<String> access(String propertyName);
Copy link
Member

Choose a reason for hiding this comment

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

I would change the method name to getConfigValue instead

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'd rather not do that. Then we'd have getValue and getConfigValue. That would confuse users I fear.

@@ -0,0 +1,42 @@
/*
*******************************************************************************
* Copyright (c) 2011-2017 Contributors to the Eclipse Foundation and others
Copy link
Member

Choose a reason for hiding this comment

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

should be 2011-2018

package javax.config;

/**
* A value holder for TypedResolver values which all got resolved in a guaranteed atomic way.
Copy link
Member

Choose a reason for hiding this comment

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

Where was TypedResolver defined?

/**
* A value holder for TypedResolver values which all got resolved in a guaranteed atomic way.
*
* @see Config#snapshotFor(ConfigValue[])
Copy link
Member

Choose a reason for hiding this comment

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

It is varargs

* @return This builder as a typed ConfigValue
*/
<N> ConfigValue<N> useConverter(Converter<N> converter);
ConfigValue<T> useConverter(Converter<T> converter);
Copy link
Member

Choose a reason for hiding this comment

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

Why should this converter here? Is this converter not loaded via service loader pattern? What is the use case 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.

No this is intended for when you do not want to use the default converter but a special handling.

@@ -192,29 +209,24 @@
String getKey();
Copy link
Member

Choose a reason for hiding this comment

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

Why does getKey() return a value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the name of the oridingal config property name. We might probably rename it.

int i2 = vals.get(DynamicChangeConfigSource.TEST_ATTRIBUTE);
assertTrue(i2 > i1);
public void testValueInvalidationOnConfigChange() throws Exception {
ConfigValue<Integer> valCfg = config.access(DynamicChangeConfigSource.TEST_ATTRIBUTE)
Copy link
Member

Choose a reason for hiding this comment

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

We need to find a way to test this. Otherwise, how to mandate implementor implement this?

@@ -0,0 +1,79 @@
/*
* Copyright (c) 2016-2017 Contributors to the Eclipse Foundation
Copy link
Member

Choose a reason for hiding this comment

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

2016-2018

Copy link
Contributor Author

Choose a reason for hiding this comment

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

bulk replaced/fixed all Copyright years to 2018

@struberg struberg merged commit 987ece9 into eclipse:master May 17, 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.

3 participants