Search in sources :

Example 6 with MapStoreConfig

use of com.hazelcast.config.MapStoreConfig in project hazelcast by hazelcast.

the class ClientMapTest method setup.

@Before
public void setup() {
    Config config = getConfig();
    config.getMapConfig("flushMap").setMapStoreConfig(new MapStoreConfig().setWriteDelaySeconds(1000).setImplementation(flushMapStore));
    config.getMapConfig("putTransientMap").setMapStoreConfig(new MapStoreConfig().setWriteDelaySeconds(1000).setImplementation(transientMapStore));
    server = hazelcastFactory.newHazelcastInstance(config);
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.getSerializationConfig().addPortableFactory(TestSerializationConstants.PORTABLE_FACTORY_ID, new PortableFactory() {

        public Portable create(int classId) {
            return new NamedPortable();
        }
    });
    client = hazelcastFactory.newHazelcastClient(clientConfig);
}
Also used : Portable(com.hazelcast.nio.serialization.Portable) NamedPortable(com.hazelcast.nio.serialization.NamedPortable) MapStoreConfig(com.hazelcast.config.MapStoreConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) Config(com.hazelcast.config.Config) MapStoreConfig(com.hazelcast.config.MapStoreConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) PortableFactory(com.hazelcast.nio.serialization.PortableFactory) NamedPortable(com.hazelcast.nio.serialization.NamedPortable) Before(org.junit.Before)

Example 7 with MapStoreConfig

use of com.hazelcast.config.MapStoreConfig in project hazelcast by hazelcast.

the class ClientMapNearCacheTest method testMemberLoadAll_invalidates_clientNearCache.

