tkalkirill commented on a change in pull request #483:
URL: https://github.com/apache/ignite-3/pull/483#discussion_r761025146
##########
File path:
modules/configuration/src/main/java/org/apache/ignite/internal/configuration/ConfigurationChanger.java
##########
@@ -374,68 +374,94 @@ public SuperRoot superRoot() {
}
/**
- * Internal configuration change method that completes provided future.
+ * Entry point for configuration changes.
*
* @param src Configuration source.
* @return fut Future that will be completed after changes are written to
the storage.
*/
private CompletableFuture<Void> changeInternally(ConfigurationSource src) {
StorageRoots localRoots = storageRoots;
+ return storage.revisionLatest()
+ .thenCompose(storageRevision -> {
+ assert storageRevision != null;
+
+ if (localRoots.version < storageRevision) {
+ // Need to wait for the configuration updates from the
storage, then try to update again (loop).
+ return localRoots.changeFuture.thenCompose(v ->
changeInternally(src));
+ } else {
+ return changeInternally0(localRoots, src);
+ }
+ })
+ .exceptionally(throwable -> {
+ Throwable cause = throwable.getCause();
+
+ if (cause instanceof ConfigurationChangeException) {
+ throw ((ConfigurationChangeException) cause);
+ } else {
+ throw new ConfigurationChangeException("Failed to change
configuration", cause);
+ }
+ });
+ }
+
+ /**
+ * Internal configuration change method that completes provided future.
+ *
+ * @param src Configuration source.
+ * @return fut Future that will be completed after changes are written to
the storage.
+ */
+ private CompletableFuture<Void> changeInternally0(StorageRoots localRoots,
ConfigurationSource src) {
return CompletableFuture
- .supplyAsync(() -> {
- SuperRoot curRoots = localRoots.roots;
+ .supplyAsync(() -> {
+ SuperRoot curRoots = localRoots.roots;
- SuperRoot changes = curRoots.copy();
+ SuperRoot changes = curRoots.copy();
- src.reset();
+ src.reset();
- src.descend(changes);
+ src.descend(changes);
- addDefaults(changes);
+ addDefaults(changes);
- Map<String, Serializable> allChanges =
createFlattenedUpdatesMap(curRoots, changes);
+ Map<String, Serializable> allChanges =
createFlattenedUpdatesMap(curRoots, changes);
- // Unlikely but still possible.
- if (allChanges.isEmpty()) {
- return null;
- }
+ // Unlikely but still possible.
+ if (allChanges.isEmpty()) {
+ return null;
+ }
- dropNulls(changes);
+ dropNulls(changes);
- List<ValidationIssue> validationIssues =
ValidationUtil.validate(
- curRoots,
- changes,
- this::getRootNode,
- cachedAnnotations,
- validators
- );
+ List<ValidationIssue> validationIssues =
ValidationUtil.validate(
+ curRoots,
+ changes,
+ this::getRootNode,
+ cachedAnnotations,
+ validators
+ );
- if (!validationIssues.isEmpty()) {
- throw new
ConfigurationValidationException(validationIssues);
- }
+ if (!validationIssues.isEmpty()) {
+ throw new
ConfigurationValidationException(validationIssues);
+ }
- return allChanges;
- }, pool)
- .thenCompose(allChanges -> {
- if (allChanges == null) {
- return completedFuture(null);
- }
+ return allChanges;
+ }, pool)
+ .thenCompose(allChanges -> {
+ if (allChanges == null) {
Review comment:
I tried to fix it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]