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 ofGuavaResourceMetadataCache
with 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 void
delete(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)
long
getSize()
void
merge(org.opennms.newts.api.Context context, org.opennms.newts.api.Resource resource, org.opennms.newts.cassandra.search.ResourceMetadata metadata)
void
onRemoval(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:
get
in interfaceorg.opennms.newts.cassandra.search.ResourceMetadataCache
-
delete
public void delete(org.opennms.newts.api.Context context, org.opennms.newts.api.Resource resource)
- Specified by:
delete
in 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:
merge
in interfaceorg.opennms.newts.cassandra.search.ResourceMetadataCache
-
getResourceIdsWithPrefix
public List<String> getResourceIdsWithPrefix(org.opennms.newts.api.Context context, String resourceIdPrefix)
- Specified by:
getResourceIdsWithPrefix
in interfaceSearchableResourceMetadataCache
-
onRemoval
public void onRemoval(com.google.common.cache.RemovalNotification<String,org.opennms.newts.cassandra.search.ResourceMetadata> notification)
- Specified by:
onRemoval
in interfacecom.google.common.cache.RemovalListener<String,org.opennms.newts.cassandra.search.ResourceMetadata>
-
getSize
public long getSize()
-
-