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 6e76175c72fd4..0ba6aa2fc6978 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 @@ -38,6 +38,7 @@ import org.apache.ignite.internal.managers.encryption.ChangeCacheEncryptionRequest; import org.apache.ignite.internal.managers.encryption.GenerateEncryptionKeyRequest; import org.apache.ignite.internal.managers.encryption.GenerateEncryptionKeyResponse; +import org.apache.ignite.internal.managers.encryption.GroupKeyEncrypted; import org.apache.ignite.internal.managers.encryption.MasterKeyChangeRequest; import org.apache.ignite.internal.managers.eventstorage.GridEventStorageMessage; import org.apache.ignite.internal.plugin.AbstractMarshallableMessageFactoryProvider; @@ -63,6 +64,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheEntryInfo; import org.apache.ignite.internal.processors.cache.GridCacheReturn; import org.apache.ignite.internal.processors.cache.GridChangeGlobalStateMessageResponse; +import org.apache.ignite.internal.processors.cache.StoredCacheData; import org.apache.ignite.internal.processors.cache.TxTimeoutOnPartitionMapExchangeChangeMessage; import org.apache.ignite.internal.processors.cache.WalStateAckMessage; import org.apache.ignite.internal.processors.cache.WalStateFinishMessage; @@ -509,6 +511,7 @@ public CoreMessagesProvider(Marshaller dfltMarsh, Marshaller schemaAwareMarsh, C withNoSchema(StartRoutineDiscoveryMessage.class); withNoSchema(StartRoutineAckDiscoveryMessage.class); withNoSchema(StartRoutineDiscoveryMessageV2.class); + withNoSchema(StoredCacheData.class); // [10600-10800]: Affinity & partition maps. msgIdx = 10600; @@ -636,6 +639,7 @@ public CoreMessagesProvider(Marshaller dfltMarsh, Marshaller schemaAwareMarsh, C withNoSchema(GenerateEncryptionKeyResponse.class); withNoSchema(ChangeCacheEncryptionRequest.class); withNoSchema(MasterKeyChangeRequest.class); + withNoSchema(GroupKeyEncrypted.class); // [13000 - 13300]: Control, configuration, diagnostincs and other messages. msgIdx = 13000; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/encryption/GroupKeyEncrypted.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/encryption/GroupKeyEncrypted.java index 6b2ed0543038b..495c2da7f9be2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/encryption/GroupKeyEncrypted.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/encryption/GroupKeyEncrypted.java @@ -18,19 +18,29 @@ package org.apache.ignite.internal.managers.encryption; import java.io.Serializable; +import org.apache.ignite.internal.Order; +import org.apache.ignite.plugin.extensions.communication.Message; +import org.apache.ignite.plugin.extensions.communication.MessageFactory; /** * Cache group encryption key with identifier. Key is encrypted. */ -public class GroupKeyEncrypted implements Serializable { +public class GroupKeyEncrypted implements Serializable, Message { /** Serial version UID. */ private static final long serialVersionUID = 0L; /** Encryption key ID. */ - private final int id; + @Order(0) + int id; /** Encryption key. */ - private final byte[] key; + @Order(1) + byte[] key; + + /** Default constructor for {@link MessageFactory}. */ + public GroupKeyEncrypted() { + // No-op. + } /** * @param id Encryption key ID. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/StoredCacheData.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/StoredCacheData.java index 9a9e85e6d5e6d..dc94809a9446c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/StoredCacheData.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/StoredCacheData.java @@ -19,9 +19,12 @@ import java.io.Serializable; import java.util.Collection; +import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.cache.QueryEntity; import org.apache.ignite.cdc.CdcCacheEvent; import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.internal.MarshallableMessage; +import org.apache.ignite.internal.Order; import org.apache.ignite.internal.managers.encryption.GroupKeyEncrypted; import org.apache.ignite.internal.pagemem.store.IgnitePageStoreManager; import org.apache.ignite.internal.util.tostring.GridToStringInclude; @@ -29,7 +32,10 @@ import org.apache.ignite.internal.util.typedef.internal.A; import org.apache.ignite.internal.util.typedef.internal.CU; 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.marshaller.jdk.JdkMarshaller; +import org.apache.ignite.plugin.extensions.communication.MessageFactory; /** * Cache data to write to and read from {@link IgnitePageStoreManager}. In a nutshell, contains (most importantly) @@ -39,7 +45,7 @@ *

* All changes must be made with the respect of RU rules. */ -public class StoredCacheData implements Serializable, CdcCacheEvent { +public class StoredCacheData implements Serializable, CdcCacheEvent, MarshallableMessage { /** */ private static final long serialVersionUID = 0L; @@ -47,15 +53,25 @@ public class StoredCacheData implements Serializable, CdcCacheEvent { @GridToStringInclude private CacheConfiguration ccfg; + /** Serialized {@link #ccfg}. */ + @Order(0) + transient byte[] ccfgBytes; + /** Query entities. */ @GridToStringInclude private Collection qryEntities; + /** Serialized {@link #qryEntities}. */ + @Order(1) + transient byte[] qryEntitiesBytes; + /** SQL flag - {@code true} if cache was created with {@code CREATE TABLE}. */ - private boolean sql; + @Order(2) + boolean sql; /** Cache configuration enrichment. */ - private CacheConfigurationEnrichment cacheConfigurationEnrichment; + @Order(3) + CacheConfigurationEnrichment cacheConfigurationEnrichment; /** * Encryption key. {@code Null} if encryption is disabled. @@ -64,7 +80,13 @@ public class StoredCacheData implements Serializable, CdcCacheEvent { * Metastore. But it is currently unreadable as simple structure. Once it is done, we should move snapshot * encryption keys there. */ - private GroupKeyEncrypted grpKeyEncrypted; + @Order(4) + GroupKeyEncrypted grpKeyEncrypted; + + /** Default constructor for {@link MessageFactory}. */ + public StoredCacheData() { + // No-op. + } /** * Constructor. @@ -75,18 +97,18 @@ public StoredCacheData(CacheConfiguration ccfg) { A.notNull(ccfg, "ccfg"); this.ccfg = ccfg; - this.qryEntities = ccfg.getQueryEntities(); + qryEntities = ccfg.getQueryEntities(); } /** * @param cacheData Cache data. */ public StoredCacheData(StoredCacheData cacheData) { - this.ccfg = cacheData.ccfg; - this.qryEntities = cacheData.qryEntities; - this.sql = cacheData.sql; - this.cacheConfigurationEnrichment = cacheData.cacheConfigurationEnrichment; - this.grpKeyEncrypted = cacheData.grpKeyEncrypted; + ccfg = cacheData.ccfg; + qryEntities = cacheData.qryEntities; + sql = cacheData.sql; + cacheConfigurationEnrichment = cacheData.cacheConfigurationEnrichment; + grpKeyEncrypted = cacheData.grpKeyEncrypted; } /** @@ -151,7 +173,7 @@ public void groupKeyEncrypted(GroupKeyEncrypted grpKeyEncrypted) { * @param ccfgEnrichment Configuration enrichment. */ public StoredCacheData cacheConfigurationEnrichment(CacheConfigurationEnrichment ccfgEnrichment) { - this.cacheConfigurationEnrichment = ccfgEnrichment; + cacheConfigurationEnrichment = ccfgEnrichment; return this; } @@ -201,4 +223,28 @@ public StoredCacheData withSplittedCacheConfig(CacheConfigurationSplitter splitt @Override public CacheConfiguration configuration() { return ccfg; } + + /** {@inheritDoc} */ + @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { + if (ccfg != null) + ccfgBytes = U.marshal(marsh, ccfg); + + if (qryEntities != null) + qryEntitiesBytes = U.marshal(marsh, qryEntities); + } + + /** {@inheritDoc} */ + @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + if (ccfgBytes != null) { + ccfg = U.unmarshal(marsh, ccfgBytes, clsLdr); + + ccfgBytes = null; + } + + if (qryEntitiesBytes != null) { + qryEntities = U.unmarshal(marsh, qryEntitiesBytes, clsLdr); + + qryEntitiesBytes = null; + } + } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotRestoreOperationResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotRestoreOperationResponse.java index e4948be69b9ef..7da00956e0287 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotRestoreOperationResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotRestoreOperationResponse.java @@ -20,23 +20,17 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; -import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.cache.StoredCacheData; -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; /** Snapshot operation prepare response. */ -public class SnapshotRestoreOperationResponse implements MarshallableMessage { +public class SnapshotRestoreOperationResponse implements Message { /** Cache configurations on local node. */ - private List ccfgs; - - /** */ @Order(0) - byte[] ccfgsBytes; - + List ccfgs; + /** Snapshot metadata files on local node. */ @Order(1) List metas; @@ -67,14 +61,4 @@ public List cacheConfigurations() { public List metadata() { return metas; } - - /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { - ccfgsBytes = U.marshal(marsh, ccfgs); - } - - /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { - ccfgs = U.unmarshal(marsh, ccfgsBytes, clsLdr); - } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ChangeGlobalStateMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ChangeGlobalStateMessage.java index 7d60b92e0775b..461d36f8bdb17 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ChangeGlobalStateMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ChangeGlobalStateMessage.java @@ -54,11 +54,8 @@ public class ChangeGlobalStateMessage extends DiscoveryCustomMessage implements ClusterState state; /** Configurations read from persistent store. */ - private List storedCfgs; - - /** JDK Serialized version of storedCfgs. */ @Order(3) - byte[] storedCfgsBytes; + List storedCfgs; /** */ @Nullable private BaselineTopology baselineTopology; @@ -226,18 +223,12 @@ public UUID requestId() { /** {@inheritDoc} */ @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { - if (storedCfgs != null) - storedCfgsBytes = U.marshal(marsh, storedCfgs); - if (baselineTopology != null) baselineTopologyBytes = U.marshal(marsh, baselineTopology); } /** {@inheritDoc} */ @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { - if (storedCfgsBytes != null) - storedCfgs = U.unmarshal(marsh, storedCfgsBytes, clsLdr); - if (baselineTopologyBytes != null) baselineTopology = U.unmarshal(marsh, baselineTopologyBytes, clsLdr); }