com.hazelcast.map.merge.PutIfAbsentMapMergePolicy Java Examples

The following examples show how to use com.hazelcast.map.merge.PutIfAbsentMapMergePolicy. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AdminApplicationHazelcastTest.java    From Moss with Apache License 2.0 6 votes vote down vote up
@Bean
public Config hazelcastConfig() {
    MapConfig mapConfig = new MapConfig("spring-boot-admin-event-store").setInMemoryFormat(InMemoryFormat.OBJECT)
                                                                        .setBackupCount(1)
                                                                        .setEvictionPolicy(EvictionPolicy.NONE)
                                                                        .setMergePolicyConfig(new MergePolicyConfig(
                                                                            PutIfAbsentMapMergePolicy.class.getName(),
                                                                            100
                                                                        ));

    Config config = new Config();
    config.addMapConfig(mapConfig);
    config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
    TcpIpConfig tcpIpConfig = config.getNetworkConfig().getJoin().getTcpIpConfig();
    tcpIpConfig.setEnabled(true);
    tcpIpConfig.setMembers(singletonList("127.0.0.1"));
    return config;
}
 
Example #2
Source File: AdminApplicationHazelcastTest.java    From spring-boot-admin with Apache License 2.0 6 votes vote down vote up
@Bean
public Config hazelcastConfig() {
	MapConfig eventStoreMap = new MapConfig(DEFAULT_NAME_EVENT_STORE_MAP)
			.setInMemoryFormat(InMemoryFormat.OBJECT).setBackupCount(1).setEvictionPolicy(EvictionPolicy.NONE)
			.setMergePolicyConfig(new MergePolicyConfig(PutIfAbsentMapMergePolicy.class.getName(), 100));

	MapConfig sentNotificationsMap = new MapConfig(DEFAULT_NAME_SENT_NOTIFICATIONS_MAP)
			.setInMemoryFormat(InMemoryFormat.OBJECT).setBackupCount(1).setEvictionPolicy(EvictionPolicy.LRU)
			.setMergePolicyConfig(new MergePolicyConfig(PutIfAbsentMapMergePolicy.class.getName(), 100));

	Config config = new Config();
	config.addMapConfig(eventStoreMap);
	config.addMapConfig(sentNotificationsMap);
	config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
	TcpIpConfig tcpIpConfig = config.getNetworkConfig().getJoin().getTcpIpConfig();
	tcpIpConfig.setEnabled(true);
	tcpIpConfig.setMembers(singletonList("127.0.0.1"));
	return config;
}
 
Example #3
Source File: SpringBootAdminHazelcastApplication.java    From spring-boot-admin with Apache License 2.0 5 votes vote down vote up
@Bean
public Config hazelcastConfig() {
	// This map is used to store the events.
	// It should be configured to reliably hold all the data,
	// Spring Boot Admin will compact the events, if there are too many
	MapConfig eventStoreMap = new MapConfig(DEFAULT_NAME_EVENT_STORE_MAP).setInMemoryFormat(InMemoryFormat.OBJECT)
			.setBackupCount(1).setEvictionPolicy(EvictionPolicy.NONE)
			.setMergePolicyConfig(new MergePolicyConfig(PutIfAbsentMapMergePolicy.class.getName(), 100));

	// This map is used to deduplicate the notifications.
	// If data in this map gets lost it should not be a big issue as it will atmost
	// lead to
	// the same notification to be sent by multiple instances
	MapConfig sentNotificationsMap = new MapConfig(DEFAULT_NAME_SENT_NOTIFICATIONS_MAP)
			.setInMemoryFormat(InMemoryFormat.OBJECT).setBackupCount(1).setEvictionPolicy(EvictionPolicy.LRU)
			.setMergePolicyConfig(new MergePolicyConfig(PutIfAbsentMapMergePolicy.class.getName(), 100));

	Config config = new Config();
	config.addMapConfig(eventStoreMap);
	config.addMapConfig(sentNotificationsMap);
	config.setProperty("hazelcast.jmx", "true");

	// WARNING: This setups a local cluster, you change it to fit your needs.
	config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
	TcpIpConfig tcpIpConfig = config.getNetworkConfig().getJoin().getTcpIpConfig();
	tcpIpConfig.setEnabled(true);
	tcpIpConfig.setMembers(singletonList("127.0.0.1"));
	return config;
}
 
Example #4
Source File: HazelcastConfig.java    From tutorials with MIT License 5 votes vote down vote up
@Bean
public Config hazelcast() {
    MapConfig eventStoreMap = new MapConfig("spring-boot-admin-event-store").setInMemoryFormat(InMemoryFormat.OBJECT)
        .setBackupCount(1)
        .setEvictionPolicy(EvictionPolicy.NONE)
        .setMergePolicyConfig(new MergePolicyConfig(PutIfAbsentMapMergePolicy.class.getName(), 100));

    MapConfig sentNotificationsMap = new MapConfig("spring-boot-admin-application-store").setInMemoryFormat(InMemoryFormat.OBJECT)
        .setBackupCount(1)
        .setEvictionPolicy(EvictionPolicy.LRU)
        .setMergePolicyConfig(new MergePolicyConfig(PutIfAbsentMapMergePolicy.class.getName(), 100));

    Config config = new Config();
    config.addMapConfig(eventStoreMap);
    config.addMapConfig(sentNotificationsMap);
    config.setProperty("hazelcast.jmx", "true");

    config.getNetworkConfig()
        .getJoin()
        .getMulticastConfig()
        .setEnabled(false);
    TcpIpConfig tcpIpConfig = config.getNetworkConfig()
        .getJoin()
        .getTcpIpConfig();
    tcpIpConfig.setEnabled(true);
    tcpIpConfig.setMembers(Collections.singletonList("127.0.0.1"));
    return config;
}