anton-vinogradov commented on code in PR #13454: URL: https://github.com/apache/ignite/pull/13454#discussion_r3752278538
########## modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerReceiverMessage.java: ########## @@ -0,0 +1,68 @@ +/* + * 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; +import org.jetbrains.annotations.Nullable; + +/** DataStreamer cache receiver/updater message. */ +@UseBinaryMarshaller +public class DataStreamerReceiverMessage implements Message { + /** Custom cache receiver/updater; {@code null} when {@link #builtIn} is effective. */ + @Marshalled("rcvrBytes") + @Nullable StreamReceiver<?, ?> rcvr; + + /** Serialized {@link #rcvr}; {@code null} when {@link #builtIn} is effective. */ + @Order(0) + volatile @Nullable byte[] rcvrBytes; + + /** A built-in updater every node has; {@code null} when {@link #rcvr} is effective. */ + @Order(1) + @Nullable DataStreamerBuiltInUpdater builtIn; + + /** Empty constructor for serialization purposes. */ + public DataStreamerReceiverMessage() { + // No-op. + } + + /** @param rcvr Custom receiver. */ + DataStreamerReceiverMessage(StreamReceiver<?, ?> rcvr) { + assert DataStreamerBuiltInUpdater.of(rcvr) == null : "A built-in updater travels by name: " + rcvr; + + this.rcvr = rcvr; + } + + /** @param builtIn Built-in updater, sent as a name rather than as a copy. */ + DataStreamerReceiverMessage(DataStreamerBuiltInUpdater builtIn) { + this.builtIn = builtIn; + } + + /** @return {@code True} if this is a custom receiver, {@code false} if a built-in one. */ + boolean custom() { Review Comment: Renamed — `customUpdater()` on the carrier as well, so it reads the same as on the request. ########## modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerBuiltInUpdater.java: ########## @@ -0,0 +1,70 @@ +/* + * 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.stream.StreamReceiver; +import org.jetbrains.annotations.Nullable; + +/** + * The built-in updaters. Every node has them, so a request names the one it needs instead of carrying a serialized + * copy. + */ +enum DataStreamerBuiltInUpdater { + /** {@link DataStreamerImpl#ISOLATED_UPDATER}. */ + ISOLATED(DataStreamerImpl.ISOLATED_UPDATER), + + /** {@link DataStreamerCacheUpdaters#individual()}. */ + INDIVIDUAL(DataStreamerCacheUpdaters.individual()), Review Comment: They do sit close, but they answer different questions, and I am not sure which way you want them merged — so let me lay out what I see. `DataStreamerCacheUpdaters` is public API: factories a user calls to pick an updater, plus the implementations behind them. `DataStreamerBuiltInUpdater` is a wire-level registry: it exists so a request can name an updater instead of sending it, and it has to cover the Isolated one too, which lives in `DataStreamerImpl` and is not part of that public class. So a full merge would mean moving `IsolatedUpdater` out of `DataStreamerImpl` into the public class — a bigger change than this ticket, and one that touches what the class means. What is cheap is nesting: make the enum `DataStreamerCacheUpdaters.BuiltIn`, package-private, so there is one top-level name instead of two similar ones. It still points at `DataStreamerImpl.ISOLATED_UPDATER` for that constant. Tell me if the nested variant is what you meant and I will do it; if you had the full merge in mind, I would rather file it separately. -- 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]
