use of com.hazelcast.config.IndexConfig in project cas by apereo.
the class HazelcastSessionConfiguration method hazelcastInstance.
/**
* Hazelcast instance that is used by the spring session
* repository to broadcast session events. The name
* of this bean must be left untouched.
*
* @param casProperties the cas properties
* @param hazelcastSessionProperties the hazelcast session properties
* @param sessionProperties the session properties
* @param serverProperties the server properties
* @return the hazelcast instance
*/
@Bean(destroyMethod = "shutdown")
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
public HazelcastInstance hazelcastInstance(final CasConfigurationProperties casProperties, final HazelcastSessionProperties hazelcastSessionProperties, final SessionProperties sessionProperties, final ServerProperties serverProperties) {
val hz = casProperties.getWebflow().getSession().getHazelcast();
val config = HazelcastConfigurationFactory.build(hz);
val serializerConfig = new SerializerConfig();
serializerConfig.setImplementation(new HazelcastSessionSerializer()).setTypeClass(MapSession.class);
config.getSerializationConfig().addSerializerConfig(serializerConfig);
val duration = (Duration) ObjectUtils.defaultIfNull(sessionProperties.getTimeout(), serverProperties.getServlet().getSession().getTimeout());
val hazelcastInstance = HazelcastInstanceFactory.getOrCreateHazelcastInstance(config);
val mapConfig = HazelcastConfigurationFactory.buildMapConfig(hz, hazelcastSessionProperties.getMapName(), duration.toSeconds());
if (mapConfig instanceof MapConfig) {
val finalConfig = (MapConfig) mapConfig;
val attributeConfig = new AttributeConfig();
attributeConfig.setName(Hazelcast4IndexedSessionRepository.PRINCIPAL_NAME_ATTRIBUTE);
attributeConfig.setExtractorClassName(HazelcastSessionPrincipalNameExtractor.class.getName());
finalConfig.addAttributeConfig(attributeConfig);
val indexConfig = new IndexConfig();
indexConfig.addAttribute(Hazelcast4IndexedSessionRepository.PRINCIPAL_NAME_ATTRIBUTE);
finalConfig.addIndexConfig(indexConfig);
}
HazelcastConfigurationFactory.setConfigMap(mapConfig, hazelcastInstance.getConfig());
return hazelcastInstance;
}
use of com.hazelcast.config.IndexConfig in project hazelcast by hazelcast.
the class SqlIndexCastTest method before.
@Before
public void before() {
IndexConfig indexConfig = new IndexConfig().setName("index").setType(IndexType.HASH).addAttribute("field1");
instance().getMap(MAP_NAME).addIndex(indexConfig);
}
use of com.hazelcast.config.IndexConfig in project hazelcast by hazelcast.
the class MapIndexScanPTest method test_pointLookup_hashed.
// We also don't test full hash index scan, because such plan aren't allowed to be created.
@Test
public void test_pointLookup_hashed() {
List<JetSqlRow> expected = new ArrayList<>();
for (int i = count; i > 0; i--) {
map.put(i, new Person("value-" + i, i));
}
expected.add(jetRow((5), "value-5", 5));
IndexConfig indexConfig = new IndexConfig(IndexType.HASH, "age").setName(randomName());
map.addIndex(indexConfig);
IndexFilter filter = new IndexEqualsFilter(intValue(5));
MapIndexScanMetadata metadata = metadata(indexConfig.getName(), filter, -1, false);
TestSupport.verifyProcessor(adaptSupplier(MapIndexScanP.readMapIndexSupplier(metadata))).hazelcastInstance(instance()).jobConfig(new JobConfig().setArgument(SQL_ARGUMENTS_KEY_NAME, emptyList())).outputChecker(LENIENT_SAME_ITEMS_IN_ORDER).disableSnapshots().disableProgressAssertion().expectOutput(expected);
}
use of com.hazelcast.config.IndexConfig in project hazelcast by hazelcast.
the class MapIndexScanPTest method test_whenFilterExistsWithoutSpecificProjection_sorted.
@Test
public void test_whenFilterExistsWithoutSpecificProjection_sorted() {
List<JetSqlRow> expected = new ArrayList<>();
for (int i = count; i > 0; i--) {
map.put(i, new Person("value-" + i, i));
if (i > count / 2) {
expected.add(jetRow((count - i + 1), "value-" + (count - i + 1), (count - i + 1)));
}
}
IndexConfig indexConfig = new IndexConfig(IndexType.SORTED, "age").setName(randomName());
map.addIndex(indexConfig);
IndexFilter filter = new IndexRangeFilter(intValue(0), true, intValue(count / 2), true);
MapIndexScanMetadata metadata = metadata(indexConfig.getName(), filter, 2, false);
TestSupport.verifyProcessor(adaptSupplier(MapIndexScanP.readMapIndexSupplier(metadata))).hazelcastInstance(instance()).jobConfig(new JobConfig().setArgument(SQL_ARGUMENTS_KEY_NAME, emptyList())).outputChecker(LENIENT_SAME_ITEMS_IN_ORDER).disableSnapshots().disableProgressAssertion().expectOutput(expected);
}
use of com.hazelcast.config.IndexConfig in project hazelcast by hazelcast.
the class SqlNoSerializationTest method before.
@Before
public void before() {
Map<Key, Value> localMap = new HashMap<>();
for (int i = 0; i < KEY_COUNT; i++) {
localMap.put(new Key(i), new Value(i));
}
createMapping(MAP_NAME, Key.class, Value.class);
IMap<Key, Value> map = instance().getMap(MAP_NAME);
map.putAll(localMap);
// An index may change the behavior due to MapContainer.isUseCachedDeserializedValuesEnabled.
if (useIndex) {
map.addIndex(new IndexConfig(IndexType.HASH, "val"));
}
failOnSerialization = true;
}
Aggregations