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 b43dba33469 IGNITE-25993 Use MessageSerializer for
GridDhtPartitionExchangeId (#12217)
b43dba33469 is described below
commit b43dba334690a257d845f14e6dd73c0ac8c02b41
Author: Ilya Shishkov <[email protected]>
AuthorDate: Mon Jul 28 11:43:28 2025 +0300
IGNITE-25993 Use MessageSerializer for GridDhtPartitionExchangeId (#12217)
---
.../communication/GridIoMessageFactory.java | 3 +-
.../dht/preloader/GridDhtPartitionExchangeId.java | 99 ++++++----------------
2 files changed, 27 insertions(+), 75 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 bb067029de1..b7bf7f5ddc5 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
@@ -29,6 +29,7 @@ import org.apache.ignite.internal.binary.BinaryUtils;
import org.apache.ignite.internal.codegen.GridCacheEntryInfoSerializer;
import org.apache.ignite.internal.codegen.GridCacheVersionExSerializer;
import org.apache.ignite.internal.codegen.GridCacheVersionSerializer;
+import org.apache.ignite.internal.codegen.GridDhtPartitionExchangeIdSerializer;
import org.apache.ignite.internal.codegen.GridIntListSerializer;
import org.apache.ignite.internal.codegen.GridJobCancelRequestSerializer;
import org.apache.ignite.internal.codegen.GridQueryKillRequestSerializer;
@@ -279,7 +280,7 @@ public class GridIoMessageFactory implements
MessageFactoryProvider {
factory.register((short)84, GridByteArrayList::new);
factory.register((short)85, GridLongList::new);
factory.register((short)86, GridCacheVersion::new, new
GridCacheVersionSerializer());
- factory.register((short)87, GridDhtPartitionExchangeId::new);
+ factory.register((short)87, GridDhtPartitionExchangeId::new, new
GridDhtPartitionExchangeIdSerializer());
factory.register((short)88, GridCacheReturn::new);
factory.register((short)89, CacheObjectImpl::new);
factory.register((short)90, KeyCacheObjectImpl::new);
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionExchangeId.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionExchangeId.java
index f2d66478bae..039a9caf3de 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionExchangeId.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionExchangeId.java
@@ -21,18 +21,15 @@ import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
-import java.nio.ByteBuffer;
import java.util.UUID;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.events.DiscoveryEvent;
-import org.apache.ignite.internal.GridDirectTransient;
+import org.apache.ignite.internal.Order;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.plugin.extensions.communication.Message;
-import org.apache.ignite.plugin.extensions.communication.MessageReader;
-import org.apache.ignite.plugin.extensions.communication.MessageWriter;
import static org.apache.ignite.events.EventType.EVT_NODE_FAILED;
import static org.apache.ignite.events.EventType.EVT_NODE_JOINED;
@@ -47,18 +44,20 @@ public class GridDhtPartitionExchangeId implements Message,
Comparable<GridDhtPa
private static final long serialVersionUID = 0L;
/** Node ID. */
+ @Order(0)
@GridToStringExclude
private UUID nodeId;
/** Event type. */
+ @Order(value = 1, method = "event")
@GridToStringExclude
private int evt;
/** Topology version. */
+ @Order(value = 2, method = "topologyVersion")
private AffinityTopologyVersion topVer;
/** */
- @GridDirectTransient
private DiscoveryEvent discoEvt;
/**
@@ -105,6 +104,13 @@ public class GridDhtPartitionExchangeId implements
Message, Comparable<GridDhtPa
return nodeId;
}
+ /**
+ * @param nodeId New node ID.
+ */
+ public void nodeId(UUID nodeId) {
+ this.nodeId = nodeId;
+ }
+
/**
* @return Event.
*/
@@ -112,6 +118,13 @@ public class GridDhtPartitionExchangeId implements
Message, Comparable<GridDhtPa
return evt;
}
+ /**
+ * @param evt New event type.
+ */
+ public void event(int evt) {
+ this.evt = evt;
+ }
+
/**
* @return Discovery event timestamp.
*/
@@ -158,6 +171,13 @@ public class GridDhtPartitionExchangeId implements
Message, Comparable<GridDhtPa
return topVer;
}
+ /**
+ * @param topVer New topology version.
+ */
+ public void topologyVersion(AffinityTopologyVersion topVer) {
+ this.topVer = topVer;
+ }
+
/**
* @return {@code True} if exchange is for new node joining.
*/
@@ -222,75 +242,6 @@ public class GridDhtPartitionExchangeId implements
Message, Comparable<GridDhtPa
return evt == id.evt && topVer.equals(id.topVer) &&
nodeId.equals(id.nodeId);
}
- /** {@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.writeInt(evt))
- return false;
-
- writer.incrementState();
-
- case 1:
- if (!writer.writeUuid(nodeId))
- return false;
-
- writer.incrementState();
-
- case 2:
- if (!writer.writeAffinityTopologyVersion(topVer))
- return false;
-
- writer.incrementState();
-
- }
-
- return true;
- }
-
- /** {@inheritDoc} */
- @Override public boolean readFrom(ByteBuffer buf, MessageReader reader) {
- reader.setBuffer(buf);
-
- switch (reader.state()) {
- case 0:
- evt = reader.readInt();
-
- if (!reader.isLastRead())
- return false;
-
- reader.incrementState();
-
- case 1:
- nodeId = reader.readUuid();
-
- if (!reader.isLastRead())
- return false;
-
- reader.incrementState();
-
- case 2:
- topVer = reader.readAffinityTopologyVersion();
-
- if (!reader.isLastRead())
- return false;
-
- reader.incrementState();
-
- }
-
- return true;
- }
-
/** {@inheritDoc} */
@Override public short directType() {
return 87;