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