-
Notifications
You must be signed in to change notification settings - Fork 1.9k
IGNITE-27759 Remove redundant serialization of SnapshotHandlerResult#node #12702
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
Merged
+63
−65
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
05b7626
IGNITE-27759 Remove redundant serialization of SnapshotHandlerResult#…
NSAmelchev 277153b
IGNITE-27759 Remove redundant serialization of SnapshotHandlerResult#…
NSAmelchev a311c8f
IGNITE-27759 Remove redundant serialization of SnapshotHandlerResult#…
NSAmelchev c71d48c
IGNITE-27759 Remove redundant serialization of SnapshotHandlerResult#…
NSAmelchev 8cbf089
IGNITE-27759 Remove redundant serialization of SnapshotHandlerResult#…
NSAmelchev 6858fc2
Fix javadoc
NSAmelchev 36ea9c2
review fixes
NSAmelchev f08e763
review fixes
NSAmelchev 3c7a270
Merge remote-tracking branch 'refs/remotes/apache/master' into ignite…
NSAmelchev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1152,7 +1152,7 @@ else if (!F.isEmpty(err)) { | |
| "Uncompleted snapshot will be deleted [err=" + err + ']')); | ||
| } | ||
|
|
||
| completeHandlersAsyncIfNeeded(snpOp, res.values()) | ||
| completeHandlersAsyncIfNeeded(snpOp, res) | ||
| .listen(f -> { | ||
| if (f.error() != null) | ||
| snpOp.error(f.error()); | ||
|
|
@@ -1194,30 +1194,31 @@ public <M extends Serializable> void storeSnapshotMeta(M meta, File smf) { | |
| } | ||
|
|
||
| /** | ||
| * Execute the {@link SnapshotHandler#complete(String, Collection)} method of the snapshot handlers asynchronously. | ||
| * Execute the {@link SnapshotHandler#complete(String, Map)} method of the snapshot handlers asynchronously. | ||
| * | ||
| * @param snpOp Snapshot creation operation. | ||
| * @param res Results. | ||
| * @return Future that will be completed when the handlers are finished executing. | ||
| */ | ||
| private IgniteInternalFuture<Void> completeHandlersAsyncIfNeeded( | ||
| SnapshotOperation snpOp, | ||
| Collection<SnapshotOperationResponse> res | ||
| Map<UUID, SnapshotOperationResponse> res | ||
| ) { | ||
| if (snpOp.error() != null) | ||
| return new GridFinishedFuture<>(); | ||
|
|
||
| SnapshotOperationRequest req = snpOp.request(); | ||
|
|
||
| Map<String, List<SnapshotHandlerResult<?>>> clusterHndResults = new HashMap<>(); | ||
| Map<String, Map<UUID, SnapshotHandlerResult<?>>> clusterHndResults = new HashMap<>(); | ||
|
|
||
| for (SnapshotOperationResponse snpRes : res) { | ||
| res.forEach((nodeId, snpRes) -> { | ||
| if (snpRes == null || snpRes.handlerResults() == null) | ||
| continue; | ||
| return; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Previously, iteration was performed via a loop; now it is done using a lambda |
||
|
|
||
| for (Map.Entry<String, SnapshotHandlerResult<Object>> entry : snpRes.handlerResults().entrySet()) | ||
| clusterHndResults.computeIfAbsent(entry.getKey(), v -> new ArrayList<>()).add(entry.getValue()); | ||
| } | ||
| snpRes.handlerResults().forEach((hndName, hndRes) -> | ||
| clusterHndResults.computeIfAbsent(hndName, v -> new HashMap<>()) | ||
| .put(nodeId, hndRes)); | ||
| }); | ||
|
|
||
| if (clusterHndResults.isEmpty()) | ||
| return new GridFinishedFuture<>(); | ||
|
|
@@ -2944,7 +2945,7 @@ private void initialize(GridKernalContext ctx, ExecutorService execSvc) { | |
| protected void completeAll( | ||
| SnapshotHandlerType type, | ||
| String snpName, | ||
| Map<String, List<SnapshotHandlerResult<?>>> res, | ||
| Map<String, Map<UUID, SnapshotHandlerResult<?>>> res, | ||
| Collection<UUID> reqNodes, | ||
| Consumer<List<String>> wrnsHnd | ||
| ) throws Exception { | ||
|
|
@@ -2963,13 +2964,13 @@ protected void completeAll( | |
| List<String> wrns = new ArrayList<>(); | ||
|
|
||
| for (SnapshotHandler hnd : hnds) { | ||
| List<SnapshotHandlerResult<?>> nodesRes = res.get(hnd.getClass().getName()); | ||
| Map<UUID, SnapshotHandlerResult<?>> nodesRes = res.get(hnd.getClass().getName()); | ||
|
|
||
| if (nodesRes == null || nodesRes.size() < reqNodes.size()) { | ||
| Set<UUID> missing = new HashSet<>(reqNodes); | ||
|
|
||
| if (nodesRes != null) | ||
| missing.removeAll(F.viewReadOnly(nodesRes, r -> r.node().id())); | ||
| missing.removeAll(nodesRes.keySet()); | ||
|
|
||
| throw new IgniteCheckedException("Snapshot handlers configuration mismatch, " + | ||
| "\"" + hnd.getClass().getName() + "\" handler is missing on the remote node(s). " + | ||
|
|
@@ -2996,12 +2997,12 @@ protected void completeAll( | |
| */ | ||
| private SnapshotHandlerResult<Object> invoke(SnapshotHandler<Object> hnd, SnapshotHandlerContext ctx) { | ||
| try { | ||
| return new SnapshotHandlerResult<>(hnd.invoke(ctx), null, ctx.localNode()); | ||
| return new SnapshotHandlerResult<>(hnd.invoke(ctx), null); | ||
| } | ||
| catch (Exception e) { | ||
| U.error(null, "Error invoking snapshot handler", e); | ||
|
|
||
| return new SnapshotHandlerResult<>(null, e, ctx.localNode()); | ||
| return new SnapshotHandlerResult<>(null, e); | ||
| } | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Fixed