Ejemplo n.º 1
0
        public HashRingBasedStreamQueueMapper(int nQueues, string queueNamePrefix)
        {
            numQueues = nQueues;
            var queueIds = new List <QueueId>(numQueues);

            if (nQueues == 1)
            {
                uint uniformHashCode = 0;
                queueIds.Add(QueueId.GetQueueId(queueNamePrefix, 0, uniformHashCode));
            }
            else
            {
                uint portion = checked ((uint)(RangeFactory.RING_SIZE / numQueues + 1));
                for (uint i = 0; i < numQueues; i++)
                {
                    uint uniformHashCode = checked (portion * i);
                    queueIds.Add(QueueId.GetQueueId(queueNamePrefix, i, uniformHashCode));
                }
            }
            this.hashRing = new HashRing <QueueId>(queueIds);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HashRingBasedStreamQueueMapper"/> class.
        /// </summary>
        /// <param name="options">The options.</param>
        /// <param name="queueNamePrefix">The queue name prefix.</param>
        public HashRingBasedStreamQueueMapper(HashRingStreamQueueMapperOptions options, string queueNamePrefix)
        {
            var numQueues = options.TotalQueueCount;
            var queueIds  = new QueueId[numQueues];

            if (numQueues == 1)
            {
                queueIds[0] = QueueId.GetQueueId(queueNamePrefix, 0, 0);
            }
            else
            {
                uint portion = checked ((uint)(RangeFactory.RING_SIZE / numQueues + 1));
                for (uint i = 0; i < numQueues; i++)
                {
                    uint uniformHashCode = checked (portion * i);
                    queueIds[i] = QueueId.GetQueueId(queueNamePrefix, i, uniformHashCode);
                }
            }

            this.hashRing = new HashRing <QueueId>(queueIds);
        }