Java Code Examples for com.hazelcast.config.Config#addMapConfig()

The following examples show how to use com.hazelcast.config.Config#addMapConfig() . 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: HazelcastOperationMapsConfig.java    From eventapis with Apache License 2.0 6 votes vote down vote up
@Override
public Config configure(Config config) {

    List<MapIndexConfig> indexes = Arrays.asList(
            new MapIndexConfig("spanningServices[any].serviceName", true)
    );

    MapConfig mapConfig = new MapConfig(EVENTS_OPS_MAP_NAME)
            .setMapIndexConfigs(indexes)
            .setMaxSizeConfig(new MaxSizeConfig(evictFreePercentage, MaxSizeConfig.MaxSizePolicy.FREE_HEAP_PERCENTAGE))
            .setEvictionPolicy(EvictionPolicy.LRU)
            .setQuorumName("default")
            .setName(EVENTS_OPS_MAP_NAME);
    config.addMapConfig(mapConfig);
    return config;
}
 
Example 3
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 4
Source File: HazelcastSymmetric.java    From Android_Code_Arbiter with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void init() {

        //Specific map time to live
        MapConfig myMapConfig = new MapConfig();
        myMapConfig.setName("cachetest");
        myMapConfig.setTimeToLiveSeconds(10);

        //Package config
        Config myConfig = new Config();
        myConfig.addMapConfig(myMapConfig);

        //Symmetric Encryption
        SymmetricEncryptionConfig symmetricEncryptionConfig = new SymmetricEncryptionConfig();
        symmetricEncryptionConfig.setAlgorithm("DESede");
        symmetricEncryptionConfig.setSalt("saltysalt");
        symmetricEncryptionConfig.setPassword("lamepassword");
        symmetricEncryptionConfig.setIterationCount(1337);

        //Weak Network config..
        NetworkConfig networkConfig = new NetworkConfig();
        networkConfig.setSymmetricEncryptionConfig(symmetricEncryptionConfig);

        myConfig.setNetworkConfig(networkConfig);

        Hazelcast.init(myConfig);

        cacheMap = Hazelcast.getMap("cachetest");
    }
 
Example 5
Source File: ServiceCacheConfiguration.java    From iotplatform with Apache License 2.0 5 votes vote down vote up
@Bean
public HazelcastInstance hazelcastInstance() {
    Config config = new Config();

    if (zkEnabled) {
        addZkConfig(config);
    }

    config.addMapConfig(createDeviceCredentialsCacheConfig());

    return Hazelcast.newHazelcastInstance(config);
}
 
Example 6
Source File: ClassLoadingTest.java    From subzero with Apache License 2.0 5 votes vote down vote up
@Test
public void givenMemberHasClassLoaderConfigured_whenObjectIsStored_thenClassLoaderWillBeUsed() throws Exception {
    String mapName = randomMapName();
    Config config = new Config();
    SubZero.useAsGlobalSerializer(config);
    ClassLoader spyingClassLoader = createSpyingClassLoader();
    config.setClassLoader(spyingClassLoader);
    config.addMapConfig(new MapConfig(mapName).setInMemoryFormat(OBJECT));
    HazelcastInstance member = hazelcastFactory.newHazelcastInstance(config);
    IMap<Integer, Object> myMap = member.getMap(mapName);

    myMap.put(0, new MyClass());

    verify(spyingClassLoader).loadClass("info.jerrinot.subzero.ClassLoadingTest$MyClass");
}
 
Example 7
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 8
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;
}
 
Example 9
Source File: CacheClient.java    From code-examples with MIT License 4 votes vote down vote up
public Config createConfig() {
    Config config = new Config();
    config.addMapConfig(mapConfig());
    config.getSerializationConfig().addSerializerConfig(serializerConfig());
    return config;
}
 
Example 10
Source File: IdempotentEventFilter.java    From concursus with MIT License 2 votes vote down vote up
/**
 * Add configuration for an {@link IMap} that will contain the event window.
 * @param eventWindowName The name of the {@link IMap} to configure.
 * @param timeToLiveSeconds The number of seconds to keep an event's identity in the window before discarding it.
 * @param config The {@link Config} to add the {@link IMap} configuration to.
 * @return The updated {@link Config}
 */
public static Config configureCache(String eventWindowName, int timeToLiveSeconds, Config config) {
    config.addMapConfig(new MapConfig(eventWindowName).setTimeToLiveSeconds(timeToLiveSeconds));
    return config;
}