Search in sources :

Example 66 with TcpDiscoveryVmIpFinder

use of org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder in project ignite by apache.

the class IgfsOneClientNodeTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    cfg.setCacheConfiguration(cacheConfiguration(CACHE_NAME));
    cfg.setClientMode(true);
    cfg.setDiscoverySpi(new TcpDiscoverySpi().setForceServerMode(true).setIpFinder(new TcpDiscoveryVmIpFinder(true)));
    FileSystemConfiguration igfsCfg = new FileSystemConfiguration();
    igfsCfg.setName("igfs");
    igfsCfg.setMetaCacheConfiguration(cacheConfiguration(DEFAULT_CACHE_NAME));
    igfsCfg.setDataCacheConfiguration(cacheConfiguration(DEFAULT_CACHE_NAME));
    cfg.setFileSystemConfiguration(igfsCfg);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TcpDiscoveryVmIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder) FileSystemConfiguration(org.apache.ignite.configuration.FileSystemConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 67 with TcpDiscoveryVmIpFinder

use of org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder in project ignite by apache.

the class TcpClientDiscoverySpiSelfTest method clientMessageWorkerStart.

/**
 * @param srvs Number of server nodes.
 * @param connectTo What server connect to.
 * @throws Exception If failed.
 */
private void clientMessageWorkerStart(int srvs, int connectTo) throws Exception {
    startServerNodes(srvs);
    Ignite srv = G.ignite("server-" + (connectTo - 1));
    final TcpDiscoveryNode srvNode = (TcpDiscoveryNode) srv.cluster().localNode();
    assertEquals((long) connectTo, srvNode.order());
    TestTcpDiscoverySpi srvSpi = ((TestTcpDiscoverySpi) srv.configuration().getDiscoverySpi());
    final String client0 = "client-" + clientIdx.getAndIncrement();
    srvSpi.delayJoinAckFor = client0;
    IgniteInternalFuture<?> fut = GridTestUtils.runAsync(new Callable<Object>() {

        @Override
        public Object call() throws Exception {
            clientIpFinder = new TcpDiscoveryVmIpFinder();
            clientIpFinder.setAddresses(Collections.singleton("localhost:" + srvNode.discoveryPort()));
            Ignite client = startGrid(client0);
            clientIpFinder = null;
            clientNodeIds.add(client.cluster().localNode().id());
            TestTcpDiscoverySpi clientSpi = ((TestTcpDiscoverySpi) client.configuration().getDiscoverySpi());
            assertFalse(clientSpi.invalidResponse());
            TcpDiscoveryNode clientNode = (TcpDiscoveryNode) client.cluster().localNode();
            assertEquals(srvNode.id(), clientNode.clientRouterNodeId());
            return null;
        }
    });
    final String client1 = "client-" + clientIdx.getAndIncrement();
    while (!fut.isDone()) {
        startGrid(client1);
        stopGrid(client1);
    }
    fut.get();
    checkNodes(srvs, 1);
}
Also used : TcpDiscoveryVmIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder) Ignite(org.apache.ignite.Ignite) TcpDiscoveryNode(org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode) IgniteClientDisconnectedException(org.apache.ignite.IgniteClientDisconnectedException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteSpiOperationTimeoutException(org.apache.ignite.spi.IgniteSpiOperationTimeoutException) IgniteSpiException(org.apache.ignite.spi.IgniteSpiException) IgniteInterruptedException(org.apache.ignite.IgniteInterruptedException) IOException(java.io.IOException)

Example 68 with TcpDiscoveryVmIpFinder

use of org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder in project ignite by apache.

the class TcpClientDiscoverySpiSelfTest method testClientReconnectHistoryMissingOnRouter.

/**
 * @throws Exception if failed.
 */
public void testClientReconnectHistoryMissingOnRouter() throws Exception {
    clientFailureDetectionTimeout = 60000;
    netTimeout = 60000;
    startServerNodes(2);
    Ignite srv0 = grid("server-0");
    TcpDiscoveryNode srv0Node = (TcpDiscoveryNode) srv0.cluster().localNode();
    clientIpFinder = new TcpDiscoveryVmIpFinder();
    clientIpFinder.setAddresses(Collections.singleton("localhost:" + srv0Node.discoveryPort()));
    startClientNodes(1);
    attachListeners(0, 1);
    Ignite client = grid("client-0");
    TcpDiscoveryNode clientNode = (TcpDiscoveryNode) client.cluster().localNode();
    TestTcpDiscoverySpi clientSpi = (TestTcpDiscoverySpi) client.configuration().getDiscoverySpi();
    UUID clientNodeId = clientNode.id();
    checkNodes(2, 1);
    clientSpi.pauseAll(true);
    stopGrid(srv0.name());
    startServerNodes(1);
    Ignite srv2 = grid("server-2");
    TcpDiscoveryNode srv2Node = (TcpDiscoveryNode) srv2.cluster().localNode();
    clientIpFinder.setAddresses(Collections.singleton("localhost:" + srv2Node.discoveryPort()));
    clientSpi.resumeAll();
    awaitPartitionMapExchange();
    assertEquals("connected", clientSpi.getSpiState());
    assertEquals(clientNodeId, clientNode.id());
    assertEquals(srv2Node.id(), clientNode.clientRouterNodeId());
}
Also used : TcpDiscoveryVmIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder) Ignite(org.apache.ignite.Ignite) UUID(java.util.UUID) TcpDiscoveryNode(org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode)

