Skip to content

Instantly share code, notes, and snippets.

View gurbuzali's full-sized avatar
🏠
Working from home

Ali Gurbuz gurbuzali

🏠
Working from home
View GitHub Profile
public static void main(String[] args) {
Config config = new Config();
MapConfig mapConfig = config.getMapConfig("map");
MapStoreConfig mapStoreConfig = new MapStoreConfig();
mapStoreConfig.setEnabled(true).setWriteDelaySeconds(60).setImplementation(new MyStore());
mapConfig.setMapStoreConfig(mapStoreConfig);
HazelcastInstance instance = Hazelcast.newHazelcastInstance(config);
IMap<Object, Object> map = instance.getMap("map");
for (int i = 0; i < 10; i++) {
map.put(i, -1);
public static void main(String[] args) {
HazelcastInstance instance1 = Hazelcast.newHazelcastInstance();
HazelcastInstance instance2 = Hazelcast.newHazelcastInstance();
HazelcastInstance instance3 = Hazelcast.newHazelcastInstance();
HazelcastInstance instance4 = Hazelcast.newHazelcastInstance();
IExecutorService exec = instance1.getExecutorService("exec");
exec.submitToAllMembers(new MyCallable());
}
import com.hazelcast.config.Config;
import com.hazelcast.config.InMemoryFormat;
import com.hazelcast.config.MapConfig;
import com.hazelcast.config.MapStoreConfig;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.IMap;
import com.hazelcast.core.MapLoader;
import java.util.ArrayList;
import com.hazelcast.config.Config;
import com.hazelcast.config.EvictionPolicy;
import com.hazelcast.config.InMemoryFormat;
import com.hazelcast.config.MapConfig;
import com.hazelcast.config.MaxSizeConfig;
import com.hazelcast.core.EntryEvent;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.IMap;
import com.hazelcast.core.MapEvent;
Config config = new Config();
QueueConfig queueConfig = config.getQueueConfig("queue");
queueConfig.setEmptyQueueTtl(5);
HazelcastInstance instance = Hazelcast.newHazelcastInstance(config);
IQueue<Object> queue = instance.getQueue("queue");
int size = instance.getDistributedObjects().size();
System.err.println("Size [" + size + "] should be 1");
queue.offer("item");
queue.poll();
/*
* Copyright (c) 2008-2015, Hazelcast, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
/*
* Copyright (c) 2008-2015, Hazelcast, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
/*
* Copyright (c) 2008-2015, Hazelcast, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
package compile;
import com.hazelcast.config.Config;
import com.hazelcast.core.EntryAdapter;
import com.hazelcast.core.EntryEvent;
import com.hazelcast.core.EntryListener;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.IMap;
import com.hazelcast.core.MapEvent;
@gurbuzali
gurbuzali / map-name
Created February 26, 2015 09:08
map-name
public class GurbuzTest {
public static void main(String[] args) {
Config config = new Config();
MapConfig mapConfig = new MapConfig();
mapConfig.setName("query.archive.*");
MapStoreConfig mapStoreConfig = new MapStoreConfig();
mapStoreConfig.setEnabled(true).setFactoryImplementation(new MyFac());
mapConfig.setMapStoreConfig(mapStoreConfig);
config.addMapConfig(mapConfig);
HazelcastInstance instance = Hazelcast.newHazelcastInstance(config);