Class RedisResourceMetadataCache

  • All Implemented Interfaces:
    SearchableResourceMetadataCache, org.opennms.newts.cassandra.search.ResourceMetadataCache

    public class RedisResourceMetadataCache
    extends java.lang.Object
    implements SearchableResourceMetadataCache
    A caching strategy that stores the ResourceMetadata in a Redis database. Can be used when the cache needs to be shared amongst several JVMs, or when persistence is required. Note that this cache will operate slower than the GuavaSearchableResourceMetadataCache since it requires network I/O and serialization/deserialization of the associated structures. However, this cache will also operate with significantly less memory. FST is used for serialization instead Java's default implementation.
    Author:
    jwhite
    • Constructor Summary

      Constructors 
      Constructor Description
      RedisResourceMetadataCache​(java.lang.String hostname, java.lang.Integer port, java.lang.Integer numWriterThreads, com.codahale.metrics.MetricRegistry registry, org.opennms.newts.cassandra.search.ResourceIdSplitter resourceIdSplitter)  
    • 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)  
      void merge​(org.opennms.newts.api.Context context, org.opennms.newts.api.Resource resource, org.opennms.newts.cassandra.search.ResourceMetadata metadata)  
      • Methods inherited from class java.lang.Object

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

      • RedisResourceMetadataCache

        @Inject
        public RedisResourceMetadataCache​(@Named("redis.hostname")
                                          java.lang.String hostname,
                                          @Named("redis.port")
                                          java.lang.Integer port,
                                          @Named("newts.writer_threads")
                                          java.lang.Integer numWriterThreads,
                                          @Named("newtsMetricRegistry")
                                          com.codahale.metrics.MetricRegistry registry,
                                          org.opennms.newts.cassandra.search.ResourceIdSplitter resourceIdSplitter)
    • Method Detail

      • 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
      • 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