Example 69 with TcpDiscoveryVmIpFinder

use of org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder in project ignite by apache.

the class TcpClientDiscoverySpiSelfTest method testJoinTimeout.

/**
 * @throws Exception If failed.
 */
public void testJoinTimeout() throws Exception {
    clientIpFinder = new TcpDiscoveryVmIpFinder();
    joinTimeout = 1000;
    try {
        startClientNodes(1);
        fail("Client cannot be start because no server nodes run");
    } catch (IgniteCheckedException e) {
        IgniteSpiException spiEx = e.getCause(IgniteSpiException.class);
        assert spiEx != null : e;
        assert spiEx.getMessage().contains("Join process timed out") : spiEx.getMessage();
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) TcpDiscoveryVmIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder) IgniteSpiException(org.apache.ignite.spi.IgniteSpiException)

Example 70 with TcpDiscoveryVmIpFinder

use of org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder in project ignite by apache.

the class TcpClientDiscoverySpiSelfTest method setClientRouter.

/**
 * @param clientIdx Client index.
 * @param srvIdx Server index.
 * @throws Exception In case of error.
 */
private void setClientRouter(int clientIdx, int srvIdx) throws Exception {
    TcpDiscoverySpi disco = (TcpDiscoverySpi) G.ignite("client-" + clientIdx).configuration().getDiscoverySpi();
    TcpDiscoveryVmIpFinder ipFinder = (TcpDiscoveryVmIpFinder) disco.getIpFinder();
    String addr = new ArrayList<>(IP_FINDER.getRegisteredAddresses()).get(srvIdx).toString();
    if (addr.startsWith("/"))
        addr = addr.substring(1);
    ipFinder.setAddresses(Collections.singletonList(addr));
}
Also used : TcpDiscoveryVmIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder) ArrayList(java.util.ArrayList)

Aggregations

TcpDiscoveryVmIpFinder (org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder)97 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)81 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)80 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)38 FileSystemConfiguration (org.apache.ignite.configuration.FileSystemConfiguration)16 Ignite (org.apache.ignite.Ignite)14 IgfsGroupDataBlocksKeyMapper (org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper)12 ConnectorConfiguration (org.apache.ignite.configuration.ConnectorConfiguration)8 BinaryMarshaller (org.apache.ignite.internal.binary.BinaryMarshaller)6 TcpDiscoveryNode (org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode)6 ArrayList (java.util.ArrayList)5 IgfsIpcEndpointConfiguration (org.apache.ignite.igfs.IgfsIpcEndpointConfiguration)5 HashMap (java.util.HashMap)4 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)4 IgniteException (org.apache.ignite.IgniteException)4 TcpDiscoveryIpFinder (org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder)4 InetSocketAddress (java.net.InetSocketAddress)3 UUID (java.util.UUID)3 TcpCommunicationSpi (org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi)3 File (java.io.File)2