Search in sources :

Example 1 with MetadataMortalCacheEntry

use of org.infinispan.container.entries.metadata.MetadataMortalCacheEntry in project infinispan by infinispan.

the class InternalEntryFactoryImpl method create.

@Override
public InternalCacheEntry create(Object key, Object value, Metadata metadata) {
    long lifespan = metadata != null ? metadata.lifespan() : -1;
    long maxIdle = metadata != null ? metadata.maxIdle() : -1;
    if (!isStoreMetadata(metadata, null)) {
        if (lifespan < 0 && maxIdle < 0)
            return new ImmortalCacheEntry(key, value);
        if (lifespan > -1 && maxIdle < 0)
            return new MortalCacheEntry(key, value, lifespan, timeService.wallClockTime());
        if (lifespan < 0 && maxIdle > -1)
            return new TransientCacheEntry(key, value, maxIdle, timeService.wallClockTime());
        return new TransientMortalCacheEntry(key, value, maxIdle, lifespan, timeService.wallClockTime());
    } else {
        if (lifespan < 0 && maxIdle < 0)
            return new MetadataImmortalCacheEntry(key, value, metadata);
        if (lifespan > -1 && maxIdle < 0)
            return new MetadataMortalCacheEntry(key, value, metadata, timeService.wallClockTime());
        if (lifespan < 0 && maxIdle > -1)
            return new MetadataTransientCacheEntry(key, value, metadata, timeService.wallClockTime());
        return new MetadataTransientMortalCacheEntry(key, value, metadata, timeService.wallClockTime());
    }
}
Also used : TransientMortalCacheEntry(org.infinispan.container.entries.TransientMortalCacheEntry) MetadataMortalCacheEntry(org.infinispan.container.entries.metadata.MetadataMortalCacheEntry) MortalCacheEntry(org.infinispan.container.entries.MortalCacheEntry) MetadataTransientMortalCacheEntry(org.infinispan.container.entries.metadata.MetadataTransientMortalCacheEntry) ImmortalCacheEntry(org.infinispan.container.entries.ImmortalCacheEntry) MetadataImmortalCacheEntry(org.infinispan.container.entries.metadata.MetadataImmortalCacheEntry) MetadataTransientCacheEntry(org.infinispan.container.entries.metadata.MetadataTransientCacheEntry) MetadataTransientMortalCacheEntry(org.infinispan.container.entries.metadata.MetadataTransientMortalCacheEntry) TransientMortalCacheEntry(org.infinispan.container.entries.TransientMortalCacheEntry) MetadataTransientMortalCacheEntry(org.infinispan.container.entries.metadata.MetadataTransientMortalCacheEntry) MetadataImmortalCacheEntry(org.infinispan.container.entries.metadata.MetadataImmortalCacheEntry) MetadataMortalCacheEntry(org.infinispan.container.entries.metadata.MetadataMortalCacheEntry) TransientCacheEntry(org.infinispan.container.entries.TransientCacheEntry) MetadataTransientCacheEntry(org.infinispan.container.entries.metadata.MetadataTransientCacheEntry)

Example 2 with MetadataMortalCacheEntry

use of org.infinispan.container.entries.metadata.MetadataMortalCacheEntry in project infinispan by infinispan.

the class InternalEntryFactoryImpl method create.

@Override
public // TODO: Do we need this???
InternalCacheEntry create(Object key, Object value, Metadata metadata, long lifespan, long maxIdle) {
    if (!isStoreMetadata(metadata, null)) {
        if (lifespan < 0 && maxIdle < 0)
            return new ImmortalCacheEntry(key, value);
        if (lifespan > -1 && maxIdle < 0)
            return new MortalCacheEntry(key, value, lifespan, timeService.wallClockTime());
        if (lifespan < 0 && maxIdle > -1)
            return new TransientCacheEntry(key, value, maxIdle, timeService.wallClockTime());
        return new TransientMortalCacheEntry(key, value, maxIdle, lifespan, timeService.wallClockTime());
    } else {
        // Metadata to store, take lifespan and maxIdle settings from it
        long metaLifespan = metadata.lifespan();
        long metaMaxIdle = metadata.maxIdle();
        if (metaLifespan < 0 && metaMaxIdle < 0)
            return new MetadataImmortalCacheEntry(key, value, metadata);
        if (metaLifespan > -1 && metaMaxIdle < 0)
            return new MetadataMortalCacheEntry(key, value, metadata, timeService.wallClockTime());
        if (metaLifespan < 0 && metaMaxIdle > -1)
            return new MetadataTransientCacheEntry(key, value, metadata, timeService.wallClockTime());
        return new MetadataTransientMortalCacheEntry(key, value, metadata, timeService.wallClockTime());
    }
}
Also used : TransientMortalCacheEntry(org.infinispan.container.entries.TransientMortalCacheEntry) MetadataMortalCacheEntry(org.infinispan.container.entries.metadata.MetadataMortalCacheEntry) MortalCacheEntry(org.infinispan.container.entries.MortalCacheEntry) MetadataTransientMortalCacheEntry(org.infinispan.container.entries.metadata.MetadataTransientMortalCacheEntry) ImmortalCacheEntry(org.infinispan.container.entries.ImmortalCacheEntry) MetadataImmortalCacheEntry(org.infinispan.container.entries.metadata.MetadataImmortalCacheEntry) MetadataTransientCacheEntry(org.infinispan.container.entries.metadata.MetadataTransientCacheEntry) MetadataTransientMortalCacheEntry(org.infinispan.container.entries.metadata.MetadataTransientMortalCacheEntry) TransientMortalCacheEntry(org.infinispan.container.entries.TransientMortalCacheEntry) MetadataTransientMortalCacheEntry(org.infinispan.container.entries.metadata.MetadataTransientMortalCacheEntry) MetadataImmortalCacheEntry(org.infinispan.container.entries.metadata.MetadataImmortalCacheEntry) MetadataMortalCacheEntry(org.infinispan.container.entries.metadata.MetadataMortalCacheEntry) TransientCacheEntry(org.infinispan.container.entries.TransientCacheEntry) MetadataTransientCacheEntry(org.infinispan.container.entries.metadata.MetadataTransientCacheEntry)

