0
votes

Here is my current Apache Ignite settings:

public class IgniteCacheConfig {

    @Bean
    public Ignite applicationIgnite() {
        Ignite ignite = Ignition.start(igniteConfiguration());
        ignite.cluster().active(true);
        return ignite;
    }

    @Bean
    public CacheConfiguration<String, AppRequest> applicationCacheConfig() {
        CacheConfiguration<String, AppRequest> cfg = new CacheConfiguration<>();
        int isPartitionMode = 0;
        int backups = 0;
        CacheMode cacheMode = CacheMode.PARTITIONED;
        if (0 == isPartitionMode) {
            cacheMode = CacheMode.REPLICATED;
        }
        cfg.setName("appCache");
        cfg.setCacheMode(cacheMode);
        cfg.setBackups(backups);
        cfg.setPartitionLossPolicy(PartitionLossPolicy.IGNORE);
        cfg.setDataRegionName("DA-1");
        cfg.setDefaultLockTimeout(0L);
        cfg.setExpiryPolicyFactory(CreatedExpiryPolicy
                .factoryOf(new Duration(SECONDS, 3600)));
        cfg.setOnheapCacheEnabled(false);
        cfg.setStatisticsEnabled(true);
        return cfg;
    }

    private IgniteConfiguration igniteConfiguration() {
        IgniteConfiguration cacheConfig = new IgniteConfiguration();
        cacheConfig.setClientMode(false);
        TransactionConfiguration transactionConfig = new TransactionConfiguration();
        transactionConfig.setDefaultTxTimeout(0L);
        cacheConfig.setTransactionConfiguration(transactionConfig);
        cacheConfig.setFailureDetectionTimeout(10000L);
        cacheConfig.setIgniteInstanceName("appListener");
        DataStorageConfiguration dsCfg = new DataStorageConfiguration();
        dsCfg.setConcurrencyLevel(32);
        DataRegionConfiguration defaultRegionConf = new DataRegionConfiguration();
        defaultRegionConf.setName("DA-1");
        defaultRegionConf.setInitialSize(1024 * 1024 * 100);
        defaultRegionConf.setMaxSize(1024 * 1024 * 500);
        defaultRegionConf.setEmptyPagesPoolSize(256);
        defaultRegionConf.setEvictionThreshold(0.8);
        defaultRegionConf.setPageEvictionMode(DataPageEvictionMode.RANDOM_2_LRU);
        defaultRegionConf.setPersistenceEnabled(true);
        dsCfg.setDefaultDataRegionConfiguration(defaultRegionConf);
        cacheConfig.setDataStorageConfiguration(dsCfg);

        TcpDiscoverySpi tcpDiscovery = new TcpDiscoverySpi();
        tcpDiscovery.setLocalPort(47500);
        tcpDiscovery.setAckTimeout(5000L);
        tcpDiscovery.setSocketTimeout(5000L);
        tcpDiscovery.setNetworkTimeout(5000L);
        tcpDiscovery.setStatisticsPrintFrequency(1000 * 60 * 15);

        final Set<String> mcastAddCol = Collections.singleton("127.0.0.1:47500..47509");

        final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder()
                .setAddresses(mcastAddCol);

        tcpDiscovery.setIpFinder(ipFinder);
        cacheConfig.setDiscoverySpi(tcpDiscovery);
        TcpCommunicationSpi communicationSpi = new TcpCommunicationSpi();
        communicationSpi.setSocketWriteTimeout(5000L);
        communicationSpi.setConnectTimeout(5000L);
        cacheConfig.setCommunicationSpi(communicationSpi);
        return cacheConfig;
    }
}

Here is my task For cache (in-memory distributed) Apache Ignite version 2.7 will be used, the cluster will be deployed separately. It is necessary to implement a connection to the cluster, reconnecting in the background during failures in working with Ignite. If for some reason the cluster is unavailable, output to the log, assume that nothing was found in the cache.

Now I'm getting an error:

Caused by: class org.apache.ignite.IgniteException: Failed to activate cluster

Can you suggest me any solution of starting the cluster and realizing my task about reconnecting because of a failure?

1
Is there a stack trace to that exception? Anything interesting in the logs? - alamar
@alamar nothing. just the line about the exception - Максим Рыбалкин

1 Answers

1
votes

I think there was a bug when you tried to activate the cluster on every node's start-up. Maybe it's IGNITE-10417

Please remember you only need to activate the cluster once, when all nodes are ready, as opposed to calling active() every time just in case.