Search Results for

    Show / Hide Table of Contents

    Class ConsistentHash<T>

    Consistent Hashing node ring implementation.

    A good explanation of Consistent Hashing: http://weblogs.java.net/blog/tomwhite/archive/2007/11/consistent_hash.html

    Note that toString of the ring nodes are used for the node hash, i.e. make sure it is different for different nodes.

    Inheritance
    object
    ConsistentHash<T>
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Akka.Routing
    Assembly: Akka.dll
    Syntax
    public class ConsistentHash<T>
    Type Parameters
    Name Description
    T

    The type of objects to store in the hash.

    Constructors

    | Edit this page View Source

    ConsistentHash(SortedDictionary<int, T>, int)

    Initializes a new instance of the ConsistentHash<T> class.

    Declaration
    public ConsistentHash(SortedDictionary<int, T> nodes, int virtualNodesFactor)
    Parameters
    Type Name Description
    SortedDictionary<int, T> nodes

    TBD

    int virtualNodesFactor

    TBD

    Exceptions
    Type Condition
    ArgumentException

    This exception is thrown if the given virtualNodesFactor is less than one.

    Properties

    | Edit this page View Source

    IsEmpty

    Check to determine if the node ring is empty (i.e. no nodes added or all removed)

    Declaration
    public bool IsEmpty { get; }
    Property Value
    Type Description
    bool

    Methods

    | Edit this page View Source

    Add(T)

    Adds a node to the hash ring.

    Note that ConsistentHash<T> is immutable and this operation returns a new instance.

    Declaration
    public ConsistentHash<T> Add(T node)
    Parameters
    Type Name Description
    T node

    The node to add to the hash ring

    Returns
    Type Description
    ConsistentHash<T>

    A new instance of this hash ring with the given node added.

    | Edit this page View Source

    NodeFor(byte[])

    Retrieves the node associated with the data key.

    Declaration
    public T NodeFor(byte[] key)
    Parameters
    Type Name Description
    byte[] key

    The data key used for lookup.

    Returns
    Type Description
    T

    The node associated with the data key

    Exceptions
    Type Condition
    InvalidOperationException

    This exception is thrown if the node ring is empty.

    | Edit this page View Source

    NodeFor(string)

    Retrieves the node associated with the data key.

    Declaration
    public T NodeFor(string key)
    Parameters
    Type Name Description
    string key

    The data key used for lookup.

    Returns
    Type Description
    T

    The node associated with the data key

    Exceptions
    Type Condition
    InvalidOperationException

    This exception is thrown if the node ring is empty.

    | Edit this page View Source

    Remove(T)

    Removes a node from the hash ring.

    Note that ConsistentHash<T> is immutable and this operation returns a new instance.

    Declaration
    public ConsistentHash<T> Remove(T node)
    Parameters
    Type Name Description
    T node

    The node to remove from the hash ring

    Returns
    Type Description
    ConsistentHash<T>

    A new instance of this hash ring with the given node removed.

    Operators

    | Edit this page View Source

    operator +(ConsistentHash<T>, T)

    Adds a node to the hash ring.

    Note that ConsistentHash<T> is immutable and this operation returns a new instance.

    Declaration
    public static ConsistentHash<T> operator +(ConsistentHash<T> hash, T node)
    Parameters
    Type Name Description
    ConsistentHash<T> hash

    The hash ring used to derive a new ring with the given node added.

    T node

    The node to add to the hash ring

    Returns
    Type Description
    ConsistentHash<T>

    A new instance of this hash ring with the given node added.

    | Edit this page View Source

    operator -(ConsistentHash<T>, T)

    Removes a node from the hash ring.

    Note that ConsistentHash<T> is immutable and this operation returns a new instance.

    Declaration
    public static ConsistentHash<T> operator -(ConsistentHash<T> hash, T node)
    Parameters
    Type Name Description
    ConsistentHash<T> hash

    The hash ring used to derive a new ring with the given node removed.

    T node

    The node to remove from the hash ring

    Returns
    Type Description
    ConsistentHash<T>

    A new instance of this hash ring with the given node removed.

    Extension Methods

    ObjectExtensions.IsDefaultForType<T>(T)
    ObjectExtensions.AsOption<T>(T)
    Extensions.AsInstanceOf<T>(object)
    In this article
    • githubEdit this page
    • View Source
    Back to top
    Contribute
    • Project Chat
    • Discussion Forum
    • Source Code
    Support
    • Akka.NET Support Plans
    • Akka.NET Observability Tools
    • Akka.NET Training & Consulting
    Maintained By
    • Petabridge - The Akka.NET Company
    • Learn Akka.NET