use of org.infinispan.client.hotrod.MetadataValue in project infinispan by infinispan.
the class NearCacheService method calculateBloomBits.
public byte[] calculateBloomBits() {
if (bloomFilterBits <= 0) {
return null;
}
BloomFilter<byte[]> bloomFilter = MurmurHash3BloomFilter.createFilter(bloomFilterBits);
for (Map.Entry<K, MetadataValue<V>> entry : cache) {
bloomFilter.addToFilter(remote.keyToBytes(entry.getKey()));
}
IntSet intSet = bloomFilter.getIntSet();
return intSet.toBitSet();
}
use of org.infinispan.client.hotrod.MetadataValue in project wildfly by wildfly.
the class SessionManagerNearCacheFactory method onRemoval.
@Override
public void onRemoval(Object key, Object value, RemovalCause cause) {
// Cascade invalidation to dependent entries
if ((cause == RemovalCause.SIZE) && (key instanceof SessionCreationMetaDataKey)) {
String id = ((SessionCreationMetaDataKey) key).getId();
Cache<K, MetadataValue<V>> cache = this.cache.get();
List<Object> keys = new LinkedList<>();
keys.add(new SessionAccessMetaDataKey(id));
switch(this.strategy) {
case COARSE:
{
keys.add(new SessionAttributesKey(id));
break;
}
case FINE:
{
SessionAttributeNamesKey namesKey = new SessionAttributeNamesKey(id);
keys.add(namesKey);
MetadataValue<V> namesValue = cache.getIfPresent(namesKey);
if (namesValue != null) {
@SuppressWarnings("unchecked") Map<String, UUID> names = (Map<String, UUID>) namesValue.getValue();
for (UUID attributeId : names.values()) {
keys.add(new SessionAttributeKey(id, attributeId));
}
}
break;
}
}
cache.invalidateAll(keys);
}
}
use of org.infinispan.client.hotrod.MetadataValue in project infinispan by infinispan.
the class MigrationTask method migrateEntriesWithMetadata.
private void migrateEntriesWithMetadata(RemoteCache<Object, Object> sourceCache, AtomicInteger counter, ExecutorService executorService, Cache<Object, Object> cache) {
AdvancedCache<Object, Object> destinationCache = cache.getAdvancedCache();
DataConversion keyDataConversion = destinationCache.getKeyDataConversion();
DataConversion valueDataConversion = destinationCache.getValueDataConversion();
try (CloseableIterator<Entry<Object, MetadataValue<Object>>> iterator = sourceCache.retrieveEntriesWithMetadata(segments, readBatch)) {
CompletableFuture<?>[] completableFutures = StreamSupport.stream(spliteratorUnknownSize(iterator, 0), false).map(entry -> {
Object key = entry.getKey();
MetadataValue<Object> metadataValue = entry.getValue();
int lifespan = metadataValue.getLifespan();
int maxIdle = metadataValue.getMaxIdle();
long version = metadataValue.getVersion();
Metadata metadata = new EmbeddedMetadata.Builder().version(new NumericVersion(version)).lifespan(lifespan, TimeUnit.SECONDS).maxIdle(maxIdle, TimeUnit.SECONDS).build();
if (!deletedKeys.contains(ByteArrayWrapper.INSTANCE.wrap(key))) {
return CompletableFuture.supplyAsync(() -> {
int currentCount = counter.incrementAndGet();
if (log.isDebugEnabled() && currentCount % 100 == 0)
log.debugf(">> Migrated %s entries\n", currentCount);
return writeToDestinationCache(entry, metadata, keyDataConversion, valueDataConversion);
}, executorService);
}
return CompletableFuture.completedFuture(null);
}).toArray(CompletableFuture[]::new);
CompletableFuture.allOf(completableFutures).join();
}
}
use of org.infinispan.client.hotrod.MetadataValue in project infinispan by infinispan.
the class RemoteStore method publishEntries.
@Override
public Publisher<MarshallableEntry<K, V>> publishEntries(IntSet segments, Predicate<? super K> filter, boolean includeValues) {
// We assume our segments don't map to the remote node when segmentation is disabled
IntSet segmentsToUse = configuration.segmented() ? segments : null;
if (configuration.rawValues()) {
Flowable<Map.Entry<Object, MetadataValue<Object>>> entryFlowable = Flowable.fromPublisher(remoteCache.publishEntriesWithMetadata(segmentsToUse, 512));
if (filter != null) {
entryFlowable = entryFlowable.filter(e -> filter.test(wrap(e.getKey())));
}
return entryFlowable.map(e -> {
MetadataValue<Object> value = e.getValue();
Metadata metadata = new EmbeddedMetadata.Builder().version(new NumericVersion(value.getVersion())).lifespan(value.getLifespan(), TimeUnit.SECONDS).maxIdle(value.getMaxIdle(), TimeUnit.SECONDS).build();
long created = value.getCreated();
long lastUsed = value.getLastUsed();
Object realValue = value.getValue();
return entryFactory.create(wrap(e.getKey()), wrap(realValue), metadata, null, created, lastUsed);
});
} else {
Flowable<Map.Entry<Object, Object>> entryFlowable = Flowable.fromPublisher(remoteCache.publishEntries(null, null, segmentsToUse, 512));
if (filter != null) {
entryFlowable = entryFlowable.filter(e -> filter.test(wrap(e.getKey())));
}
// Technically we will send the metadata and value to the user, no matter what.
return entryFlowable.map(e -> e.getValue() == null ? null : entryFactory.create(wrap(e.getKey()), (MarshalledValue) e.getValue()));
}
}
Aggregations