Package org.apache.solr.common.cloud
Class Aliases
- java.lang.Object
- 
- org.apache.solr.common.cloud.Aliases
 
- 
 public class Aliases extends Object Holds collection aliases -- virtual collections that point to one or more other collections. We might add other types of aliases here some day. Immutable.
- 
- 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AliasescloneWithCollectionAlias(String alias, String collections)Creates a new Aliases instance with the same data as the current one but with a modification based on the parameters.AliasescloneWithCollectionAliasProperties(String alias, String propertiesKey, String propertiesValue)Set the value for some properties on a collection alias.AliasescloneWithCollectionAliasProperties(String alias, Map<String,String> properties)Set the values for some properties keys on a collection alias.AliasescloneWithRename(String before, String after)Rename an alias.static Map<String,List<String>>convertMapOfCommaDelimitedToMapOfList(Map<String,String> collectionAliasMap)static Map<String,String>convertMapOfListToMapOfCommaDelimited(Map<String,List<String>> collectionAliasMap)voidforEachAlias(BiConsumer<String,List<String>> consumer)static AliasesfromJSON(byte[] bytes, int zNodeVersion)Create an instance from the JSON bytes read from zookeeper.Map<String,List<String>>getCollectionAliasListMap()Get a fully parsed map of collection aliases.Map<String,String>getCollectionAliasMap()Get a map similar to the JSON data as stored in zookeeper.Map<String,String>getCollectionAliasProperties(String alias)Returns an unmodifiable Map of properties for a given alias.intgetZNodeVersion()booleanhasAlias(String aliasName)Returns true if an alias is defined, false otherwise.booleanisRoutedAlias(String aliasName)Returns true if an alias exists and is a routed alias, false otherwise.List<String>resolveAliases(String aliasName)List the collections associated with a particular alias.static List<String>resolveAliasesGivenAliasMap(Map<String,List<String>> collectionAliasListMap, String aliasName)StringresolveSimpleAlias(String aliasName)Resolve an alias that points to a single collection.static StringresolveSimpleAliasGivenAliasMap(Map<String,List<String>> collectionAliasListMap, String aliasName)intsize()byte[]toJSON()Serialize our state.StringtoString()
 
- 
- 
- 
Field Detail- 
EMPTYpublic static final Aliases EMPTY An empty, minimal Aliases primarily used to support the non-cloud solr use cases. Not normally useful in cloud situations where the version of the node needs to be tracked even if all aliases are removed. The -1 version makes it subordinate to any real version, and furthermore we never "set" this EMPTY instance into ZK.
 
- 
 - 
Method Detail- 
forEachAliaspublic void forEachAlias(BiConsumer<String,List<String>> consumer) 
 - 
sizepublic int size() 
 - 
fromJSONpublic static Aliases fromJSON(byte[] bytes, int zNodeVersion) Create an instance from the JSON bytes read from zookeeper. Generally this should only be done by a ZkStateReader.- Parameters:
- bytes- The bytes read via a getData request to zookeeper (possibly null)
- zNodeVersion- the version of the data in zookeeper that this instance corresponds to
- Returns:
- A new immutable Aliases object
 
 - 
toJSONpublic byte[] toJSON() Serialize our state.
 - 
convertMapOfCommaDelimitedToMapOfListpublic static Map<String,List<String>> convertMapOfCommaDelimitedToMapOfList(Map<String,String> collectionAliasMap) 
 - 
convertMapOfListToMapOfCommaDelimitedpublic static Map<String,String> convertMapOfListToMapOfCommaDelimited(Map<String,List<String>> collectionAliasMap) 
 - 
getZNodeVersionpublic int getZNodeVersion() 
 - 
getCollectionAliasMappublic Map<String,String> getCollectionAliasMap() Get a map similar to the JSON data as stored in zookeeper. Callers may prefer use ofgetCollectionAliasListMap()instead, if collection names will be iterated.- Returns:
- an unmodifiable Map of collection aliases mapped to a comma delimited string of the collection(s) the alias maps to. Does not return null.
 
 - 
getCollectionAliasListMappublic Map<String,List<String>> getCollectionAliasListMap() Get a fully parsed map of collection aliases.- Returns:
- an unmodifiable Map of collection aliases mapped to a list of the collection(s) the alias maps to. Does not return null.
 
 - 
