private void Process(PersistentQueueMessage message)
        {
            HostStartedMessage hostStartedMessage = message as HostStartedMessage;

            if (hostStartedMessage != null)
            {
                _hostIndexer.ProcessHostStarted(hostStartedMessage);
                return;
            }

            FunctionCompletedMessage functionCompletedMessage = message as FunctionCompletedMessage;

            if (functionCompletedMessage != null)
            {
                _functionIndexer.ProcessFunctionCompleted(functionCompletedMessage);
                return;
            }

            FunctionStartedMessage functionStartedMessage = message as FunctionStartedMessage;

            if (functionStartedMessage != null)
            {
                _functionIndexer.ProcessFunctionStarted(functionStartedMessage);
                return;
            }

            string errorMessage = String.Format(CultureInfo.InvariantCulture, "Unknown message type '{0}'.", message.Type);
            throw new InvalidOperationException(errorMessage);
        }
示例#2
0
        private void Process(PersistentQueueMessage message)
        {
            HostStartedMessage hostStartedMessage = message as HostStartedMessage;

            if (hostStartedMessage != null)
            {
                _hostIndexer.ProcessHostStarted(hostStartedMessage);
                return;
            }

            FunctionCompletedMessage functionCompletedMessage = message as FunctionCompletedMessage;

            if (functionCompletedMessage != null)
            {
                _functionIndexer.ProcessFunctionCompleted(functionCompletedMessage);
                return;
            }

            FunctionStartedMessage functionStartedMessage = message as FunctionStartedMessage;

            if (functionStartedMessage != null)
            {
                _functionIndexer.ProcessFunctionStarted(functionStartedMessage);
                return;
            }

            string errorMessage =
                String.Format(CultureInfo.InvariantCulture, "Unknown message type '{0}'.", message.Type);

            throw new InvalidOperationException(errorMessage);
        }
        public void JsonConvertRepeatedIdenticalChildConverterType_Roundtrips()
        {
            // Arrange
            HostStartedMessage expectedMessage = new HostStartedMessage
            {
                Functions = new FunctionDescriptor[]
                {
                    new FunctionDescriptor
                    {
                        Parameters = new ParameterDescriptor[]
                        {
                            new CallerSuppliedParameterDescriptor {
                                Name = "A"
                            },
                            new CallerSuppliedParameterDescriptor {
                                Name = "B"
                            }
                        }
                    }
                }
            };

            // Act
            PersistentQueueMessage message = JsonConvert.DeserializeObject <PersistentQueueMessage>(
                JsonConvert.SerializeObject(expectedMessage));

            // Assert
            Assert.NotNull(message);
            Assert.IsType <HostStartedMessage>(message);
            HostStartedMessage  typedMessage    = (HostStartedMessage)message;
            ParameterDescriptor secondChildItem = typedMessage.Functions.Single().Parameters.FirstOrDefault(p => p.Name == "B");

            Assert.IsType <CallerSuppliedParameterDescriptor>(secondChildItem);
        }
示例#4
0
        private void UpdateCore()
        {
            PersistentQueueMessage message = _queueReader.Dequeue();

            while (message != null)
            {
                Process(message);
                _queueReader.Delete(message);

                message = _queueReader.Dequeue();
            }
        }
        private IConcurrentDocument <DashboardVersion> StartRestoringArchive(IConcurrentDocument <DashboardVersion> version)
        {
            const int IndexerPollIntervalMilliseconds = 5000;

            _dashboardVersionManager.StartRestoringArchive(version.ETag);

            PersistentQueueMessage message = _upgradeQueueReader.Dequeue();

            int count = 0;

            do
            {
                while (message != null)
                {
                    version = _dashboardVersionManager.Read();
                    if (version.Document.UpgradeState != DashboardUpgradeState.RestoringArchive)
                    {
                        _upgradeQueueReader.TryMakeItemVisible(message);
                        return(version);
                    }

                    // Delete auto-"archives" from host-archive back to host-output.
                    _upgradeQueueReader.Delete(message);

                    message = _upgradeQueueReader.Dequeue();
                }

                version = _dashboardVersionManager.Read();
                if (version.Document.UpgradeState != DashboardUpgradeState.RestoringArchive)
                {
                    return(version);
                }

                // Get items left
                // while limiting pagination to first page since we're only interested in
                // knowing if we're out of items.
                count = _upgradeQueueReader.Count(1);
                if (count > 0)
                {
                    // wait for a while before resuming
                    Thread.Sleep(IndexerPollIntervalMilliseconds);
                }
            }while (count > 0);

            return(version);
        }