Search in sources :

Example 16 with TcpDiscoveryNode

use of org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode in project ignite by apache.

the class TcpDiscoverySelfTest method testNodeAdded.

/**
     * @throws Exception If any error occurs.
     */
public void testNodeAdded() throws Exception {
    try {
        final Ignite g1 = startGrid(1);
        final CountDownLatch cnt = new CountDownLatch(2);
        g1.events().localListen(new IgnitePredicate<Event>() {

            @Override
            public boolean apply(Event evt) {
                info("Node joined: " + evt.message());
                DiscoveryEvent discoEvt = (DiscoveryEvent) evt;
                TcpDiscoveryNode node = ((TcpDiscoveryNode) discoMap.get(g1.name()).getNode(discoEvt.eventNode().id()));
                assert node != null && node.visible();
                cnt.countDown();
                return true;
            }
        }, EventType.EVT_NODE_JOINED);
        startGrid(2);
        startGrid(3);
        info("Nodes were started");
        assert cnt.await(1, SECONDS);
    } finally {
        stopAllGrids();
    }
}
Also used : Event(org.apache.ignite.events.Event) DiscoveryEvent(org.apache.ignite.events.DiscoveryEvent) DiscoveryEvent(org.apache.ignite.events.DiscoveryEvent) Ignite(org.apache.ignite.Ignite) CountDownLatch(java.util.concurrent.CountDownLatch) TcpDiscoveryNode(org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode)

Example 17 with TcpDiscoveryNode

use of org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode in project ignite by apache.

the class CacheMetricsForClusterGroupSelfTest method testMetricsStatisticsDisabled.

/**
     * Test cluster group metrics in case of statistics disabled.
     */
public void testMetricsStatisticsDisabled() throws Exception {
    createCaches(false);
    populateCacheData(cache1, ENTRY_CNT_CACHE1);
    populateCacheData(cache2, ENTRY_CNT_CACHE2);
    readCacheData(cache1, ENTRY_CNT_CACHE1);
    readCacheData(cache2, ENTRY_CNT_CACHE2);
    awaitMetricsUpdate();
    Collection<ClusterNode> nodes = grid(0).cluster().forRemotes().nodes();
    for (ClusterNode node : nodes) {
        Map<Integer, CacheMetrics> metrics = ((TcpDiscoveryNode) node).cacheMetrics();
        assertNotNull(metrics);
        assertTrue(metrics.isEmpty());
    }
    assertMetrics(cache1);
    assertMetrics(cache2);
    destroyCaches();
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) CacheMetrics(org.apache.ignite.cache.CacheMetrics) TcpDiscoveryNode(org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode)

Example 18 with TcpDiscoveryNode

use of org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode in project ignite by apache.

the class IgniteKernal method dumpDebugInfo.

/** {@inheritDoc} */
public void dumpDebugInfo() {
    try {
        GridKernalContextImpl ctx = this.ctx;
        GridDiscoveryManager discoMrg = ctx != null ? ctx.discovery() : null;
        ClusterNode locNode = discoMrg != null ? discoMrg.localNode() : null;
        if (ctx != null && discoMrg != null && locNode != null) {
            boolean client = ctx.clientNode();
            UUID routerId = locNode instanceof TcpDiscoveryNode ? ((TcpDiscoveryNode) locNode).clientRouterNodeId() : null;
            U.warn(log, "Dumping debug info for node [id=" + locNode.id() + ", name=" + ctx.igniteInstanceName() + ", order=" + locNode.order() + ", topVer=" + discoMrg.topologyVersion() + ", client=" + client + (client && routerId != null ? ", routerId=" + routerId : "") + ']');
            ctx.cache().context().exchange().dumpDebugInfo();
        } else
            U.warn(log, "Dumping debug info for node, context is not initialized [name=" + igniteInstanceName + ']');
    } catch (Exception e) {
        U.error(log, "Failed to dump debug info for node: " + e, e);
    }
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) GridDiscoveryManager(org.apache.ignite.internal.managers.discovery.GridDiscoveryManager) UUID(java.util.UUID) TcpDiscoveryNode(org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode) InvalidObjectException(java.io.InvalidObjectException) JMException(javax.management.JMException) IOException(java.io.IOException) ObjectStreamException(java.io.ObjectStreamException) IgniteSpiVersionCheckException(org.apache.ignite.spi.IgniteSpiVersionCheckException) IgniteClientDisconnectedException(org.apache.ignite.IgniteClientDisconnectedException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) CacheException(javax.cache.CacheException) PluginNotFoundException(org.apache.ignite.plugin.PluginNotFoundException)

Example 19 with TcpDiscoveryNode

use of org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode in project ignite by apache.

the class TcpDiscoverySpiFailureTimeoutSelfTest method testConnectionCheckMessage.

/**
     * @throws Exception In case of error.
     */
