This is an automated email from the ASF dual-hosted git repository. sergeychugunov pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push: new d20774c9c1a IGNITE-26332 Remove GridMessageCollection (#12302) d20774c9c1a is described below commit d20774c9c1aa42f75b6e25cf8ec711278bd0ca23 Author: Dmitry Werner <grimekil...@gmail.com> AuthorDate: Tue Sep 2 16:53:36 2025 +0500 IGNITE-26332 Remove GridMessageCollection (#12302) --- .../communication/GridIoMessageFactory.java | 2 - .../internal/util/GridMessageCollection.java | 154 --------------------- .../main/resources/META-INF/classnames.properties | 1 - .../ignite/testsuites/IgniteUtilSelfTestSuite.java | 2 - .../ignite/util/GridMessageCollectionTest.java | 127 ----------------- 5 files changed, 286 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java index 665f92e5e7b..df3350aa798 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java @@ -194,7 +194,6 @@ import org.apache.ignite.internal.processors.service.ServiceSingleNodeDeployment import org.apache.ignite.internal.util.GridByteArrayList; import org.apache.ignite.internal.util.GridIntList; import org.apache.ignite.internal.util.GridLongList; -import org.apache.ignite.internal.util.GridMessageCollection; import org.apache.ignite.internal.util.UUIDCollectionMessage; import org.apache.ignite.internal.util.distributed.SingleNodeMessage; import org.apache.ignite.plugin.extensions.communication.MessageFactory; @@ -336,7 +335,6 @@ public class GridIoMessageFactory implements MessageFactoryProvider { BinaryUtils.registerMessages(factory::register); // [120..123] - DR - factory.register((short)124, GridMessageCollection::new); factory.register((short)125, GridNearAtomicSingleUpdateRequest::new); factory.register((short)126, GridNearAtomicSingleUpdateInvokeRequest::new); factory.register((short)127, GridNearAtomicSingleUpdateFilterRequest::new); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridMessageCollection.java b/modules/core/src/main/java/org/apache/ignite/internal/util/GridMessageCollection.java deleted file mode 100644 index ed7bad534ec..00000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridMessageCollection.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * 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.util; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import org.apache.ignite.internal.GridDirectCollection; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.plugin.extensions.communication.Message; -import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType; -import org.apache.ignite.plugin.extensions.communication.MessageReader; -import org.apache.ignite.plugin.extensions.communication.MessageWriter; - -/** - * Collection of messages. - */ -public final class GridMessageCollection<M extends Message> implements Message { - /** */ - @GridDirectCollection(Message.class) - private Collection<M> msgs; - - /** - * - */ - public GridMessageCollection() { - // No-op. - } - - /** - * @param msgs Collection of messages. - */ - public GridMessageCollection(Collection<M> msgs) { - this.msgs = msgs; - } - - /** - * @param msgs Messages. - * @return Message list. - */ - public static <X extends Message> GridMessageCollection<X> of(X... msgs) { - if (msgs == null || msgs.length == 0) - return null; - - List<X> list = msgs.length == 1 ? Collections.singletonList(msgs[0]) : Arrays.asList(msgs); - - return new GridMessageCollection<>(list); - } - - /** - * @return Messages. - */ - public Collection<M> messages() { - return msgs; - } - - /** - * @param msgs Messages. - */ - public void messages(Collection<M> msgs) { - this.msgs = msgs; - } - - /** {@inheritDoc} */ - @Override public void onAckReceived() { - // No-op. - } - - /** {@inheritDoc} */ - @Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) { - writer.setBuffer(buf); - - if (!writer.isHeaderWritten()) { - if (!writer.writeHeader(directType())) - return false; - - writer.onHeaderWritten(); - } - - switch (writer.state()) { - case 0: - if (!writer.writeCollection(msgs, MessageCollectionItemType.MSG)) - return false; - - writer.incrementState(); - - } - - return true; - } - - /** {@inheritDoc} */ - @Override public boolean readFrom(ByteBuffer buf, MessageReader reader) { - reader.setBuffer(buf); - - switch (reader.state()) { - case 0: - msgs = reader.readCollection(MessageCollectionItemType.MSG); - - if (!reader.isLastRead()) - return false; - - reader.incrementState(); - - } - - return true; - } - - /** {@inheritDoc} */ - @Override public short directType() { - return 124; - } - - /** {@inheritDoc} */ - @Override public boolean equals(Object o) { - if (this == o) - return true; - - if (o == null || getClass() != o.getClass()) - return false; - - GridMessageCollection<?> that = (GridMessageCollection<?>)o; - - return msgs == that.msgs || (msgs != null && msgs.equals(that.msgs)); - } - - /** {@inheritDoc} */ - @Override public int hashCode() { - return msgs != null ? msgs.hashCode() : 0; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(GridMessageCollection.class, this, "msgsSize", msgs == null ? null : msgs.size()); - } -} diff --git a/modules/core/src/main/resources/META-INF/classnames.properties b/modules/core/src/main/resources/META-INF/classnames.properties index 0b75870cf18..071bc6eb437 100644 --- a/modules/core/src/main/resources/META-INF/classnames.properties +++ b/modules/core/src/main/resources/META-INF/classnames.properties @@ -1983,7 +1983,6 @@ org.apache.ignite.internal.util.GridLogThrottle$LogLevel$1 org.apache.ignite.internal.util.GridLogThrottle$LogLevel$2 org.apache.ignite.internal.util.GridLogThrottle$LogLevel$3 org.apache.ignite.internal.util.GridLongList -org.apache.ignite.internal.util.GridMessageCollection org.apache.ignite.internal.util.GridMutex org.apache.ignite.internal.util.GridPartitionStateMap org.apache.ignite.internal.util.GridRandom diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteUtilSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteUtilSelfTestSuite.java index 70119dd1fe8..abacbcaa46c 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteUtilSelfTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteUtilSelfTestSuite.java @@ -60,7 +60,6 @@ import org.apache.ignite.util.GridConcurrentLinkedDequeMultiThreadedTest; import org.apache.ignite.util.GridIntListSelfTest; import org.apache.ignite.util.GridLogThrottleTest; import org.apache.ignite.util.GridLongListSelfTest; -import org.apache.ignite.util.GridMessageCollectionTest; import org.apache.ignite.util.GridPartitionMapSelfTest; import org.apache.ignite.util.GridQueueSelfTest; import org.apache.ignite.util.GridRandomSelfTest; @@ -102,7 +101,6 @@ import org.junit.runners.Suite; GridIntListSelfTest.class, GridArraysSelfTest.class, IgniteExceptionRegistrySelfTest.class, - GridMessageCollectionTest.class, WorkersControlMXBeanTest.class, GridConcurrentLinkedDequeMultiThreadedTest.class, GridLogThrottleTest.class, diff --git a/modules/core/src/test/java/org/apache/ignite/util/GridMessageCollectionTest.java b/modules/core/src/test/java/org/apache/ignite/util/GridMessageCollectionTest.java deleted file mode 100644 index c7aad15c1bc..00000000000 --- a/modules/core/src/test/java/org/apache/ignite/util/GridMessageCollectionTest.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * 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.util; - -import java.nio.ByteBuffer; -import org.apache.ignite.internal.direct.DirectMessageReader; -import org.apache.ignite.internal.direct.DirectMessageWriter; -import org.apache.ignite.internal.managers.communication.GridIoMessageFactory; -import org.apache.ignite.internal.managers.communication.IgniteMessageFactoryImpl; -import org.apache.ignite.internal.util.UUIDCollectionMessage; -import org.apache.ignite.plugin.extensions.communication.Message; -import org.apache.ignite.plugin.extensions.communication.MessageFactory; -import org.apache.ignite.plugin.extensions.communication.MessageFactoryProvider; -import org.apache.ignite.plugin.extensions.communication.MessageReader; -import org.apache.ignite.plugin.extensions.communication.MessageWriter; -import org.junit.Test; - -import static java.util.UUID.randomUUID; -import static org.apache.ignite.internal.util.GridMessageCollection.of; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - -/** - * - */ -public class GridMessageCollectionTest { - /** - * @return Writer. - */ - protected MessageWriter writer(MessageFactory msgFactory) { - return new DirectMessageWriter(msgFactory); - } - - /** - * @param msgFactory Message factory. - * @return Writer. - */ - protected MessageReader reader(MessageFactory msgFactory) { - return new DirectMessageReader(msgFactory); - } - - /** - * - */ - @Test - public void testMarshal() { - UUIDCollectionMessage um0 = UUIDCollectionMessage.of(); - UUIDCollectionMessage um1 = UUIDCollectionMessage.of(randomUUID()); - UUIDCollectionMessage um2 = UUIDCollectionMessage.of(randomUUID(), randomUUID()); - UUIDCollectionMessage um3 = UUIDCollectionMessage.of(randomUUID(), randomUUID(), randomUUID()); - - assertNull(um0); - assertEquals(3, um3.uuids().size()); - - doTestMarshal(um0, um1, um2, um3); - } - - /** - * @param um0 Null. - * @param um1 One uuid list. - * @param um2 Two uuid list. - * @param um3 Three uuid list. - */ - private void doTestMarshal( - UUIDCollectionMessage um0, - UUIDCollectionMessage um1, - UUIDCollectionMessage um2, - UUIDCollectionMessage um3 - ) { - doTestMarshal(um1); - doTestMarshal(um2); - doTestMarshal(um3); - - doTestMarshal(of(um0)); - doTestMarshal(of(um1)); - doTestMarshal(of(um2)); - doTestMarshal(of(um3)); - - doTestMarshal(of(um2, um3)); - doTestMarshal(of(um1, um0, um3)); - - doTestMarshal(of(of(um3), of(um2))); - doTestMarshal(of(of(of(of(of(um0))), um1, of(um3)))); - } - - /** - * @param m Message. - */ - private void doTestMarshal(Message m) { - ByteBuffer buf = ByteBuffer.allocate(8 * 1024); - - MessageFactory msgFactory = - new IgniteMessageFactoryImpl(new MessageFactoryProvider[]{new GridIoMessageFactory()}); - - m.writeTo(buf, writer(msgFactory)); - - buf.flip(); - - byte b0 = buf.get(); - byte b1 = buf.get(); - - short type = (short)((b1 & 0xFF) << 8 | b0 & 0xFF); - - assertEquals(m.directType(), type); - - Message mx = msgFactory.create(type); - - mx.readFrom(buf, reader(msgFactory)); - - assertEquals(m, mx); - } -}