-
Notifications
You must be signed in to change notification settings - Fork 1.9k
IGNITE-27977 Refactor bytes serialization for DataStreamerRequest #13454
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?
Changes from all commits
817073d
e3ba9b0
bf633f0
d92c105
29cf297
d3d15ae
7b82b61
491bdce
0b9c412
36c67f2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.ignite.internal.processors.datastreamer; | ||
|
|
||
| import org.apache.ignite.internal.Marshalled; | ||
| import org.apache.ignite.internal.Order; | ||
| import org.apache.ignite.internal.UseBinaryMarshaller; | ||
| import org.apache.ignite.plugin.extensions.communication.Message; | ||
| import org.apache.ignite.stream.StreamReceiver; | ||
|
|
||
| /** | ||
| * The receiver of a streamer on its way to the nodes that own the data: a user object here, its serialized form on | ||
| * the wire. One instance serves every batch of a streamer, so the receiver is marshalled once and the batches share | ||
| * the result; a streamer given another receiver builds another instance. | ||
| */ | ||
| @UseBinaryMarshaller | ||
| public class StreamReceiverMessage implements Message { | ||
| /** */ | ||
| @Marshalled("rcvrBytes") | ||
| StreamReceiver<?, ?> rcvr; | ||
|
|
||
| /** | ||
| * Serialized {@link #rcvr}, written by whichever batch is marshalled first and read by the rest. Those batches | ||
| * leave on different threads, hence the {@code volatile}: a reader seeing the reference before the contents would | ||
| * skip the marshalling and send a half-written array. | ||
| */ | ||
| @Order(0) | ||
| volatile byte[] rcvrBytes; | ||
|
Contributor
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. Should
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. I don't think so: the marker means the opposite of what this class does.
If what you had in mind is the side effects the marker brings — the marshaller becoming mandatory at registration, and |
||
|
|
||
| /** Empty constructor. */ | ||
| public StreamReceiverMessage() { | ||
| // No-op. | ||
| } | ||
|
|
||
| /** @param rcvr Receiver. */ | ||
| StreamReceiverMessage(StreamReceiver<?, ?> rcvr) { | ||
| this.rcvr = rcvr; | ||
| } | ||
|
|
||
| /** @return Receiver. */ | ||
| StreamReceiver<?, ?> receiver() { | ||
| return rcvr; | ||
| } | ||
| } | ||
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.
What changed? One external, not automated marshalling changed with another.
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.
The call stays external, but what it does is not the same.
Before, this line picked the marshaller itself —
marshwasctx.marshaller()— and deserialized one particular field. That is what makes a blob a hole for IGNITE-28940: the field decides its own marshaller, whatever the transport decides. Now the processor only starts the read; which fields are touched, and with which marshaller, is decided by the generated marshaller that the message factory holds for this type (@UseBinaryMarshalleronStreamReceiverMessageselects the schema-aware one). The processor no longer knows that the receiver has a serialized form at all, and the entries of the same request are read by the same pass.What cannot become automatic here is the moment of the call. The message is a
DeferredUnmarshalMessage: its class loader is known only at this point — the grid loader under forced local deployment, the sender's global deployment otherwise — and a missing deployment has to travel back to the sender as a response instead of being thrown on the inbound thread.GridEventStorageManager,GridJobProcessor,GridTaskWorkerandGridCacheIoManagercallMessageMarshalling.unmarshalexplicitly for the same reason.