You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 10 Next »

Design

Micronaut is a microservice framework for building moudlar applications. This develops a configuration that bests works with Micronaut.

Auto-Configuration

Minimum Configuration

example config
ignite: 
	enabled: true
	comunication-spi:
		local-port: 5555

Ignite Cache Configuration

example config
ignite: 
	enabled: true
	cache-configurations:
		name:
			group-name: string
			onheap-cache: boolean
			sql-onheap-cache: boolean
			eager-ttl: boolean
			cache-mode: LOCAL | REPLICATED | PARTITIONED
			rebalance-mode: SYNC | ASYNC | NONE
			data-region-name: string
			key-type: java.Object
			value-type: java.Object
		second:
			group-name: two
example config
@Factory
public class configurationFactory(){

    @Singleton
    @Bean
    @IgnitePrimary
    CacheConfiguration<String,String> cacheInstance() {
        return new CacheConfiguration<String, String>("my-cache")
            .setBackups(10);
    }
}
			

Ignite discovery-spi Configuration

kubernetes

example config
ignite: 
	enabled: true
	discovery-spi:
		kubernetes-ip-finder:
			enabled: trued
			namespace: default
			service-name: ignite

static-ip-finder

example config
ignite: 
	enabled: true
	discovery-spi:
		static-ip-finder:
			enabled: true
			addresses:
			- 127.0.0.1:47500
			- 127.0.0.1:47501

Ignite factory configuration

A bean for an IgniteConfiguration can be provided from a factory.

Example:
@Factory
public class MyFactory {
    @Singleton
    @Bean
    @Primary
    @Named("default")
    IgniteConfiguration defaultConfiguration() {
        IgniteConfiguration cfg = new IgniteConfiguration();

        // The node will be started as a client node.
        cfg.setClientMode(true);
        // Setting up an IP Finder to ensure the client can locate the servers.
        TcpDiscoveryMulticastIpFinder ipFinder = new TcpDiscoveryMulticastIpFinder();
        ipFinder.setAddresses(Collections.singletonList("localhost:47500..47509"));
        cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(ipFinder));
        return cfg;
    }
}

Micronaut Ignite Cache

Micronaut cache  is covered under snapshot documentation. By default the primary Ignite instance is used for Micronaut cache and the key from for each cache operation will refer to the IgniteCache instance.

IgniteCacheManager
@Singleton
public class IgniteCacheManager implements DynamicCacheManager<IgniteCache> {
    private final Ignite ignite;
    private final ConversionService<?> service;
    private final ExecutorService executorService;

    public IgniteCacheManager(@Primary Ignite ignite,
                              ConversionService<?> service,
                              @Named(TaskExecutors.IO) ExecutorService executorService) {
        this.ignite = ignite;
        this.service = service;
        this.executorService = executorService;
    }

    @NonNull
    @Override
    public SyncCache<IgniteCache> getCache(String name) {
        return new IgniteSyncCache(service, ignite.getOrCreateCache(name), executorService);
    }
}


Micronaut Ignite Application


  • No labels