use of com.hazelcast.config.IndexConfig in project hazelcast by hazelcast.
the class ExternalizableDeserializationProtectionTest method testExternalizableProtectedOnMember.
@Test
public void testExternalizableProtectedOnMember() {
JavaSerializationFilterConfig javaSerializationFilterConfig = new JavaSerializationFilterConfig().setDefaultsDisabled(true);
javaSerializationFilterConfig.getBlacklist().addClasses(TestExternalizableDeserialized.class.getName());
Config config = smallInstanceConfig();
config.getSerializationConfig().setJavaSerializationFilterConfig(javaSerializationFilterConfig);
// the index will force deserialization
config.getMapConfig("test").addIndexConfig(new IndexConfig(IndexType.HASH, "name"));
hazelcastFactory.newHazelcastInstance(config);
HazelcastInstance client = hazelcastFactory.newHazelcastClient();
expected.expect(HazelcastSerializationException.class);
client.getMap("test").put("key", new TestExternalizableDeserialized());
}
use of com.hazelcast.config.IndexConfig in project hazelcast by hazelcast.
the class TestClientApplicationContext method testFullQueryCacheConfig.
@Test
public void testFullQueryCacheConfig() throws Exception {
ClientConfig config = client6.getClientConfig();
QueryCacheConfig queryCacheConfig = getQueryCacheConfig(config);
EntryListenerConfig entryListenerConfig = queryCacheConfig.getEntryListenerConfigs().get(0);
assertTrue(entryListenerConfig.isIncludeValue());
assertFalse(entryListenerConfig.isLocal());
assertEquals("com.hazelcast.spring.DummyEntryListener", entryListenerConfig.getClassName());
assertFalse(queryCacheConfig.isIncludeValue());
assertEquals("my-query-cache-1", queryCacheConfig.getName());
assertEquals(12, queryCacheConfig.getBatchSize());
assertEquals(33, queryCacheConfig.getBufferSize());
assertEquals(12, queryCacheConfig.getDelaySeconds());
assertEquals(InMemoryFormat.OBJECT, queryCacheConfig.getInMemoryFormat());
assertTrue(queryCacheConfig.isCoalesce());
assertFalse(queryCacheConfig.isPopulate());
assertEquals("__key > 12", queryCacheConfig.getPredicateConfig().getSql());
assertEquals(EvictionPolicy.LRU, queryCacheConfig.getEvictionConfig().getEvictionPolicy());
assertEquals(MaxSizePolicy.ENTRY_COUNT, queryCacheConfig.getEvictionConfig().getMaxSizePolicy());
assertEquals(111, queryCacheConfig.getEvictionConfig().getSize());
assertEquals(2, queryCacheConfig.getIndexConfigs().size());
IndexConfig hashIndex = queryCacheConfig.getIndexConfigs().get(0);
assertEquals(IndexType.HASH, hashIndex.getType());
assertNull(hashIndex.getName());
assertEquals(1, hashIndex.getAttributes().size());
assertEquals("name", hashIndex.getAttributes().get(0));
IndexConfig sortedIndex = queryCacheConfig.getIndexConfigs().get(1);
assertEquals(IndexType.SORTED, sortedIndex.getType());
assertEquals("sortedIndex", sortedIndex.getName());
assertEquals(2, sortedIndex.getAttributes().size());
assertEquals("age", sortedIndex.getAttributes().get(0));
assertEquals("name", sortedIndex.getAttributes().get(1));
}
use of com.hazelcast.config.IndexConfig in project hazelcast by hazelcast.
the class TestFullApplicationContext method assertIndexesEqual.
private void assertIndexesEqual(QueryCacheConfig queryCacheConfig) {
for (IndexConfig indexConfig : queryCacheConfig.getIndexConfigs()) {
assertEquals("name", indexConfig.getAttributes().get(0));
assertFalse(indexConfig.getType() == IndexType.SORTED);
}
}
use of com.hazelcast.config.IndexConfig in project hazelcast by hazelcast.
the class PlanExecutor method execute.
SqlResult execute(CreateIndexPlan plan) {
if (!plan.ifNotExists()) {
// If `IF NOT EXISTS` isn't specified, we do a simple check for the existence of the index. This is not
// OK if two clients concurrently try to create the index (they could both succeed), but covers the
// common case. There's no atomic operation to create an index in IMDG, so it's not easy to
// implement.
MapContainer mapContainer = getMapContainer(hazelcastInstance.getMap(plan.mapName()));
if (mapContainer.getIndexes().getIndex(plan.indexName()) != null) {
throw QueryException.error("Can't create index: index '" + plan.indexName() + "' already exists");
}
}
IndexConfig indexConfig = new IndexConfig(plan.indexType(), plan.attributes()).setName(plan.indexName());
if (plan.indexType().equals(IndexType.BITMAP)) {
Map<String, String> options = plan.options();
String uniqueKey = options.get(UNIQUE_KEY);
if (uniqueKey == null) {
uniqueKey = DEFAULT_UNIQUE_KEY;
}
String uniqueKeyTransform = options.get(UNIQUE_KEY_TRANSFORMATION);
if (uniqueKeyTransform == null) {
uniqueKeyTransform = DEFAULT_UNIQUE_KEY_TRANSFORMATION;
}
BitmapIndexOptions bitmapIndexOptions = new BitmapIndexOptions();
bitmapIndexOptions.setUniqueKey(uniqueKey);
bitmapIndexOptions.setUniqueKeyTransformation(UniqueKeyTransformation.fromName(uniqueKeyTransform));
indexConfig.setBitmapIndexOptions(bitmapIndexOptions);
}
// The `addIndex()` call does nothing, if an index with the same name already exists.
// Even if its config is different.
hazelcastInstance.getMap(plan.mapName()).addIndex(indexConfig);
return UpdateSqlResultImpl.createUpdateCountResult(0);
}
use of com.hazelcast.config.IndexConfig in project hazelcast by hazelcast.
the class MapReplicationStateHolder method prepare.
void prepare(PartitionContainer container, Collection<ServiceNamespace> namespaces, int replicaIndex) {
storesByMapName = createHashMap(namespaces.size());
loaded = createHashMap(namespaces.size());
mapIndexInfos = new ArrayList<>(namespaces.size());
for (ServiceNamespace namespace : namespaces) {
ObjectNamespace mapNamespace = (ObjectNamespace) namespace;
String mapName = mapNamespace.getObjectName();
RecordStore recordStore = container.getExistingRecordStore(mapName);
if (recordStore == null) {
continue;
}
MapContainer mapContainer = recordStore.getMapContainer();
MapConfig mapConfig = mapContainer.getMapConfig();
if (mapConfig.getTotalBackupCount() < replicaIndex) {
continue;
}
loaded.put(mapName, recordStore.isLoaded());
storesByMapName.put(mapName, recordStore);
statsByMapName.put(mapName, mapContainer.getMapServiceContext().getLocalMapStatsProvider().getLocalMapStatsImpl(mapName).getReplicationStats());
Set<IndexConfig> indexConfigs = new HashSet<>();
if (mapContainer.isGlobalIndexEnabled()) {
// global-index
final Indexes indexes = mapContainer.getIndexes();
for (Index index : indexes.getIndexes()) {
indexConfigs.add(index.getConfig());
}
indexConfigs.addAll(indexes.getIndexDefinitions());
} else {
// partitioned-index
final Indexes indexes = mapContainer.getIndexes(container.getPartitionId());
if (indexes != null && indexes.haveAtLeastOneIndexOrDefinition()) {
for (Index index : indexes.getIndexes()) {
indexConfigs.add(index.getConfig());
}
indexConfigs.addAll(indexes.getIndexDefinitions());
}
}
MapIndexInfo mapIndexInfo = new MapIndexInfo(mapName);
mapIndexInfo.addIndexCofigs(indexConfigs);
mapIndexInfos.add(mapIndexInfo);
}
}
Aggregations