public class SimpleMetadataStore extends Object implements ConcurrentMetadataStore
MetadataStore
that uses a ConcurrentMap
for the data store.
The metadata may not be persisted across application restarts, if the provided ConcurrentMap
is an in-memory instance.Constructor and Description |
---|
SimpleMetadataStore()
Instantiate a
SimpleMetadataStore using an in-memory ConcurrentHashMap . |
SimpleMetadataStore(ConcurrentMap<String,String> metadata)
Instantiate a
SimpleMetadataStore using the provided ConcurrentMap . |
Modifier and Type | Method and Description |
---|---|
String |
get(String key)
Reads a value for the given key from this MetadataStore.
|
void |
put(String key,
String value)
Writes a key value pair to this MetadataStore.
|
String |
putIfAbsent(String key,
String value)
Atomically insert the key into the store.
|
String |
remove(String key)
Remove a value for the given key from this MetadataStore.
|
boolean |
replace(String key,
String oldValue,
String newValue)
Atomically replace the value for the key in the store if the old
value matches the oldValue argument.
|
public SimpleMetadataStore()
SimpleMetadataStore
using an in-memory ConcurrentHashMap
.public SimpleMetadataStore(ConcurrentMap<String,String> metadata)
SimpleMetadataStore
using the provided ConcurrentMap
.
The implementation may be a distributed map provided by projects such as Redis and Hazelcast.metadata
- the ConcurrentMap
instance for metadata.public void put(String key, String value)
MetadataStore
put
in interface MetadataStore
key
- The key.value
- The value.public String get(String key)
MetadataStore
get
in interface MetadataStore
key
- The key.public String remove(String key)
MetadataStore
remove
in interface MetadataStore
key
- The key.public String putIfAbsent(String key, String value)
ConcurrentMetadataStore
putIfAbsent
in interface ConcurrentMetadataStore
key
- The key.value
- The value.public boolean replace(String key, String oldValue, String newValue)
ConcurrentMetadataStore
replace
in interface ConcurrentMetadataStore
key
- The key.oldValue
- The old value.newValue
- The new value.