public class FilePerKeyValueStore extends Object implements StringBytesStoreKeyValueStore, Closeable
Map implementation that stores each entry as a file in a
directory. The key is the file fullName and the value
is the contents of the file.
The class is effectively an abstraction over a directory in the file system. Therefore when the underlying files are changed an event will be fired to those registered for notifications.
Updates will be fired every time the file is saved but will be suppressed if the value has not changed. To avoid temporary files (e.g. if edited in vi) being included in the map, any file starting with a '.' will be ignored.
Note the WatchService is extremely OS dependant. Mas OSX registers
very few events if they are done quickly and there is a significant delay
between the event and the event being triggered.
KeyValueStore.Entry<K,V>| Constructor and Description |
|---|
FilePerKeyValueStore(RequestContext context,
Asset asset) |
| Modifier and Type | Method and Description |
|---|---|
void |
accept(EngineReplication.ReplicationEntry replicationEntry) |
Asset |
asset() |
void |
clear() |
void |
close() |
boolean |
containsValue(net.openhft.chronicle.bytes.Bytes value) |
void |
entriesFor(int segment,
SubscriptionConsumer<MapEvent<String,net.openhft.chronicle.bytes.BytesStore>> kvConsumer) |
Iterator<Map.Entry<String,net.openhft.chronicle.bytes.BytesStore>> |
entrySetIterator() |
net.openhft.chronicle.bytes.BytesStore |
getAndPut(String key,
net.openhft.chronicle.bytes.BytesStore value) |
net.openhft.chronicle.bytes.BytesStore |
getAndRemove(String key) |
java.util.stream.Stream<Map.Entry<String,net.openhft.chronicle.bytes.BytesStore>> |
getEntryStream() |
net.openhft.chronicle.bytes.BytesStore |
getUsing(String key,
net.openhft.chronicle.bytes.Bytes value) |
Iterator<String> |
keySetIterator() |
void |
keysFor(int segment,
SubscriptionConsumer<String> stringConsumer) |
long |
longSize() |
boolean |
put(String key,
net.openhft.chronicle.bytes.BytesStore value)
put an entry
|
boolean |
remove(String key)
remove a key
|
RawKVSSubscription<String,net.openhft.chronicle.bytes.Bytes,net.openhft.chronicle.bytes.BytesStore> |
subscription(boolean createIfAbsent) |
KeyValueStore<String,net.openhft.chronicle.bytes.Bytes,net.openhft.chronicle.bytes.BytesStore> |
underlying() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcontainsKey, get, isKeyType, isReadOnly, keyedView, putIfAbsent, removeIfEqual, replace, replaceIfEqual, segmentFor, segments, valuesIteratorandThenpublic FilePerKeyValueStore(@NotNull
RequestContext context,
@NotNull
Asset asset)
throws net.openhft.chronicle.bytes.IORuntimeException
net.openhft.chronicle.bytes.IORuntimeException@NotNull public RawKVSSubscription<String,net.openhft.chronicle.bytes.Bytes,net.openhft.chronicle.bytes.BytesStore> subscription(boolean createIfAbsent)
subscription in interface SubscriptionKeyValueStore<String,net.openhft.chronicle.bytes.Bytes,net.openhft.chronicle.bytes.BytesStore>public long longSize()
longSize in interface KeyValueStore<String,net.openhft.chronicle.bytes.Bytes,net.openhft.chronicle.bytes.BytesStore>@Nullable public net.openhft.chronicle.bytes.BytesStore getUsing(String key, net.openhft.chronicle.bytes.Bytes value)
getUsing in interface KeyValueStore<String,net.openhft.chronicle.bytes.Bytes,net.openhft.chronicle.bytes.BytesStore>public void keysFor(int segment,
@NotNull
SubscriptionConsumer<String> stringConsumer)
keysFor in interface KeyValueStore<String,net.openhft.chronicle.bytes.Bytes,net.openhft.chronicle.bytes.BytesStore>public void entriesFor(int segment,
@NotNull
SubscriptionConsumer<MapEvent<String,net.openhft.chronicle.bytes.BytesStore>> kvConsumer)
throws InvalidSubscriberException
entriesFor in interface KeyValueStore<String,net.openhft.chronicle.bytes.Bytes,net.openhft.chronicle.bytes.BytesStore>InvalidSubscriberExceptionpublic Iterator<String> keySetIterator()
keySetIterator in interface KeyValueStore<String,net.openhft.chronicle.bytes.Bytes,net.openhft.chronicle.bytes.BytesStore>public Iterator<Map.Entry<String,net.openhft.chronicle.bytes.BytesStore>> entrySetIterator()
entrySetIterator in interface KeyValueStore<String,net.openhft.chronicle.bytes.Bytes,net.openhft.chronicle.bytes.BytesStore>public java.util.stream.Stream<Map.Entry<String,net.openhft.chronicle.bytes.BytesStore>> getEntryStream()
public boolean put(String key, @NotNull net.openhft.chronicle.bytes.BytesStore value)
KeyValueStoreput in interface KeyValueStore<String,net.openhft.chronicle.bytes.Bytes,net.openhft.chronicle.bytes.BytesStore>key - to setvalue - to set@Nullable public net.openhft.chronicle.bytes.BytesStore getAndPut(String key, @NotNull net.openhft.chronicle.bytes.BytesStore value)
getAndPut in interface KeyValueStore<String,net.openhft.chronicle.bytes.Bytes,net.openhft.chronicle.bytes.BytesStore>@Nullable public net.openhft.chronicle.bytes.BytesStore getAndRemove(String key)
getAndRemove in interface KeyValueStore<String,net.openhft.chronicle.bytes.Bytes,net.openhft.chronicle.bytes.BytesStore>public boolean remove(String key)
KeyValueStoreremove in interface KeyValueStore<String,net.openhft.chronicle.bytes.Bytes,net.openhft.chronicle.bytes.BytesStore>key - to removepublic void clear()
clear in interface KeyValueStore<String,net.openhft.chronicle.bytes.Bytes,net.openhft.chronicle.bytes.BytesStore>public boolean containsValue(net.openhft.chronicle.bytes.Bytes value)
containsValue in interface KeyValueStore<String,net.openhft.chronicle.bytes.Bytes,net.openhft.chronicle.bytes.BytesStore>public void close()
close in interface Closeableclose in interface AutoCloseablepublic Asset asset()
asset in interface Assetted<KeyValueStore<String,net.openhft.chronicle.bytes.Bytes,net.openhft.chronicle.bytes.BytesStore>>@Nullable public KeyValueStore<String,net.openhft.chronicle.bytes.Bytes,net.openhft.chronicle.bytes.BytesStore> underlying()
underlying in interface Assetted<KeyValueStore<String,net.openhft.chronicle.bytes.Bytes,net.openhft.chronicle.bytes.BytesStore>>public void accept(EngineReplication.ReplicationEntry replicationEntry)
accept in interface java.util.function.Consumer<EngineReplication.ReplicationEntry>Copyright © 2015. All rights reserved.