Package org.apache.solr.common.cloud
Class CollectionPropertiesZkStateReader
java.lang.Object
org.apache.solr.common.cloud.CollectionPropertiesZkStateReader
- All Implemented Interfaces:
Closeable,AutoCloseable
Fetches and manages collection properties from a ZooKeeper ensemble
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()getCollectionProperties(String collection, long cacheForMillis) Get and cache collection properties for a given collection.static StringgetCollectionPropsPath(String collection) protected voidvoidregisterCollectionPropsWatcher(String collection, CollectionPropsWatcher propsWatcher) voidremoveCollectionPropsWatcher(String collection, CollectionPropsWatcher watcher)
-
Constructor Details
-
CollectionPropertiesZkStateReader
-
-
Method Details
-
getCollectionProperties
Get and cache collection properties for a given collection. If the collection is watched, or still cached simply return it from the cache, otherwise fetch it directly from zookeeper and retain the value for at least cacheForMillis milliseconds. Cached properties are watched in zookeeper and updated automatically. This version ofgetCollectionPropertiesshould be used when properties need to be consulted frequently in the absence of an activeCollectionPropsWatcher.- Parameters:
collection- The collection for which properties are desiredcacheForMillis- The minimum number of milliseconds to maintain a cache for the specified collection's properties. Setting aCollectionPropsWatcherwill override this value and retain the cache for the life of the watcher. A lack of changes in zookeeper may allow the caching to remain for a greater duration up to the cycle time ofCacheCleaner. Passing zero for this value will explicitly remove the cached copy if and only if it is due to expire and no watch exists. Any positive value will extend the expiration time if required.- Returns:
- a map representing the key/value properties for the collection.
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
registerCollectionPropsWatcher
-
refreshCollectionProperties
protected void refreshCollectionProperties() -
getCollectionPropsPath
-
removeCollectionPropsWatcher
-