com.hazelcast.config.InMemoryFormat Java Examples

The following examples show how to use com.hazelcast.config.InMemoryFormat. 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: DistributedTableMetadataManager.java    From foxtrot with Apache License 2.0 6 votes vote down vote up
private MapConfig tableMapConfig() {
    MapConfig mapConfig = new MapConfig();
    mapConfig.setReadBackupData(true);
    mapConfig.setInMemoryFormat(InMemoryFormat.BINARY);
    mapConfig.setTimeToLiveSeconds(TIME_TO_LIVE_TABLE_CACHE);
    mapConfig.setBackupCount(0);

    MapStoreConfig mapStoreConfig = new MapStoreConfig();
    mapStoreConfig.setFactoryImplementation(TableMapStore.factory(elasticsearchConnection));
    mapStoreConfig.setEnabled(true);
    mapStoreConfig.setInitialLoadMode(MapStoreConfig.InitialLoadMode.EAGER);
    mapConfig.setMapStoreConfig(mapStoreConfig);

    NearCacheConfig nearCacheConfig = new NearCacheConfig();
    nearCacheConfig.setTimeToLiveSeconds(TIME_TO_LIVE_TABLE_CACHE);
    nearCacheConfig.setInvalidateOnChange(true);
    mapConfig.setNearCacheConfig(nearCacheConfig);
    return mapConfig;
}
 
Example #4
Source File: StaticMapConfig.java    From hazelcast-demo with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
	MapConfig mapConfig = new MapConfig();
	mapConfig.setName("cacheMap")// 设置Map名称
			.setInMemoryFormat(InMemoryFormat.BINARY)// 设置内存格式
			.setBackupCount(1);// 设置副本个数

	mapConfig.getMapStoreConfig()//
			.setWriteDelaySeconds(60)//
			.setWriteBatchSize(1000);// 设置缓存格式

	mapConfig.addMapIndexConfig(new MapIndexConfig().setAttribute("id").setOrdered(true));// 增加索引
	mapConfig.addMapIndexConfig(new MapIndexConfig().setAttribute("name").setOrdered(true));
}
 
Example #5
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 #6
Source File: DistributedCacheFactory.java    From foxtrot with Apache License 2.0 5 votes vote down vote up
private MapConfig getDefaultMapConfig(CacheConfig cacheConfig) {
    MapConfig mapConfig = new MapConfig(CACHE_NAME_PREFIX + "*");
    mapConfig.setInMemoryFormat(InMemoryFormat.BINARY);
    mapConfig.setBackupCount(0);
    mapConfig.setEvictionPolicy(EvictionPolicy.LRU);

    if(cacheConfig.getMaxIdleSeconds() == 0) {
        mapConfig.setMaxIdleSeconds(DEFAULT_MAX_IDLE_SECONDS);
    } else {
        mapConfig.setMaxIdleSeconds(cacheConfig.getMaxIdleSeconds());
    }

    if(cacheConfig.getTimeToLiveSeconds() == 0) {
        mapConfig.setTimeToLiveSeconds(DEFAULT_TIME_TO_LIVE_SECONDS);
    } else {
        mapConfig.setTimeToLiveSeconds(cacheConfig.getTimeToLiveSeconds());
    }

    MaxSizeConfig maxSizeConfig = new MaxSizeConfig();
    maxSizeConfig.setMaxSizePolicy(MaxSizeConfig.MaxSizePolicy.USED_HEAP_PERCENTAGE);
    if(cacheConfig.getSize() == 0) {
        maxSizeConfig.setSize(DEFAULT_SIZE);
    } else {
        maxSizeConfig.setSize(cacheConfig.getSize());
    }
    mapConfig.setMaxSizeConfig(maxSizeConfig);
    return mapConfig;
}
 
Example #7
Source File: DistributedTableMetadataManager.java    From foxtrot with Apache License 2.0 5 votes vote down vote up
private MapConfig fieldMetaMapConfig() {
    MapConfig mapConfig = new MapConfig();
    mapConfig.setReadBackupData(true);
    mapConfig.setInMemoryFormat(InMemoryFormat.BINARY);
    mapConfig.setTimeToLiveSeconds(TIME_TO_LIVE_CACHE);
    mapConfig.setBackupCount(0);

    NearCacheConfig nearCacheConfig = new NearCacheConfig();
    nearCacheConfig.setTimeToLiveSeconds(TIME_TO_NEAR_CACHE);
    nearCacheConfig.setInvalidateOnChange(true);
    mapConfig.setNearCacheConfig(nearCacheConfig);

    return mapConfig;
}
 
Example #8
Source File: DistributedTableMetadataManager.java    From foxtrot with Apache License 2.0 5 votes vote down vote up
private MapConfig cardinalityFieldMetaMapConfig() {
    MapConfig mapConfig = new MapConfig();
    mapConfig.setReadBackupData(true);
    mapConfig.setInMemoryFormat(InMemoryFormat.BINARY);
    mapConfig.setTimeToLiveSeconds(TIME_TO_LIVE_CARDINALITY_CACHE);
    mapConfig.setBackupCount(0);

    NearCacheConfig nearCacheConfig = new NearCacheConfig();
    nearCacheConfig.setTimeToLiveSeconds(TIME_TO_LIVE_CARDINALITY_CACHE);
    nearCacheConfig.setInvalidateOnChange(true);
    mapConfig.setNearCacheConfig(nearCacheConfig);

    return mapConfig;
}
 
Example #9
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;
}