Exemplo n.º 1
0
        private static IContainer SetUp()
        {
            var container = new Container();

            container.Register(made: Made.Of(() => LocationFactory.Get()), reuse: Reuse.Singleton);
            container.RegisterDelegate <Action <string> >((r) => x => Console.WriteLine(x));
            container.RegisterDelegate <Func <string> >((r) => () => Console.ReadLine());
            container.Register <ILogger>(made: Made.Of(() => LogFactory.Get(Arg.Of <string>())), reuse: Reuse.Singleton);
            container.Register <IConfigurationProvider>(made: Made.Of(() => ConfigurationProviderFactory.Get(Arg.Of <string>())), reuse: Reuse.Singleton);
            container.Register <StationValidator>(reuse: Reuse.Singleton);
            container.Register <IStationProvider, StationProvider>(Reuse.Singleton);
            container.Register <IRadio, Radio>(Reuse.Singleton);
            container.Register <ICommand, DatabaseCommand>();
            container.Register <ICommand, HelpCommand>();
            container.Register <ICommand, ListCommand>();
            container.Register <ICommand, PauseCommand>();
            container.Register <ICommand, PlayCommand>();
            container.Register <ICommand, StartCommand>();
            container.Register <ICommand, VolumeCommand>();
            container.Register <ICommand, StopCommand>();
            container.Register <ICommand, StatusCommand>();
            container.Register <IMainLoop, MainLoop>(reuse: Reuse.Singleton);

            return(container);
        }
Exemplo n.º 2
0
        public virtual void TestCompareRMNodeAfterReconnect()
        {
            Configuration     yarnConf  = new YarnConfiguration();
            CapacityScheduler scheduler = new CapacityScheduler();

            scheduler.SetConf(yarnConf);
            ConfigurationProvider configurationProvider = ConfigurationProviderFactory.GetConfigurationProvider
                                                              (yarnConf);

            configurationProvider.Init(yarnConf);
            context.SetConfigurationProvider(configurationProvider);
            RMNodeLabelsManager nlm = new RMNodeLabelsManager();

            nlm.Init(yarnConf);
            nlm.Start();
            context.SetNodeLabelManager(nlm);
            scheduler.SetRMContext(context);
            scheduler.Init(yarnConf);
            scheduler.Start();
            dispatcher.Register(typeof(SchedulerEventType), scheduler);
            string   hostname1  = "localhost1";
            Resource capability = BuilderUtils.NewResource(4096, 4);
            RegisterNodeManagerRequest request1 = recordFactory.NewRecordInstance <RegisterNodeManagerRequest
                                                                                   >();
            NodeId nodeId1 = NodeId.NewInstance(hostname1, 0);

            request1.SetNodeId(nodeId1);
            request1.SetHttpPort(0);
            request1.SetResource(capability);
            resourceTrackerService.RegisterNodeManager(request1);
            NUnit.Framework.Assert.IsNotNull(context.GetRMNodes()[nodeId1]);
            // verify Scheduler and RMContext use same RMNode reference.
            NUnit.Framework.Assert.IsTrue(scheduler.GetSchedulerNode(nodeId1).GetRMNode() ==
                                          context.GetRMNodes()[nodeId1]);
            NUnit.Framework.Assert.AreEqual(context.GetRMNodes()[nodeId1].GetTotalCapability(
                                                ), capability);
            Resource capability1 = BuilderUtils.NewResource(2048, 2);

            request1.SetResource(capability1);
            resourceTrackerService.RegisterNodeManager(request1);
            NUnit.Framework.Assert.IsNotNull(context.GetRMNodes()[nodeId1]);
            // verify Scheduler and RMContext use same RMNode reference
            // after reconnect.
            NUnit.Framework.Assert.IsTrue(scheduler.GetSchedulerNode(nodeId1).GetRMNode() ==
                                          context.GetRMNodes()[nodeId1]);
            // verify RMNode's capability is changed.
            NUnit.Framework.Assert.AreEqual(context.GetRMNodes()[nodeId1].GetTotalCapability(
                                                ), capability1);
            nlm.Stop();
            scheduler.Stop();
        }