Search in sources :

Example 6 with MapConfigReadOnly

use of com.hazelcast.internal.config.MapConfigReadOnly in project hazelcast by hazelcast.

the class MapConfigReadOnlyTest method getIndexConfigsOfReadOnlyMapConfigShouldReturnUnmodifiable.

@Test(expected = UnsupportedOperationException.class)
public void getIndexConfigsOfReadOnlyMapConfigShouldReturnUnmodifiable() {
    MapConfig config = new MapConfig().addIndexConfig(new IndexConfig()).addIndexConfig(new IndexConfig());
    List<IndexConfig> indexConfigs = new MapConfigReadOnly(config).getIndexConfigs();
    indexConfigs.add(new IndexConfig());
}
Also used : MapConfigReadOnly(com.hazelcast.internal.config.MapConfigReadOnly) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 7 with MapConfigReadOnly

use of com.hazelcast.internal.config.MapConfigReadOnly in project hazelcast by hazelcast.

the class MapConfigReadOnlyTest method getWanReplicationRefOfReadOnlyMapConfigShouldReturnUnmodifiable.

@Test(expected = UnsupportedOperationException.class)
public void getWanReplicationRefOfReadOnlyMapConfigShouldReturnUnmodifiable() {
    MapConfig config = new MapConfig().setWanReplicationRef(new WanReplicationRef());
    WanReplicationRef wanReplicationRef = new MapConfigReadOnly(config).getWanReplicationRef();
    wanReplicationRef.setName("myWanReplicationRef");
}
Also used : MapConfigReadOnly(com.hazelcast.internal.config.MapConfigReadOnly) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 8 with MapConfigReadOnly

use of com.hazelcast.internal.config.MapConfigReadOnly 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(timeToLiveSeconds);
    newConfig.setMaxIdleSeconds(maxIdleSeconds);
    newConfig.setReadBackupData(readBackupData);
    EvictionConfig evictionConfig = newConfig.getEvictionConfig();
    evictionConfig.setEvictionPolicy(EvictionPolicy.getById(evictionPolicyId));
    evictionConfig.setMaxSizePolicy(MaxSizePolicy.getById(maxSizePolicyId));
    evictionConfig.setSize(maxSize);
    MapContainer mapContainer = service.getMapServiceContext().getMapContainer(mapName);
    mapContainer.setMapConfig(new MapConfigReadOnly(newConfig));
    mapContainer.initEvictor();
}
Also used : MapConfigReadOnly(com.hazelcast.internal.config.MapConfigReadOnly) EvictionConfig(com.hazelcast.config.EvictionConfig) MapConfig(com.hazelcast.config.MapConfig) MapService(com.hazelcast.map.impl.MapService) MapContainer(com.hazelcast.map.impl.MapContainer)

Example 9 with MapConfigReadOnly

use of com.hazelcast.internal.config.MapConfigReadOnly in project hazelcast by hazelcast.

the class GetMapConfigMessageTask method encodeResponse.

@Override
protected ClientMessage encodeResponse(Object response) {
    MapConfigReadOnly config = (MapConfigReadOnly) response;
    EvictionConfig evictionConfig = config.getEvictionConfig();
    int maxSize = evictionConfig.getSize();
    int maxSizePolicyId = evictionConfig.getMaxSizePolicy().getId();
    int evictionPolicyId = evictionConfig.getEvictionPolicy().getId();
    String mergePolicy = config.getMergePolicyConfig().getPolicy();
    return MCGetMapConfigCodec.encodeResponse(config.getInMemoryFormat().getId(), config.getBackupCount(), config.getAsyncBackupCount(), config.getTimeToLiveSeconds(), config.getMaxIdleSeconds(), maxSize, maxSizePolicyId, config.isReadBackupData(), evictionPolicyId, mergePolicy, config.getIndexConfigs());
}
Also used : MapConfigReadOnly(com.hazelcast.internal.config.MapConfigReadOnly) EvictionConfig(com.hazelcast.config.EvictionConfig)

Example 10 with MapConfigReadOnly

use of com.hazelcast.internal.config.MapConfigReadOnly in project hazelcast by hazelcast.

the class GetMapConfigOperation method run.

@Override
public void run() throws Exception {
    MapService service = getService();
    MapServiceContext mapServiceContext = service.getMapServiceContext();
    MapContainer mapContainer = mapServiceContext.getMapContainer(mapName);
    MapConfig readOnlyMapConfig = mapContainer.getMapConfig();
    List<IndexConfig> indexConfigs = getIndexConfigsFromContainer(mapContainer);
    if (indexConfigs.isEmpty()) {
        mapConfig = readOnlyMapConfig;
    } else {
        MapConfig enrichedConfig = new MapConfig(readOnlyMapConfig);
        enrichedConfig.setIndexConfigs(indexConfigs);
        mapConfig = new MapConfigReadOnly(enrichedConfig);
    }
}
Also used : IndexConfig(com.hazelcast.config.IndexConfig) MapConfigReadOnly(com.hazelcast.internal.config.MapConfigReadOnly) MapConfig(com.hazelcast.config.MapConfig) MapService(com.hazelcast.map.impl.MapService) MapServiceContext(com.hazelcast.map.impl.MapServiceContext) MapContainer(com.hazelcast.map.impl.MapContainer)

Aggregations

MapConfigReadOnly (com.hazelcast.internal.config.MapConfigReadOnly)16 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)13 QuickTest (com.hazelcast.test.annotation.QuickTest)13 Test (org.junit.Test)13 EvictionConfig (com.hazelcast.config.EvictionConfig)2 MapConfig (com.hazelcast.config.MapConfig)2 MapContainer (com.hazelcast.map.impl.MapContainer)2 MapService (com.hazelcast.map.impl.MapService)2 IndexConfig (com.hazelcast.config.IndexConfig)1 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)1 DiscardMergePolicy (com.hazelcast.spi.merge.DiscardMergePolicy)1 PutIfAbsentMergePolicy (com.hazelcast.spi.merge.PutIfAbsentMergePolicy)1