Skip to content

Commit d0a3df5

Browse files
IGNITE-26754 Fix binary compatibility issue with dcId property (#12432)
1 parent 342c36a commit d0a3df5

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import java.util.List;
3131
import java.util.Map;
3232
import java.util.UUID;
33+
import org.apache.ignite.IgniteSystemProperties;
3334
import org.apache.ignite.cache.CacheMetrics;
3435
import org.apache.ignite.cluster.ClusterMetrics;
3536
import org.apache.ignite.cluster.ClusterNode;
@@ -590,7 +591,6 @@ public TcpDiscoveryNode clientReconnectNode(Map<String, Object> nodeAttrs) {
590591
out.writeLong(intOrder);
591592
out.writeObject(ver);
592593
U.writeUuid(out, clientRouterNodeId);
593-
out.writeObject(dcId);
594594
}
595595

596596
/** {@inheritDoc} */
@@ -628,7 +628,7 @@ public TcpDiscoveryNode clientReconnectNode(Map<String, Object> nodeAttrs) {
628628
else
629629
consistentId = consistentIdAttr != null ? consistentIdAttr : U.consistentId(addrs, discPort);
630630

631-
dcId = (String)in.readObject();
631+
dcId = (String)attrs.get(IgniteSystemProperties.IGNITE_DATA_CENTER_ID);
632632
}
633633

634634
/** {@inheritDoc} */

modules/core/src/test/java/org/apache/ignite/spi/discovery/datacenter/MultiDataCenterDeploymentTest.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ public class MultiDataCenterDeploymentTest extends GridCommonAbstractTest {
4848
return cfg;
4949
}
5050

51+
/** {@inheritDoc} */
52+
@Override protected IgniteConfiguration optimize(IgniteConfiguration cfg) throws IgniteCheckedException {
53+
// super.optimize() method sets includeProperties to a non-null value which later leads to
54+
// IgniteSystemProperties not being added to node attributes.
55+
// This test relies on the presence of IgniteSystemProperties in node attributes so we need set includeProperties to null.
56+
return super.optimize(cfg).setIncludeProperties((String[])null);
57+
}
58+
5159
/** {@inheritDoc} */
5260
@Override protected void afterTest() throws Exception {
5361
super.afterTest();
@@ -68,8 +76,11 @@ public void testAttributeSetLocallyFromSystemProperty() throws Exception {
6876
String dcId = testGrid.localNode().dataCenterId();
6977

7078
assertNotNull("Data Center ID of the node should not be null", dcId);
71-
7279
assertEquals(DC_ID_0, dcId);
80+
81+
String dcIdFromSysProp = testGrid.localNode().attribute(IgniteSystemProperties.IGNITE_DATA_CENTER_ID);
82+
assertNotNull("Data Center ID of the node should not be null", dcIdFromSysProp);
83+
assertEquals(DC_ID_0, dcIdFromSysProp);
7384
}
7485

7586
/**

modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperClusterNode.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.util.HashMap;
2828
import java.util.Map;
2929
import java.util.UUID;
30+
import org.apache.ignite.IgniteSystemProperties;
3031
import org.apache.ignite.cache.CacheMetrics;
3132
import org.apache.ignite.cluster.ClusterMetrics;
3233
import org.apache.ignite.internal.ClusterMetricsSnapshot;
@@ -340,8 +341,6 @@ public void local(boolean loc) {
340341
mtr = ClusterMetricsSnapshot.serialize(metrics);
341342

342343
U.writeByteArray(out, mtr);
343-
344-
out.writeObject(dcId);
345344
}
346345

347346
/** {@inheritDoc} */
@@ -363,7 +362,7 @@ public void local(boolean loc) {
363362
if (mtr != null)
364363
metrics = ClusterMetricsSnapshot.deserialize(mtr, 0);
365364

366-
dcId = (String)in.readObject();
365+
dcId = (String)attrs.get(IgniteSystemProperties.IGNITE_DATA_CENTER_ID);
367366
}
368367

369368
/** {@inheritDoc} */

0 commit comments

Comments
 (0)