Example 3 with MetadataMortalCacheEntry

use of org.infinispan.container.entries.metadata.MetadataMortalCacheEntry in project infinispan by infinispan.

the class CacheEntrySizeCalculator method calculateSize.

@Override
public long calculateSize(K key, InternalCacheEntry<K, V> ice) {
    // This will be non zero when use expiration, but don't want to store the metadata
    long noMetadataSize = 0;
    boolean metadataAware;
    // ImmortalCacheEntry so it has to come before
    if (ice instanceof MetadataImmortalCacheEntry) {
        metadataAware = true;
    } else if (ice instanceof ImmortalCacheEntry) {
        metadataAware = false;
    } else if (ice instanceof MortalCacheEntry) {
        noMetadataSize += 16;
        metadataAware = false;
    } else if (ice instanceof TransientCacheEntry) {
        noMetadataSize += 16;
        metadataAware = false;
    } else if (ice instanceof TransientMortalCacheEntry) {
        noMetadataSize += 32;
        metadataAware = false;
    } else if (ice instanceof MetadataMortalCacheEntry) {
        metadataAware = true;
    } else if (ice instanceof MetadataTransientCacheEntry) {
        metadataAware = true;
    } else {
        metadataAware = ice instanceof MetadataTransientMortalCacheEntry;
    }
    Metadata metadata;
    if (metadataAware) {
        metadata = ice.getMetadata();
        // We don't support other metadata types currently
        if (!(metadata instanceof EmbeddedMetadata)) {
            metadata = null;
        }
    } else {
        metadata = null;
    }
    long keyValueMetadataSize = calculateSize(key, ice.getValue(), metadata, ice.getInternalMetadata());
    return keyValueMetadataSize + noMetadataSize;
}
Also used : MetadataTransientMortalCacheEntry(org.infinispan.container.entries.metadata.MetadataTransientMortalCacheEntry) MetadataMortalCacheEntry(org.infinispan.container.entries.metadata.MetadataMortalCacheEntry) EmbeddedMetadata(org.infinispan.metadata.EmbeddedMetadata) MetadataImmortalCacheEntry(org.infinispan.container.entries.metadata.MetadataImmortalCacheEntry) MetadataTransientCacheEntry(org.infinispan.container.entries.metadata.MetadataTransientCacheEntry) MetadataTransientMortalCacheEntry(org.infinispan.container.entries.metadata.MetadataTransientMortalCacheEntry) EmbeddedMetadata(org.infinispan.metadata.EmbeddedMetadata) PrivateMetadata(org.infinispan.metadata.impl.PrivateMetadata) Metadata(org.infinispan.metadata.Metadata) MetadataTransientMortalCacheEntry(org.infinispan.container.entries.metadata.MetadataTransientMortalCacheEntry) MetadataImmortalCacheEntry(org.infinispan.container.entries.metadata.MetadataImmortalCacheEntry) MetadataMortalCacheEntry(org.infinispan.container.entries.metadata.MetadataMortalCacheEntry) MetadataTransientCacheEntry(org.infinispan.container.entries.metadata.MetadataTransientCacheEntry)

Example 4 with MetadataMortalCacheEntry

use of org.infinispan.container.entries.metadata.MetadataMortalCacheEntry in project infinispan by infinispan.

the class MetadataMortalCacheEntryExternalizer method readObject.

@Override
public MetadataMortalCacheEntry readObject(ObjectInput input) throws IOException, ClassNotFoundException {
    Object key = input.readObject();
    Object value = input.readObject();
    Metadata metadata = (Metadata) input.readObject();
    long created = UnsignedNumeric.readUnsignedLong(input);
    return new MetadataMortalCacheEntry(key, value, metadata, created);
}
Also used : Metadata(org.infinispan.metadata.Metadata) MetadataMortalCacheEntry(org.infinispan.container.entries.metadata.MetadataMortalCacheEntry)

Aggregations

MetadataMortalCacheEntry (org.infinispan.container.entries.metadata.MetadataMortalCacheEntry)4 MetadataImmortalCacheEntry (org.infinispan.container.entries.metadata.MetadataImmortalCacheEntry)3 MetadataTransientCacheEntry (org.infinispan.container.entries.metadata.MetadataTransientCacheEntry)3 MetadataTransientMortalCacheEntry (org.infinispan.container.entries.metadata.MetadataTransientMortalCacheEntry)3 ImmortalCacheEntry (org.infinispan.container.entries.ImmortalCacheEntry)2 MortalCacheEntry (org.infinispan.container.entries.MortalCacheEntry)2 TransientCacheEntry (org.infinispan.container.entries.TransientCacheEntry)2 TransientMortalCacheEntry (org.infinispan.container.entries.TransientMortalCacheEntry)2 Metadata (org.infinispan.metadata.Metadata)2 EmbeddedMetadata (org.infinispan.metadata.EmbeddedMetadata)1 PrivateMetadata (org.infinispan.metadata.impl.PrivateMetadata)1