Package org.apache.solr.common.cloud
Class CollectionPropertiesZkStateReader
- java.lang.Object
-
- org.apache.solr.common.cloud.CollectionPropertiesZkStateReader
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public class CollectionPropertiesZkStateReader extends Object implements Closeable
Fetches and manages collection properties from a ZooKeeper ensemble
-
-
Constructor Summary
Constructors Constructor Description CollectionPropertiesZkStateReader(ZkStateReader zkStateReader)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Map<String,String>
getCollectionProperties(String collection, long cacheForMillis)
Get and cache collection properties for a given collection.static String
getCollectionPropsPath(String collection)
protected void
refreshCollectionProperties()
void
registerCollectionPropsWatcher(String collection, CollectionPropsWatcher propsWatcher)
void
removeCollectionPropsWatcher(String collection, CollectionPropsWatcher watcher)
-
-
-
Constructor Detail
-
CollectionPropertiesZkStateReader
public CollectionPropertiesZkStateReader(ZkStateReader zkStateReader)
-
-
Method Detail
-
getCollectionProperties
public Map<String,String> getCollectionProperties(String collection, long cacheForMillis)
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 ofgetCollectionProperties
should 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 aCollectionPropsWatcher
will 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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
registerCollectionPropsWatcher
public void registerCollectionPropsWatcher(String collection, CollectionPropsWatcher propsWatcher)
-
refreshCollectionProperties
protected void refreshCollectionProperties()
-
removeCollectionPropsWatcher
public void removeCollectionPropsWatcher(String collection, CollectionPropsWatcher watcher)
-
-