Interface PropStore
-
- All Known Implementing Classes:
ZooPropStore
public interface PropStore
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidcreate(PropStoreKey<?> propStoreKey, Map<String,String> props)Create an initial entry for the PropCacheId.voiddelete(PropStoreKey<?> propStoreKey)Delete the store node from the underlying store.booleanexists(PropStoreKey<?> propStoreKey)Test that a node for properties exists without throwing a KeeperException.@NonNull VersionedPropertiesget(PropStoreKey<?> propCacheId)PropCachegetCache()@Nullable VersionedPropertiesgetIfCached(PropStoreKey<?> propStoreKey)voidputAll(PropStoreKey<?> propStoreKey, Map<String,String> props)Adds or updates current properties.voidregisterAsListener(PropStoreKey<?> propStoreKey, PropChangeListener listener)External processes can register for notifications if the properties change.voidremoveProperties(PropStoreKey<?> propStoreKey, Collection<String> keys)Deletes individual properties specified by the set of keys.voidreplaceAll(PropStoreKey<?> propStoreKey, long version, Map<String,String> props)Replaces all current properties with map provided.booleanvalidateDataVersion(PropStoreKey<?> storeKey, long expectedVersion)Compare the stored data version with the expected version.
-
-
-
Method Detail
-
exists
boolean exists(PropStoreKey<?> propStoreKey)
Test that a node for properties exists without throwing a KeeperException.- Parameters:
propStoreKey- the prop cache key- Returns:
- true if the property node exists, false otherwise.
- Throws:
IllegalStateException- if the check fails due to interrupt.
-
create
void create(PropStoreKey<?> propStoreKey, Map<String,String> props)
Create an initial entry for the PropCacheId. If properties already exist, they are not modified.- Parameters:
propStoreKey- the prop cache keyprops- a map of property k,v pairs- Throws:
IllegalStateException- if the updates fails because of an underlying store exception
-
get
@NonNull VersionedProperties get(PropStoreKey<?> propCacheId)
- Parameters:
propCacheId- the prop cache key- Returns:
- The versioned properties.
- Throws:
IllegalStateException- if the updates fails because of an underlying store exception or if the properties do not exist for the propCacheId
-
putAll
void putAll(PropStoreKey<?> propStoreKey, Map<String,String> props)
Adds or updates current properties. If the property currently exists it is overwritten, otherwise it is added.- Parameters:
propStoreKey- the prop cache keyprops- a map of property k,v pairs- Throws:
IllegalStateException- if the values cannot be written or if an underlying store exception occurs.
-
replaceAll
void replaceAll(PropStoreKey<?> propStoreKey, long version, Map<String,String> props) throws ConcurrentModificationException
Replaces all current properties with map provided. If a property is not included in the new map, the property will not be set.- Parameters:
propStoreKey- the prop cache keyversion- the version of the propertiesprops- a map of property k,v pairs- Throws:
IllegalStateException- if the values cannot be written or if an underlying store exception occurs.ConcurrentModificationException- if the properties changed since reading and can not be modified
-
delete
void delete(PropStoreKey<?> propStoreKey)
Delete the store node from the underlying store.- Parameters:
propStoreKey- the prop cache key- Throws:
IllegalStateException- if the updates fails because of an underlying store exception
-
removeProperties
void removeProperties(PropStoreKey<?> propStoreKey, Collection<String> keys)
Deletes individual properties specified by the set of keys.- Parameters:
propStoreKey- the prop cache keykeys- a set of keys.- Throws:
IllegalStateException- if the values cannot be deleted or if an underlying store exception occurs.
-
registerAsListener
void registerAsListener(PropStoreKey<?> propStoreKey, PropChangeListener listener)
External processes can register for notifications if the properties change. Normally processes can read from the store and always receive the current snapshot of the latest values. However, it the process wants to take an active action on change detections, then they can register and receive notifications.Implementation detail - the notification occurs on a separate thread from the underlying store, but listeners should not perform lengthy operations on the notification to prevent delaying other listeners from receive timely notification of the changes detected.
- Parameters:
propStoreKey- the prop cache keylistener- a listener
-
getCache
PropCache getCache()
-
getIfCached
@Nullable VersionedProperties getIfCached(PropStoreKey<?> propStoreKey)
-
validateDataVersion
boolean validateDataVersion(PropStoreKey<?> storeKey, long expectedVersion)
Compare the stored data version with the expected version. Notifies subscribers of the change detection.- Parameters:
storeKey- specifies key for backend storeexpectedVersion- the expected data version- Returns:
- true if the stored version matches the provided expected version.
-
-