use of org.wildfly.clustering.ee.Key in project wildfly by wildfly.
the class AffinityIdentifierFactoryTestCase method init.
@Before
public void init() throws Exception {
EmbeddedCacheManager manager = mock(EmbeddedCacheManager.class);
try (AutoCloseable test = MockitoAnnotations.openMocks(this)) {
when(this.affinityFactory.createService(same(this.cache), this.capturedGenerator.capture())).thenReturn(this.affinity);
when(this.cache.getCacheManager()).thenReturn(manager);
when(manager.getAddress()).thenReturn(this.localAddress);
this.subject = new AffinityIdentifierFactory<>(this.factory, this.cache, this.affinityFactory);
KeyGenerator<Key<UUID>> generator = this.capturedGenerator.getValue();
assertSame(generator, this.subject);
UUID expected = UUID.randomUUID();
when(this.factory.get()).thenReturn(expected);
Key<UUID> result = generator.getKey();
assertSame(expected, result.getId());
}
}
use of org.wildfly.clustering.ee.Key in project wildfly by wildfly.
the class HotRodSessionMetaDataFactory method findValue.
@Override
public CompositeSessionMetaDataEntry<L> findValue(String id) {
SessionCreationMetaDataKey creationMetaDataKey = new SessionCreationMetaDataKey(id);
SessionAccessMetaDataKey accessMetaDataKey = new SessionAccessMetaDataKey(id);
Set<Key<String>> keys = new HashSet<>(3);
keys.add(creationMetaDataKey);
keys.add(accessMetaDataKey);
// Use bulk read
Map<Key<String>, Object> entries = this.cache.getAll(keys);
@SuppressWarnings("unchecked") SessionCreationMetaDataEntry<L> creationMetaDataEntry = (SessionCreationMetaDataEntry<L>) entries.get(creationMetaDataKey);
SessionAccessMetaData accessMetaData = (SessionAccessMetaData) entries.get(accessMetaDataKey);
if ((creationMetaDataEntry != null) && (accessMetaData != null)) {
return new CompositeSessionMetaDataEntry<>(creationMetaDataEntry, accessMetaData);
}
return null;
}
use of org.wildfly.clustering.ee.Key in project wildfly by wildfly.
the class AbstractInfinispanSessionMetaDataFactory method createValue.
@Override
public CompositeSessionMetaDataEntry<L> createValue(String id, Void context) {
Map<Key<String>, Object> entries = new HashMap<>(3);
SessionCreationMetaDataEntry<L> creationMetaDataEntry = new SessionCreationMetaDataEntry<>(new SimpleSessionCreationMetaData());
entries.put(new SessionCreationMetaDataKey(id), creationMetaDataEntry);
SessionAccessMetaData accessMetaData = new SimpleSessionAccessMetaData();
entries.put(new SessionAccessMetaDataKey(id), accessMetaData);
this.writeCache.putAll(entries);
return new CompositeSessionMetaDataEntry<>(creationMetaDataEntry, accessMetaData);
}
use of org.wildfly.clustering.ee.Key in project wildfly by wildfly.
the class InfinispanSessionMetaDataFactory method apply.
@Override
public CompositeSessionMetaDataEntry<L> apply(String id, Set<Flag> flags) {
SessionCreationMetaDataKey creationMetaDataKey = new SessionCreationMetaDataKey(id);
SessionAccessMetaDataKey accessMetaDataKey = new SessionAccessMetaDataKey(id);
Set<Key<String>> keys = new HashSet<>(3);
keys.add(creationMetaDataKey);
keys.add(accessMetaDataKey);
// Use bulk read
Map<Key<String>, Object> entries = this.cache.getAdvancedCache().withFlags(flags).getAll(keys);
@SuppressWarnings("unchecked") SessionCreationMetaDataEntry<L> creationMetaDataEntry = (SessionCreationMetaDataEntry<L>) entries.get(creationMetaDataKey);
SessionAccessMetaData accessMetaData = (SessionAccessMetaData) entries.get(accessMetaDataKey);
if ((creationMetaDataEntry != null) && (accessMetaData != null)) {
return new CompositeSessionMetaDataEntry<>(creationMetaDataEntry, accessMetaData);
}
if (flags.isEmpty() && ((creationMetaDataEntry != null) || (accessMetaData != null))) {
this.purge(id);
}
return null;
}
use of org.wildfly.clustering.ee.Key in project wildfly by wildfly.
the class InfinispanSessionManager method stop.
@Override
public void stop() {
if (!this.properties.isPersistent()) {
PersistenceConfiguration persistence = this.cache.getCacheConfiguration().persistence();
// Don't passivate sessions on stop if we will purge the store on startup
if (persistence.passivation() && !persistence.stores().stream().allMatch(StoreConfiguration::purgeOnStartup)) {
try (Stream<Key<String>> stream = this.cache.getAdvancedCache().withFlags(Flag.CACHE_MODE_LOCAL, Flag.SKIP_CACHE_LOAD, Flag.SKIP_LOCKING).keySet().stream()) {
stream.filter(SessionCreationMetaDataKeyFilter.INSTANCE).forEach(this.cache::evict);
}
}
}
this.expirationRegistration.close();
if (this.recorder != null) {
this.cache.removeListener(this);
}
this.identifierFactory.stop();
this.contextRegistration.close();
}
Aggregations