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);
}
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()));
}
}
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;
}
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;
}
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());
}
});
}
Aggregations