Class GuavaSearchableResourceMetadataCache

  • All Implemented Interfaces:
    com.google.common.cache.RemovalListener<java.lang.String,​org.opennms.newts.cassandra.search.ResourceMetadata>, SearchableResourceMetadataCache, org.opennms.newts.cassandra.search.ResourceMetadataCache

    public class GuavaSearchableResourceMetadataCache
    extends java.lang.Object
    implements SearchableResourceMetadataCache, com.google.common.cache.RemovalListener<java.lang.String,​org.opennms.newts.cassandra.search.ResourceMetadata>
    A copy of GuavaResourceMetadataCache 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 a RemovalListener.
    Author:
    jwhite
    • 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)  
      java.util.List<java.lang.String> getResourceIdsWithPrefix​(org.opennms.newts.api.Context context, java.lang.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<java.lang.String,​org.opennms.newts.cassandra.search.ResourceMetadata> notification)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GuavaSearchableResourceMetadataCache

        @Inject
        public GuavaSearchableResourceMetadataCache​(@Named("search.resourceMetadata.maxCacheEntries")
                                                    long maxSize,
                                                    @Named("newtsMetricRegistry")
                                                    com.codahale.metrics.MetricRegistry registry)
    • 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 interface org.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 interface org.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 interface org.opennms.newts.cassandra.search.ResourceMetadataCache
      • onRemoval

        public void onRemoval​(com.google.common.cache.RemovalNotification<java.lang.String,​org.opennms.newts.cassandra.search.ResourceMetadata> notification)
        Specified by:
        onRemoval in interface com.google.common.cache.RemovalListener<java.lang.String,​org.opennms.newts.cassandra.search.ResourceMetadata>
      • getSize

        public long getSize()