Ejemplo n.º 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);
        }
Ejemplo n.º 3
0
 private Org.Apache.Hadoop.Yarn.Api.Records.Resource GetCurrentLimitResource(string
                                                                             nodeLabel, Org.Apache.Hadoop.Yarn.Api.Records.Resource clusterResource, ResourceLimits
                                                                             currentResourceLimits)
 {
     /*
      * Current limit resource: For labeled resource: limit = queue-max-resource
      * (TODO, this part need update when we support labeled-limit) For
      * non-labeled resource: limit = min(queue-max-resource,
      * limit-set-by-parent)
      */
     Org.Apache.Hadoop.Yarn.Api.Records.Resource queueMaxResource = Resources.MultiplyAndNormalizeDown
                                                                        (resourceCalculator, labelManager.GetResourceByLabel(nodeLabel, clusterResource)
                                                                        , queueCapacities.GetAbsoluteMaximumCapacity(nodeLabel), minimumAllocation);
     if (nodeLabel.Equals(RMNodeLabelsManager.NoLabel))
     {
         return(Resources.Min(resourceCalculator, clusterResource, queueMaxResource, currentResourceLimits
                              .GetLimit()));
     }
     return(queueMaxResource);
 }