Ejemplo n.º 1
0
        public MessageEntranceTest()
        {
            this.PlatformMessageInQueue = new PlatformMessage()
            {
                Command = new ScrapyCore.Core.Platform.Commands.Command()
                {
                    CommandCode = ScrapyCore.Core.Platform.Commands.CommandCode.Configure,
                    CommandType = ScrapyCore.Core.Platform.Commands.CommandTransfer.Random
                }
            };
            this.PlatformMessageInMemory = new PlatformMessage()
            {
                Command = new ScrapyCore.Core.Platform.Commands.Command()
                {
                    CommandCode = ScrapyCore.Core.Platform.Commands.CommandCode.HeartBeat,
                    CommandType = ScrapyCore.Core.Platform.Commands.CommandTransfer.Forward
                }
            };

            IMessageQueueHandler <PlatformMessage> messageQueueHandler = Moq.Mock.Of <IMessageQueueHandler <PlatformMessage> >();

            Moq.Mock.Get(messageQueueHandler).Setup(x => x.MessageObject).Returns(PlatformMessageInQueue);
            IMessageQueue messageQueue = Moq.Mock.Of <IMessageQueue>();

            Moq.Mock.Get(messageQueue).Setup(x => x.GetMessage <PlatformMessage>())
            .Returns(Task.FromResult(messageQueueHandler));

            messageEntrance = new MessageEntrance(messageQueue);
        }
        public HydraliskSystemController(Bootstrap bootstrap, IHostedMachine hostedMachine)
            : base(bootstrap)
        {
            IMessageEntrance messageEntrance = new MessageEntrance(bootstrap.GetMessageQueueFromVariableSet("Entrance"));

            WorkingProcessor = new SourceIntergation(bootstrap.Provisioning.Caches["default-cache"],
                                                     new ExtractorManager(bootstrap.InjectionProvider));
            MetricCollections.Default.AddMetricCollector("idle", new IncreasedMetricCollector("HydraliskIdle"));
            MetricCollections.Default.AddMetricCollector("busy", new IncreasedMetricCollector("HydraliskBusy"));
            IMessageTermination messageTermination = new MessageTermination(bootstrap, this);

            messagePipline     = new MessagePipline(messageEntrance, messageTermination);
            messageOut         = bootstrap.GetMessageQueueFromVariableSet("Termination");
            this.hostedMachine = hostedMachine;
            //TODO : Cache should comes from the variable.
        }
        public KerriganSystemController(Bootstrap bootstrap, IHostedMachine hostedMachine)
            : base(bootstrap)
        {
            var entrance = new MessageEntrance(bootstrap.GetMessageQueueFromVariableSet("Entrance"));

            MetricCollections.Default.AddMetricCollector("idle", new IncreasedMetricCollector("KerriganIdle"));
            MetricCollections.Default.AddMetricCollector("busy", new IncreasedMetricCollector("KerriganBusy"));
            this.loadProviderManager = new LoadProviderManager();
            this.WorkingProcessor    = new LoadIntegration(
                bootstrap.GetCachedFromVariableSet("HeartbeatCache"),
                bootstrap.GetStorageFromVariableSet("CoreStorage"),
                this.loadProviderManager
                );
            IMessageTermination messageTermination = new MessageTermination(bootstrap, this);

            messagePipline     = new MessagePipline(entrance, messageTermination);
            messageOut         = bootstrap.GetMessageQueueFromVariableSet("Termination");
            this.hostedMachine = hostedMachine;
        }
        static (MessageEntrance, ITestableObserver <Response>, TestConfig) Init()
        {
            var config = new TestConfig {
                UtcNow = new DateTimeOffset(2000, 1, 1, 0, 0, 0, 0, TimeSpan.Zero)
            };

            using (var context = MainDbContext.GetInstance(config))
            {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();
            }

            var testScheduler = new TestScheduler();
            var testObserver  = testScheduler.CreateObserver <Response>();
            var entrance      = new MessageEntrance(TestLazySocketClient.Default, config);

            entrance.ResponseSent.Subscribe(testObserver);

            return(entrance, testObserver, config);
        }