muscleman71
muscleman71

Reputation: 91

GridGain with SpringBoot

I've compiled a docker image of GridGain Pro and run this. with Java i do the following...

Create the following @Configuration file

@Configuration
@EnableCaching
public class CustomConfiguration extends CachingConfigurerSupport {

@Bean
@Override
public KeyGenerator keyGenerator() {
    return (target, method, params) -> {
        StringBuilder sb = new StringBuilder();
        sb.append(target.getClass().getName());
        sb.append(method.getName());
        for (Object obj : params) {
            sb.append("|");
            sb.append(obj.toString());
        }
        return sb.toString();
    };
}

@Bean("cacheManager")
public SpringCacheManager cacheManager(IgniteConfiguration igniteConfiguration){
    try {
        SpringCacheManager springCacheManager =  new SpringCacheManager();
        springCacheManager.setIgniteInstanceName("ignite");
        springCacheManager.setConfiguration(igniteConfiguration);
        springCacheManager.setDynamicCacheConfiguration(new CacheConfiguration<>().setCacheMode(CacheMode.REPLICATED));
        return springCacheManager;
    }
    catch (Exception ex){

    }
    return null;
}

@Bean
@Profile("!dev")
IgniteConfiguration igniteConfiguration() {

    GridGainConfiguration gridGainConfiguration = new GridGainConfiguration();
    gridGainConfiguration.setRollingUpdatesEnabled(true);
    IgniteConfiguration igniteConfiguration = new IgniteConfiguration()
    .setPluginConfigurations(gridGainConfiguration)
    .setClientMode(true)
    .setPeerClassLoadingEnabled(false)
    .setIgniteInstanceName("MyIgnite");
    DataStorageConfiguration dataStorageConfiguration = new DataStorageConfiguration();
    DataRegionConfiguration dataRegionConfiguration = new DataRegionConfiguration();
    dataRegionConfiguration.setInitialSize(20 * 1024 * 1024);
    dataRegionConfiguration.setMaxSize(40 * 1024 * 1024);
    dataRegionConfiguration.setMetricsEnabled(true);
    dataStorageConfiguration.setDefaultDataRegionConfiguration(dataRegionConfiguration);
    igniteConfiguration.setDataStorageConfiguration(dataStorageConfiguration);
    TcpDiscoverySpi tcpDiscoverySpi = new TcpDiscoverySpi();
    TcpDiscoveryVmIpFinder tcpDiscoveryVmIpFinder = new TcpDiscoveryVmIpFinder();
    tcpDiscoveryVmIpFinder.setAddresses(Arrays.asList("192.168.99.100:47500..47502"));

    tcpDiscoverySpi.setIpFinder(tcpDiscoveryVmIpFinder);
    igniteConfiguration.setDiscoverySpi(tcpDiscoverySpi);
    return igniteConfiguration;
}

}

Start spring and get the following error.

2018-04-18 12:27:29.277 WARN 12588 --- [ main] .GridEntDiscoveryNodeValidationProcessor : GridGain node cannot be in one cluster with Ignite node [locNodeAddrs=[server/0:0:0:0:0:0:0:1, server/10.29.96.164, server/127.0.0.1, /192.168.56.1, /192.168.99.1], rmtNodeAddrs=[172.17.0.1/0:0:0:0:0:0:0:1%lo, 192.168.99.100/10.0.2.15, 10.0.2.15/127.0.0.1, /172.17.0.1, /192.168.99.100]] 2018-04-18 12:27:29.283 ERROR 12588 --- [ main] o.a.i.internal.IgniteKernal%MyIgnite : Got exception while starting (will rollback startup routine).

I'm trying to use gridgain as a replacement for redis and use the @Cacheable annotation. Does anyone have a working gridgain example? What is causing the error above?

G.

Upvotes: 0

Views: 842

Answers (2)

alamar
alamar

Reputation: 19343

GridGain node cannot be in one cluster with Ignite node is pretty self-explanatory.

  • Either you have forgot to stop some local Apache Ignite from earlier experiments.
  • Or you have deliberately tried to make GridGain join an Ignite cluster.
  • Or better yet, there is an instance of Apache Ignite running somewhere in your local network, and you have set multicast discovery or other kind of too-broad discovery, so they're seeing each other.
  • Maybe gridgain-core.x.x.x.jar jar is miising from one of nodes' classpath. Check and add it if necessary.

Upvotes: 1

muscleman71
muscleman71

Reputation: 91

1) okay seems the issue was not providing H2 as a dependency. 2) using GridGain professional instead of GridGain Enterprise.

G.

Upvotes: 1

Related Questions