Search in sources :

Example 21 with TcpDiscoveryVmIpFinder

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

the class TcpClientDiscoverySpiSelfTest method missedAddFinishedMessage.

/**
     * @param singleSrv If {@code true} starts one server node two otherwise.
     * @throws Exception If failed.
     */
private void missedAddFinishedMessage(boolean singleSrv) throws Exception {
    int srvs = singleSrv ? 1 : 2;
    startServerNodes(srvs);
    afterWrite = new CIX2<TcpDiscoveryAbstractMessage, Socket>() {

        private boolean first = true;

        @Override
        public void applyx(TcpDiscoveryAbstractMessage msg, Socket sock) throws IgniteCheckedException {
            if (first && (msg instanceof TcpDiscoveryJoinRequestMessage)) {
                first = false;
                log.info("Close socket after message write [msg=" + msg + "]");
                try {
                    sock.close();
                } catch (IOException e) {
                    throw new IgniteCheckedException(e);
                }
                log.info("Delay after message write [msg=" + msg + "]");
                // Wait when server process join request.
                U.sleep(5000);
            }
        }
    };
    Ignite srv = singleSrv ? G.ignite("server-0") : G.ignite("server-1");
    TcpDiscoveryNode srvNode = (TcpDiscoveryNode) srv.cluster().localNode();
    assertEquals(singleSrv ? 1 : 2, srvNode.order());
    clientIpFinder = new TcpDiscoveryVmIpFinder();
    clientIpFinder.setAddresses(Collections.singleton("localhost:" + srvNode.discoveryPort()));
    startClientNodes(1);
    TcpDiscoveryNode clientNode = (TcpDiscoveryNode) G.ignite("client-0").cluster().localNode();
    assertEquals(srvNode.id(), clientNode.clientRouterNodeId());
    checkNodes(srvs, 1);
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) TcpDiscoveryAbstractMessage(org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage) TcpDiscoveryVmIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder) Ignite(org.apache.ignite.Ignite) IOException(java.io.IOException) Socket(java.net.Socket) TcpDiscoveryNode(org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode) TcpDiscoveryJoinRequestMessage(org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryJoinRequestMessage)

Example 22 with TcpDiscoveryVmIpFinder

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

the class TcpClientDiscoverySpiSelfTest method getConfiguration.

/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    cfg.setClientFailureDetectionTimeout(clientFailureDetectionTimeout());
    TcpDiscoverySpi disco = getDiscoverySpi();
    if (igniteInstanceName.startsWith("server"))
        disco.setIpFinder(IP_FINDER);
    else if (igniteInstanceName.startsWith("client")) {
        cfg.setClientMode(true);
        TcpDiscoveryVmIpFinder ipFinder;
        if (clientIpFinder != null)
            ipFinder = clientIpFinder;
        else {
            ipFinder = new TcpDiscoveryVmIpFinder();
            String addr = new ArrayList<>(IP_FINDER.getRegisteredAddresses()).get((clientIdx.get() - 1) / clientsPerSrv).toString();
            if (addr.startsWith("/"))
                addr = addr.substring(1);
            ipFinder.setAddresses(Collections.singletonList(addr));
        }
        disco.setIpFinder(ipFinder);
        String nodeId = cfg.getNodeId().toString();
        nodeId = "cc" + nodeId.substring(2);
        cfg.setNodeId(UUID.fromString(nodeId));
    } else
        throw new IllegalArgumentException();
    if (useFailureDetectionTimeout())
        cfg.setFailureDetectionTimeout(failureDetectionTimeout());
    else {
        if (longSockTimeouts) {
            disco.setAckTimeout(2000);
            disco.setSocketTimeout(2000);
        } else {
            disco.setAckTimeout(igniteInstanceName.startsWith("client") ? TcpDiscoverySpi.DFLT_ACK_TIMEOUT_CLIENT : TcpDiscoverySpi.DFLT_ACK_TIMEOUT);
            disco.setSocketTimeout(igniteInstanceName.startsWith("client") ? TcpDiscoverySpi.DFLT_SOCK_TIMEOUT_CLIENT : TcpDiscoverySpi.DFLT_SOCK_TIMEOUT);
        }
    }
    disco.setJoinTimeout(joinTimeout);
    disco.setNetworkTimeout(netTimeout);
    disco.setClientReconnectDisabled(reconnectDisabled);
    if (disco instanceof TestTcpDiscoverySpi)
        ((TestTcpDiscoverySpi) disco).afterWrite(afterWrite);
    cfg.setDiscoverySpi(disco);
    if (nodeId != null)
        cfg.setNodeId(nodeId);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TcpDiscoveryVmIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder)

