Skip to content

Conversation

@ibessonov
Copy link
Contributor

Signed-off-by: ibessonov bessonov.ip@gmail.com

Signed-off-by: ibessonov <bessonov.ip@gmail.com>
# Conflicts:
#	modules/configuration/src/main/java/org/apache/ignite/configuration/ConfigurationChanger.java
Signed-off-by: ibessonov <bessonov.ip@gmail.com>
Signed-off-by: ibessonov <bessonov.ip@gmail.com>
Signed-off-by: ibessonov <bessonov.ip@gmail.com>
if (valueAnnotation != null) {
ClassName dynPropClass = ClassName.get(DynamicProperty.class);
ClassName confValueClass = ClassName.get(ConfigurationValue.class);
ClassName dynPropClass = ClassName.get("org.apache.ignite.configuration.internal", "DynamicProperty");
Copy link
Contributor

Choose a reason for hiding this comment

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

Just being curious: why did you change 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.

Because I kept getting "NoClassDefFoundError" from that damn ITProcessorTest and this turned out to be the only way to fix it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it deserves a comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

accidentallyget -- typo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

}
});

return CompletableFuture.allOf(futures.stream().map(listenerFut -> listenerFut.handle((res, throwable) -> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please extract the inner stream into a variable, it's hard to read otherwise

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure

/** Annotation classes mapped to validator objects. */
private Map<Class<? extends Annotation>, Set<Validator<?, ?>>> validators = new HashMap<>();

/** */
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be a proper javadoc)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@FunctionalInterface
public interface Notificator {
/** */
@NotNull CompletableFuture<?> notify(SuperRoot oldRoot, SuperRoot newRoot, long storageRevision);
Copy link
Contributor

Choose a reason for hiding this comment

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

why not CompletableFuture<Void>?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Honestly, I see no difference between these two. Should I change it?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that the difference is that CompletableFuture<Void> explicitly states that there's no value inside it, while CompletableFuture<?> is closer to CompletableFuture<Object>

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, that makes sense. That's my laziness.

/** Constructor. */
public ConfigurationChanger(RootKey<?, ?>... rootKeys) {
/**
* @param notificator Closure to execute when update forom storage is received.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* @param notificator Closure to execute when update forom storage is received.
* @param notificator Closure to execute when update from the storage is received.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

InnerNode newInnerNode,
DynamicConfiguration<InnerNode, ?, ?> cfgNode,
long storageRevision,
List<CompletableFuture<?>> futures
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we make it a return 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.

You mean the list? It's more convenient to accumulate values this way I think, method is recursive and I wouldn't want to merge collections every time.

Copy link
Contributor

Choose a reason for hiding this comment

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

You can create a public method that will return a List, while inside you can call some recursive private methods that will populate this list. This is effectively the same approach, but I think it will make the API cleaner

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So basically you mean that I should make this one private and create new public method that will return list, right? Ok, not a problem

Copy link
Contributor

Choose a reason for hiding this comment

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

exactly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We call this method from outside several times so I'll leave it with list parameter.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok!

* Called on property value update.
*
* @param ctx Notification context.
* @return Future that signifies end of listener execution. Can be {@code null}.
Copy link
Contributor

Choose a reason for hiding this comment

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

What does null mean in this context?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

null is equivalent to completed future. I'll clarify it in the comment.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we return a completed future 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.

That's for convenience, people will implement this method and return completed future in most cases, why not allow them to return null instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

Writing Future.completedFuture is not that hard, while dealing with both nulls and normal futures looks confusing and not a very clean design. Of course, that's mostly subjective.

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, I fixed it

void removeListener(ConfigurationStorageListener listener);

/**
* Notify storage that this specific revision was successfully handled and there's no necessity to repeat the same
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Notify storage that this specific revision was successfully handled and there's no necessity to repeat the same
* Notify storage that this specific revision was successfully handled and it is not necessary to repeat the same

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

}

/**
* Nullifies values in {@code newNode} that 100% match with corresponding values in {@code curNode}.
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I don't understand what you are trying to say 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, I will try my best to rephrase it))

import static org.apache.ignite.configuration.internal.util.ConfigurationUtil.namedListNodeVisitor;

/** */
public class ConfigurationNotificationsUtil {
Copy link
Contributor

Choose a reason for hiding this comment

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

why do you need this class? It's only used in ConfigurationRegistry

Copy link
Contributor Author

@ibessonov ibessonov Apr 1, 2021

Choose a reason for hiding this comment

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

Because methods in it are big and I don't want to have too much extra stuff in ConfigurationRegistry

Signed-off-by: ibessonov <bessonov.ip@gmail.com>
private Map<Class<? extends Annotation>, Set<Validator<?, ?>>> validators = new HashMap<>();

/**
* Closure interface to be used by configuration changer. Instance of this closur is passed into constructor and
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Closure interface to be used by configuration changer. Instance of this closur is passed into constructor and
* Closure interface to be used by configuration changer. An instance of this closure is passed into constructor and

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, thank you!

Signed-off-by: ibessonov <bessonov.ip@gmail.com>
Signed-off-by: ibessonov <bessonov.ip@gmail.com>
Signed-off-by: ibessonov <bessonov.ip@gmail.com>

try {
change(defaultsNode, storageType).get();
change0(defaultsNode, storageInstances.get(storageType)).get();
Copy link
Contributor

Choose a reason for hiding this comment

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

It's interesting that you've decided to remove the method with the name change and not change0 =)

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'll rename it in the future)

Copy link
Contributor

Choose a reason for hiding this comment

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

why not now?

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

ibessonov and others added 8 commits April 2, 2021 13:30
…ation/ConfigurationChanger.java

Co-authored-by: Alexander Polovtcev <alex.polovtcev@gmail.com>
…ation/ConfigurationChanger.java

Co-authored-by: Alexander Polovtcev <alex.polovtcev@gmail.com>
…ation/ConfigurationChanger.java

Co-authored-by: Alexander Polovtcev <alex.polovtcev@gmail.com>
…ation/ConfigurationChanger.java

Co-authored-by: Alexander Polovtcev <alex.polovtcev@gmail.com>
…ation/internal/util/ConfigurationUtil.java

Co-authored-by: Alexander Polovtcev <alex.polovtcev@gmail.com>
…ation/internal/util/ConfigurationUtil.java

Co-authored-by: Alexander Polovtcev <alex.polovtcev@gmail.com>
Signed-off-by: ibessonov <bessonov.ip@gmail.com>
Signed-off-by: ibessonov <bessonov.ip@gmail.com>
@ibessonov ibessonov merged commit 297468b into apache:main Apr 2, 2021
@ibessonov ibessonov deleted the ignite-14180 branch June 4, 2021 07:22
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.

4 participants