Search in sources :

Example 26 with MapConfig

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

the class BasicMapStoreContext method setStoreImplToWritableMapStoreConfig.

private static void setStoreImplToWritableMapStoreConfig(NodeEngine nodeEngine, String mapName, Object store) {
    final Config config = nodeEngine.getConfig();
    // get writable config (not read-only one) from node engine.
    final MapConfig mapConfig = config.getMapConfig(mapName);
    final MapStoreConfig mapStoreConfig = mapConfig.getMapStoreConfig();
    mapStoreConfig.setImplementation(store);
}
Also used : Config(com.hazelcast.config.Config) MapConfig(com.hazelcast.config.MapConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) MapConfig(com.hazelcast.config.MapConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig)

Example 27 with MapConfig

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

the class WriteBehindStateHolder method prepare.

void prepare(PartitionContainer container, int replicaIndex) {
    int size = container.getMaps().size();
    flushSequences = new HashMap<String, Queue<WriteBehindStore.Sequence>>(size);
    delayedEntries = new HashMap<String, List<DelayedEntry>>(size);
    for (Map.Entry<String, RecordStore> entry : container.getMaps().entrySet()) {
        RecordStore recordStore = entry.getValue();
        MapContainer mapContainer = recordStore.getMapContainer();
        MapConfig mapConfig = mapContainer.getMapConfig();
        if (mapConfig.getTotalBackupCount() < replicaIndex || !mapContainer.getMapStoreContext().isWriteBehindMapStoreEnabled()) {
            continue;
        }
        WriteBehindStore mapDataStore = (WriteBehindStore) recordStore.getMapDataStore();
        WriteBehindQueue<DelayedEntry> writeBehindQueue = mapDataStore.getWriteBehindQueue();
        List<DelayedEntry> entries = writeBehindQueue.asList();
        if (entries == null || entries.isEmpty()) {
            continue;
        }
        String mapName = entry.getKey();
        delayedEntries.put(mapName, entries);
        flushSequences.put(mapName, new ArrayDeque<WriteBehindStore.Sequence>(mapDataStore.getFlushSequences()));
    }
}
Also used : DelayedEntry(com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry) WriteBehindStore(com.hazelcast.map.impl.mapstore.writebehind.WriteBehindStore) MapContainer(com.hazelcast.map.impl.MapContainer) RecordStore(com.hazelcast.map.impl.recordstore.RecordStore) ArrayList(java.util.ArrayList) List(java.util.List) MapConfig(com.hazelcast.config.MapConfig) WriteBehindQueue(com.hazelcast.map.impl.mapstore.writebehind.WriteBehindQueue) Queue(java.util.Queue) HashMap(java.util.HashMap) Map(java.util.Map)

Example 28 with MapConfig

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

the class AbstractRecordStore method createRecord.

@Override
public Record createRecord(Object value, long ttlMillis, long now) {
    MapConfig mapConfig = mapContainer.getMapConfig();
    Record record = recordFactory.newRecord(value);
    record.setCreationTime(now);
    record.setLastUpdateTime(now);
    final long ttlMillisFromConfig = calculateTTLMillis(mapConfig);
    final long ttl = pickTTL(ttlMillis, ttlMillisFromConfig);
    record.setTtl(ttl);
    final long maxIdleMillis = calculateMaxIdleMillis(mapConfig);
    setExpirationTime(record, maxIdleMillis);
    updateStatsOnPut(true, now);
    return record;
}
Also used : Record(com.hazelcast.map.impl.record.Record) MapConfig(com.hazelcast.config.MapConfig)

Example 29 with MapConfig

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

the class NodeQueryCacheConfigurator method getOrNull.

@Override
public QueryCacheConfig getOrNull(String mapName, String cacheName) {
    MapConfig mapConfig = config.getMapConfig(mapName);
    List<QueryCacheConfig> queryCacheConfigs = mapConfig.getQueryCacheConfigs();
    Iterator<QueryCacheConfig> iterator = queryCacheConfigs.iterator();
    while (iterator.hasNext()) {
        QueryCacheConfig config = iterator.next();
        if (config.getName().equals(cacheName)) {
            return config;
        }
    }
    return null;
}
Also used : QueryCacheConfig(com.hazelcast.config.QueryCacheConfig) MapConfig(com.hazelcast.config.MapConfig)

Example 30 with MapConfig

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

the class ListenerTest method testMapPartitionLostListener_registeredViaImplementationInConfigObject.

@Test
public void testMapPartitionLostListener_registeredViaImplementationInConfigObject() {
    final String name = randomString();
    Config config = getConfig();
    MapConfig mapConfig = config.getMapConfig(name);
    MapPartitionLostListener listener = mock(MapPartitionLostListener.class);
    mapConfig.addMapPartitionLostListenerConfig(new MapPartitionLostListenerConfig(listener));
    mapConfig.setBackupCount(0);
    HazelcastInstance instance = createHazelcastInstance(config);
    instance.getMap(name);
    final EventService eventService = getNode(instance).getNodeEngine().getEventService();
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            final Collection<EventRegistration> registrations = eventService.getRegistrations(MapService.SERVICE_NAME, name);
            assertFalse(registrations.isEmpty());
        }
    });
}
Also used : MapPartitionLostListener(com.hazelcast.map.listener.MapPartitionLostListener) HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapPartitionLostListenerConfig(com.hazelcast.config.MapPartitionLostListenerConfig) MapConfig(com.hazelcast.config.MapConfig) EntryListenerConfig(com.hazelcast.config.EntryListenerConfig) Config(com.hazelcast.config.Config) MapPartitionLostListenerConfig(com.hazelcast.config.MapPartitionLostListenerConfig) AssertTask(com.hazelcast.test.AssertTask) Collection(java.util.Collection) EventService(com.hazelcast.spi.EventService) MapConfig(com.hazelcast.config.MapConfig) IOException(java.io.IOException) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

MapConfig (com.hazelcast.config.MapConfig)178 Config (com.hazelcast.config.Config)123 HazelcastInstance (com.hazelcast.core.HazelcastInstance)78 Test (org.junit.Test)75 QuickTest (com.hazelcast.test.annotation.QuickTest)68 ParallelTest (com.hazelcast.test.annotation.ParallelTest)62 MapStoreConfig (com.hazelcast.config.MapStoreConfig)43 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)41 NearCacheConfig (com.hazelcast.config.NearCacheConfig)27 MaxSizeConfig (com.hazelcast.config.MaxSizeConfig)26 MapIndexConfig (com.hazelcast.config.MapIndexConfig)20 QuorumConfig (com.hazelcast.config.QuorumConfig)19 EntryListenerConfig (com.hazelcast.config.EntryListenerConfig)18 QueryCacheConfig (com.hazelcast.config.QueryCacheConfig)16 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)14 NightlyTest (com.hazelcast.test.annotation.NightlyTest)12 PartitionedCluster (com.hazelcast.quorum.PartitionedCluster)10 CountDownLatch (java.util.concurrent.CountDownLatch)10 BeforeClass (org.junit.BeforeClass)10 AssertTask (com.hazelcast.test.AssertTask)9