Example 23 with TcpDiscoveryVmIpFinder

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

the class Log4j2LoggerSelfTest method getConfiguration.

/**
     * Creates grid configuration.
     *
     * @param igniteInstanceName Ignite instance name.
     * @param logPath Logger configuration path.
     * @return Grid configuration.
     * @throws Exception If error occurred.
     */
private static IgniteConfiguration getConfiguration(String igniteInstanceName, String logPath) throws Exception {
    TcpDiscoverySpi disco = new TcpDiscoverySpi();
    disco.setIpFinder(new TcpDiscoveryVmIpFinder(false) {

        {
            setAddresses(Collections.singleton("127.0.0.1:47500..47509"));
        }
    });
    return new IgniteConfiguration().setIgniteInstanceName(igniteInstanceName).setGridLogger(new Log4J2Logger(logPath)).setConnectorConfiguration(null).setDiscoverySpi(disco);
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TcpDiscoveryVmIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 24 with TcpDiscoveryVmIpFinder

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

the class GridCacheTcpClientDiscoveryMultiThreadedTest method getConfiguration.

/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    // Filling configuration for client nodes
    if (client) {
        TcpDiscoveryVmIpFinder clientFinder = new TcpDiscoveryVmIpFinder();
        Collection<String> addrs = new ArrayList<>(ipFinder.getRegisteredAddresses().size());
        for (InetSocketAddress sockAddr : ipFinder.getRegisteredAddresses()) addrs.add(sockAddr.getHostString() + ":" + sockAddr.getPort());
        clientFinder.setAddresses(addrs);
        cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(clientFinder));
        cfg.setClientMode(true);
    }
    cfg.setLocalHost("127.0.0.1");
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TcpDiscoveryVmIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder) InetSocketAddress(java.net.InetSocketAddress) ArrayList(java.util.ArrayList) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 25 with TcpDiscoveryVmIpFinder

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

the class GridSessionCancelSiblingsFromTaskSelfTest method getConfiguration.

/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration c = super.getConfiguration(igniteInstanceName);
    TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
    discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true));
    c.setDiscoverySpi(discoSpi);
    c.setPublicThreadPoolSize(SPLIT_COUNT * EXEC_COUNT);
    return c;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TcpDiscoveryVmIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Aggregations

TcpDiscoveryVmIpFinder (org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder)81 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)69 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)69 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)32 FileSystemConfiguration (org.apache.ignite.configuration.FileSystemConfiguration)16 Ignite (org.apache.ignite.Ignite)12 IgfsGroupDataBlocksKeyMapper (org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper)12 ArrayList (java.util.ArrayList)5 IgfsIpcEndpointConfiguration (org.apache.ignite.igfs.IgfsIpcEndpointConfiguration)5 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)4 ConnectorConfiguration (org.apache.ignite.configuration.ConnectorConfiguration)4 TcpDiscoveryNode (org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode)4 TcpDiscoveryIpFinder (org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder)4 HashMap (java.util.HashMap)3 BinaryMarshaller (org.apache.ignite.internal.binary.BinaryMarshaller)3 TcpCommunicationSpi (org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi)3 TcpDiscoveryMulticastIpFinder (org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder)3 IOException (java.io.IOException)2 InetSocketAddress (java.net.InetSocketAddress)2 Properties (java.util.Properties)2