Example #1
0
        public ScaleoutStreamManager(Func <int, IList <Message>, Task> send,
                                     Action <int, ulong, ScaleoutMessage> receive,
                                     int streamCount,
                                     TraceSource trace,
                                     IPerformanceCounterManager performanceCounters,
                                     ScaleoutConfiguration configuration,
                                     int maxScaleoutMappings)
        {
            if (configuration.QueueBehavior != QueuingBehavior.Disabled && configuration.MaxQueueLength == 0)
            {
                throw new InvalidOperationException(Resources.Error_ScaleoutQueuingConfig);
            }

            _streams = new ScaleoutStream[streamCount];
            _send    = send;
            _receive = receive;

            var receiveMapping = new ScaleoutMappingStore[streamCount];

            performanceCounters.ScaleoutStreamCountTotal.RawValue     = streamCount;
            performanceCounters.ScaleoutStreamCountBuffering.RawValue = streamCount;
            performanceCounters.ScaleoutStreamCountOpen.RawValue      = 0;

            for (int i = 0; i < streamCount; i++)
            {
                _streams[i]       = new ScaleoutStream(trace, "Stream(" + i + ")", configuration.QueueBehavior, configuration.MaxQueueLength, performanceCounters);
                receiveMapping[i] = new ScaleoutMappingStore(maxScaleoutMappings);
            }

            Streams = new ReadOnlyCollection <ScaleoutMappingStore>(receiveMapping);
        }
Example #2
0
 public SendContext(ScaleoutStream stream, Func <object, Task> send, object state)
 {
     Stream = stream;
     TaskCompletionSource = new DispatchingTaskCompletionSource <object>();
     _send  = send;
     _state = state;
 }