Search in sources :

Example 1 with MapContainer

use of com.hazelcast.map.impl.MapContainer in project hazelcast by hazelcast.

the class UpdateMapConfigOperation method run.

@Override
public void run() throws Exception {
    MapService service = getService();
    MapConfig oldConfig = service.getMapServiceContext().getMapContainer(mapName).getMapConfig();
    MapConfig newConfig = new MapConfig(oldConfig);
    newConfig.setTimeToLiveSeconds(mapConfig.getTimeToLiveSeconds());
    newConfig.setMaxIdleSeconds(mapConfig.getMaxIdleSeconds());
    newConfig.setEvictionPolicy(mapConfig.getEvictionPolicy());
    newConfig.setEvictionPercentage(mapConfig.getEvictionPercentage());
    newConfig.setMinEvictionCheckMillis(mapConfig.getMinEvictionCheckMillis());
    newConfig.setReadBackupData(mapConfig.isReadBackupData());
    newConfig.setBackupCount(mapConfig.getBackupCount());
    newConfig.setAsyncBackupCount(mapConfig.getAsyncBackupCount());
    newConfig.setMaxSizeConfig(mapConfig.getMaxSizeConfig());
    MapContainer mapContainer = service.getMapServiceContext().getMapContainer(mapName);
    mapContainer.setMapConfig(newConfig.getAsReadOnly());
    mapContainer.initEvictor();
}
Also used : MapConfig(com.hazelcast.config.MapConfig) MapService(com.hazelcast.map.impl.MapService) MapContainer(com.hazelcast.map.impl.MapContainer)

Example 2 with MapContainer

use of com.hazelcast.map.impl.MapContainer in project hazelcast by hazelcast.

the class EvictionChecker method checkEvictable.

public boolean checkEvictable(RecordStore recordStore) {
    if (recordStore.size() == 0) {
        return false;
    }
    String mapName = recordStore.getName();
    MapContainer mapContainer = recordStore.getMapContainer();
    MaxSizeConfig maxSizeConfig = mapContainer.getMapConfig().getMaxSizeConfig();
    MaxSizeConfig.MaxSizePolicy maxSizePolicy = maxSizeConfig.getMaxSizePolicy();
    switch(maxSizePolicy) {
        case PER_NODE:
            return checkPerNodeEviction(recordStore);
        case PER_PARTITION:
            int partitionId = recordStore.getPartitionId();
            return checkPerPartitionEviction(mapName, maxSizeConfig, partitionId);
        case USED_HEAP_PERCENTAGE:
            return checkHeapPercentageEviction(mapName, maxSizeConfig);
        case USED_HEAP_SIZE:
            return checkHeapSizeEviction(mapName, maxSizeConfig);
        case FREE_HEAP_PERCENTAGE:
            return checkFreeHeapPercentageEviction(maxSizeConfig);
        case FREE_HEAP_SIZE:
            return checkFreeHeapSizeEviction(maxSizeConfig);
        default:
            throw new IllegalArgumentException("Not an appropriate max size policy [" + maxSizePolicy + ']');
    }
}
Also used : MaxSizeConfig(com.hazelcast.config.MaxSizeConfig) MemorySize.toPrettyString(com.hazelcast.memory.MemorySize.toPrettyString) MapContainer(com.hazelcast.map.impl.MapContainer)

Example 3 with MapContainer

use of com.hazelcast.map.impl.MapContainer in project hazelcast by hazelcast.

the class EntryBackupOperation method publishWanReplicationEvent.

