use of com.hazelcast.config.PartitioningStrategyConfig in project hazelcast by hazelcast.
the class PartitioningStrategyFactoryTest method whenStrategyForMapAlreadyDefined_getPartitioningStrategy_returnsSameInstance.
// when a partitioning strategy has already been cached, then another invocation to obtain the partitioning
// strategy for the same map name retrieves the same instance
@Test
public void whenStrategyForMapAlreadyDefined_getPartitioningStrategy_returnsSameInstance() {
PartitioningStrategyConfig cfg = new PartitioningStrategyConfig();
cfg.setPartitioningStrategyClass("com.hazelcast.partition.strategy.StringPartitioningStrategy");
// when we have already obtained the partitioning strategy for a given map name
PartitioningStrategy partitioningStrategy = partitioningStrategyFactory.getPartitioningStrategy(mapName, cfg);
// then once we get it again with the same arguments, we retrieve the same instance
PartitioningStrategy cachedPartitioningStrategy = partitioningStrategyFactory.getPartitioningStrategy(mapName, cfg);
assertSame(partitioningStrategy, cachedPartitioningStrategy);
}
use of com.hazelcast.config.PartitioningStrategyConfig in project hazelcast by hazelcast.
the class PartitioningStrategyFactoryTest method whenRemoveInvoked_entryIsRemovedFromCache.
@Test
public void whenRemoveInvoked_entryIsRemovedFromCache() {
PartitioningStrategyConfig cfg = new PartitioningStrategyConfig();
cfg.setPartitioningStrategyClass("com.hazelcast.partition.strategy.StringPartitioningStrategy");
PartitioningStrategy partitioningStrategy = partitioningStrategyFactory.getPartitioningStrategy(mapName, cfg);
partitioningStrategyFactory.removePartitioningStrategyFromCache(mapName);
assertFalse(partitioningStrategyFactory.cache.containsKey(mapName));
}
use of com.hazelcast.config.PartitioningStrategyConfig in project hazelcast by hazelcast.
the class PartitioningStrategyFactoryTest method getConfig.
@Override
protected Config getConfig() {
Config config = new Config();
MapConfig mapConfig = new MapConfig(mapName);
PartitioningStrategyConfig partitioningStrategyConfig = new PartitioningStrategyConfig();
partitioningStrategyConfig.setPartitioningStrategyClass("com.hazelcast.partition.strategy.StringPartitioningStrategy");
mapConfig.setPartitioningStrategyConfig(partitioningStrategyConfig);
config.addMapConfig(mapConfig);
return config;
}
use of com.hazelcast.config.PartitioningStrategyConfig in project hazelcast by hazelcast.
the class AbstractDynamicConfigGeneratorTest method testMap.
// UTILITY - TESTS
private void testMap(MapStoreConfig mapStoreConfig) {
AttributeConfig attrConfig = new AttributeConfig().setName("power").setExtractorClassName("com.car.PowerExtractor");
EvictionConfig evictionConfig1 = new EvictionConfig().setSize(10).setMaxSizePolicy(MaxSizePolicy.FREE_NATIVE_MEMORY_SIZE);
IndexConfig indexConfig = new IndexConfig().addAttribute("attribute").setType(IndexType.SORTED);
EntryListenerConfig listenerConfig = new EntryListenerConfig("com.hazelcast.entrylistener", false, false);
EvictionConfig evictionConfig2 = new EvictionConfig().setMaxSizePolicy(MaxSizePolicy.FREE_NATIVE_MEMORY_SIZE).setSize(100).setComparatorClassName("comparatorClassName").setEvictionPolicy(EvictionPolicy.LRU);
PredicateConfig predicateConfig1 = new PredicateConfig();
predicateConfig1.setClassName("className");
PredicateConfig predicateConfig2 = new PredicateConfig();
predicateConfig2.setSql("sqlQuery");
QueryCacheConfig queryCacheConfig1 = new QueryCacheConfig().setName("queryCache1").setPredicateConfig(predicateConfig1).addEntryListenerConfig(listenerConfig).setBatchSize(230).setDelaySeconds(20).setPopulate(false).setBufferSize(8).setInMemoryFormat(InMemoryFormat.BINARY).setEvictionConfig(evictionConfig2).setIncludeValue(false).setCoalesce(false).addIndexConfig(indexConfig);
QueryCacheConfig queryCacheConfig2 = new QueryCacheConfig().setName("queryCache2").setPredicateConfig(predicateConfig2).addEntryListenerConfig(listenerConfig).setBatchSize(500).setDelaySeconds(10).setPopulate(true).setBufferSize(10).setInMemoryFormat(InMemoryFormat.OBJECT).setEvictionConfig(evictionConfig2).setIncludeValue(true).setCoalesce(true).addIndexConfig(indexConfig);
MapConfig expectedConfig = newMapConfig().setName("carMap").setEvictionConfig(evictionConfig1).setInMemoryFormat(InMemoryFormat.NATIVE).setMetadataPolicy(MetadataPolicy.CREATE_ON_UPDATE).setMaxIdleSeconds(100).setTimeToLiveSeconds(1000).setCacheDeserializedValues(CacheDeserializedValues.ALWAYS).setStatisticsEnabled(true).setPerEntryStatsEnabled(false).setReadBackupData(true).setBackupCount(2).setAsyncBackupCount(3).setMapStoreConfig(mapStoreConfig).setWanReplicationRef(wanReplicationRef()).setPartitioningStrategyConfig(new PartitioningStrategyConfig("partitionStrategyClass")).setMerkleTreeConfig(merkleTreeConfig()).setEventJournalConfig(eventJournalConfig()).setDataPersistenceConfig(dataPersistenceConfig()).addEntryListenerConfig(listenerConfig).setIndexConfigs(singletonList(indexConfig)).addAttributeConfig(attrConfig).setPartitionLostListenerConfigs(singletonList(new MapPartitionLostListenerConfig("partitionLostListener")));
expectedConfig.setQueryCacheConfigs(asList(queryCacheConfig1, queryCacheConfig2));
Config config = new Config().addMapConfig(expectedConfig);
Config decConfig = getNewConfigViaGenerator(config);
MapConfig actualConfig = decConfig.getMapConfig("carMap");
AttributeConfig decAttrConfig = actualConfig.getAttributeConfigs().get(0);
assertEquals(attrConfig.getName(), decAttrConfig.getName());
assertEquals(attrConfig.getExtractorClassName(), decAttrConfig.getExtractorClassName());
ConfigCompatibilityChecker.checkMapConfig(expectedConfig, actualConfig);
}
use of com.hazelcast.config.PartitioningStrategyConfig in project hazelcast by hazelcast.
the class ConfigDataSerializerHook method createFactory.
@Override
public DataSerializableFactory createFactory() {
ConstructorFunction<Integer, IdentifiedDataSerializable>[] constructors = new ConstructorFunction[LEN];
constructors[WAN_REPLICATION_CONFIG] = arg -> new WanReplicationConfig();
constructors[WAN_CONSUMER_CONFIG] = arg -> new WanConsumerConfig();
constructors[WAN_CUSTOM_PUBLISHER_CONFIG] = arg -> new WanCustomPublisherConfig();
constructors[WAN_BATCH_PUBLISHER_CONFIG] = arg -> new WanBatchPublisherConfig();
constructors[NEAR_CACHE_CONFIG] = arg -> new NearCacheConfig();
constructors[NEAR_CACHE_PRELOADER_CONFIG] = arg -> new NearCachePreloaderConfig();
constructors[ADD_DYNAMIC_CONFIG_OP] = arg -> new AddDynamicConfigOperation();
constructors[DYNAMIC_CONFIG_PRE_JOIN_OP] = arg -> new DynamicConfigPreJoinOperation();
constructors[MULTIMAP_CONFIG] = arg -> new MultiMapConfig();
constructors[LISTENER_CONFIG] = arg -> new ListenerConfig();
constructors[ENTRY_LISTENER_CONFIG] = arg -> new EntryListenerConfig();
constructors[MAP_CONFIG] = arg -> new MapConfig();
constructors[MAP_STORE_CONFIG] = arg -> new MapStoreConfig();
constructors[MAP_PARTITION_LOST_LISTENER_CONFIG] = arg -> new MapPartitionLostListenerConfig();
constructors[INDEX_CONFIG] = arg -> new IndexConfig();
constructors[MAP_ATTRIBUTE_CONFIG] = arg -> new AttributeConfig();
constructors[QUERY_CACHE_CONFIG] = arg -> new QueryCacheConfig();
constructors[PREDICATE_CONFIG] = arg -> new PredicateConfig();
constructors[PARTITION_STRATEGY_CONFIG] = arg -> new PartitioningStrategyConfig();
constructors[HOT_RESTART_CONFIG] = arg -> new HotRestartConfig();
constructors[TOPIC_CONFIG] = arg -> new TopicConfig();
constructors[RELIABLE_TOPIC_CONFIG] = arg -> new ReliableTopicConfig();
constructors[ITEM_LISTENER_CONFIG] = arg -> new ItemListenerConfig();
constructors[QUEUE_STORE_CONFIG] = arg -> new QueueStoreConfig();
constructors[QUEUE_CONFIG] = arg -> new QueueConfig();
constructors[LIST_CONFIG] = arg -> new ListConfig();
constructors[SET_CONFIG] = arg -> new SetConfig();
constructors[EXECUTOR_CONFIG] = arg -> new ExecutorConfig();
constructors[DURABLE_EXECUTOR_CONFIG] = arg -> new DurableExecutorConfig();
constructors[SCHEDULED_EXECUTOR_CONFIG] = arg -> new ScheduledExecutorConfig();
constructors[REPLICATED_MAP_CONFIG] = arg -> new ReplicatedMapConfig();
constructors[RINGBUFFER_CONFIG] = arg -> new RingbufferConfig();
constructors[RINGBUFFER_STORE_CONFIG] = arg -> new RingbufferStoreConfig();
constructors[CARDINALITY_ESTIMATOR_CONFIG] = arg -> new CardinalityEstimatorConfig();
constructors[SIMPLE_CACHE_CONFIG] = arg -> new CacheSimpleConfig();
constructors[SIMPLE_CACHE_CONFIG_EXPIRY_POLICY_FACTORY_CONFIG] = arg -> new CacheSimpleConfig.ExpiryPolicyFactoryConfig();
constructors[SIMPLE_CACHE_CONFIG_TIMED_EXPIRY_POLICY_FACTORY_CONFIG] = arg -> new CacheSimpleConfig.ExpiryPolicyFactoryConfig.TimedExpiryPolicyFactoryConfig();
constructors[SIMPLE_CACHE_CONFIG_DURATION_CONFIG] = arg -> new CacheSimpleConfig.ExpiryPolicyFactoryConfig.DurationConfig();
constructors[SPLIT_BRAIN_PROTECTION_CONFIG] = arg -> new SplitBrainProtectionConfig();
constructors[EVENT_JOURNAL_CONFIG] = arg -> new EventJournalConfig();
constructors[SPLIT_BRAIN_PROTECTION_LISTENER_CONFIG] = arg -> new SplitBrainProtectionListenerConfig();
constructors[CACHE_PARTITION_LOST_LISTENER_CONFIG] = arg -> new CachePartitionLostListenerConfig();
constructors[SIMPLE_CACHE_ENTRY_LISTENER_CONFIG] = arg -> new CacheSimpleEntryListenerConfig();
constructors[FLAKE_ID_GENERATOR_CONFIG] = arg -> new FlakeIdGeneratorConfig();
constructors[MERGE_POLICY_CONFIG] = arg -> new MergePolicyConfig();
constructors[PN_COUNTER_CONFIG] = arg -> new PNCounterConfig();
constructors[MERKLE_TREE_CONFIG] = arg -> new MerkleTreeConfig();
constructors[WAN_SYNC_CONFIG] = arg -> new WanSyncConfig();
constructors[KUBERNETES_CONFIG] = arg -> new KubernetesConfig();
constructors[EUREKA_CONFIG] = arg -> new EurekaConfig();
constructors[GCP_CONFIG] = arg -> new GcpConfig();
constructors[AZURE_CONFIG] = arg -> new AzureConfig();
constructors[AWS_CONFIG] = arg -> new AwsConfig();
constructors[DISCOVERY_CONFIG] = arg -> new DiscoveryConfig();
constructors[DISCOVERY_STRATEGY_CONFIG] = arg -> new DiscoveryStrategyConfig();
constructors[WAN_REPLICATION_REF] = arg -> new WanReplicationRef();
constructors[EVICTION_CONFIG] = arg -> new EvictionConfig();
constructors[PERMISSION_CONFIG] = arg -> new PermissionConfig();
constructors[BITMAP_INDEX_OPTIONS] = arg -> new BitmapIndexOptions();
constructors[DATA_PERSISTENCE_CONFIG] = arg -> new DataPersistenceConfig();
constructors[TIERED_STORE_CONFIG] = arg -> new TieredStoreConfig();
constructors[MEMORY_TIER_CONFIG] = arg -> new MemoryTierConfig();
constructors[DISK_TIER_CONFIG] = arg -> new DiskTierConfig();
return new ArrayDataSerializableFactory(constructors);
}
Aggregations