Index: incubator-ignite/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/CoordinatorTest.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- incubator-ignite/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/CoordinatorTest.java (date 1615744893610) +++ incubator-ignite/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/CoordinatorTest.java (date 1615744893610) @@ -0,0 +1,54 @@ +package org.apache.ignite.spi.discovery.tcp; + +import org.apache.ignite.cluster.ClusterNode; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; +import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.latch.ExchangeLatchManager; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; + +import java.lang.reflect.Method; +import java.util.UUID; + +public class CoordinatorTest extends GridCommonAbstractTest { + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + return super + .getConfiguration(igniteInstanceName) + .setDaemon("daemon".equals(igniteInstanceName)); + } + + @Test + public void test() throws Exception { + IgniteEx srv1 = startGrid("server1"); + IgniteEx daemon = startGrid("daemon"); + IgniteEx srv2 = startGrid("server2"); + + stopGrid("server1"); + + AffinityTopologyVersion topVer = srv2.context().discovery().topologyVersionEx(); + + ExchangeLatchManager latchMgr = srv2.context().cache().context().exchange().latch(); + + Method method = latchMgr.getClass().getDeclaredMethod("getLatchCoordinator", AffinityTopologyVersion.class); + + method.setAccessible(true); + + UUID latchCrd = ((ClusterNode) method.invoke(latchMgr, topVer)).id(); + + TcpDiscoverySpi discoverySpi = (TcpDiscoverySpi)srv2.configuration().getDiscoverySpi(); + + ServerImpl srvImpl = U.field(discoverySpi, "impl"); + + Method method2 = srvImpl.getClass().getDeclaredMethod("resolveCoordinator"); + + method2.setAccessible(true); + + UUID spiCrd = ((ClusterNode) method2.invoke(srvImpl)).id(); + + assertEquals(latchCrd, spiCrd); + } +}