@Test
public void testMemberLoadAll_invalidates_clientNearCache() {
    int mapSize = 1000;
    String mapName = randomMapName();
    HazelcastInstance member = hazelcastFactory.newHazelcastInstance(newConfig());
    HazelcastInstance client = getClient(hazelcastFactory, newInvalidationOnChangeEnabledNearCacheConfig(mapName));
    Config config = member.getConfig();
    SimpleMapStore store = new SimpleMapStore();
    MapStoreConfig mapStoreConfig = new MapStoreConfig();
    mapStoreConfig.setEnabled(true);
    mapStoreConfig.setImplementation(store);
    config.getMapConfig(mapName).setMapStoreConfig(mapStoreConfig);
    final IMap<Integer, Integer> clientMap = client.getMap(mapName);
    populateMap(clientMap, mapSize);
    populateNearCache(clientMap, mapSize);
    IMap<Integer, Integer> map = member.getMap(mapName);
    map.loadAll(true);
    assertTrueEventually(new AssertTask() {

        public void run() {
            assertThatOwnedEntryCountEquals(clientMap, 0);
        }
    });
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapConfig(com.hazelcast.config.MapConfig) NearCacheConfig(com.hazelcast.config.NearCacheConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) Config(com.hazelcast.config.Config) AssertTask(com.hazelcast.test.AssertTask) MapStoreConfig(com.hazelcast.config.MapStoreConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 8 with MapStoreConfig

use of com.hazelcast.config.MapStoreConfig in project hazelcast by hazelcast.

the class BasicMapStoreContext method callLifecycleSupportInit.

private static void callLifecycleSupportInit(MapStoreContext mapStoreContext) {
    final MapStoreWrapper mapStoreWrapper = mapStoreContext.getMapStoreWrapper();
    final MapServiceContext mapServiceContext = mapStoreContext.getMapServiceContext();
    final NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
    final HazelcastInstance hazelcastInstance = nodeEngine.getHazelcastInstance();
    final MapStoreConfig mapStoreConfig = mapStoreContext.getMapStoreConfig();
    final Properties properties = mapStoreConfig.getProperties();
    final String mapName = mapStoreContext.getMapName();
    mapStoreWrapper.init(hazelcastInstance, properties, mapName);
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) MapStoreWrapper(com.hazelcast.map.impl.MapStoreWrapper) HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapStoreConfig(com.hazelcast.config.MapStoreConfig) Properties(java.util.Properties) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 9 with MapStoreConfig

use of com.hazelcast.config.MapStoreConfig in project hazelcast by hazelcast.

the class BasicMapStoreContext method create.

static MapStoreContext create(MapContainer mapContainer) {
    final BasicMapStoreContext context = new BasicMapStoreContext();
    final String mapName = mapContainer.getName();
    final MapServiceContext mapServiceContext = mapContainer.getMapServiceContext();
    final NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
    final PartitioningStrategy partitioningStrategy = mapContainer.getPartitioningStrategy();
    final MapConfig mapConfig = mapContainer.getMapConfig();
    final MapStoreConfig mapStoreConfig = mapConfig.getMapStoreConfig();
    final ClassLoader configClassLoader = nodeEngine.getConfigClassLoader();
    // create store.
    final Object store = createStore(mapName, mapStoreConfig, configClassLoader);
    final MapStoreWrapper storeWrapper = new MapStoreWrapper(mapName, store);
    storeWrapper.instrument(nodeEngine);
    setStoreImplToWritableMapStoreConfig(nodeEngine, mapName, store);
    context.setMapName(mapName);
    context.setMapStoreConfig(mapStoreConfig);
    context.setPartitioningStrategy(partitioningStrategy);
    context.setMapServiceContext(mapServiceContext);
    context.setStoreWrapper(storeWrapper);
    final MapStoreManager mapStoreManager = createMapStoreManager(context);
    context.setMapStoreManager(mapStoreManager);
    // todo this is user code. it may also block map store creation.
    callLifecycleSupportInit(context);
    return context;
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) MapStoreWrapper(com.hazelcast.map.impl.MapStoreWrapper) PartitioningStrategy(com.hazelcast.core.PartitioningStrategy) MapConfig(com.hazelcast.config.MapConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 10 with MapStoreConfig

use of com.hazelcast.config.MapStoreConfig in project hazelcast by hazelcast.

the class MapDataStores method createWriteBehindStore.

/**
     * Creates a write behind data store.
     *
     * @param mapStoreContext      context for map store operations.
     * @param partitionId          partition id of partition.
     * @param writeBehindProcessor the {@link WriteBehindProcessor}
     * @param <K>                  type of key to store.
     * @param <V>                  type of value to store.
     * @return new write behind store manager.
     */
public static <K, V> MapDataStore<K, V> createWriteBehindStore(MapStoreContext mapStoreContext, int partitionId, WriteBehindProcessor writeBehindProcessor) {
    MapServiceContext mapServiceContext = mapStoreContext.getMapServiceContext();
    MapStoreConfig mapStoreConfig = mapStoreContext.getMapStoreConfig();
    WriteBehindStore mapDataStore = new WriteBehindStore(mapStoreContext, partitionId);
    mapDataStore.setWriteBehindQueue(newWriteBehindQueue(mapServiceContext, mapStoreConfig.isWriteCoalescing()));
    mapDataStore.setWriteBehindProcessor(writeBehindProcessor);
    return (MapDataStore<K, V>) mapDataStore;
}
Also used : MapStoreConfig(com.hazelcast.config.MapStoreConfig) MapServiceContext(com.hazelcast.map.impl.MapServiceContext) WriteBehindStore(com.hazelcast.map.impl.mapstore.writebehind.WriteBehindStore)

Aggregations

MapStoreConfig (com.hazelcast.config.MapStoreConfig)76 Config (com.hazelcast.config.Config)70 MapConfig (com.hazelcast.config.MapConfig)61 HazelcastInstance (com.hazelcast.core.HazelcastInstance)51 Test (org.junit.Test)50 QuickTest (com.hazelcast.test.annotation.QuickTest)43 ParallelTest (com.hazelcast.test.annotation.ParallelTest)42 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)23 GroupConfig (com.hazelcast.config.GroupConfig)21 IMap (com.hazelcast.core.IMap)12 AssertTask (com.hazelcast.test.AssertTask)12 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)12 MapIndexConfig (com.hazelcast.config.MapIndexConfig)10 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)9 NightlyTest (com.hazelcast.test.annotation.NightlyTest)8 HashSet (java.util.HashSet)8 NearCacheConfig (com.hazelcast.config.NearCacheConfig)6 HashMap (java.util.HashMap)6 Map (java.util.Map)6 MapStoreAdapter (com.hazelcast.core.MapStoreAdapter)5