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 f7330c5a47f57..2580a267e32e1 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 @@ -54,14 +54,20 @@ import org.apache.ignite.internal.processors.authentication.UserManagementOperationFinishedMessage; 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.CacheEntryPredicateAdapter; import org.apache.ignite.internal.processors.cache.CacheEvictionEntry; +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.CacheReconnectInfo; import org.apache.ignite.internal.processors.cache.CacheStatisticsClearMessage; import org.apache.ignite.internal.processors.cache.CacheStatisticsModeChangeMessage; import org.apache.ignite.internal.processors.cache.ClientCacheChangeDiscoveryMessage; import org.apache.ignite.internal.processors.cache.ClientCacheChangeDummyDiscoveryMessage; +import org.apache.ignite.internal.processors.cache.ClusterCacheGroupRecoveryData; import org.apache.ignite.internal.processors.cache.DynamicCacheChangeBatch; import org.apache.ignite.internal.processors.cache.DynamicCacheChangeRequest; import org.apache.ignite.internal.processors.cache.ExchangeFailureMessage; @@ -458,6 +464,12 @@ public CoreMessagesProvider(Marshaller dfltMarsh, Marshaller schemaAwareMarsh, C withNoSchema(CacheStatisticsClearMessage.class); withNoSchema(ClientCacheChangeDummyDiscoveryMessage.class); withNoSchema(DynamicCacheChangeBatch.class); + withNoSchemaResolvedClassLoader(CacheClientReconnectDiscoveryData.class); + withNoSchemaResolvedClassLoader(CacheGroupRecoveryState.class); + withNoSchemaResolvedClassLoader(CacheJoinInfo.class); + withNoSchemaResolvedClassLoader(CacheJoinNodeDiscoveryData.class); + withNoSchemaResolvedClassLoader(CacheReconnectInfo.class); + withNoSchemaResolvedClassLoader(ClusterCacheGroupRecoveryData.class); // [10000 - 10200]: Transaction and lock related messages. Most of them originally comes from Communication. msgIdx = 10000; @@ -529,7 +541,7 @@ public CoreMessagesProvider(Marshaller dfltMarsh, Marshaller schemaAwareMarsh, C withNoSchema(StartRequestData.class); withNoSchema(StartRoutineAckDiscoveryMessage.class); withNoSchema(StartRoutineDiscoveryMessage.class); - withNoSchema(StoredCacheData.class); + withNoSchemaResolvedClassLoader(StoredCacheData.class); // [10600-10800]: Affinity & partition maps. msgIdx = 10600; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheClientReconnectDiscoveryData.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheClientReconnectDiscoveryData.java index 83692fb75201f..98f0b746d59cc 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheClientReconnectDiscoveryData.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheClientReconnectDiscoveryData.java @@ -17,175 +17,30 @@ package org.apache.ignite.internal.processors.cache; -import java.io.Serializable; import java.util.Map; -import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.internal.Order; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.lang.IgniteUuid; - -/** - * Discovery data sent from client reconnecting to cluster. - */ -public class CacheClientReconnectDiscoveryData implements Serializable { - /** */ - private static final long serialVersionUID = 0L; +import org.apache.ignite.plugin.extensions.communication.Message; +/** Discovery data sent from client reconnecting to cluster. */ +public class CacheClientReconnectDiscoveryData implements Message { /** */ - private final Map clientCacheGrps; + @Order(0) + Map clientCaches; /** */ - private final Map clientCaches; + public CacheClientReconnectDiscoveryData() { } - /** - * @param clientCaches Information about caches started on re-joining client node. - * @param clientCacheGrps Information about cach groups started on re-joining client node. - */ - CacheClientReconnectDiscoveryData(Map clientCacheGrps, - Map clientCaches) { - this.clientCacheGrps = clientCacheGrps; + /** @param clientCaches Information about caches started on re-joining client node. */ + CacheClientReconnectDiscoveryData(Map clientCaches) { this.clientCaches = clientCaches; } - /** - * @return Information about caches started on re-joining client node. - */ - Map clientCacheGroups() { - return clientCacheGrps; - } - - /** - * @return Information about caches started on re-joining client node. - */ - public Map clientCaches() { + /** @return Information about caches started on re-joining client node. */ + public Map clientCaches() { return clientCaches; } - /** - * - */ - static class CacheGroupInfo implements Serializable { - /** */ - private static final long serialVersionUID = 0L; - - /** */ - private final CacheConfiguration ccfg; - - /** */ - private final IgniteUuid deploymentId; - - /** Flags added for future usage. */ - private final long flags; - - /** - * @param ccfg Cache group configuration. - * @param deploymentId Cache group deployment ID. - * @param flags Flags (for future usage). - */ - CacheGroupInfo(CacheConfiguration ccfg, - IgniteUuid deploymentId, - long flags) { - assert ccfg != null; - assert deploymentId != null; - - this.ccfg = ccfg; - this.deploymentId = deploymentId; - this.flags = flags; - } - - /** - * @return Cache group configuration. - */ - CacheConfiguration config() { - return ccfg; - } - - /** - * @return Cache group deployment ID. - */ - IgniteUuid deploymentId() { - return deploymentId; - } - } - - /** - * - */ - static class CacheInfo implements Serializable { - /** */ - private static final long serialVersionUID = 0L; - - /** */ - private final CacheConfiguration ccfg; - - /** */ - private final CacheType cacheType; - - /** */ - private final IgniteUuid deploymentId; - - /** */ - private final boolean nearCache; - - /** Flags added for future usage. */ - private final long flags; - - /** - * @param ccfg Cache configuration. - * @param cacheType Cache type. - * @param deploymentId Cache deployment ID. - * @param nearCache Near cache flag. - * @param flags Flags (for future usage). - */ - CacheInfo(CacheConfiguration ccfg, - CacheType cacheType, - IgniteUuid deploymentId, - boolean nearCache, - long flags) { - assert ccfg != null; - assert cacheType != null; - assert deploymentId != null; - - this.ccfg = ccfg; - this.cacheType = cacheType; - this.deploymentId = deploymentId; - this.nearCache = nearCache; - this.flags = flags; - } - - /** - * @return Cache configuration. - */ - CacheConfiguration config() { - return ccfg; - } - - /** - * @return Cache type. - */ - CacheType cacheType() { - return cacheType; - } - - /** - * @return Cache deployment ID. - */ - IgniteUuid deploymentId() { - return deploymentId; - } - - /** - * @return Near cache flag. - */ - boolean nearCache() { - return nearCache; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(CacheInfo.class, this); - } - } - /** {@inheritDoc} */ @Override public String toString() { return S.toString(CacheClientReconnectDiscoveryData.class, this); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupRecoveryState.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupRecoveryState.java index 880fa09b21c62..3cd4e77ea0497 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupRecoveryState.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupRecoveryState.java @@ -25,19 +25,23 @@ import java.util.Collections; import java.util.Set; import java.util.stream.Collectors; +import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopology; import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.plugin.extensions.communication.Message; /** */ -public class CacheGroupRecoveryState implements Externalizable { +public class CacheGroupRecoveryState implements Externalizable, Message { /** */ private static final long serialVersionUID = 0L; /** */ - private Set lostParts; + @Order(0) + Set lostParts; /** */ - private Set zeroParts; + @Order(1) + Set zeroParts; /** */ public CacheGroupRecoveryState() { @@ -53,12 +57,12 @@ public CacheGroupRecoveryState(CacheGroupContext grp) { } /** */ - public Set zeroUpdateCounterParititons() { + public Set zeroUpdateCounterPartitions() { return Collections.unmodifiableSet(zeroParts); } /** */ - public Set lostParititons() { + public Set lostPartitions() { return Collections.unmodifiableSet(lostParts); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheJoinInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheJoinInfo.java new file mode 100644 index 0000000000000..b1151d5a62ad1 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheJoinInfo.java @@ -0,0 +1,98 @@ +/* + * 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; + +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; + +/** Cache information exchanged during node join. */ +public class CacheJoinInfo implements Message { + /** */ + @Order(0) + @GridToStringInclude + StoredCacheData cacheData; + + /** */ + @Order(1) + @GridToStringInclude + CacheType cacheType; + + /** */ + @Order(2) + @GridToStringInclude + boolean sql; + + /** Flags added for future usage. */ + @Order(3) + long flags; + + /** Statically configured flag. */ + @Order(4) + boolean staticallyConfigured; + + /** */ + public CacheJoinInfo() { } + + /** + * @param cacheData Cache data. + * @param cacheType Cache type. + * @param sql SQL flag - {@code true} if cache was created with {@code CREATE TABLE}. + * @param flags Flags (for future usage). + * @param staticallyConfigured {@code true} if it was configured by static config and {@code false} otherwise. + */ + public CacheJoinInfo(StoredCacheData cacheData, CacheType cacheType, boolean sql, long flags, + boolean staticallyConfigured) { + this.cacheData = cacheData; + this.cacheType = cacheType; + this.sql = sql; + this.flags = flags; + this.staticallyConfigured = staticallyConfigured; + } + + /** @return Cache data. */ + public StoredCacheData cacheData() { + return cacheData; + } + + /** @return Cache type. */ + public CacheType cacheType() { + return cacheType; + } + + /** @return SQL flag - {@code true} if cache was created with {@code CREATE TABLE}. */ + public boolean sql() { + return sql; + } + + /** @return {@code true} if it was configured by static config and {@code false} otherwise. */ + public boolean isStaticallyConfigured() { + return staticallyConfigured; + } + + /** @return Long which bits represent some flags. */ + public long getFlags() { + return flags; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(CacheJoinInfo.class, this); + } +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheJoinNodeDiscoveryData.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheJoinNodeDiscoveryData.java index 700d5166608e7..e36c193ddeb27 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheJoinNodeDiscoveryData.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheJoinNodeDiscoveryData.java @@ -17,39 +17,41 @@ package org.apache.ignite.internal.processors.cache; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.Serializable; import java.util.Map; +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.lang.IgniteUuid; +import org.apache.ignite.plugin.extensions.communication.Message; import org.jetbrains.annotations.Nullable; -/** - * Information about configured caches sent from joining node. - */ -public class CacheJoinNodeDiscoveryData implements Serializable { +/** Information about configured caches sent from joining node. */ +public class CacheJoinNodeDiscoveryData implements Message { /** */ - private static final long serialVersionUID = 0L; + @Order(0) + @GridToStringInclude + Map caches; /** */ + @Order(1) @GridToStringInclude - private final Map caches; + Map templates; /** */ + @Order(2) @GridToStringInclude - private final Map templates; + IgniteUuid cacheDeploymentId; /** */ - @GridToStringInclude - private final IgniteUuid cacheDeploymentId; + @Order(3) + boolean startCaches; /** */ - private final boolean startCaches; + @Order(4) + @Nullable ClusterCacheGroupRecoveryData clusterCacheGrpRecoveryData; /** */ - @Nullable private ClusterCacheGroupRecoveryData clusterCacheGroupRecoveryData; + public CacheJoinNodeDiscoveryData() { } /** * @param cacheDeploymentId Deployment ID for started caches. @@ -59,8 +61,8 @@ public class CacheJoinNodeDiscoveryData implements Serializable { */ public CacheJoinNodeDiscoveryData( IgniteUuid cacheDeploymentId, - Map caches, - Map templates, + Map caches, + Map templates, boolean startCaches ) { this.cacheDeploymentId = cacheDeploymentId; @@ -69,138 +71,34 @@ public CacheJoinNodeDiscoveryData( this.startCaches = startCaches; } - /** - * @return {@code True} if required to start all caches on joining node. - */ + /** @return {@code True} if required to start all caches on joining node. */ boolean startCaches() { return startCaches; } - /** - * @return Deployment ID assigned on joining node. - */ + /** @return Deployment ID assigned on joining node. */ public IgniteUuid cacheDeploymentId() { return cacheDeploymentId; } - /** - * @return Templates configured on joining node. - */ - public Map templates() { + /** @return Templates configured on joining node. */ + public Map templates() { return templates; } - /** - * @return Caches configured on joining node. - */ - public Map caches() { + /** @return Caches configured on joining node. */ + public Map caches() { return caches; } /** */ - public void clusterCacheGroupRecoveryData(@Nullable ClusterCacheGroupRecoveryData clusterCacheGroupRecoveryData) { - this.clusterCacheGroupRecoveryData = clusterCacheGroupRecoveryData; + public void clusterCacheGroupRecoveryData(@Nullable ClusterCacheGroupRecoveryData clusterCacheGrpRecoveryData) { + this.clusterCacheGrpRecoveryData = clusterCacheGrpRecoveryData; } /** */ @Nullable public ClusterCacheGroupRecoveryData clusterCacheGroupRecoveryData() { - return clusterCacheGroupRecoveryData; - } - - /** - * - */ - public static class CacheInfo implements Serializable { - /** */ - private static final long serialVersionUID = 0L; - - /** */ - @GridToStringInclude - private StoredCacheData cacheData; - - /** */ - @GridToStringInclude - private CacheType cacheType; - - /** */ - @GridToStringInclude - private boolean sql; - - /** Flags added for future usage. */ - private long flags; - - /** Statically configured flag */ - private boolean staticallyConfigured; - - /** - * @param cacheData Cache data. - * @param cacheType Cache type. - * @param sql SQL flag - {@code true} if cache was created with {@code CREATE TABLE}. - * @param flags Flags (for future usage). - * @param staticallyConfigured {@code true} if it was configured by static config and {@code false} otherwise. - */ - public CacheInfo(StoredCacheData cacheData, CacheType cacheType, boolean sql, long flags, - boolean staticallyConfigured) { - this.cacheData = cacheData; - this.cacheType = cacheType; - this.sql = sql; - this.flags = flags; - this.staticallyConfigured = staticallyConfigured; - } - - /** - * @return Cache data. - */ - public StoredCacheData cacheData() { - return cacheData; - } - - /** - * @return Cache type. - */ - public CacheType cacheType() { - return cacheType; - } - - /** - * @return SQL flag - {@code true} if cache was created with {@code CREATE TABLE}. - */ - public boolean sql() { - return sql; - } - - /** - * @return {@code true} if it was configured by static config and {@code false} otherwise. - */ - public boolean isStaticallyConfigured() { - return staticallyConfigured; - } - - /** - * @return Long which bits represent some flags. - */ - public long getFlags() { - return flags; - } - - /** - * @param ois ObjectInputStream. - */ - private void readObject(ObjectInputStream ois) - throws IOException, ClassNotFoundException { - ObjectInputStream.GetField gf = ois.readFields(); - - cacheData = (StoredCacheData)gf.get("cacheData", null); - cacheType = (CacheType)gf.get("cacheType", null); - sql = gf.get("sql", false); - flags = gf.get("flags", 0L); - staticallyConfigured = gf.get("staticallyConfigured", true); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(CacheInfo.class, this); - } + return clusterCacheGrpRecoveryData; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheReconnectInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheReconnectInfo.java new file mode 100644 index 0000000000000..ad9453a0e7ddc --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheReconnectInfo.java @@ -0,0 +1,75 @@ +/* + * 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; + +import org.apache.ignite.internal.Order; +import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.lang.IgniteUuid; +import org.apache.ignite.plugin.extensions.communication.Message; + +/** Cache information from a reconnecting client node. */ +public class CacheReconnectInfo implements Message { + /** */ + @Order(0) + String cacheName; + + /** */ + @Order(1) + IgniteUuid deploymentId; + + /** */ + @Order(2) + boolean nearCache; + + /** */ + public CacheReconnectInfo() { } + + /** + * @param cacheName Cache name. + * @param deploymentId Cache deployment ID. + * @param nearCache Near cache flag. + */ + public CacheReconnectInfo(String cacheName, IgniteUuid deploymentId, boolean nearCache) { + assert cacheName != null; + assert deploymentId != null; + + this.cacheName = cacheName; + this.deploymentId = deploymentId; + this.nearCache = nearCache; + } + + /** @return Cache configuration. */ + String cacheName() { + return cacheName; + } + + /** @return Cache deployment ID. */ + IgniteUuid deploymentId() { + return deploymentId; + } + + /** @return Near cache flag. */ + boolean nearCache() { + return nearCache; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(CacheReconnectInfo.class, this); + } +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCacheGroupRecoveryData.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCacheGroupRecoveryData.java index 0d71593378a49..6cf7f44053edc 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCacheGroupRecoveryData.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCacheGroupRecoveryData.java @@ -24,19 +24,23 @@ import java.util.Collection; import java.util.Map; import java.util.stream.Collectors; +import org.apache.ignite.internal.Order; import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.plugin.extensions.communication.Message; import org.jetbrains.annotations.Nullable; /** */ -public class ClusterCacheGroupRecoveryData implements Externalizable { +public class ClusterCacheGroupRecoveryData implements Externalizable, Message { /** */ private static final long serialVersionUID = 0L; /** */ - private long clusterBaselineTopologyVersion; + @Order(0) + long clusterBaselineTopVer; /** */ - private Map grpStates; + @Order(1) + Map grpStates; /** */ public ClusterCacheGroupRecoveryData() { @@ -44,14 +48,14 @@ public ClusterCacheGroupRecoveryData() { } /** */ - public ClusterCacheGroupRecoveryData(long clusterBaselineTopologyVersion, Collection grps) { - this.clusterBaselineTopologyVersion = clusterBaselineTopologyVersion; - this.grpStates = grps.stream().collect(Collectors.toMap(CacheGroupContext::groupId, CacheGroupRecoveryState::new)); + public ClusterCacheGroupRecoveryData(long clusterBaselineTopVer, Collection grps) { + this.clusterBaselineTopVer = clusterBaselineTopVer; + grpStates = grps.stream().collect(Collectors.toMap(CacheGroupContext::groupId, CacheGroupRecoveryState::new)); } /** */ public boolean isMoreRelevantThan(ClusterCacheGroupRecoveryData data) { - return clusterBaselineTopologyVersion > data.clusterBaselineTopologyVersion; + return clusterBaselineTopVer > data.clusterBaselineTopVer; } /** */ @@ -61,13 +65,13 @@ public boolean isMoreRelevantThan(ClusterCacheGroupRecoveryData data) { /** {@inheritDoc} */ @Override public void writeExternal(ObjectOutput out) throws IOException { - out.writeLong(clusterBaselineTopologyVersion); + out.writeLong(clusterBaselineTopVer); U.writeMap(out, grpStates); } /** {@inheritDoc} */ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { - clusterBaselineTopologyVersion = in.readLong(); + clusterBaselineTopVer = in.readLong(); grpStates = U.readHashMap(in); } } 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 d5c7d8dce2536..a9101902b22c4 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 @@ -18,7 +18,6 @@ package org.apache.ignite.internal.processors.cache; import java.io.File; -import java.io.Serializable; import java.nio.file.InvalidPathException; import java.util.ArrayList; import java.util.Arrays; @@ -82,6 +81,7 @@ import org.apache.ignite.plugin.CachePluginContext; import org.apache.ignite.plugin.CachePluginProvider; import org.apache.ignite.plugin.PluginProvider; +import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.spi.discovery.DiscoveryDataBag; import org.apache.ignite.spi.systemview.view.CacheGroupView; import org.apache.ignite.spi.systemview.view.CacheView; @@ -301,7 +301,7 @@ public void onStart(CacheJoinNodeDiscoveryData joinDiscoData) throws IgniteCheck Map grpCfgs = new HashMap<>(); - for (CacheJoinNodeDiscoveryData.CacheInfo info : joinDiscoData.caches().values()) { + for (CacheJoinInfo info : joinDiscoData.caches().values()) { if (info.cacheData().config().getGroupName() == null) continue; @@ -330,7 +330,7 @@ public void onKernalStart(boolean checkConsistency) throws IgniteCheckedExceptio if (gridData != null && gridData.joinDiscoData != null) { CacheJoinNodeDiscoveryData joinDiscoData = gridData.joinDiscoData; - for (CacheJoinNodeDiscoveryData.CacheInfo locCacheInfo : joinDiscoData.caches().values()) { + for (CacheJoinInfo locCacheInfo : joinDiscoData.caches().values()) { CacheConfiguration locCfg = locCacheInfo.cacheData().config(); CacheData cacheData = gridData.gridData.caches().get(locCfg.getName()); @@ -388,7 +388,7 @@ public void onKernalStart(boolean checkConsistency) throws IgniteCheckedExceptio * @throws IgniteCheckedException If check failed. */ @SuppressWarnings("unchecked") - private void checkCache(CacheJoinNodeDiscoveryData.CacheInfo locInfo, CacheData rmtData, UUID rmt) + private void checkCache(CacheJoinInfo locInfo, CacheData rmtData, UUID rmt) throws IgniteCheckedException { GridCacheAttributes rmtAttr = new GridCacheAttributes(rmtData.cacheConfiguration(), rmtData.cacheConfigurationEnrichment()); GridCacheAttributes locAttr = @@ -1277,37 +1277,22 @@ Collection restartingCaches() { /** * @return Discovery date sent on local node join. */ - private Serializable joinDiscoveryData() { + private Message joinDiscoveryData() { if (cachesOnDisconnect != null) { - Map cacheGrpsInfo = new HashMap<>(); - Map cachesInfo = new HashMap<>(); + Map cachesInfo = new HashMap<>(); - Map grps = cachesOnDisconnect.cacheGrps; Map caches = cachesOnDisconnect.caches; - for (CacheGroupContext grp : ctx.cache().cacheGroups()) { - CacheGroupDescriptor desc = grps.get(grp.groupId()); - - assert desc != null : grp.cacheOrGroupName(); - - cacheGrpsInfo.put(grp.groupId(), new CacheClientReconnectDiscoveryData.CacheGroupInfo(desc.config(), - desc.deploymentId(), - 0)); - } - - for (IgniteInternalCache cache : ctx.cache().caches()) { + for (IgniteInternalCache cache : ctx.cache().caches()) { DynamicCacheDescriptor desc = caches.get(cache.name()); assert desc != null : cache.name(); - cachesInfo.put(cache.name(), new CacheClientReconnectDiscoveryData.CacheInfo(desc.cacheConfiguration(), - desc.cacheType(), - desc.deploymentId(), - cache.context().isNear(), - 0)); + cachesInfo.put(cache.name(), new CacheReconnectInfo(desc.cacheConfiguration().getName(), + desc.deploymentId(), cache.context().isNear())); } - return new CacheClientReconnectDiscoveryData(cacheGrpsInfo, cachesInfo); + return new CacheClientReconnectDiscoveryData(cachesInfo); } else { assert joinDiscoData != null; @@ -1539,7 +1524,7 @@ public void onGridDataReceived(DiscoveryDataBag.GridDiscoveryData data) { String conflictErr = null; if (joinDiscoData != null) { - for (Map.Entry e : joinDiscoData.caches().entrySet()) { + for (Map.Entry e : joinDiscoData.caches().entrySet()) { if (!registeredCaches.containsKey(e.getKey())) { conflictErr = checkCacheConflict(e.getValue().cacheData().config(), true); @@ -1811,7 +1796,7 @@ private Collection getLocalQueryEntities(String cacheName) { if (joinDiscoData == null) return Collections.emptyList(); - CacheJoinNodeDiscoveryData.CacheInfo cacheInfo = joinDiscoData.caches().get(cacheName); + CacheJoinInfo cacheInfo = joinDiscoData.caches().get(cacheName); if (cacheInfo == null) return Collections.emptyList(); @@ -1848,7 +1833,7 @@ private void initStartCachesForLocalJoin(boolean firstNode, boolean reconnect) { if (reconnect && surviveReconnect(cfg.getName()) && cachesOnDisconnect.state.active() && active) continue; - CacheJoinNodeDiscoveryData.CacheInfo locCfg = joinDiscoData.caches().get(cfg.getName()); + CacheJoinInfo locCfg = joinDiscoData.caches().get(cfg.getName()); NearCacheConfiguration nearCfg = null; @@ -2037,20 +2022,18 @@ public ExchangeActions onStateChangeRequest(ChangeGlobalStateMessage msg, Affini */ public void onJoiningNodeDataReceived(DiscoveryDataBag.JoiningNodeDiscoveryData data) { if (data.hasJoiningNodeData()) { - Serializable joiningNodeData = data.joiningNodeData(); - - if (joiningNodeData instanceof CacheClientReconnectDiscoveryData) { + if (data.joiningNodeData() instanceof CacheClientReconnectDiscoveryData reconData) { if (disconnectedState()) { if (clientReconnectReqs == null) clientReconnectReqs = new LinkedHashMap<>(); - clientReconnectReqs.put(data.joiningNodeId(), (CacheClientReconnectDiscoveryData)joiningNodeData); + clientReconnectReqs.put(data.joiningNodeId(), reconData); } else - processClientReconnectData((CacheClientReconnectDiscoveryData)joiningNodeData, data.joiningNodeId()); + processClientReconnectData(reconData, data.joiningNodeId()); } - else if (joiningNodeData instanceof CacheJoinNodeDiscoveryData) - processJoiningNode((CacheJoinNodeDiscoveryData)joiningNodeData, data.joiningNodeId(), false); + else if (data.joiningNodeData() instanceof CacheJoinNodeDiscoveryData joinData) + processJoiningNode(joinData, data.joiningNodeId(), false); } } @@ -2061,15 +2044,11 @@ else if (joiningNodeData instanceof CacheJoinNodeDiscoveryData) */ public String validateJoiningNodeData(DiscoveryDataBag.JoiningNodeDiscoveryData data, boolean joiningNodeClient) { if (data.hasJoiningNodeData()) { - Serializable joiningNodeData = data.joiningNodeData(); - - if (joiningNodeData instanceof CacheJoinNodeDiscoveryData) { - CacheJoinNodeDiscoveryData joinData = (CacheJoinNodeDiscoveryData)joiningNodeData; - + if (data.joiningNodeData() instanceof CacheJoinNodeDiscoveryData joinData) { Set problemCaches = null; Set encClientCaches = null; - for (CacheJoinNodeDiscoveryData.CacheInfo cacheInfo : joinData.caches().values()) { + for (CacheJoinInfo cacheInfo : joinData.caches().values()) { CacheConfiguration cfg = cacheInfo.cacheData().config(); if (!registeredCaches.containsKey(cfg.getName())) { @@ -2125,16 +2104,16 @@ private void processClientReconnectData(CacheClientReconnectDiscoveryData client DiscoveryDataClusterState state = ctx.state().clusterState(); if (state.state().active() && !state.transition()) { - for (CacheClientReconnectDiscoveryData.CacheInfo cacheInfo : clientData.clientCaches().values()) { - String cacheName = cacheInfo.config().getName(); + for (CacheReconnectInfo cacheReconnectInfo : clientData.clientCaches().values()) { + String cacheName = cacheReconnectInfo.cacheName(); if (surviveReconnect(cacheName)) ctx.discovery().addClientNode(cacheName, clientNodeId, false); else { DynamicCacheDescriptor desc = registeredCaches.get(cacheName); - if (desc != null && desc.deploymentId().equals(cacheInfo.deploymentId())) - ctx.discovery().addClientNode(cacheName, clientNodeId, cacheInfo.nearCache()); + if (desc != null && desc.deploymentId().equals(cacheReconnectInfo.deploymentId())) + ctx.discovery().addClientNode(cacheName, clientNodeId, cacheReconnectInfo.nearCache()); } } } @@ -2216,7 +2195,7 @@ private String processJoiningNode(CacheJoinNodeDiscoveryData joinData, UUID node boolean hasSchemaPatchConflict = false; boolean active = ctx.state().clusterState().active(); - for (CacheJoinNodeDiscoveryData.CacheInfo cacheInfo : joinData.caches().values()) { + for (CacheJoinInfo cacheInfo : joinData.caches().values()) { CacheConfiguration cfg = cacheInfo.cacheData().config(); if (!registeredCaches.containsKey(cfg.getName())) { @@ -2278,7 +2257,7 @@ else if (!schemaPatch.isEmpty() && !hasSchemaPatchConflict) private void registerNewCache( CacheJoinNodeDiscoveryData joinData, UUID nodeId, - CacheJoinNodeDiscoveryData.CacheInfo cacheInfo + CacheJoinInfo cacheInfo ) { CacheConfiguration cfg = cacheInfo.cacheData().config(); @@ -2345,7 +2324,7 @@ private void registerNewCache( * @param nodeId Joining node id. */ private void registerNewCacheTemplates(CacheJoinNodeDiscoveryData joinData, UUID nodeId) { - for (CacheJoinNodeDiscoveryData.CacheInfo cacheInfo : joinData.templates().values()) { + for (CacheJoinInfo cacheInfo : joinData.templates().values()) { CacheConfiguration cfg = cacheInfo.cacheData().config(); if (!registeredTemplates.containsKey(cfg.getName())) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridLocalConfigManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridLocalConfigManager.java index 24ec163584f0c..324849ec7af79 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridLocalConfigManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridLocalConfigManager.java @@ -354,9 +354,9 @@ public Set localCachesOnStart() { * @throws IgniteCheckedException If failed. */ public CacheJoinNodeDiscoveryData restoreCacheConfigurations() throws IgniteCheckedException { - Map caches = new HashMap<>(); + Map caches = new HashMap<>(); - Map templates = new HashMap<>(); + Map templates = new HashMap<>(); restoreCaches(caches, templates, ctx.config()); @@ -488,8 +488,8 @@ private boolean startAllCachesOnClientStart() { * @param igniteCfg Ignite configuration. */ private void restoreCaches( - Map caches, - Map templates, + Map caches, + Map templates, IgniteConfiguration igniteCfg ) throws IgniteCheckedException { CacheConfiguration[] cfgs = igniteCfg.getCacheConfiguration(); @@ -567,7 +567,7 @@ private void restoreCaches( * @param isStaticallyConfigured Statically configured flag. */ private void addStoredCache( - Map caches, + Map caches, StoredCacheData cacheData, String cacheName, CacheType cacheType, @@ -581,7 +581,7 @@ private void addStoredCache( stopSeq.addFirst(cacheName); } - caches.put(cacheName, new CacheJoinNodeDiscoveryData.CacheInfo(cacheData, cacheType, cacheData.sql(), + caches.put(cacheName, new CacheJoinInfo(cacheData, cacheType, cacheData.sql(), persistedBefore ? 1 : 0, isStaticallyConfigured)); } @@ -595,8 +595,8 @@ private void addStoredCache( private void addCacheFromConfiguration( CacheConfiguration cfg, boolean sql, - Map caches, - Map templates + Map caches, + Map templates ) throws IgniteCheckedException { String cacheName = cfg.getName(); @@ -604,7 +604,7 @@ private void addCacheFromConfiguration( Collection> ccfgs = new ArrayList<>(caches.size()); - for (CacheJoinNodeDiscoveryData.CacheInfo cacheInfo : caches.values()) + for (CacheJoinInfo cacheInfo : caches.values()) ccfgs.add(cacheInfo.cacheData().config()); String err = validateIncomingConfiguration(ccfgs, cfg); @@ -631,7 +631,7 @@ private void addCacheFromConfiguration( cfg = splitCfg.get1(); if (GridCacheUtils.isCacheTemplateName(cacheName)) - templates.put(cacheName, new CacheJoinNodeDiscoveryData.CacheInfo(cacheData, CacheType.USER, false, 0, true)); + templates.put(cacheName, new CacheJoinInfo(cacheData, CacheType.USER, false, 0, true)); else { if (caches.containsKey(cacheName)) { throw new IgniteCheckedException("Duplicate cache name found (check configuration and " + diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ValidationOnNodeJoinUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ValidationOnNodeJoinUtils.java index 16ea96c3cf40d..4e039917c83fe 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ValidationOnNodeJoinUtils.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ValidationOnNodeJoinUtils.java @@ -156,7 +156,7 @@ public class ValidationOnNodeJoinUtils { } } - for (CacheJoinNodeDiscoveryData.CacheInfo cacheInfo : nodeData.caches().values()) { + for (CacheJoinInfo cacheInfo : nodeData.caches().values()) { if (secCtx != null && cacheInfo.cacheType() == CacheType.USER) { try (Scope ignored = ctx.security().withContext(secCtx)) { GridCacheProcessor.authorizeCacheCreate(ctx.security(), cacheInfo.cacheData().config()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridDhtPartitionTopologyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridDhtPartitionTopologyImpl.java index 5c651e8e7ad5c..afbb0c191f682 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridDhtPartitionTopologyImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridDhtPartitionTopologyImpl.java @@ -3260,12 +3260,12 @@ private void consistencyCheck() { /** */ private void restoreLostPartitions(CacheGroupRecoveryState grpState) { - grpState.lostParititons().forEach(this::registerLostPartition); + grpState.lostPartitions().forEach(this::registerLostPartition); } /** */ private void detectPartitionLossDuringInactivity(CacheGroupRecoveryState grpState) { - Set recoveryZeroParts = grpState.zeroUpdateCounterParititons(); + Set recoveryZeroParts = grpState.zeroUpdateCounterPartitions(); Set detectedLostParts = new HashSet<>(); diff --git a/modules/core/src/main/resources/META-INF/classnames.properties b/modules/core/src/main/resources/META-INF/classnames.properties index 431e7ee68b9b7..91b37c246ef54 100644 --- a/modules/core/src/main/resources/META-INF/classnames.properties +++ b/modules/core/src/main/resources/META-INF/classnames.properties @@ -796,8 +796,6 @@ org.apache.ignite.internal.processors.cache.CacheAffinitySharedManager$7 org.apache.ignite.internal.processors.cache.CacheAffinitySharedManager$8 org.apache.ignite.internal.processors.cache.CacheAffinitySharedManager$9 org.apache.ignite.internal.processors.cache.CacheClientReconnectDiscoveryData -org.apache.ignite.internal.processors.cache.CacheClientReconnectDiscoveryData$CacheGroupInfo -org.apache.ignite.internal.processors.cache.CacheClientReconnectDiscoveryData$CacheInfo org.apache.ignite.internal.processors.cache.CacheConfigurationEnrichment org.apache.ignite.internal.processors.cache.CacheData org.apache.ignite.internal.processors.cache.CacheDefaultBinaryAffinityKeyMapper @@ -813,7 +811,6 @@ org.apache.ignite.internal.processors.cache.CacheInvokeDirectResult org.apache.ignite.internal.processors.cache.CacheInvokeEntry$Operation org.apache.ignite.internal.processors.cache.CacheInvokeResult org.apache.ignite.internal.processors.cache.CacheJoinNodeDiscoveryData -org.apache.ignite.internal.processors.cache.CacheJoinNodeDiscoveryData$CacheInfo org.apache.ignite.internal.processors.cache.CacheMetricsSnapshot org.apache.ignite.internal.processors.cache.CacheNodeCommonDiscoveryData org.apache.ignite.internal.processors.cache.CacheObject