Exemplo n.º 1
0
 private static void CheckSlaveProjectionsStarted(ProjectionManagementMessage.StartSlaveProjections message, ref int counter, Dictionary <string, SlaveProjectionCommunicationChannel[]> result)
 {
     counter--;
     if (counter == 0)
     {
         message.Envelope.ReplyWith(
             new ProjectionManagementMessage.SlaveProjectionsStarted(
                 message.MasterCorrelationId, new SlaveProjectionCommunicationChannels(result)));
     }
 }
Exemplo n.º 2
0
        private void CINP(
            ProjectionManagementMessage.StartSlaveProjections message, SlaveProjectionDefinitions.Definition @group,
            SlaveProjectionCommunicationChannel[] resultArray, int queueIndex, int arrayIndex, Action completed)
        {
            var projectionCorrelationId = Guid.NewGuid();
            var slaveProjectionName     = message.Name + "-" + @group.Name + "-" + queueIndex;
            var initializer             = new NewProjectionInitializer(
                ProjectionQueryId, slaveProjectionName, @group.Mode, @group.HandlerType, @group.Query, true,
                @group.EmitEnabled, @group.CheckpointsEnabled, @group.EnableRunAs, @group.RunAs);

            initializer.CreateAndInitializeNewProjection(
                this, managedProjection =>
            {
                resultArray[arrayIndex] = new SlaveProjectionCommunicationChannel(
                    slaveProjectionName, projectionCorrelationId, managedProjection.SlaveProjectionSubscriptionId,
                    _queues[queueIndex]);
                completed();
            }, projectionCorrelationId, queueIndex, true, message.ResultsPublisher, message.MasterCorrelationId);
        }
Exemplo n.º 3
0
        public void Handle(ProjectionManagementMessage.StartSlaveProjections message)
        {
            var result  = new Dictionary <string, SlaveProjectionCommunicationChannel[]>();
            var counter = 0;

            foreach (var g in message.SlaveProjections.Definitions)
            {
                var @group = g;
                switch (g.RequestedNumber)
                {
                case SlaveProjectionDefinitions.SlaveProjectionRequestedNumber.One:
                case SlaveProjectionDefinitions.SlaveProjectionRequestedNumber.OnePerNode:
                {
                    var resultArray = new SlaveProjectionCommunicationChannel[1];
                    result.Add(g.Name, resultArray);
                    counter++;
                    CINP(
                        message, @group, resultArray, GetNextQueueIndex(), 0,
                        () => CheckSlaveProjectionsStarted(message, ref counter, result));
                    break;
                }

                case SlaveProjectionDefinitions.SlaveProjectionRequestedNumber.OnePerThread:
                {
                    var resultArray = new SlaveProjectionCommunicationChannel[_queues.Length];
                    result.Add(g.Name, resultArray);

                    for (int index = 0; index < _queues.Length; index++)
                    {
                        counter++;
                        CINP(
                            message, @group, resultArray, index, index,
                            () => CheckSlaveProjectionsStarted(message, ref counter, result));
                    }
                    break;
                }

                default:
                    throw new NotSupportedException();
                }
            }
        }