Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,23 @@

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;
import org.apache.ignite.internal.util.typedef.T2;
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)
Expand All @@ -39,23 +45,33 @@
* <p>
* 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;

/** Cache configuration. */
@GridToStringInclude
private CacheConfiguration<?, ?> ccfg;

/** Serialized {@link #ccfg}. */
@Order(0)
transient byte[] ccfgBytes;

/** Query entities. */
@GridToStringInclude
private Collection<QueryEntity> 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.
Expand All @@ -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.
Expand All @@ -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;
}

/**
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,19 @@ public class SnapshotMetadata implements Message, Serializable {
@Nullable transient Set<Integer> comprGrpIds;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to check such transient fields. It seems that they are not necessary for serde.


/** */
private boolean hasComprGrps;
@Order(14)
boolean hasComprGrps;

/** If {@code true} snapshot only primary copies of partitions. */
@Order(14)
@Order(15)
boolean onlyPrimary;

/** If {@code true} cache group dump stored. */
@Order(15)
@Order(16)
boolean dump;

/** Encryption key. */
@Order(16)
@Order(17)
@Nullable byte[] encKey;

/** Empty constructor for a {@link MessageFactory}. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,20 @@
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<StoredCacheData> ccfgs;

/** */
@Order(0)
byte[] ccfgsBytes;

/** Snapshot metadata files on local node. */
private List<SnapshotMetadata> metas;
List<StoredCacheData> ccfgs;

/** */
/** Snapshot metadata files on local node. */
@Order(1)
byte[] metasBytes;
List<SnapshotMetadata> metas;

/** Default constructor for {@link MessageFactory}. */
public SnapshotRestoreOperationResponse() {
Expand Down Expand Up @@ -70,19 +61,4 @@ public List<StoredCacheData> cacheConfigurations() {
public List<SnapshotMetadata> metadata() {
return metas;
}

/** {@inheritDoc} */
@Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException {
ccfgsBytes = U.marshal(marsh, ccfgs);
metasBytes = U.marshal(marsh, metas);
}

/** {@inheritDoc} */
@Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException {
if (ccfgsBytes != null)
ccfgs = U.unmarshal(marsh, ccfgsBytes, clsLdr);

if (metasBytes != null)
metas = U.unmarshal(marsh, metasBytes, clsLdr);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,8 @@ public class ChangeGlobalStateMessage extends DiscoveryCustomMessage implements
ClusterState state;

/** Configurations read from persistent store. */
private List<StoredCacheData> storedCfgs;

/** JDK Serialized version of storedCfgs. */
@Order(3)
byte[] storedCfgsBytes;
List<StoredCacheData> storedCfgs;

/** */
@Nullable private BaselineTopology baselineTopology;
Expand Down Expand Up @@ -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);
}
Expand Down
Loading