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 9b529887447 IGNITE-28512 Use MessageSerializer for PartitionKey
(#13120)
9b529887447 is described below
commit 9b529887447bdacd49707d856630a621a33ec944
Author: Vladimir Steshin <[email protected]>
AuthorDate: Wed May 13 09:04:24 2026 +0300
IGNITE-28512 Use MessageSerializer for PartitionKey (#13120)
---
.../ignite/internal/CoreMessagesProvider.java | 5 +++
.../internal/management/cache/PartitionKey.java | 19 +++++++--
.../SnapshotCheckPartitionHashesResponse.java | 24 ++----------
.../SnapshotPartitionsVerifyHandlerResponse.java | 24 ++----------
.../cache/verify/PartitionHashRecord.java | 45 +++++++++++++++++++---
5 files changed, 66 insertions(+), 51 deletions(-)
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/CoreMessagesProvider.java
b/modules/core/src/main/java/org/apache/ignite/internal/CoreMessagesProvider.java
index a96e2457e62..836e36254e1 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/CoreMessagesProvider.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/CoreMessagesProvider.java
@@ -23,6 +23,7 @@ import
org.apache.ignite.internal.cache.query.QueryIndexMessage;
import org.apache.ignite.internal.cache.query.index.IndexQueryResultMeta;
import org.apache.ignite.internal.cache.query.index.sorted.IndexKeyDefinition;
import
org.apache.ignite.internal.cache.query.index.sorted.IndexKeyTypeSettings;
+import org.apache.ignite.internal.management.cache.PartitionKey;
import org.apache.ignite.internal.managers.checkpoint.GridCheckpointRequest;
import org.apache.ignite.internal.managers.communication.CompressedMessage;
import org.apache.ignite.internal.managers.communication.ErrorMessage;
@@ -170,6 +171,7 @@ import
org.apache.ignite.internal.processors.cache.transactions.TxEntryValueHold
import org.apache.ignite.internal.processors.cache.transactions.TxLock;
import org.apache.ignite.internal.processors.cache.transactions.TxLocksRequest;
import
org.apache.ignite.internal.processors.cache.transactions.TxLocksResponse;
+import org.apache.ignite.internal.processors.cache.verify.PartitionHashRecord;
import
org.apache.ignite.internal.processors.cache.version.GridCacheRawVersionedEntry;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersionEx;
@@ -438,6 +440,7 @@ public class CoreMessagesProvider extends
AbstractMarshallableMessageFactoryProv
withNoSchema(ExchangeFailureMessage.class);
withNoSchema(CacheStatisticsClearMessage.class);
withNoSchema(ClientCacheChangeDummyDiscoveryMessage.class);
+ // TODO: revise using resolved class loader,
https://issues.apache.org/jira/browse/IGNITE-28637
withNoSchemaResolvedClassLoader(DynamicCacheChangeBatch.class);
// [10000 - 10200]: Transaction and lock related messages. Most of
them originally comes from Communication.
@@ -534,6 +537,8 @@ public class CoreMessagesProvider extends
AbstractMarshallableMessageFactoryProv
withNoSchema(GridDhtPartitionsFullMessage.class);
withNoSchema(GridDhtPartitionsSingleMessage.class);
withNoSchema(GridDhtPartitionsSingleRequest.class);
+ withNoSchema(PartitionKey.class);
+ withNoSchema(PartitionHashRecord.class);
// [10900-11100]: Query, schema and SQL related messages.
msgIdx = 10900;
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/management/cache/PartitionKey.java
b/modules/core/src/main/java/org/apache/ignite/internal/management/cache/PartitionKey.java
index f9a212852d7..8819d9a0b0b 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/management/cache/PartitionKey.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/management/cache/PartitionKey.java
@@ -17,23 +17,34 @@
package org.apache.ignite.internal.management.cache;
import java.io.Serializable;
+import org.apache.ignite.internal.Order;
import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.plugin.extensions.communication.Message;
+import org.apache.ignite.plugin.extensions.communication.MessageFactory;
/**
* Partition key - pair of cache group ID and partition ID.
*/
-public class PartitionKey implements Serializable {
+public class PartitionKey implements Message, Serializable {
/** */
private static final long serialVersionUID = 0L;
/** Group id. */
- private final int grpId;
+ @Order(0)
+ int grpId;
/** Group name. Optional field, used only for output. */
- private final String grpName;
+ @Order(1)
+ String grpName;
/** Partition id. */
- private final int partId;
+ @Order(2)
+ int partId;
+
+ /** Empty constructor for a {@link MessageFactory}. */
+ public PartitionKey() {
+ // No-op.
+ }
/**
* @param grpId Group id.
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotCheckPartitionHashesResponse.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotCheckPartitionHashesResponse.java
index 624f26af604..f1d6426f77c 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotCheckPartitionHashesResponse.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotCheckPartitionHashesResponse.java
@@ -18,23 +18,17 @@
package org.apache.ignite.internal.processors.cache.persistence.snapshot;
import java.util.Map;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.MarshallableMessage;
import org.apache.ignite.internal.Order;
import org.apache.ignite.internal.management.cache.PartitionKey;
import org.apache.ignite.internal.processors.cache.verify.PartitionHashRecord;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.plugin.extensions.communication.Message;
import org.apache.ignite.plugin.extensions.communication.MessageFactory;
/** */
-public class SnapshotCheckPartitionHashesResponse implements
MarshallableMessage {
+public class SnapshotCheckPartitionHashesResponse implements Message {
/** Per metas result: consistent id -> check results per partition key. */
- private Map<String, Map<PartitionKey, PartitionHashRecord>> perMetaResults;
-
- /** */
@Order(0)
- byte[] perMetaResultsBytes;
+ Map<String, Map<PartitionKey, PartitionHashRecord>> perMetaResults;
/** Default constructor for {@link MessageFactory}. */
public SnapshotCheckPartitionHashesResponse() {
@@ -50,16 +44,4 @@ public class SnapshotCheckPartitionHashesResponse implements
MarshallableMessage
public Map<String, Map<PartitionKey, PartitionHashRecord>>
perMetaResults() {
return perMetaResults;
}
-
- /** {@inheritDoc} */
- @Override public void prepareMarshal(Marshaller marsh) throws
IgniteCheckedException {
- perMetaResultsBytes = U.marshal(marsh, perMetaResults);
- }
-
- /** {@inheritDoc} */
- @Override public void finishUnmarshal(Marshaller marsh, ClassLoader
clsLdr) throws IgniteCheckedException {
- if (perMetaResultsBytes != null)
- perMetaResults = U.unmarshal(marsh, perMetaResultsBytes, clsLdr);
- }
-
}
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotPartitionsVerifyHandlerResponse.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotPartitionsVerifyHandlerResponse.java
index ee795b8f049..c6879e25e3e 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotPartitionsVerifyHandlerResponse.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotPartitionsVerifyHandlerResponse.java
@@ -18,23 +18,17 @@
package org.apache.ignite.internal.processors.cache.persistence.snapshot;
import java.util.Map;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.MarshallableMessage;
import org.apache.ignite.internal.Order;
import org.apache.ignite.internal.management.cache.PartitionKey;
import org.apache.ignite.internal.processors.cache.verify.PartitionHashRecord;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.plugin.extensions.communication.Message;
import org.apache.ignite.plugin.extensions.communication.MessageFactory;
/** */
-public class SnapshotPartitionsVerifyHandlerResponse implements
MarshallableMessage {
- /** */
- private Map<PartitionKey, PartitionHashRecord> res;
-
+public class SnapshotPartitionsVerifyHandlerResponse implements Message {
/** */
@Order(0)
- byte[] resBytes;
+ Map<PartitionKey, PartitionHashRecord> res;
/** Default constructor for {@link MessageFactory}. */
public SnapshotPartitionsVerifyHandlerResponse() {
@@ -50,16 +44,4 @@ public class SnapshotPartitionsVerifyHandlerResponse
implements MarshallableMess
public Map<PartitionKey, PartitionHashRecord> response() {
return res;
}
-
- /** {@inheritDoc} */
- @Override public void prepareMarshal(Marshaller marsh) throws
IgniteCheckedException {
- resBytes = U.marshal(marsh, res);
- }
-
- /** {@inheritDoc} */
- @Override public void finishUnmarshal(Marshaller marsh, ClassLoader
clsLdr) throws IgniteCheckedException {
- if (resBytes != null)
- res = U.unmarshal(marsh, resBytes, clsLdr);
- }
-
}
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/PartitionHashRecord.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/PartitionHashRecord.java
index a344159ae9e..06ce5642fe8 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/PartitionHashRecord.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/PartitionHashRecord.java
@@ -16,22 +16,27 @@
*/
package org.apache.ignite.internal.processors.cache.verify;
+import java.io.Serializable;
import java.util.Objects;
+import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.configuration.BinaryConfiguration;
+import org.apache.ignite.internal.MarshallableMessage;
import org.apache.ignite.internal.Order;
import org.apache.ignite.internal.binary.GridBinaryMarshaller;
-import org.apache.ignite.internal.dto.IgniteDataTransferObject;
import org.apache.ignite.internal.management.cache.PartitionKey;
import
org.apache.ignite.internal.processors.cache.verify.IdleVerifyUtility.VerifyPartitionContext;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.plugin.extensions.communication.MessageFactory;
import org.jetbrains.annotations.Nullable;
/**
* Record containing partition checksum, primary flag and consistent ID of
owner.
*/
-public class PartitionHashRecord extends IgniteDataTransferObject {
+public class PartitionHashRecord implements MarshallableMessage, Serializable {
/** */
private static final long serialVersionUID = 0L;
@@ -48,10 +53,14 @@ public class PartitionHashRecord extends
IgniteDataTransferObject {
boolean isPrimary;
/** Consistent id. */
- @Order(2)
@GridToStringInclude
Object consistentId;
+ /** Bytes of {@link #consistentId}. */
+ @Order(2)
+ @GridToStringExclude
+ byte[] consistentIdBytes;
+
/** Partition entries content hash. */
@Order(3)
@GridToStringExclude
@@ -63,10 +72,14 @@ public class PartitionHashRecord extends
IgniteDataTransferObject {
int partVerHash;
/** Update counter's state. */
- @Order(5)
@GridToStringInclude
Object updateCntr;
+ /** Bytes of {@link #updateCntr}. */
+ @Order(5)
+ @GridToStringExclude
+ byte[] updateCntrBytes;
+
/** Size. */
@Order(6)
@GridToStringExclude
@@ -143,9 +156,10 @@ public class PartitionHashRecord extends
IgniteDataTransferObject {
}
/**
- * Default constructor for Externalizable.
+ * Default constructor for Externalizable and a {@link MessageFactory}.
*/
public PartitionHashRecord() {
+ // No-op.
}
/**
@@ -234,6 +248,27 @@ public class PartitionHashRecord extends
IgniteDataTransferObject {
this.hasExpiringEntries = hasExpiringEntries;
}
+ /** {@inheritDoc} */
+ @Override public void prepareMarshal(Marshaller marsh) throws
IgniteCheckedException {
+ if (consistentId != null)
+ consistentIdBytes = U.marshal(marsh, consistentId);
+
+ if (updateCntr != null)
+ updateCntrBytes = U.marshal(marsh, updateCntr);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void finishUnmarshal(Marshaller marsh, ClassLoader
clsLdr) throws IgniteCheckedException {
+ if (consistentIdBytes != null)
+ consistentId = U.unmarshal(marsh, consistentIdBytes, clsLdr);
+
+ if (updateCntrBytes != null)
+ updateCntr = U.unmarshal(marsh, updateCntrBytes, clsLdr);
+
+ consistentId = null;
+ updateCntrBytes = null;
+ }
+
/** {@inheritDoc} */
@Override public String toString() {
return size == MOVING_PARTITION_SIZE ?