getCollectionAliasPropertiespublic Map<String,String> getCollectionAliasProperties(String alias) Returns an unmodifiable Map of properties for a given alias. This method will never return null.- Parameters:
- alias- the name of an alias also found as a key in- getCollectionAliasListMap()
- Returns:
- The properties for the alias (possibly empty).
 
 - 
resolveAliasespublic List<String> resolveAliases(String aliasName) List the collections associated with a particular alias. One level of alias indirection is supported (alias to alias to collection). Such indirection may be deprecated in the future, use with caution.- Returns:
- An unmodifiable list of collections names that the input alias name maps to. If there are none, the input is returned.
 
 - 
hasAliaspublic boolean hasAlias(String aliasName) Returns true if an alias is defined, false otherwise.
 - 
isRoutedAliaspublic boolean isRoutedAlias(String aliasName) Returns true if an alias exists and is a routed alias, false otherwise.
 - 
resolveSimpleAliaspublic String resolveSimpleAlias(String aliasName) throws SolrException Resolve an alias that points to a single collection. One level of alias indirection is supported.- Parameters:
- aliasName- alias name
- Returns:
- original name if there's no such alias, or a resolved name. If an alias points to more than 1 collection (directly or indirectly) an exception is thrown
- Throws:
- SolrException- if either direct or indirect alias points to more than 1 name.
 
 - 
resolveSimpleAliasGivenAliasMappublic static String resolveSimpleAliasGivenAliasMap(Map<String,List<String>> collectionAliasListMap, String aliasName) throws SolrException - Throws:
- SolrException
- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
 
 - 
resolveAliasesGivenAliasMappublic static List<String> resolveAliasesGivenAliasMap(Map<String,List<String>> collectionAliasListMap, String aliasName) - NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
 
 - 
cloneWithCollectionAliaspublic Aliases cloneWithCollectionAlias(String alias, String collections) Creates a new Aliases instance with the same data as the current one but with a modification based on the parameters.Note that the state in zookeeper is unaffected by this method and the change must still be persisted via ZkStateReader.AliasesManager#applyModificationAndExportToZk(UnaryOperator)- Parameters:
- alias- the alias to update, must not be null
- collections- the comma separated list of collections for the alias, null to remove the alias
 
 - 
cloneWithRenamepublic Aliases cloneWithRename(String before, String after) throws SolrException Rename an alias. This performs a "deep rename", which changes also the second-level alias lists. Renaming routed aliases is not supported.Note that the state in zookeeper is unaffected by this method and the change must still be persisted via ZkStateReader.AliasesManager#applyModificationAndExportToZk(UnaryOperator)- Parameters:
- before- previous alias name, must not be null
- after- new alias name. If this is null then it's equivalent to calling- cloneWithCollectionAlias(String, String)with the second argument set to null, ie. removing an alias.
- Returns:
- new instance with the renamed alias
- Throws:
- SolrException- when either- beforeor- afteris empty, or the- beforename is a routed alias
 
 - 
cloneWithCollectionAliasPropertiespublic Aliases cloneWithCollectionAliasProperties(String alias, String propertiesKey, String propertiesValue) Set the value for some properties on a collection alias. This is done by creating a new Aliases instance with the same data as the current one but with a modification based on the parameters.Note that the state in zookeeper is unaffected by this method and the change must still be persisted via ZkStateReader.AliasesManager#applyModificationAndExportToZk(UnaryOperator)- Parameters:
- alias- the alias to update
- propertiesKey- the key for the properties
- propertiesValue- the properties to add/replace, null to remove the key.
- Returns:
- An immutable copy of the aliases with the new properties.
 
 - 
cloneWithCollectionAliasPropertiespublic Aliases cloneWithCollectionAliasProperties(String alias, Map<String,String> properties) throws SolrException Set the values for some properties keys on a collection alias. This is done by creating a new Aliases instance with the same data as the current one but with a modification based on the parameters.Note that the state in zookeeper is unaffected by this method and the change must still be persisted via ZkStateReader.AliasesManager#applyModificationAndExportToZk(UnaryOperator)- Parameters:
- alias- the alias to update
- properties- the properties to add/replace, null values in the map will remove the key.
- Returns:
- An immutable copy of the aliases with the new properties.
- Throws:
- SolrException
 
 
- 
 
-