anton-vinogradov commented on code in PR #13454: URL: https://github.com/apache/ignite/pull/13454#discussion_r3751713640
########## modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerBuiltInUpdater.java: ########## @@ -0,0 +1,75 @@ +/* + * 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 updaters DataStreamer ships with. 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()), + + /** {@link DataStreamerCacheUpdaters#batched()}. */ + BATCHED(DataStreamerCacheUpdaters.batched()), + + /** {@link DataStreamerCacheUpdaters#batchedSorted()}. */ + BATCHED_SORTED(DataStreamerCacheUpdaters.batchedSorted()); + + /** */ + private final StreamReceiver<?, ?> updater; + + /** */ + private final DataStreamerReceiverMessage msg; + + /** @param updater Updater this constant stands for. */ + DataStreamerBuiltInUpdater(StreamReceiver<?, ?> updater) { + this.updater = updater; + + msg = new DataStreamerReceiverMessage(this); + } + + /** @return Updater of this node. */ + StreamReceiver<?, ?> updater() { + return updater; + } + + /** @return Message holding {@link #updater()}; one per constant, as these updaters never change. */ + DataStreamerReceiverMessage message() { + return msg; Review Comment: Lazy now — the message is built on first use: ```java DataStreamerReceiverMessage message() { if (msg == null) msg = new DataStreamerReceiverMessage(this); return msg; } ``` A race would build a second one, which is harmless here: a built-in updater travels by name, so this message never carries bytes that would have to be shared. ########## modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerBuiltInUpdater.java: ########## @@ -0,0 +1,75 @@ +/* + * 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 updaters DataStreamer ships with. 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()), + + /** {@link DataStreamerCacheUpdaters#batched()}. */ + BATCHED(DataStreamerCacheUpdaters.batched()), + + /** {@link DataStreamerCacheUpdaters#batchedSorted()}. */ + BATCHED_SORTED(DataStreamerCacheUpdaters.batchedSorted()); + + /** */ + private final StreamReceiver<?, ?> updater; + + /** */ + private final DataStreamerReceiverMessage msg; + + /** @param updater Updater this constant stands for. */ + DataStreamerBuiltInUpdater(StreamReceiver<?, ?> updater) { + this.updater = updater; + + msg = new DataStreamerReceiverMessage(this); + } + + /** @return Updater of this node. */ + StreamReceiver<?, ?> updater() { + return updater; Review Comment: Same — the constant holds a supplier and resolves it on first use: ```java ISOLATED(() -> DataStreamerImpl.ISOLATED_UPDATER), INDIVIDUAL(DataStreamerCacheUpdaters::individual), ``` So a streamer that keeps the default receiver never touches `DataStreamerCacheUpdaters`, and `of()` — which does resolve all four — only runs when someone actually sets a receiver. The suppliers hand back singletons, so a race still yields the same instance and the identity lookup holds. ########## modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerBuiltInUpdater.java: ########## @@ -0,0 +1,75 @@ +/* + * 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 updaters DataStreamer ships with. 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()), + + /** {@link DataStreamerCacheUpdaters#batched()}. */ + BATCHED(DataStreamerCacheUpdaters.batched()), + + /** {@link DataStreamerCacheUpdaters#batchedSorted()}. */ + BATCHED_SORTED(DataStreamerCacheUpdaters.batchedSorted()); + + /** */ + private final StreamReceiver<?, ?> updater; + + /** */ + private final DataStreamerReceiverMessage msg; + + /** @param updater Updater this constant stands for. */ + DataStreamerBuiltInUpdater(StreamReceiver<?, ?> updater) { + this.updater = updater; + + msg = new DataStreamerReceiverMessage(this); + } + + /** @return Updater of this node. */ + StreamReceiver<?, ?> updater() { + return updater; + } + + /** @return Message holding {@link #updater()}; one per constant, as these updaters never change. */ + DataStreamerReceiverMessage message() { + return msg; + } + + /** + * @param updater Updater to look up. + * @return Constant standing for {@code updater}, or {@code null} when it is not one the streamer ships with. Review Comment: Reworded throughout: "built-in" for the updaters every node has, without claiming the streamer ships with them — only the Isolated one is its own. ########## modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerReceiverMessage.java: ########## @@ -0,0 +1,67 @@ +/* + * 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; + +/** DataStreamer cache receiver/updater message. */ +@UseBinaryMarshaller +public class DataStreamerReceiverMessage implements Message { + /** DataStreamer cache receiver/updater; {@code null} when {@link #builtIn} names it. */ + @Marshalled("rcvrBytes") + StreamReceiver<?, ?> rcvr; + + /** Serialized {@link #rcvr}. */ + @Order(0) + volatile byte[] rcvrBytes; + + /** The updater every node has; {@code null} when {@link #rcvr} is a user one. */ + @Order(1) + DataStreamerBuiltInUpdater builtIn; Review Comment: Done. ########## modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerReceiverMessage.java: ########## @@ -0,0 +1,67 @@ +/* + * 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; + +/** DataStreamer cache receiver/updater message. */ +@UseBinaryMarshaller +public class DataStreamerReceiverMessage implements Message { + /** DataStreamer cache receiver/updater; {@code null} when {@link #builtIn} names it. */ + @Marshalled("rcvrBytes") + StreamReceiver<?, ?> rcvr; Review Comment: Done. ########## modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java: ########## @@ -655,7 +667,7 @@ public IgniteFuture<?> addDataInternal(Collection<? extends DataStreamerEntry> e lock(false); - if (rcvr instanceof IsolatedUpdater && inconsistencyWarned.compareAndSet(false, true)) + if (!allowOverwrite() && inconsistencyWarned.compareAndSet(false, true)) Review Comment: Added: ```java // Without overwrite the Isolated updater is in use, and it is the one the warning is about. ``` ########## modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerReceiverMessage.java: ########## @@ -0,0 +1,67 @@ +/* + * 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; + +/** DataStreamer cache receiver/updater message. */ +@UseBinaryMarshaller +public class DataStreamerReceiverMessage implements Message { + /** DataStreamer cache receiver/updater; {@code null} when {@link #builtIn} names it. */ Review Comment: Done — `{@code null} when {@link #builtIn} is effective`. ########## modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerReceiverMessage.java: ########## @@ -0,0 +1,67 @@ +/* + * 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; + +/** DataStreamer cache receiver/updater message. */ +@UseBinaryMarshaller +public class DataStreamerReceiverMessage implements Message { + /** DataStreamer cache receiver/updater; {@code null} when {@link #builtIn} names it. */ + @Marshalled("rcvrBytes") + StreamReceiver<?, ?> rcvr; + + /** Serialized {@link #rcvr}. */ + @Order(0) + volatile byte[] rcvrBytes; + + /** The updater every node has; {@code null} when {@link #rcvr} is a user one. */ Review Comment: Done — `A built-in updater every node has`. -- 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]
