Class 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.
    • Field Detail

      • EMPTY

        public 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

      • fromJSON

        public 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
      • toJSON

        public byte[] toJSON()
        Serialize our state.
      • getZNodeVersion

        public int getZNodeVersion()
      • getCollectionAliasMap

        public Map<String,​String> getCollectionAliasMap()
        Get a map similar to the JSON data as stored in zookeeper. Callers may prefer use of getCollectionAliasListMap() 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.
      • getCollectionAliasListMap

        public 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.
      • getCollectionAliasProperties

        public Map<String,​String> getCollectionAliasProperties​(String alias)
        Returns an unmodifiable Map of properties for a given alias. If an alias by the given name exists, 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) or null if the alias does not exist.
      • resolveAliases

        public 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.
      • resolveAliasesGivenAliasMap

        public 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.
      • cloneWithCollectionAlias

        public 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
      • cloneWithCollectionAliasProperties

        public 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.
      • cloneWithCollectionAliasProperties

        public Aliases cloneWithCollectionAliasProperties​(String alias,
                                                          Map<String,​String> properties)
        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.