This is an automated email from the ASF dual-hosted git repository.
shishkovilja 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 8d6de1a8dbd IGNITE-26423 Use MessageSerializer for
GridDhtPartitionsSingleRequest (#12341)
8d6de1a8dbd is described below
commit 8d6de1a8dbd451ce218f9fc0886c83c88f55d4bb
Author: Dmitry Werner <[email protected]>
AuthorDate: Mon Sep 15 12:35:20 2025 +0500
IGNITE-26423 Use MessageSerializer for GridDhtPartitionsSingleRequest
(#12341)
---
.../communication/GridIoMessageFactory.java | 3 +-
.../GridDhtPartitionsAbstractMessage.java | 27 ++++++++++
.../preloader/GridDhtPartitionsSingleRequest.java | 61 ++++------------------
3 files changed, 39 insertions(+), 52 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 9c19488a702..804df58ac83 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
@@ -35,6 +35,7 @@ import
org.apache.ignite.internal.codegen.GridCacheVersionSerializer;
import org.apache.ignite.internal.codegen.GridCheckpointRequestSerializer;
import org.apache.ignite.internal.codegen.GridDeploymentResponseSerializer;
import org.apache.ignite.internal.codegen.GridDhtPartitionExchangeIdSerializer;
+import
org.apache.ignite.internal.codegen.GridDhtPartitionsSingleRequestSerializer;
import
org.apache.ignite.internal.codegen.GridDhtTxOnePhaseCommitAckRequestSerializer;
import org.apache.ignite.internal.codegen.GridIntListSerializer;
import org.apache.ignite.internal.codegen.GridJobCancelRequestSerializer;
@@ -278,7 +279,7 @@ public class GridIoMessageFactory implements
MessageFactoryProvider {
factory.register((short)45, GridDhtPartitionDemandMessage::new);
factory.register((short)46, GridDhtPartitionsFullMessage::new);
factory.register((short)47, GridDhtPartitionsSingleMessage::new);
- factory.register((short)48, GridDhtPartitionsSingleRequest::new);
+ factory.register((short)48, GridDhtPartitionsSingleRequest::new, new
GridDhtPartitionsSingleRequestSerializer());
factory.register((short)49, GridNearGetRequest::new);
factory.register((short)50, GridNearGetResponse::new);
factory.register((short)51, GridNearLockRequest::new);
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsAbstractMessage.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsAbstractMessage.java
index a0547e76b95..30f901fe3ff 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsAbstractMessage.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsAbstractMessage.java
@@ -18,6 +18,7 @@
package org.apache.ignite.internal.processors.cache.distributed.dht.preloader;
import java.nio.ByteBuffer;
+import org.apache.ignite.internal.Order;
import org.apache.ignite.internal.managers.communication.GridIoMessage;
import org.apache.ignite.internal.processors.cache.GridCacheMessage;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
@@ -37,12 +38,15 @@ public abstract class GridDhtPartitionsAbstractMessage
extends GridCacheMessage
private static final byte RESTORE_STATE_FLAG_MASK = 0x02;
/** Exchange ID. */
+ @Order(value = 3, method = "exchangeId")
private GridDhtPartitionExchangeId exchId;
/** Last used cache version. */
+ @Order(value = 4, method = "lastVersion")
private GridCacheVersion lastVer;
/** */
+ @Order(5)
protected byte flags;
/**
@@ -111,6 +115,27 @@ public abstract class GridDhtPartitionsAbstractMessage
extends GridCacheMessage
return lastVer;
}
+ /**
+ * @param lastVer Last used version among all nodes.
+ */
+ public void lastVersion(GridCacheVersion lastVer) {
+ this.lastVer = lastVer;
+ }
+
+ /**
+ * @return Flags.
+ */
+ public byte flags() {
+ return flags;
+ }
+
+ /**
+ * @param flags Flags.
+ */
+ public void flags(byte flags) {
+ this.flags = flags;
+ }
+
/**
* @return {@code True} if message data is compressed.
*/
@@ -141,6 +166,7 @@ public abstract class GridDhtPartitionsAbstractMessage
extends GridCacheMessage
/** {@inheritDoc} */
@Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) {
+ // TODO: Remove #writeTo() after all inheritors have migrated to the
new ser/der scheme (IGNITE-25490).
writer.setBuffer(buf);
if (!super.writeTo(buf, writer))
@@ -179,6 +205,7 @@ public abstract class GridDhtPartitionsAbstractMessage
extends GridCacheMessage
/** {@inheritDoc} */
@Override public boolean readFrom(ByteBuffer buf, MessageReader reader) {
+ // TODO: Remove #readFrom() after all inheritors have migrated to the
new ser/der scheme (IGNITE-25490).
reader.setBuffer(buf);
if (!super.readFrom(buf, reader))
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleRequest.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleRequest.java
index cc9a4a9a8ca..48411cdaf7c 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleRequest.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleRequest.java
@@ -17,16 +17,15 @@
package org.apache.ignite.internal.processors.cache.distributed.dht.preloader;
-import java.nio.ByteBuffer;
+import org.apache.ignite.internal.Order;
import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.plugin.extensions.communication.MessageReader;
-import org.apache.ignite.plugin.extensions.communication.MessageWriter;
/**
* Request for single partition info.
*/
public class GridDhtPartitionsSingleRequest extends
GridDhtPartitionsAbstractMessage {
/** */
+ @Order(value = 6, method = "restoreExchangeId")
private GridDhtPartitionExchangeId restoreExchId;
/**
@@ -62,60 +61,20 @@ public class GridDhtPartitionsSingleRequest extends
GridDhtPartitionsAbstractMes
/**
* @return ID of current exchange on new coordinator.
*/
- GridDhtPartitionExchangeId restoreExchangeId() {
+ public GridDhtPartitionExchangeId restoreExchangeId() {
return restoreExchId;
}
- /** {@inheritDoc} */
- @Override public int handlerId() {
- return 0;
- }
-
- /** {@inheritDoc} */
- @Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) {
- writer.setBuffer(buf);
-
- if (!super.writeTo(buf, writer))
- return false;
-
- if (!writer.isHeaderWritten()) {
- if (!writer.writeHeader(directType()))
- return false;
-
- writer.onHeaderWritten();
- }
-
- switch (writer.state()) {
- case 6:
- if (!writer.writeMessage(restoreExchId))
- return false;
-
- writer.incrementState();
-
- }
-
- return true;
+ /**
+ * @param restoreExchId ID of current exchange on new coordinator.
+ */
+ public void restoreExchangeId(GridDhtPartitionExchangeId restoreExchId) {
+ this.restoreExchId = restoreExchId;
}
/** {@inheritDoc} */
- @Override public boolean readFrom(ByteBuffer buf, MessageReader reader) {
- reader.setBuffer(buf);
-
- if (!super.readFrom(buf, reader))
- return false;
-
- switch (reader.state()) {
- case 6:
- restoreExchId = reader.readMessage();
-
- if (!reader.isLastRead())
- return false;
-
- reader.incrementState();
-
- }
-
- return true;
+ @Override public int handlerId() {
+ return 0;
}
/** {@inheritDoc} */