Skip to content

Commit 0a84482

Browse files
committed
IGNITE-28607 Use Message DTO for DiscoveryDataBag#GridDiscoveryData
1 parent a30f898 commit 0a84482

39 files changed

Lines changed: 653 additions & 536 deletions

modules/core/src/main/java/org/apache/ignite/internal/CoreMessagesProvider.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,13 @@
4040
import org.apache.ignite.internal.managers.encryption.GenerateEncryptionKeyRequest;
4141
import org.apache.ignite.internal.managers.encryption.GenerateEncryptionKeyResponse;
4242
import org.apache.ignite.internal.managers.encryption.GroupKeyEncrypted;
43+
import org.apache.ignite.internal.managers.encryption.KnownEncryptionKeys;
4344
import org.apache.ignite.internal.managers.encryption.MasterKeyChangeRequest;
4445
import org.apache.ignite.internal.managers.encryption.NodeEncryptionKeys;
46+
import org.apache.ignite.internal.managers.eventstorage.EnabledEvents;
4547
import org.apache.ignite.internal.managers.eventstorage.GridEventStorageMessage;
4648
import org.apache.ignite.internal.plugin.AbstractMarshallableMessageFactoryProvider;
49+
import org.apache.ignite.internal.processors.authentication.InitialUsersData;
4750
import org.apache.ignite.internal.processors.authentication.User;
4851
import org.apache.ignite.internal.processors.authentication.UserAcceptedMessage;
4952
import org.apache.ignite.internal.processors.authentication.UserAuthenticateRequestMessage;
@@ -181,6 +184,8 @@
181184
import org.apache.ignite.internal.processors.cluster.CacheMetricsMessage;
182185
import org.apache.ignite.internal.processors.cluster.ChangeGlobalStateFinishMessage;
183186
import org.apache.ignite.internal.processors.cluster.ChangeGlobalStateMessage;
187+
import org.apache.ignite.internal.processors.cluster.ClusterFlags;
188+
import org.apache.ignite.internal.processors.cluster.ClusterIdAndTag;
184189
import org.apache.ignite.internal.processors.cluster.ClusterMetricsUpdateMessage;
185190
import org.apache.ignite.internal.processors.cluster.NodeFullMetricsMessage;
186191
import org.apache.ignite.internal.processors.cluster.NodeMetricsMessage;
@@ -205,14 +210,16 @@
205210
import org.apache.ignite.internal.processors.metastorage.persistence.DistributedMetaStorageCasMessage;
206211
import org.apache.ignite.internal.processors.metastorage.persistence.DistributedMetaStorageUpdateAckMessage;
207212
import org.apache.ignite.internal.processors.metastorage.persistence.DistributedMetaStorageUpdateMessage;
208-
import org.apache.ignite.internal.processors.query.InlineSizesData;
213+
import org.apache.ignite.internal.processors.plugin.PluginsData;
209214
import org.apache.ignite.internal.processors.query.QueryField;
210215
import org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryCancelRequest;
211216
import org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryFailResponse;
212217
import org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryNextPageRequest;
213218
import org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryNextPageResponse;
214219
import org.apache.ignite.internal.processors.query.messages.GridQueryKillRequest;
215220
import org.apache.ignite.internal.processors.query.messages.GridQueryKillResponse;
221+
import org.apache.ignite.internal.processors.query.schema.message.ActiveProposals;
222+
import org.apache.ignite.internal.processors.query.schema.message.InlineSizesData;
216223
import org.apache.ignite.internal.processors.query.schema.message.SchemaFinishDiscoveryMessage;
217224
import org.apache.ignite.internal.processors.query.schema.message.SchemaOperationStatusMessage;
218225
import org.apache.ignite.internal.processors.query.schema.message.SchemaProposeDiscoveryMessage;
@@ -253,7 +260,7 @@
253260
import org.apache.ignite.spi.communication.tcp.messages.HandshakeWaitMessage;
254261
import org.apache.ignite.spi.communication.tcp.messages.NodeIdMessage;
255262
import org.apache.ignite.spi.communication.tcp.messages.RecoveryLastReceivedMessage;
256-
import org.apache.ignite.spi.discovery.ObjectData;
263+
import org.apache.ignite.spi.discovery.DataBagItem;
257264
import org.apache.ignite.spi.discovery.tcp.internal.DiscoveryDataPacket;
258265
import org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode;
259266
import org.apache.ignite.spi.discovery.tcp.messages.InetAddressMessage;
@@ -353,7 +360,7 @@ public CoreMessagesProvider(Marshaller dfltMarsh, Marshaller schemaAwareMarsh, C
353360
withNoSchema(GridCacheVersion.class);
354361
withNoSchema(GridCacheVersionEx.class);
355362
withNoSchema(WALPointer.class);
356-
withNoSchemaResolvedClassLoader(ObjectData.class);
363+
withNoSchemaResolvedClassLoader(DataBagItem.class);
357364
withSchemaResolvedClassLoader(GridTopicMessage.class);
358365

359366
// [5700 - 5900]: Discovery originated messages.
@@ -446,6 +453,7 @@ public CoreMessagesProvider(Marshaller dfltMarsh, Marshaller schemaAwareMarsh, C
446453
withNoSchema(CacheStatisticsClearMessage.class);
447454
withNoSchema(ClientCacheChangeDummyDiscoveryMessage.class);
448455
withNoSchema(DynamicCacheChangeBatch.class);
456+
withSchema(InitialUsersData.class);
449457

450458
// [10000 - 10200]: Transaction and lock related messages. Most of them originally comes from Communication.
451459
msgIdx = 10000;
@@ -575,6 +583,7 @@ public CoreMessagesProvider(Marshaller dfltMarsh, Marshaller schemaAwareMarsh, C
575583
withNoSchema(CacheContinuousQueryBatchAck.class);
576584
withSchema(CacheContinuousQueryEntry.class);
577585
withNoSchema(InlineSizesData.class);
586+
withSchema(ActiveProposals.class);
578587

579588
// [11200 - 11300]: Compute, distributed process messages.
580589
msgIdx = 11200;
@@ -652,6 +661,7 @@ public CoreMessagesProvider(Marshaller dfltMarsh, Marshaller schemaAwareMarsh, C
652661
withNoSchema(MasterKeyChangeRequest.class);
653662
withNoSchema(GroupKeyEncrypted.class);
654663
withNoSchema(NodeEncryptionKeys.class);
664+
withNoSchema(KnownEncryptionKeys.class);
655665

656666
// [13000 - 13300]: Control, configuration, diagnostincs and other messages.
657667
msgIdx = 13000;
@@ -665,6 +675,10 @@ public CoreMessagesProvider(Marshaller dfltMarsh, Marshaller schemaAwareMarsh, C
665675
withNoSchemaResolvedClassLoader(DynamicCacheChangeRequest.class);
666676
withNoSchema(PartitionHashRecord.class);
667677
withNoSchema(TransactionsHashRecord.class);
678+
withNoSchema(ClusterIdAndTag.class);
679+
withNoSchema(ClusterFlags.class);
680+
withNoSchemaResolvedClassLoader(PluginsData.class);
681+
withSchema(EnabledEvents.class);
668682

669683
assert msgIdx <= MAX_MESSAGE_ID;
670684
}

modules/core/src/main/java/org/apache/ignite/internal/GridPluginComponent.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717

1818
package org.apache.ignite.internal;
1919

20-
import java.io.Serializable;
21-
import java.util.Map;
2220
import org.apache.ignite.IgniteCheckedException;
2321
import org.apache.ignite.cluster.ClusterNode;
22+
import org.apache.ignite.internal.processors.plugin.PluginsData;
23+
import org.apache.ignite.internal.util.typedef.F;
2424
import org.apache.ignite.lang.IgniteFuture;
2525
import org.apache.ignite.plugin.PluginProvider;
2626
import org.apache.ignite.plugin.PluginValidationException;
@@ -115,10 +115,10 @@ public PluginProvider plugin() {
115115
@Nullable @Override public IgniteNodeValidationResult validateNode(ClusterNode node,
116116
JoiningNodeDiscoveryData discoData) {
117117
try {
118-
Map<String, Serializable> map = discoData.joiningNodeData();
118+
PluginsData pluginsData = discoData.joiningNodeData();
119119

120-
if (map != null)
121-
plugin.validateNewNode(node, map.get(plugin.name()));
120+
if (pluginsData != null && !F.isEmpty(pluginsData.data()))
121+
plugin.validateNewNode(node, pluginsData.data().get(plugin.name()));
122122
else
123123
plugin.validateNewNode(node, null);
124124

modules/core/src/main/java/org/apache/ignite/internal/managers/encryption/GridEncryptionManager.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -563,28 +563,23 @@ public void onLocalJoin() {
563563
}
564564
}
565565

566-
dataBag.addGridCommonData(ENCRYPTION_MGR.ordinal(), knownEncKeys);
566+
dataBag.addGridCommonData(ENCRYPTION_MGR.ordinal(), new KnownEncryptionKeys(knownEncKeys));
567567
}
568568

569569
/** {@inheritDoc} */
570570
@Override public void onGridDataReceived(GridDiscoveryData data) {
571571
if (ctx.clientNode())
572572
return;
573573

574-
Map<Integer, Object> encKeysFromCluster = (Map<Integer, Object>)data.commonData();
574+
KnownEncryptionKeys encKeysFromCluster = data.commonData();
575575

576-
if (F.isEmpty(encKeysFromCluster))
576+
if (encKeysFromCluster == null || F.isEmpty(encKeysFromCluster.keys))
577577
return;
578578

579-
for (Map.Entry<Integer, Object> entry : encKeysFromCluster.entrySet()) {
579+
for (Map.Entry<Integer, GroupKeyEncrypted> entry : encKeysFromCluster.keys.entrySet()) {
580580
int grpId = entry.getKey();
581581

582-
GroupKeyEncrypted rmtKey;
583-
584-
if (entry.getValue() instanceof GroupKeyEncrypted)
585-
rmtKey = (GroupKeyEncrypted)entry.getValue();
586-
else
587-
rmtKey = new GroupKeyEncrypted(INITIAL_KEY_ID, (byte[])entry.getValue());
582+
GroupKeyEncrypted rmtKey = entry.getValue();
588583

589584
GroupKey locGrpKey = getActiveKey(grpId);
590585

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.ignite.internal.managers.encryption;
19+
20+
import java.util.Map;
21+
import org.apache.ignite.internal.Order;
22+
import org.apache.ignite.plugin.extensions.communication.Message;
23+
24+
/** */
25+
public class KnownEncryptionKeys implements Message {
26+
/** */
27+
@Order(0)
28+
Map<Integer, GroupKeyEncrypted> keys;
29+
30+
/** */
31+
public KnownEncryptionKeys() {}
32+
33+
/** */
34+
KnownEncryptionKeys(Map<Integer, GroupKeyEncrypted> keys) {
35+
this.keys = keys;
36+
}
37+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.ignite.internal.managers.eventstorage;
19+
20+
import org.apache.ignite.internal.Order;
21+
import org.apache.ignite.plugin.extensions.communication.Message;
22+
23+
/**
24+
*
25+
*/
26+
public class EnabledEvents implements Message {
27+
/** */
28+
@Order(0)
29+
int[] evts;
30+
31+
/** */
32+
public EnabledEvents() { }
33+
34+
/**
35+
* @param events Enabled events.
36+
*/
37+
public EnabledEvents(int[] events) {
38+
this.evts = events;
39+
}
40+
}

modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,13 +1173,15 @@ private int[] copy(int[] arr) {
11731173

11741174
/** {@inheritDoc} */
11751175
@Override public void onGridDataReceived(DiscoveryDataBag.GridDiscoveryData data) {
1176-
if (data.commonData() == null)
1176+
EnabledEvents enabled = data.commonData();
1177+
1178+
if (enabled == null)
11771179
return;
11781180

11791181
if (ctx.clientNode())
11801182
return;
11811183

1182-
GridIntList clusterData = new GridIntList((int[])data.commonData());
1184+
GridIntList clusterData = new GridIntList(enabled.evts);
11831185
GridIntList nodeData = new GridIntList(enabledEvents());
11841186

11851187
GridIntList toEnable = new GridIntList(clusterData.size());
@@ -1207,9 +1209,7 @@ private int[] copy(int[] arr) {
12071209
if (dataBag.isJoiningNodeClient() && dataBag.commonDataCollectedFor(EVENT_MGR.ordinal()))
12081210
return;
12091211

1210-
int[] clusterData = enabledEvents();
1211-
1212-
dataBag.addGridCommonData(EVENT_MGR.ordinal(), clusterData);
1212+
dataBag.addGridCommonData(EVENT_MGR.ordinal(), new EnabledEvents(enabledEvents()));
12131213
}
12141214

12151215
/**

modules/core/src/main/java/org/apache/ignite/internal/processors/authentication/IgniteAuthenticationProcessor.java

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
import org.apache.ignite.internal.thread.pool.IgniteThreadPoolExecutor;
6161
import org.apache.ignite.internal.util.future.GridFutureAdapter;
6262
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
63-
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
6463
import org.apache.ignite.internal.util.typedef.F;
6564
import org.apache.ignite.internal.util.typedef.internal.CU;
6665
import org.apache.ignite.internal.util.typedef.internal.S;
@@ -430,7 +429,7 @@ private boolean isLocalNodeCoordinator() {
430429

431430
/** {@inheritDoc} */
432431
@Override public void onGridDataReceived(DiscoveryDataBag.GridDiscoveryData data) {
433-
initUsrs = (InitialUsersData)data.commonData();
432+
initUsrs = data.commonData();
434433
}
435434

436435
/** {@inheritDoc} */
@@ -999,36 +998,6 @@ public void checkUserOperation(UserManagementOperation op) throws IgniteAccessCo
999998
}
1000999

10011000
/**
1002-
* Initial data is collected on coordinator to send to join node.
1003-
*/
1004-
private static final class InitialUsersData implements Serializable {
1005-
/** */
1006-
private static final long serialVersionUID = 0L;
1007-
1008-
/** Users. */
1009-
@GridToStringInclude
1010-
private final ArrayList<User> usrs;
1011-
1012-
/** Active user operations. */
1013-
@GridToStringInclude
1014-
private final ArrayList<UserManagementOperation> activeOps;
1015-
1016-
/**
1017-
* @param usrs Users.
1018-
* @param ops Active operations on cluster.
1019-
*/
1020-
InitialUsersData(Collection<User> usrs, Collection<UserManagementOperation> ops) {
1021-
this.usrs = new ArrayList<>(usrs);
1022-
activeOps = new ArrayList<>(ops);
1023-
}
1024-
1025-
/** {@inheritDoc} */
1026-
@Override public String toString() {
1027-
return S.toString(InitialUsersData.class, this);
1028-
}
1029-
}
1030-
1031-
/**i
10321001
*
10331002
*/
10341003
private final class UserProposedListener implements CustomEventListener<UserProposedMessage> {
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.ignite.internal.processors.authentication;
19+
20+
import java.util.ArrayList;
21+
import java.util.Collection;
22+
import org.apache.ignite.internal.Order;
23+
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
24+
import org.apache.ignite.internal.util.typedef.internal.S;
25+
import org.apache.ignite.plugin.extensions.communication.Message;
26+
27+
/** Initial data is collected on coordinator to send to join node. */
28+
public class InitialUsersData implements Message {
29+
/** Users. */
30+
@GridToStringInclude
31+
@Order(0)
32+
ArrayList<User> usrs;
33+
34+
/** Active user operations. */
35+
@GridToStringInclude
36+
@Order(1)
37+
ArrayList<UserManagementOperation> activeOps;
38+
39+
/** */
40+
public InitialUsersData() { }
41+
42+
/**
43+
* @param usrs Users.
44+
* @param ops Active operations on cluster.
45+
*/
46+
InitialUsersData(Collection<User> usrs, Collection<UserManagementOperation> ops) {
47+
this.usrs = new ArrayList<>(usrs);
48+
activeOps = new ArrayList<>(ops);
49+
}
50+
51+
/** {@inheritDoc} */
52+
@Override public String toString() {
53+
return S.toString(InitialUsersData.class, this);
54+
}
55+
}

modules/core/src/main/java/org/apache/ignite/internal/processors/authentication/UserManagementOperation.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
package org.apache.ignite.internal.processors.authentication;
1919

20-
import java.io.Serializable;
2120
import java.util.Objects;
2221
import org.apache.ignite.internal.Order;
2322
import org.apache.ignite.internal.util.typedef.internal.S;
@@ -27,10 +26,7 @@
2726
/**
2827
* The operation with users. Used to deliver the information about requested operation to all server nodes.
2928
*/
30-
public class UserManagementOperation implements Serializable, Message {
31-
/** */
32-
private static final long serialVersionUID = 0L;
33-
29+
public class UserManagementOperation implements Message {
3430
/** User. */
3531
@Order(0)
3632
User usr;

0 commit comments

Comments
 (0)