-
Notifications
You must be signed in to change notification settings - Fork 1.9k
IGNITE-26608 WIP #12429
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
base: master
Are you sure you want to change the base?
IGNITE-26608 WIP #12429
Conversation
| * @return Security context holder. | ||
| * @return Thread Context Scope. | ||
| * | ||
| * @see #withContext(Scope, SecurityContext |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * @see #withContext(Scope, SecurityContext | |
| * @see #withContext(Scope, SecurityContext) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
9bf30e8 to
324206b
Compare
da14337 to
8795941
Compare
|
|
||
| /** */ | ||
| <T> T get(ThreadContextAttribute<T> attr) { | ||
| if (attr.id() >= attrs.length) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shoulud we throw assert instead? Is it correct to access to the attribute we actually didn't set?
Could it lead to an error, when user forget to set the var and received default value instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, we shouldn't. The initial value of an attribute literally means - the value returned by the ThreadContext#get method if the attribute's value is not explicitly set.
It can be used to skip explicitly setting attributes for some internal operations/workers and still get some value for attribute.
| } | ||
| public interface Scope extends AutoCloseable { | ||
| /** Binds attribute with specified value to the current scope. */ | ||
| public <T> Scope withAttribute(ThreadContextAttribute<T> attr, T val); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Broken incapsulation. ThreadContextScope inherits Scope, then ThreadContextAttribute must be part of ThreadContextScrope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It’s more of a naming problem than an “encapsulation.” Anyway, I’ve updated the PR and removed the Scope interface entirely — on second thought, it’s redundant for the current patch. So now only ThreadContextScope remains.
da9cc26 to
a5347c7
Compare
modules/commons/src/main/java/org/apache/ignite/internal/thread/context/Scope.java
Show resolved
Hide resolved
modules/commons/src/main/java/org/apache/ignite/internal/thread/context/ScopedContext.java
Outdated
Show resolved
Hide resolved
| import java.util.concurrent.atomic.AtomicInteger; | ||
|
|
||
| /** */ | ||
| public class ContextAttribute<T> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose you publicate the "Scope" term. Let's use at least public terms if possible. ScopeAttribute looks better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope. The Scope has nothing to do with the Attribute. Context does.
| /** */ | ||
| private ContextAttribute(byte id, T initVal) { | ||
| this.id = id; | ||
| this.bitmask = 1 << id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks that storing ID is enough. The bitmask is a parameter of ContextDataChain only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope. The bitmask is used in many places to check for the presence of an attribute value. Therefore, it's better to calculate it once and store it in the attribute instance.
modules/commons/src/main/java/org/apache/ignite/internal/thread/context/ContextAttribute.java
Outdated
Show resolved
Hide resolved
| } | ||
|
|
||
| /** */ | ||
| public <T> ScopedContext with(ContextAttribute<T> attr, T val) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks weird, an object that stores an attribute value accepts another attribute (name + value). AFAIU, it's a responsibility of Scope to store all attributes within single scope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a responsibility of Scope to store all attributes within single scope
Nope. See comments above.
I changed class naming a bit so it may be less confusing now.
Looks weird, an object that stores an attribute value accepts another attribute (name + value)
Also keep in mind that the current patch is based on intrusive lists and it is unlikely to be possible to avoid the "weirdness" you mentioned.
0930d07 to
fcbcc57
Compare
fcbcc57 to
df78984
Compare
|
3e0bd2a to
ba5ad27
Compare
ba5ad27 to
e4be167
Compare
|



Thank you for submitting the pull request to the Apache Ignite.
In order to streamline the review of the contribution
we ask you to ensure the following steps have been taken:
The Contribution Checklist
The description explains WHAT and WHY was made instead of HOW.
The following pattern must be used:
IGNITE-XXXX Change summarywhereXXXX- number of JIRA issue.(see the Maintainers list)
the
green visaattached to the JIRA ticket (see TC.Bot: Check PR)Notes
If you need any help, please email dev@ignite.apache.org or ask anу advice on http://asf.slack.com #ignite channel.