public class StringMetadataCache extends Object implements LruMap.CacheEvictionCallback<String,org.apache.storm.metricstore.rocksdb.StringMetadata>, WritableStringMetadataCache, ReadOnlyStringMetadataCache
All write operations adding metadata to RocksDB are done by a single thread (a RocksDbMetricsWriter), but multiple threads can read values from the cache. To clarify which permissions are accessible by various threads, the ReadOnlyStringMetadataCache and WritableStringMetadataCache are provided to be used.
Modifier and Type | Method and Description |
---|---|
boolean |
contains(Integer stringId)
Determines if a string Id is contained in the cache.
|
Set<Map.Entry<String,org.apache.storm.metricstore.rocksdb.StringMetadata>> |
entrySet()
Get the map of the cache contents.
|
void |
evictionCallback(String key,
org.apache.storm.metricstore.rocksdb.StringMetadata val)
Callback when data is about to be removed from the cache.
|
org.apache.storm.metricstore.rocksdb.StringMetadata |
get(String s)
Get the string metadata from the cache.
|
String |
getMetadataString(Integer stringId)
Returns the string matching the string Id if in the cache.
|
void |
put(String s,
org.apache.storm.metricstore.rocksdb.StringMetadata stringMetadata,
boolean newEntry)
Add the string metadata to the cache.
|
public org.apache.storm.metricstore.rocksdb.StringMetadata get(String s)
get
in interface ReadOnlyStringMetadataCache
s
- The string to look forpublic void put(String s, org.apache.storm.metricstore.rocksdb.StringMetadata stringMetadata, boolean newEntry) throws MetricException
NOTE: this can cause data to be evicted from the cache when full. When this occurs, the evictionCallback() method is called to store the metadata back into the RocksDB database.
This method is only exposed to the WritableStringMetadataCache interface.
put
in interface WritableStringMetadataCache
s
- The string to addstringMetadata
- The string's metadatanewEntry
- Indicates the metadata is being used for the first time and should be written to RocksDB immediatelyMetricException
- when evicted data fails to save to the database or when the database is shutdownpublic void evictionCallback(String key, org.apache.storm.metricstore.rocksdb.StringMetadata val)
evictionCallback
in interface LruMap.CacheEvictionCallback<String,org.apache.storm.metricstore.rocksdb.StringMetadata>
key
- The evicted stringval
- The evicted string's metadataRuntimeException
- when evicted data fails to save to the databasepublic boolean contains(Integer stringId)
contains
in interface ReadOnlyStringMetadataCache
stringId
- The string Id to checkpublic String getMetadataString(Integer stringId)
getMetadataString
in interface ReadOnlyStringMetadataCache
stringId
- The string Id to checkpublic Set<Map.Entry<String,org.apache.storm.metricstore.rocksdb.StringMetadata>> entrySet()
entrySet
in interface WritableStringMetadataCache
Copyright © 2023 The Apache Software Foundation. All rights reserved.