Package org.opennms.netmgt.newts.support
Class GuavaSearchableResourceMetadataCache
- java.lang.Object
-
- org.opennms.netmgt.newts.support.GuavaSearchableResourceMetadataCache
-
- All Implemented Interfaces:
com.google.common.cache.RemovalListener<String,org.opennms.newts.cassandra.search.ResourceMetadata>,SearchableResourceMetadataCache,org.opennms.newts.cassandra.search.ResourceMetadataCache
public class GuavaSearchableResourceMetadataCache extends Object implements SearchableResourceMetadataCache, com.google.common.cache.RemovalListener<String,org.opennms.newts.cassandra.search.ResourceMetadata>
A copy ofGuavaResourceMetadataCachewith support for searching resources within the cache. Cached entries are maintained two structures, a Guava Cache and a Radix Tree. The main caching functionality is provided by the Guava Cache and the Radix Tree is used for searching by prefix. The additional memory usage should be minimal since we only need to duplicate the keys, the nodes references the same objects. Both structures are kept in synch via aRemovalListener.- Author:
- jwhite
-
-
Constructor Summary
Constructors Constructor Description GuavaSearchableResourceMetadataCache(long maxSize, com.codahale.metrics.MetricRegistry registry)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddelete(org.opennms.newts.api.Context context, org.opennms.newts.api.Resource resource)com.google.common.base.Optional<org.opennms.newts.cassandra.search.ResourceMetadata>get(org.opennms.newts.api.Context context, org.opennms.newts.api.Resource resource)List<String>getResourceIdsWithPrefix(org.opennms.newts.api.Context context, String resourceIdPrefix)longgetSize()voidmerge(org.opennms.newts.api.Context context, org.opennms.newts.api.Resource resource, org.opennms.newts.cassandra.search.ResourceMetadata metadata)voidonRemoval(com.google.common.cache.RemovalNotification<String,org.opennms.newts.cassandra.search.ResourceMetadata> notification)
-
-
-
Method Detail
-
get
public com.google.common.base.Optional<org.opennms.newts.cassandra.search.ResourceMetadata> get(org.opennms.newts.api.Context context, org.opennms.newts.api.Resource resource)- Specified by:
getin interfaceorg.opennms.newts.cassandra.search.ResourceMetadataCache
-
delete
public void delete(org.opennms.newts.api.Context context, org.opennms.newts.api.Resource resource)- Specified by:
deletein interfaceorg.opennms.newts.cassandra.search.ResourceMetadataCache
-
merge
public void merge(org.opennms.newts.api.Context context, org.opennms.newts.api.Resource resource, org.opennms.newts.cassandra.search.ResourceMetadata metadata)- Specified by:
mergein interfaceorg.opennms.newts.cassandra.search.ResourceMetadataCache
-
getResourceIdsWithPrefix
public List<String> getResourceIdsWithPrefix(org.opennms.newts.api.Context context, String resourceIdPrefix)
- Specified by:
getResourceIdsWithPrefixin interfaceSearchableResourceMetadataCache
-
onRemoval
public void onRemoval(com.google.common.cache.RemovalNotification<String,org.opennms.newts.cassandra.search.ResourceMetadata> notification)
- Specified by:
onRemovalin interfacecom.google.common.cache.RemovalListener<String,org.opennms.newts.cassandra.search.ResourceMetadata>
-
getSize
public long getSize()
-
-