Exemplo n.º 1
0
        /// <summary>
        /// Create a subscriptionId that is unique per grainId, grainType, namespace combination.
        /// </summary>
        /// <param name="grainIdTypeCode"></param>
        /// <param name="streamId"></param>
        /// <returns></returns>
        private Guid MakeSubscriptionGuid(int grainIdTypeCode, StreamId streamId)
        {
            // next 2 shorts ing guid are from namespace hash
            int namespaceHash = streamId.Namespace.GetHashCode();

            byte[] namespaceHashByes = BitConverter.GetBytes(namespaceHash);
            short  s1 = BitConverter.ToInt16(namespaceHashByes, 0);
            short  s2 = BitConverter.ToInt16(namespaceHashByes, 2);

            // Tailing 8 bytes of the guid are from the hash of the streamId Guid and a hash of the full streamId.

            // get streamId guid hash code
            int streamIdGuidHash = streamId.Guid.GetHashCode();
            // get full streamId hash code
            int streamIdHash = streamId.GetHashCode();

            // build guid tailing 8 bytes from grainIdHash and the hash of the full streamId.
            var tail = new List <byte>();

            tail.AddRange(BitConverter.GetBytes(streamIdGuidHash));
            tail.AddRange(BitConverter.GetBytes(streamIdHash));

            // make guid.
            // - First int is grain type
            // - Two shorts from namespace hash
            // - 8 byte tail from streamId Guid and full stream hash.
            return(SubscriptionMarker.MarkAsImplictSubscriptionId(new Guid(grainIdTypeCode, s1, s2, tail.ToArray())));
        }
Exemplo n.º 2
0
 public override int GetHashCode()
 {
     // This code was auto-generated by ReSharper
     unchecked
     {
         return(((Stream != null ? Stream.GetHashCode() : 0) * 397) ^ (Producer != null ? Producer.GetHashCode() : 0));
     }
 }
Exemplo n.º 3
0
 public override int GetHashCode()
 {
     return(streamId.GetHashCode());
 }
Exemplo n.º 4
0
 /// <inheritdoc/>
 public QueueId GetQueueForStream(StreamId streamId)
 {
     return(hashRing.CalculateResponsible((uint)streamId.GetHashCode()));
 }