Skip to content
Merged
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 @@ -41,6 +41,7 @@
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.encryption.NodeEncryptionKeys;
import org.apache.ignite.internal.managers.eventstorage.GridEventStorageMessage;
import org.apache.ignite.internal.plugin.AbstractMarshallableMessageFactoryProvider;
import org.apache.ignite.internal.processors.authentication.User;
Expand Down Expand Up @@ -71,6 +72,7 @@
import org.apache.ignite.internal.processors.cache.WalStateFinishMessage;
import org.apache.ignite.internal.processors.cache.WalStateProposeMessage;
import org.apache.ignite.internal.processors.cache.binary.BinaryMetadataVersionInfo;
import org.apache.ignite.internal.processors.cache.binary.BinaryMetadataVersionsData;
import org.apache.ignite.internal.processors.cache.binary.MetadataRemoveAcceptedMessage;
import org.apache.ignite.internal.processors.cache.binary.MetadataRemoveProposedMessage;
import org.apache.ignite.internal.processors.cache.binary.MetadataRequestMessage;
Expand Down Expand Up @@ -193,15 +195,18 @@
import org.apache.ignite.internal.processors.datastreamer.DataStreamerEntry;
import org.apache.ignite.internal.processors.datastreamer.DataStreamerRequest;
import org.apache.ignite.internal.processors.datastreamer.DataStreamerResponse;
import org.apache.ignite.internal.processors.marshaller.MappedName;
import org.apache.ignite.internal.processors.marshaller.MappingAcceptedMessage;
import org.apache.ignite.internal.processors.marshaller.MappingProposedMessage;
import org.apache.ignite.internal.processors.marshaller.MarshallerMappingItem;
import org.apache.ignite.internal.processors.marshaller.MarshallerMappingsData;
import org.apache.ignite.internal.processors.marshaller.MissingMappingRequestMessage;
import org.apache.ignite.internal.processors.marshaller.MissingMappingResponseMessage;
import org.apache.ignite.internal.processors.metastorage.persistence.DistributedMetaStorageCasAckMessage;
import org.apache.ignite.internal.processors.metastorage.persistence.DistributedMetaStorageCasMessage;
import org.apache.ignite.internal.processors.metastorage.persistence.DistributedMetaStorageUpdateAckMessage;
import org.apache.ignite.internal.processors.metastorage.persistence.DistributedMetaStorageUpdateMessage;
import org.apache.ignite.internal.processors.query.InlineSizesData;
import org.apache.ignite.internal.processors.query.QueryField;
import org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryCancelRequest;
import org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryFailResponse;
Expand Down Expand Up @@ -250,6 +255,7 @@
import org.apache.ignite.spi.communication.tcp.messages.HandshakeWaitMessage;
import org.apache.ignite.spi.communication.tcp.messages.NodeIdMessage;
import org.apache.ignite.spi.communication.tcp.messages.RecoveryLastReceivedMessage;
import org.apache.ignite.spi.discovery.ObjectData;
import org.apache.ignite.spi.discovery.tcp.internal.DiscoveryDataPacket;
import org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode;
import org.apache.ignite.spi.discovery.tcp.messages.InetAddressMessage;
Expand Down Expand Up @@ -351,6 +357,7 @@ public CoreMessagesProvider(Marshaller dfltMarsh, Marshaller schemaAwareMarsh, C
withNoSchema(GridCacheVersion.class);
withNoSchema(GridCacheVersionEx.class);
withNoSchema(WALPointer.class);
withNoSchemaResolvedClassLoader(ObjectData.class);

// [5700 - 5900]: Discovery originated messages.
msgIdx = 5700;
Expand Down Expand Up @@ -572,6 +579,7 @@ public CoreMessagesProvider(Marshaller dfltMarsh, Marshaller schemaAwareMarsh, C
withNoSchema(StatisticsResponse.class);
withNoSchema(CacheContinuousQueryBatchAck.class);
withSchema(CacheContinuousQueryEntry.class);
withNoSchema(InlineSizesData.class);

// [11200 - 11300]: Compute, distributed process messages.
msgIdx = 11200;
Expand Down Expand Up @@ -636,7 +644,10 @@ public CoreMessagesProvider(Marshaller dfltMarsh, Marshaller schemaAwareMarsh, C
withNoSchema(MetadataRequestMessage.class);
withNoSchema(MetadataResponseMessage.class);
withNoSchema(MarshallerMappingItem.class);
withNoSchema(BinaryMetadataVersionInfo.class);
withSchemaResolvedClassLoader(BinaryMetadataVersionInfo.class);
withNoSchema(BinaryMetadataVersionsData.class);
withNoSchema(MappedName.class);
withNoSchema(MarshallerMappingsData.class);

// [12400 - 12500]: Encryption messages.
msgIdx = 12400;
Expand All @@ -645,6 +656,7 @@ public CoreMessagesProvider(Marshaller dfltMarsh, Marshaller schemaAwareMarsh, C
withNoSchema(ChangeCacheEncryptionRequest.class);
withNoSchema(MasterKeyChangeRequest.class);
withNoSchema(GroupKeyEncrypted.class);
withNoSchema(NodeEncryptionKeys.class);

// [13000 - 13300]: Control, configuration, diagnostincs and other messages.
msgIdx = 13000;
Expand Down Expand Up @@ -677,6 +689,11 @@ private <T extends Message> void withNoSchemaResolvedClassLoader(Class<T> cls) {
register(cls, dfltMarsh, resolvedClsLdr);
}

/** Registers message using {@link #schemaAwareMarsh} and {@link #resolvedClsLdr}. */
private <T extends Message> void withSchemaResolvedClassLoader(Class<T> cls) {
register(cls, schemaAwareMarsh, resolvedClsLdr);
}

/** Registers message using incrementing {@link #msgIdx} as the message id/type. */
private <T extends Message> void register(Class<T> cls, Marshaller marsh, ClassLoader clsLrd) {
register(factory, cls, msgIdx++, marsh, clsLrd);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public PluginProvider plugin() {
@Nullable @Override public IgniteNodeValidationResult validateNode(ClusterNode node,
JoiningNodeDiscoveryData discoData) {
try {
Map<String, Serializable> map = (Map<String, Serializable>)discoData.joiningNodeData();
Map<String, Serializable> map = discoData.joiningNodeData();

if (map != null)
plugin.validateNewNode(node, map.get(plugin.name()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,9 @@ public void onLocalJoin() {
"Cache group key change is in progress! Node join is rejected.");
}

NodeEncryptionKeys nodeEncKeys = (NodeEncryptionKeys)discoData.joiningNodeData();
NodeEncryptionKeys nodeEncKeys = discoData.joiningNodeData();

if (!discoData.hasJoiningNodeData() || nodeEncKeys == null) {
if (nodeEncKeys == null) {
return new IgniteNodeValidationResult(ctx.localNodeId(),
"Joining node doesn't have encryption data [node=" + node.id() + "]",
"Joining node doesn't have encryption data.");
Expand Down Expand Up @@ -522,7 +522,7 @@ public void onLocalJoin() {

/** {@inheritDoc} */
@Override public void onJoiningNodeDataReceived(JoiningNodeDiscoveryData data) {
NodeEncryptionKeys nodeEncryptionKeys = (NodeEncryptionKeys)data.joiningNodeData();
NodeEncryptionKeys nodeEncryptionKeys = data.joiningNodeData();

if (nodeEncryptionKeys == null || nodeEncryptionKeys.newKeys == null || ctx.clientNode())
return;
Expand Down Expand Up @@ -1748,45 +1748,6 @@ private String decryptKeyName(byte[] data) {
});
}

/** */
protected static class NodeEncryptionKeys implements Serializable {
/** */
private static final long serialVersionUID = 0L;

/** */
NodeEncryptionKeys(
HashMap<Integer, List<GroupKeyEncrypted>> knownKeysWithIds,
Map<Integer, byte[]> newKeys,
byte[] masterKeyDigest
) {
this.newKeys = newKeys;
this.masterKeyDigest = masterKeyDigest;

if (F.isEmpty(knownKeysWithIds))
return;

// To be able to join the old cluster.
knownKeys = U.newHashMap(knownKeysWithIds.size());

for (Map.Entry<Integer, List<GroupKeyEncrypted>> entry : knownKeysWithIds.entrySet())
knownKeys.put(entry.getKey(), entry.getValue().get(0).key());

this.knownKeysWithIds = knownKeysWithIds;
}

/** Known i.e. stored in {@code ReadWriteMetastorage} keys from node (in compatible format). */
Map<Integer, byte[]> knownKeys;

/** New keys i.e. keys for a local statically configured caches. */
Map<Integer, byte[]> newKeys;

/** Master key digest. */
byte[] masterKeyDigest;

/** Known i.e. stored in {@code ReadWriteMetastorage} keys from node. */
Map<Integer, List<GroupKeyEncrypted>> knownKeysWithIds;
}

/** */
private class GenerateEncryptionKeyFuture extends GridFutureAdapter<T2<Collection<byte[]>, byte[]>> {
/** */
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.ignite.internal.managers.encryption;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.ignite.internal.Order;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.plugin.extensions.communication.Message;

/** */
public class NodeEncryptionKeys implements Message {
/** Known i.e. stored in {@code ReadWriteMetastorage} keys from node (in compatible format). */
@Order(0)
Map<Integer, byte[]> knownKeys;

/** New keys i.e. keys for a local statically configured caches. */
@Order(1)
Map<Integer, byte[]> newKeys;

/** Master key digest. */
@Order(2)
byte[] masterKeyDigest;

/** Known i.e. stored in {@code ReadWriteMetastorage} keys from node. */
@Order(3)
Map<Integer, List<GroupKeyEncrypted>> knownKeysWithIds;

/** */
public NodeEncryptionKeys() {}

/** */
NodeEncryptionKeys(
HashMap<Integer, List<GroupKeyEncrypted>> knownKeysWithIds,
Map<Integer, byte[]> newKeys,
byte[] masterKeyDigest
) {
this.newKeys = newKeys;
this.masterKeyDigest = masterKeyDigest;

if (F.isEmpty(knownKeysWithIds))
return;

// To be able to join the old cluster.
knownKeys = U.newHashMap(knownKeysWithIds.size());

for (Map.Entry<Integer, List<GroupKeyEncrypted>> entry : knownKeysWithIds.entrySet())
knownKeys.put(entry.getKey(), entry.getValue().get(0).key());

this.knownKeysWithIds = knownKeysWithIds;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public class ValidationOnNodeJoinUtils {
Function<String, DynamicCacheDescriptor> cacheDescProvider
) {
if (discoData.hasJoiningNodeData() && discoData.joiningNodeData() instanceof CacheJoinNodeDiscoveryData) {
CacheJoinNodeDiscoveryData nodeData = (CacheJoinNodeDiscoveryData)discoData.joiningNodeData();
CacheJoinNodeDiscoveryData nodeData = discoData.joiningNodeData();

boolean isGridActive = ctx.state().clusterState().active();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -841,15 +841,6 @@ private final class MetadataRequestListener implements GridMessageListener {

MetadataResponseMessage resp = new MetadataResponseMessage(typeId);

if (metaVerInfo != null) {
try {
metaVerInfo.marshalMetadata();
}
catch (IgniteCheckedException e) {
U.error(log, "Failed to marshal binary metadata for [typeId=" + typeId + ']', e);
}
}

resp.metadataVersionInfo(metaVerInfo);

try {
Expand Down Expand Up @@ -890,16 +881,9 @@ private final class MetadataResponseListener implements GridMessageListener {
return;
}

try {
metaVerInfo.unmarshalMetadata();

casBinaryMetadata(typeId, metaVerInfo);
casBinaryMetadata(typeId, metaVerInfo);

fut.onDone(MetadataUpdateResult.createSuccessfulResult(-1));
}
catch (IgniteCheckedException e) {
fut.onDone(MetadataUpdateResult.createFailureResult(new BinaryObjectException(e)));
}
fut.onDone(MetadataUpdateResult.createSuccessfulResult(-1));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,19 @@

import java.io.Serializable;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.MarshallableMessage;
import org.apache.ignite.internal.Order;
import org.apache.ignite.internal.binary.BinaryMetadata;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.plugin.extensions.communication.Message;

import static org.apache.ignite.marshaller.Marshallers.jdk;
import org.apache.ignite.marshaller.Marshaller;

/**
* Wrapper for {@link BinaryMetadata} which is stored in metadata local cache on each node.
* Used internally to track version counters (see javadoc for {@link MetadataUpdateProposedMessage} for more details).
* The version refers solely to the internal protocol for updating BinaryMetadata and is unknown externally.
* It can be updated dynamically from different nodes and threads on the same node.
*/
public final class BinaryMetadataVersionInfo implements Serializable, Message {
public final class BinaryMetadataVersionInfo implements Serializable, MarshallableMessage {
/** */
private static final long serialVersionUID = 0L;

Expand Down Expand Up @@ -130,24 +129,16 @@ boolean removing() {
return removing;
}

/**
* Marshals binary metadata to byte array.
*
* @throws IgniteCheckedException If failed.
*/
public void marshalMetadata() throws IgniteCheckedException {
if (metadataBytes == null)
metadataBytes = U.marshal(jdk(), metadata);
/** {@inheritDoc} */
@Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException {
if (metadata != null)
metadataBytes = U.marshal(marsh, metadata);
}

/**
* Unmarshals binary metadata from byte array.
*
* @throws IgniteCheckedException If failed.
*/
public void unmarshalMetadata() throws IgniteCheckedException {
if (metadata == null && metadataBytes != null) {
metadata = U.unmarshal(jdk(), metadataBytes, U.gridClassLoader());
/** {@inheritDoc} */
@Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException {
if (metadataBytes != null) {
metadata = U.unmarshal(marsh, metadataBytes, clsLdr);

// It is not required anymore.
metadataBytes = null;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.ignite.internal.processors.cache.binary;

import java.util.Map;
import org.apache.ignite.internal.Order;
import org.apache.ignite.plugin.extensions.communication.Message;

/** */
public class BinaryMetadataVersionsData implements Message {
/** */
@Order(0)
Map<Integer, BinaryMetadataVersionInfo> data;

/** */
public BinaryMetadataVersionsData() {}

/**
* @param data Data.
*/
public BinaryMetadataVersionsData(Map<Integer, BinaryMetadataVersionInfo> data) {
this.data = Map.copyOf(data);
}
}
Loading
Loading