private void publishWanReplicationEvent(EntryEventType eventType) {
    final MapContainer mapContainer = this.mapContainer;
    if (!mapContainer.isWanReplicationEnabled()) {
        return;
    }
    final MapEventPublisher mapEventPublisher = mapContainer.getMapServiceContext().getMapEventPublisher();
    final Data key = dataKey;
    if (EntryEventType.REMOVED == eventType) {
        mapEventPublisher.publishWanReplicationRemoveBackup(name, key, Clock.currentTimeMillis());
    } else {
        final Record record = recordStore.getRecord(key);
        if (record != null) {
            dataValue = mapContainer.getMapServiceContext().toData(dataValue);
            final EntryView entryView = createSimpleEntryView(key, dataValue, record);
            mapEventPublisher.publishWanReplicationUpdateBackup(name, entryView);
        }
    }
}
Also used : EntryView(com.hazelcast.core.EntryView) EntryViews.createSimpleEntryView(com.hazelcast.map.impl.EntryViews.createSimpleEntryView) Data(com.hazelcast.nio.serialization.Data) Record(com.hazelcast.map.impl.record.Record) MapContainer(com.hazelcast.map.impl.MapContainer) MapEventPublisher(com.hazelcast.map.impl.event.MapEventPublisher)

Example 4 with MapContainer

use of com.hazelcast.map.impl.MapContainer in project hazelcast by hazelcast.

the class EntryOperation method publishWanReplicationEvent.

private void publishWanReplicationEvent() {
    final MapContainer mapContainer = this.mapContainer;
    if (mapContainer.getWanReplicationPublisher() == null && mapContainer.getWanMergePolicy() == null) {
        return;
    }
    final Data key = dataKey;
    if (REMOVED.equals(eventType)) {
        mapEventPublisher.publishWanReplicationRemove(name, key, getNow());
    } else {
        final Record record = recordStore.getRecord(key);
        if (record != null) {
            dataValue = toData(dataValue);
            final EntryView entryView = createSimpleEntryView(key, dataValue, record);
            mapEventPublisher.publishWanReplicationUpdate(name, entryView);
        }
    }
}
Also used : EntryView(com.hazelcast.core.EntryView) EntryViews.createSimpleEntryView(com.hazelcast.map.impl.EntryViews.createSimpleEntryView) Data(com.hazelcast.nio.serialization.Data) Record(com.hazelcast.map.impl.record.Record) MapContainer(com.hazelcast.map.impl.MapContainer)

Example 5 with MapContainer

use of com.hazelcast.map.impl.MapContainer in project hazelcast by hazelcast.

the class MapEventPublisherImpl method publishWanReplicationEventInternal.

protected void publishWanReplicationEventInternal(String mapName, ReplicationEventObject event) {
    MapContainer mapContainer = mapServiceContext.getMapContainer(mapName);
    WanReplicationPublisher wanReplicationPublisher = mapContainer.getWanReplicationPublisher();
    wanReplicationPublisher.publishReplicationEvent(SERVICE_NAME, event);
}
Also used : WanReplicationPublisher(com.hazelcast.wan.WanReplicationPublisher) MapContainer(com.hazelcast.map.impl.MapContainer)

Aggregations

MapContainer (com.hazelcast.map.impl.MapContainer)25 MapService (com.hazelcast.map.impl.MapService)10 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)6 Data (com.hazelcast.nio.serialization.Data)5 MapConfig (com.hazelcast.config.MapConfig)4 Record (com.hazelcast.map.impl.record.Record)4 Map (java.util.Map)4 PartitionContainer (com.hazelcast.map.impl.PartitionContainer)3 MapProxyImpl (com.hazelcast.map.impl.proxy.MapProxyImpl)3 RecordStore (com.hazelcast.map.impl.recordstore.RecordStore)3 QueryableEntry (com.hazelcast.query.impl.QueryableEntry)3 HashMap (java.util.HashMap)3 EntryView (com.hazelcast.core.EntryView)2 HazelcastInstance (com.hazelcast.core.HazelcastInstance)2 EntryViews.createSimpleEntryView (com.hazelcast.map.impl.EntryViews.createSimpleEntryView)2 Predicate (com.hazelcast.query.Predicate)2 ParallelTest (com.hazelcast.test.annotation.ParallelTest)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 Test (org.junit.Test)2 Config (com.hazelcast.config.Config)1