Search in sources :

Example 46 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);
    if (reconnectCnt != null)
        disco.setReconnectCount(reconnectCnt);
    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 47 with TcpDiscoveryVmIpFinder

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

the class TcpDiscoveryWithWrongServerTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
    ipFinder.setAddresses(Collections.singleton("127.0.0.1:" + Integer.toString(SERVER_PORT) + ".." + Integer.toString(LAST_SERVER_PORT)));
    cfg.setDiscoverySpi(new TcpDiscoverySpiWithOrderedIps().setIpFinder(ipFinder));
    if (igniteInstanceName.startsWith("client"))
        cfg.setClientMode(true);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TcpDiscoveryVmIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder)

Example 48 with TcpDiscoveryVmIpFinder

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

the class IgniteClientConnectTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    TestTcpDiscoverySpi disco = new TestTcpDiscoverySpi();
    if (igniteInstanceName.equals("client")) {
        TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
        ipFinder.registerAddresses(Collections.singleton(new InetSocketAddress(InetAddress.getLoopbackAddress(), 47501)));
        disco.setIpFinder(ipFinder);
    } else
        disco.setIpFinder(ipFinder);
    disco.setJoinTimeout(2 * 60_000);
    disco.setSocketTimeout(1000);
    disco.setNetworkTimeout(2000);
    cfg.setDiscoverySpi(disco);
    CacheConfiguration cacheConfiguration = new CacheConfiguration().setName(DEFAULT_CACHE_NAME).setCacheMode(CacheMode.PARTITIONED).setAffinity(new RendezvousAffinityFunction(false, 8)).setBackups(0);
    cfg.setCacheConfiguration(cacheConfiguration);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TcpDiscoveryVmIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder) InetSocketAddress(java.net.InetSocketAddress) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 49 with TcpDiscoveryVmIpFinder

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

the class IgniteTicketRegistryConfiguration method igniteConfiguration.

/**
     * Ignite configuration ignite configuration.
     *
     * @return the ignite configuration
     */
@RefreshScope
@Bean
public IgniteConfiguration igniteConfiguration() {
    final IgniteProperties ignite = casProperties.getTicket().getRegistry().getIgnite();
    final IgniteConfiguration config = new IgniteConfiguration();
    final TcpDiscoverySpi spi = new TcpDiscoverySpi();
    spi.setHeartbeatFrequency(ignite.getHeartbeatFrequency());
    spi.setJoinTimeout(ignite.getJoinTimeout());
    if (!StringUtils.isEmpty(ignite.getLocalAddress())) {
        spi.setLocalAddress(ignite.getLocalAddress());
    }
    if (ignite.getLocalPort() != -1) {
        spi.setLocalPort(ignite.getLocalPort());
    }
    spi.setNetworkTimeout(ignite.getNetworkTimeout());
    spi.setSocketTimeout(ignite.getSocketTimeout());
    spi.setThreadPriority(ignite.getThreadPriority());
    spi.setForceServerMode(ignite.isForceServerMode());
    final TcpDiscoveryVmIpFinder finder = new TcpDiscoveryVmIpFinder();
    finder.setAddresses(StringUtils.commaDelimitedListToSet(ignite.getIgniteAddresses()));
    spi.setIpFinder(finder);
    config.setDiscoverySpi(spi);
    final List<CacheConfiguration> configurations = new ArrayList<>();
    final CacheConfiguration ticketsCache = new CacheConfiguration();
    ticketsCache.setName(ignite.getTicketsCache().getCacheName());
    ticketsCache.setCacheMode(CacheMode.valueOf(ignite.getTicketsCache().getCacheMode()));
    ticketsCache.setAtomicityMode(CacheAtomicityMode.valueOf(ignite.getTicketsCache().getAtomicityMode()));
    ticketsCache.setWriteSynchronizationMode(CacheWriteSynchronizationMode.valueOf(ignite.getTicketsCache().getWriteSynchronizationMode()));
    ticketsCache.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.SECONDS, casProperties.getTicket().getTgt().getMaxTimeToLiveInSeconds())));
    configurations.add(ticketsCache);
    config.setCacheConfiguration(configurations.toArray(new CacheConfiguration[] {}));
    return config;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TcpDiscoveryVmIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder) ArrayList(java.util.ArrayList) Duration(javax.cache.expiry.Duration) IgniteProperties(org.apereo.cas.configuration.model.support.ignite.IgniteProperties) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) Bean(org.springframework.context.annotation.Bean)

Example 50 with TcpDiscoveryVmIpFinder

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

the class IgniteInterpreter method getIgnite.

private Ignite getIgnite() {
    if (ignite == null) {
        try {
            String cfgUrl = getProperty(IGNITE_CFG_URL);
            if (cfgUrl != null && !cfgUrl.isEmpty()) {
                ignite = Ignition.start(new URL(cfgUrl));
            } else {
                IgniteConfiguration conf = new IgniteConfiguration();
                conf.setClientMode(Boolean.parseBoolean(getProperty(IGNITE_CLIENT_MODE)));
                TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
                ipFinder.setAddresses(getAddresses());
                TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
                discoSpi.setIpFinder(ipFinder);
                conf.setDiscoverySpi(discoSpi);
                conf.setPeerClassLoadingEnabled(Boolean.parseBoolean(getProperty(IGNITE_PEER_CLASS_LOADING_ENABLED)));
                ignite = Ignition.start(conf);
            }
            initEx = null;
        } catch (Exception e) {
            logger.error("Error in IgniteInterpreter while getIgnite: ", e);
            initEx = e;
        }
    }
    return ignite;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TcpDiscoveryVmIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder) URL(java.net.URL) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

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