public void testConnectionCheckMessage() throws Exception {
    TestTcpDiscoverySpi nextSpi = null;
    try {
        assert firstSpi().connCheckStatusMsgCntSent == 0;
        TcpDiscoveryNode nextNode = ((ServerImpl) (firstSpi().impl)).ring().nextNode();
        assertNotNull(nextNode);
        nextSpi = null;
        for (int i = 1; i < spis.size(); i++) if (spis.get(i).getLocalNode().id().equals(nextNode.id())) {
            nextSpi = (TestTcpDiscoverySpi) spis.get(i);
            break;
        }
        assertNotNull(nextSpi);
        assert nextSpi.connCheckStatusMsgCntReceived == 0;
        firstSpi().cntConnCheckMsg = true;
        nextSpi.cntConnCheckMsg = true;
        Thread.sleep(firstSpi().failureDetectionTimeout());
        firstSpi().cntConnCheckMsg = false;
        nextSpi.cntConnCheckMsg = false;
        int sent = firstSpi().connCheckStatusMsgCntSent;
        int received = nextSpi.connCheckStatusMsgCntReceived;
        assert sent >= 3 && sent < 7 : "messages sent: " + sent;
        assert received >= 3 && received < 7 : "messages received: " + received;
    } finally {
        firstSpi().resetState();
        if (nextSpi != null)
            nextSpi.resetState();
    }
}
Also used : TcpDiscoveryNode(org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode)

Example 20 with TcpDiscoveryNode

use of org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode in project ignite by apache.

the class TcpDiscoverySelfTest method testThreeNodesStartStop.

/**
     * @throws Exception If any error occurs.
     */
public void testThreeNodesStartStop() throws Exception {
    try {
        IgniteEx ignite1 = startGrid(1);
        IgniteEx ignite2 = startGrid(2);
        IgniteEx ignite3 = startGrid(3);
        TcpDiscoverySpi spi1 = (TcpDiscoverySpi) ignite1.configuration().getDiscoverySpi();
        TcpDiscoverySpi spi2 = (TcpDiscoverySpi) ignite2.configuration().getDiscoverySpi();
        TcpDiscoverySpi spi3 = (TcpDiscoverySpi) ignite3.configuration().getDiscoverySpi();
        TcpDiscoveryNode node = (TcpDiscoveryNode) spi1.getNode(ignite2.localNode().id());
        assertNotNull(node);
        assertNotNull(node.lastSuccessfulAddress());
        LinkedHashSet<InetSocketAddress> addrs = spi1.getNodeAddresses(node);
        assertEquals(addrs.iterator().next(), node.lastSuccessfulAddress());
        assertTrue(spi1.pingNode(ignite3.localNode().id()));
        node = (TcpDiscoveryNode) spi1.getNode(ignite3.localNode().id());
        assertNotNull(node);
        assertNotNull(node.lastSuccessfulAddress());
        addrs = spi1.getNodeAddresses(node);
        assertEquals(addrs.iterator().next(), node.lastSuccessfulAddress());
        node = (TcpDiscoveryNode) spi2.getNode(ignite1.localNode().id());
        assertNotNull(node);
        assertNotNull(node.lastSuccessfulAddress());
        node = (TcpDiscoveryNode) spi2.getNode(ignite3.localNode().id());
        assertNotNull(node);
        assertNotNull(node.lastSuccessfulAddress());
        node = (TcpDiscoveryNode) spi3.getNode(ignite1.localNode().id());
        assertNotNull(node);
        assertNotNull(node.lastSuccessfulAddress());
    } finally {
        stopAllGrids();
    }
}
Also used : InetSocketAddress(java.net.InetSocketAddress) IgniteEx(org.apache.ignite.internal.IgniteEx) TcpDiscoveryNode(org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode)

Aggregations

TcpDiscoveryNode (org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode)31 ClusterNode (org.apache.ignite.cluster.ClusterNode)9 Ignite (org.apache.ignite.Ignite)8 UUID (java.util.UUID)7 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)7 IOException (java.io.IOException)6 IgniteSpiException (org.apache.ignite.spi.IgniteSpiException)5 ArrayList (java.util.ArrayList)4 DiscoveryEvent (org.apache.ignite.events.DiscoveryEvent)4 TcpDiscoveryVmIpFinder (org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder)4 Nullable (org.jetbrains.annotations.Nullable)4 Socket (java.net.Socket)3 SocketTimeoutException (java.net.SocketTimeoutException)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 IgniteException (org.apache.ignite.IgniteException)3 Event (org.apache.ignite.events.Event)3 TcpDiscoveryJoinRequestMessage (org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryJoinRequestMessage)3 StreamCorruptedException (java.io.StreamCorruptedException)2 InetSocketAddress (java.net.InetSocketAddress)2 Collection (java.util.Collection)2