Beispiel #1
0
        /// <summary>
        /// Get a mock
        /// <see cref="Org.Apache.Hadoop.Yarn.Server.Resourcemanager.RMContext"/>
        /// for use in test cases.
        /// </summary>
        /// <returns>
        /// a mock
        /// <see cref="Org.Apache.Hadoop.Yarn.Server.Resourcemanager.RMContext"/>
        /// for use in test cases
        /// </returns>
        public static RMContext GetMockRMContext()
        {
            // Null dispatcher
            Dispatcher nullDispatcher = new _Dispatcher_73();
            // No op
            ContainerAllocationExpirer cae    = new ContainerAllocationExpirer(nullDispatcher);
            Configuration conf                = new Configuration();
            RMApplicationHistoryWriter writer = Org.Mockito.Mockito.Mock <RMApplicationHistoryWriter
                                                                          >();
            RMContextImpl rmContext = new RMContextImpl(nullDispatcher, cae, null, null, null
                                                        , new AMRMTokenSecretManager(conf, null), new RMContainerTokenSecretManager(conf
                                                                                                                                    ), new NMTokenSecretManagerInRM(conf), new ClientToAMTokenSecretManagerInRM());
            RMNodeLabelsManager nlm = Org.Mockito.Mockito.Mock <RMNodeLabelsManager>();

            Org.Mockito.Mockito.When(nlm.GetQueueResource(Matchers.Any <string>(), Matchers.Any
                                                          <Set>(), Matchers.Any <Resource>())).ThenAnswer(new _Answer_105());
            Org.Mockito.Mockito.When(nlm.GetResourceByLabel(Matchers.Any <string>(), Matchers.Any
                                                            <Resource>())).ThenAnswer(new _Answer_114());
            rmContext.SetNodeLabelManager(nlm);
            rmContext.SetSystemMetricsPublisher(Org.Mockito.Mockito.Mock <SystemMetricsPublisher
                                                                          >());
            rmContext.SetRMApplicationHistoryWriter(Org.Mockito.Mockito.Mock <RMApplicationHistoryWriter
                                                                              >());
            return(rmContext);
        }
        public static RMContext CreateRMContext(Configuration conf)
        {
            RMContext mockRmContext = Org.Mockito.Mockito.Spy(new RMContextImpl(null, null, null
                                                                                , null, null, null, new RMContainerTokenSecretManager(conf), new NMTokenSecretManagerInRM
                                                                                    (conf), new ClientToAMTokenSecretManagerInRM(), null));
            RMNodeLabelsManager nlm = Org.Mockito.Mockito.Mock <RMNodeLabelsManager>();

            Org.Mockito.Mockito.When(nlm.GetQueueResource(Matchers.Any <string>(), Matchers.AnySetOf
                                                          <string>(), Matchers.Any <Resource>())).ThenAnswer(new _Answer_228());
            Org.Mockito.Mockito.When(nlm.GetResourceByLabel(Matchers.Any <string>(), Matchers.Any
                                                            <Resource>())).ThenAnswer(new _Answer_237());
            mockRmContext.SetNodeLabelManager(nlm);
            return(mockRmContext);
        }