This is an automated email from the ASF dual-hosted git repository.

wernerdv 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 bc4c25c5ef3 IGNITE-28792 Use MessageSerializer to transfer 
CacheGroupData and CacheData (#13386)
bc4c25c5ef3 is described below

commit bc4c25c5ef3a8e0653a1e85607a42e9bfe0abd0d
Author: Dmitry Werner <[email protected]>
AuthorDate: Tue Aug 4 13:29:46 2026 +0500

    IGNITE-28792 Use MessageSerializer to transfer CacheGroupData and CacheData 
(#13386)
---
 .../ignite/internal/CoreMessagesProvider.java      |   6 +
 .../internal/processors/cache/CacheData.java       | 134 ++++++++-------------
 .../internal/processors/cache/CacheGroupData.java  | 103 ++++++++--------
 .../cache/CacheNodeCommonDiscoveryData.java        |  61 ++++------
 .../processors/cache/ClusterCachesInfo.java        |  16 +--
 5 files changed, 136 insertions(+), 184 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 df35e9ce099..8b3fe7bbd4f 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
@@ -55,12 +55,15 @@ import 
org.apache.ignite.internal.processors.authentication.UserProposedMessage;
 import org.apache.ignite.internal.processors.cache.CacheAffinityChangeMessage;
 import 
org.apache.ignite.internal.processors.cache.CacheClientReconnectDiscoveryData;
 import 
org.apache.ignite.internal.processors.cache.CacheConfigurationEnrichment;
+import org.apache.ignite.internal.processors.cache.CacheData;
 import org.apache.ignite.internal.processors.cache.CacheEntryPredicateAdapter;
 import org.apache.ignite.internal.processors.cache.CacheEvictionEntry;
+import org.apache.ignite.internal.processors.cache.CacheGroupData;
 import org.apache.ignite.internal.processors.cache.CacheGroupRecoveryState;
 import org.apache.ignite.internal.processors.cache.CacheInvokeDirectResult;
 import org.apache.ignite.internal.processors.cache.CacheJoinInfo;
 import org.apache.ignite.internal.processors.cache.CacheJoinNodeDiscoveryData;
+import 
org.apache.ignite.internal.processors.cache.CacheNodeCommonDiscoveryData;
 import org.apache.ignite.internal.processors.cache.CacheReconnectInfo;
 import org.apache.ignite.internal.processors.cache.CacheStatisticsClearMessage;
 import 
org.apache.ignite.internal.processors.cache.CacheStatisticsModeChangeMessage;
@@ -552,6 +555,9 @@ public class CoreMessagesProvider extends 
AbstractMarshallableMessageFactoryProv
         register(StartRoutineAckDiscoveryMessage.class);
         register(StartRoutineDiscoveryMessage.class);
         register(StoredCacheData.class);
+        register(CacheNodeCommonDiscoveryData.class);
+        register(CacheData.class);
+        register(CacheGroupData.class);
 
         // [10600-10800]: Affinity & partition maps.
         msgIdx = 10600;
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheData.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheData.java
index 0135f1595b7..b41be15bbe8 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheData.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheData.java
@@ -17,72 +17,83 @@
 
 package org.apache.ignite.internal.processors.cache;
 
-import java.io.Serializable;
+import java.util.Collection;
 import java.util.UUID;
+import org.apache.ignite.cache.QueryEntity;
 import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.internal.Marshalled;
+import org.apache.ignite.internal.Order;
 import org.apache.ignite.internal.processors.query.QuerySchema;
+import 
org.apache.ignite.internal.processors.query.schema.message.QueryEntityMessage;
+import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.plugin.extensions.communication.Message;
+import org.apache.ignite.plugin.extensions.communication.MessageFactory;
 
-/**
- * Cache information sent in discovery data to joining node.
- */
-public class CacheData implements Serializable {
+/** Cache information sent in discovery data to joining node. */
+public class CacheData implements Message {
     /** */
-    private static final long serialVersionUID = 0L;
+    @Marshalled("cacheCfgBytes")
+    CacheConfiguration cacheCfg;
 
-    /** */
-    private final CacheConfiguration cacheCfg;
+    /** Serialized {@link #cacheCfg}. */
+    @Order(0)
+    byte[] cacheCfgBytes;
 
     /** */
-    private final int cacheId;
+    @Order(1)
+    int grpId;
 
     /** */
-    private final int grpId;
+    @Order(2)
+    CacheType cacheType;
 
     /** */
-    private final CacheType cacheType;
+    @Order(3)
+    IgniteUuid deploymentId;
 
     /** */
-    private final IgniteUuid deploymentId;
+    private Collection<QueryEntity> entities;
 
     /** */
-    private final QuerySchema schema;
+    @Order(4)
+    Collection<QueryEntityMessage> entitiesMsgs;
 
     /** */
-    private final UUID rcvdFrom;
+    @Order(5)
+    UUID rcvdFrom;
 
     /** */
-    private final boolean staticCfg;
+    @Order(6)
+    boolean staticCfg;
 
     /** */
-    private final boolean sql;
-
-    /** */
-    private final boolean template;
-
-    /** Flags added for future usage. */
-    private final long flags;
+    @Order(7)
+    boolean sql;
 
     /** Cache configuration enrichment. */
-    private final CacheConfigurationEnrichment cacheCfgEnrichment;
+    @Order(8)
+    CacheConfigurationEnrichment cacheCfgEnrichment;
+
+    /** Default constructor for {@link MessageFactory}. */
+    public CacheData() {
+        // No-op.
+    }
 
     /**
      * @param cacheCfg Cache configuration.
-     * @param cacheId Cache ID.
      * @param grpId Cache group ID.
-     * @param cacheType Cache ID.
+     * @param cacheType Cache type.
      * @param deploymentId Cache deployment ID.
      * @param schema Query schema.
      * @param rcvdFrom Node ID cache was started from.
      * @param staticCfg {@code True} if cache was statically configured.
      * @param sql {@code True} if cache was created by an SQL command such as 
{@code CREATE TABLE}.
      * @param template {@code True} if this is cache template.
-     * @param flags Flags (added for future usage).
      * @param cacheCfgEnrichment Cache configuration enrichment.
      */
     CacheData(CacheConfiguration cacheCfg,
-        int cacheId,
         int grpId,
         CacheType cacheType,
         IgniteUuid deploymentId,
@@ -91,109 +102,68 @@ public class CacheData implements Serializable {
         boolean staticCfg,
         boolean sql,
         boolean template,
-        long flags,
         CacheConfigurationEnrichment cacheCfgEnrichment
     ) {
         assert cacheCfg != null;
         assert rcvdFrom != null : cacheCfg.getName();
         assert deploymentId != null : cacheCfg.getName();
-        assert template || cacheId != 0 : cacheCfg.getName();
         assert template || grpId != 0 : cacheCfg.getName();
 
         this.cacheCfg = cacheCfg;
-        this.cacheId = cacheId;
         this.grpId = grpId;
         this.cacheType = cacheType;
         this.deploymentId = deploymentId;
-        this.schema = schema;
+        entitiesMsgs = F.viewReadOnly(schema.entities(), 
QueryEntityMessage::new);
         this.rcvdFrom = rcvdFrom;
         this.staticCfg = staticCfg;
         this.sql = sql;
-        this.template = template;
-        this.flags = flags;
         this.cacheCfgEnrichment = cacheCfgEnrichment;
     }
 
-    /**
-     * @return Cache group ID.
-     */
+    /** @return Cache group ID. */
     public int groupId() {
         return grpId;
     }
 
-    /**
-     * @return Cache ID.
-     */
-    public int cacheId() {
-        return cacheId;
-    }
-
-    /**
-     * @return {@code True} if this is template configuration.
-     */
-    public boolean template() {
-        return template;
-    }
-
-    /**
-     * @return Cache type.
-     */
+    /** @return Cache type. */
     public CacheType cacheType() {
         return cacheType;
     }
 
-    /**
-     * @return Start ID.
-     */
+    /** @return Start ID. */
     public IgniteUuid deploymentId() {
         return deploymentId;
     }
 
-    /**
-     * @return {@code True} if statically configured.
-     */
+    /** @return {@code True} if statically configured. */
     public boolean staticallyConfigured() {
         return staticCfg;
     }
 
-    /**
-     * @return {@code True} if cache was created by an SQL command such as 
{@code CREATE TABLE}.
-     */
+    /** @return {@code True} if cache was created by an SQL command such as 
{@code CREATE TABLE}. */
     public boolean sql() {
         return sql;
     }
 
-    /**
-     * @return Cache configuration.
-     */
+    /** @return Cache configuration. */
     public CacheConfiguration cacheConfiguration() {
         return cacheCfg;
     }
 
-    /**
-     * @return Schema.
-     */
+    /** @return Schema. */
     public QuerySchema schema() {
-        return schema.copy();
+        if (entities == null)
+            entities = F.transform(entitiesMsgs, QueryEntityMessage::toEntity);
+
+        return new QuerySchema(entities);
     }
 
-    /**
-     * @return ID of node provided cache configuration.
-     */
+    /** @return ID of node provided cache configuration. */
     public UUID receivedFrom() {
         return rcvdFrom;
     }
 
-    /**
-     * @return Flags.
-     */
-    public long flags() {
-        return flags;
-    }
-
-    /**
-     * @return Cache configuration enrichment.
-     */
+    /** @return Cache configuration enrichment. */
     public CacheConfigurationEnrichment cacheConfigurationEnrichment() {
         return cacheCfgEnrichment;
     }
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupData.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupData.java
index 93b5e701ee8..379950148df 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupData.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupData.java
@@ -17,60 +17,75 @@
 
 package org.apache.ignite.internal.processors.cache;
 
-import java.io.Serializable;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.internal.Marshalled;
+import org.apache.ignite.internal.Order;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.util.tostring.GridToStringInclude;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.plugin.extensions.communication.Message;
+import org.apache.ignite.plugin.extensions.communication.MessageFactory;
 import org.jetbrains.annotations.Nullable;
 
-/**
- *
- */
-public class CacheGroupData implements Serializable {
+/** */
+public class CacheGroupData implements Message {
     /** */
-    private static final long serialVersionUID = 0L;
+    @Order(0)
+    int grpId;
 
     /** */
-    private final int grpId;
+    @Order(1)
+    String grpName;
 
     /** */
-    private final String grpName;
+    @Order(2)
+    AffinityTopologyVersion startTopVer;
 
     /** */
-    private final AffinityTopologyVersion startTopVer;
+    @Order(3)
+    UUID rcvdFrom;
 
     /** */
-    private final UUID rcvdFrom;
+    @Order(4)
+    IgniteUuid deploymentId;
 
     /** */
-    private final IgniteUuid deploymentId;
+    @Marshalled("cacheCfgBytes")
+    CacheConfiguration<?, ?> cacheCfg;
 
-    /** */
-    private final CacheConfiguration<?, ?> cacheCfg;
+    /** Serialized {@link #cacheCfg}. */
+    @Order(5)
+    byte[] cacheCfgBytes;
 
     /** */
+    @Order(6)
     @GridToStringInclude
-    private final Map<String, Integer> caches;
-
-    /** */
-    private long flags;
+    Map<String, Integer> caches;
 
     /** Persistence enabled flag. */
-    private final boolean persistenceEnabled;
+    @Order(7)
+    boolean persistenceEnabled;
 
     /** WAL state. */
-    private final boolean walEnabled;
+    @Order(8)
+    boolean walEnabled;
 
     /** WAL change requests. */
-    private final List<WalStateProposeMessage> walChangeReqs;
+    @Order(9)
+    List<WalStateProposeMessage> walChangeReqs;
 
     /** Cache configuration enrichment. */
-    private final CacheConfigurationEnrichment cacheCfgEnrichment;
+    @Order(10)
+    CacheConfigurationEnrichment cacheCfgEnrichment;
+
+    /** Default constructor for {@link MessageFactory}. */
+    public CacheGroupData() {
+        // No-op.
+    }
 
     /**
      * @param cacheCfg Cache configuration.
@@ -93,7 +108,6 @@ public class CacheGroupData implements Serializable {
         @Nullable AffinityTopologyVersion startTopVer,
         IgniteUuid deploymentId,
         Map<String, Integer> caches,
-        long flags,
         boolean persistenceEnabled,
         boolean walEnabled,
         List<WalStateProposeMessage> walChangeReqs,
@@ -110,86 +124,63 @@ public class CacheGroupData implements Serializable {
         this.startTopVer = startTopVer;
         this.deploymentId = deploymentId;
         this.caches = caches;
-        this.flags = flags;
         this.persistenceEnabled = persistenceEnabled;
         this.walEnabled = walEnabled;
         this.walChangeReqs = walChangeReqs;
         this.cacheCfgEnrichment = cacheCfgEnrichment;
     }
 
-    /**
-     * @return Start version for dynamically started group.
-     */
+    /** @return Start version for dynamically started group. */
     @Nullable public AffinityTopologyVersion startTopologyVersion() {
         return startTopVer;
     }
 
-    /**
-     * @return Node ID group was received from.
-     */
+    /** @return Node ID group was received from. */
     public UUID receivedFrom() {
         return rcvdFrom;
     }
 
-    /**
-     * @return Group name.
-     */
+    /** @return Group name. */
     @Nullable public String groupName() {
         return grpName;
     }
 
-    /**
-     * @return Group ID.
-     */
+    /** @return Group ID. */
     public int groupId() {
         return grpId;
     }
 
-    /**
-     * @return Deployment ID.
-     */
+    /** @return Deployment ID. */
     public IgniteUuid deploymentId() {
         return deploymentId;
     }
 
-    /**
-     * @return Configuration.
-     */
+    /** @return Configuration. */
     public CacheConfiguration<?, ?> config() {
         return cacheCfg;
     }
 
-    /**
-     * @return Group caches.
-     */
+    /** @return Group caches. */
     Map<String, Integer> caches() {
         return caches;
     }
 
-    /**
-     * @return Persistence enabled flag.
-     */
+    /** @return Persistence enabled flag. */
     public boolean persistenceEnabled() {
         return persistenceEnabled;
     }
 
-    /**
-     * @return {@code True} if WAL is enabled.
-     */
+    /** @return {@code True} if WAL is enabled. */
     public boolean walEnabled() {
         return walEnabled;
     }
 
-    /**
-     * @return WAL mode change requests.
-     */
+    /** @return WAL mode change requests. */
     public List<WalStateProposeMessage> walChangeRequests() {
         return walChangeReqs;
     }
 
-    /**
-     * @return Cache configuration enrichment.
-     */
+    /** @return Cache configuration enrichment. */
     public CacheConfigurationEnrichment cacheConfigurationEnrichment() {
         return cacheCfgEnrichment;
     }
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheNodeCommonDiscoveryData.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheNodeCommonDiscoveryData.java
index 379d49e46d3..1792f7dba83 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheNodeCommonDiscoveryData.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheNodeCommonDiscoveryData.java
@@ -17,55 +17,56 @@
 
 package org.apache.ignite.internal.processors.cache;
 
-import java.io.Serializable;
-import java.util.Collection;
 import java.util.Map;
 import java.util.UUID;
+import org.apache.ignite.internal.Order;
 import org.apache.ignite.internal.util.tostring.GridToStringInclude;
 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;
 import org.jetbrains.annotations.Nullable;
 
-/**
- * Cache information sent in discovery data to joining node.
- */
-public class CacheNodeCommonDiscoveryData implements Serializable {
-    /** */
-    private static final long serialVersionUID = 0L;
-
+/** Cache information sent in discovery data to joining node. */
+public class CacheNodeCommonDiscoveryData implements Message {
     /** */
+    @Order(0)
     @GridToStringInclude
-    private final Map<String, CacheData> caches;
+    Map<String, CacheData> caches;
 
     /** */
+    @Order(1)
     @GridToStringInclude
-    private final Map<String, CacheData> templates;
+    Map<String, CacheData> templates;
 
     /** */
+    @Order(2)
     @GridToStringInclude
-    private final Map<Integer, CacheGroupData> cacheGrps;
+    Map<Integer, CacheGroupData> cacheGrps;
 
     /** */
-    private final Map<String, Map<UUID, Boolean>> clientNodesMap;
+    @Order(3)
+    Map<String, Map<UUID, Boolean>> clientNodesMap;
 
     /** */
-    private final Collection<String> restartingCaches;
+    @Order(4)
+    @Nullable ClusterCacheGroupRecoveryData clusterCacheGrpRecoveryData;
 
-    /** */
-    @Nullable private final ClusterCacheGroupRecoveryData 
clusterCacheGrpRecoveryData;
+    /** Default constructor for {@link MessageFactory}. */
+    public CacheNodeCommonDiscoveryData() {
+        // No-op.
+    }
 
     /**
      * @param caches Started caches.
      * @param templates Configured templates.
      * @param cacheGrps Started cache groups.
      * @param clientNodesMap Information about cache client nodes.
-     * @param restartingCaches Collection of cache names that is being 
restarted.
      * @param clusterCacheGrpRecoveryData Cluster cache group recovery data.
      */
     public CacheNodeCommonDiscoveryData(Map<String, CacheData> caches,
         Map<String, CacheData> templates,
         Map<Integer, CacheGroupData> cacheGrps,
         Map<String, Map<UUID, Boolean>> clientNodesMap,
-        Collection<String> restartingCaches,
         @Nullable ClusterCacheGroupRecoveryData clusterCacheGrpRecoveryData
     ) {
         assert caches != null;
@@ -77,13 +78,10 @@ public class CacheNodeCommonDiscoveryData implements 
Serializable {
         this.templates = templates;
         this.cacheGrps = cacheGrps;
         this.clientNodesMap = clientNodesMap;
-        this.restartingCaches = restartingCaches;
         this.clusterCacheGrpRecoveryData = clusterCacheGrpRecoveryData;
     }
 
-    /**
-     * @return Started cache groups.
-     */
+    /** @return Started cache groups. */
     Map<Integer, CacheGroupData> cacheGroups() {
         return cacheGrps;
     }
@@ -93,34 +91,21 @@ public class CacheNodeCommonDiscoveryData implements 
Serializable {
         return clusterCacheGrpRecoveryData;
     }
 
-    /**
-     * @return Started caches.
-     */
+    /** @return Started caches. */
     public Map<String, CacheData> caches() {
         return caches;
     }
 
-    /**
-     * @return Configured templates.
-     */
+    /** @return Configured templates. */
     public Map<String, CacheData> templates() {
         return templates;
     }
 
-    /**
-     * @return Information about cache client nodes.
-     */
+    /** @return Information about cache client nodes. */
     public Map<String, Map<UUID, Boolean>> clientNodesMap() {
         return clientNodesMap;
     }
 
-    /**
-     * @return A collection of restarting cache names.
-     */
-    Collection<String> restartingCaches() {
-        return restartingCaches;
-    }
-
     /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(CacheNodeCommonDiscoveryData.class, this);
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
index a9101902b22..3cbaf1cf770 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
@@ -1416,7 +1416,6 @@ public class ClusterCachesInfo {
                 grpDesc.startTopologyVersion(),
                 grpDesc.deploymentId(),
                 grpDesc.caches(),
-                0,
                 grpDesc.persistenceEnabled(),
                 grpDesc.walEnabled(),
                 grpDesc.walChangeRequests(),
@@ -1432,7 +1431,6 @@ public class ClusterCachesInfo {
             T2<CacheConfiguration, CacheConfigurationEnrichment> splitCfg = 
cfgSplitter.split(desc);
 
             CacheData cacheData = new CacheData(splitCfg.get1(),
-                desc.cacheId(),
                 desc.groupId(),
                 desc.cacheType(),
                 desc.deploymentId(),
@@ -1441,7 +1439,6 @@ public class ClusterCachesInfo {
                 desc.staticallyConfigured(),
                 desc.sql(),
                 false,
-                0,
                 splitCfg.get2() != null ? desc.cacheConfigurationEnrichment() 
: null
             );
 
@@ -1456,7 +1453,6 @@ public class ClusterCachesInfo {
             CacheData cacheData = new CacheData(
                 splitCfg.get1(),
                 0,
-                0,
                 desc.cacheType(),
                 desc.deploymentId(),
                 desc.schema(),
@@ -1464,20 +1460,16 @@ public class ClusterCachesInfo {
                 desc.staticallyConfigured(),
                 false,
                 true,
-                0,
                 splitCfg.get2() != null ? desc.cacheConfigurationEnrichment() 
: null
             );
 
             templates.put(desc.cacheName(), cacheData);
         }
 
-        Collection<String> restarting = new 
HashSet<>(restartingCaches.keySet());
-
         return new CacheNodeCommonDiscoveryData(caches,
             templates,
             cacheGrps,
             ctx.discovery().clientNodesMap(),
-            restarting,
             clusterCacheGrpRecoveryData
         );
     }
@@ -1575,6 +1567,14 @@ public class ClusterCachesInfo {
 
             CacheConfiguration<?, ?> cfg = cacheData.cacheConfiguration();
 
+            // CacheGroupData and CacheData are marshalled as separate byte[] 
blobs, so on receipt the cache
+            // config's AffinityFunction is a different instance from the 
group config's. With JDK serialization
+            // this was transparent — the shared object graph kept reference 
identity across the wire.
+            // Restore it here so GridCacheProcessor.lifecycleAwares() does 
not start/stop the affinity twice
+            // (it compares group and cache affinity by != and adds per-cache 
affinity to the lifecycle
+            // list only when they differ).
+            cfg.setAffinity(grpDesc.config().getAffinity());
+
             DynamicCacheDescriptor desc = new DynamicCacheDescriptor(
                 ctx,
                 cacheData.cacheConfiguration(),

Reply via email to