/// <exception cref="System.Exception"/> private void SetupPlanFollower() { ReservationSystemTestUtil testUtil = new ReservationSystemTestUtil(); mClock = Org.Mockito.Mockito.Mock <Clock>(); mAgent = Org.Mockito.Mockito.Mock <ReservationAgent>(); string reservationQ = testUtil.GetFullReservationQueueName(); AllocationConfiguration allocConf = fs.GetAllocationConfiguration(); allocConf.SetReservationWindow(20L); allocConf.SetAverageCapacity(20); policy.Init(reservationQ, allocConf); }
public FairSchedulerQueueInfo(FSQueue queue, FairScheduler scheduler) { AllocationConfiguration allocConf = scheduler.GetAllocationConfiguration(); queueName = queue.GetName(); schedulingPolicy = queue.GetPolicy().GetName(); clusterResources = new ResourceInfo(scheduler.GetClusterResource()); usedResources = new ResourceInfo(queue.GetResourceUsage()); fractionMemUsed = (float)usedResources.GetMemory() / clusterResources.GetMemory(); steadyFairResources = new ResourceInfo(queue.GetSteadyFairShare()); fairResources = new ResourceInfo(queue.GetFairShare()); minResources = new ResourceInfo(queue.GetMinShare()); maxResources = new ResourceInfo(queue.GetMaxShare()); maxResources = new ResourceInfo(Resources.ComponentwiseMin(queue.GetMaxShare(), scheduler .GetClusterResource())); fractionMemSteadyFairShare = (float)steadyFairResources.GetMemory() / clusterResources .GetMemory(); fractionMemFairShare = (float)fairResources.GetMemory() / clusterResources.GetMemory (); fractionMemMinShare = (float)minResources.GetMemory() / clusterResources.GetMemory (); fractionMemMaxShare = (float)maxResources.GetMemory() / clusterResources.GetMemory (); maxApps = allocConf.GetQueueMaxApps(queueName); childQueues = new AList <Org.Apache.Hadoop.Yarn.Server.Resourcemanager.Webapp.Dao.FairSchedulerQueueInfo >(); if (allocConf.IsReservable(queueName) && !allocConf.GetShowReservationAsQueues(queueName )) { return; } ICollection <FSQueue> children = queue.GetChildQueues(); foreach (FSQueue child in children) { if (child is FSLeafQueue) { childQueues.AddItem(new FairSchedulerLeafQueueInfo((FSLeafQueue)child, scheduler) ); } else { childQueues.AddItem(new Org.Apache.Hadoop.Yarn.Server.Resourcemanager.Webapp.Dao.FairSchedulerQueueInfo (child, scheduler)); } } }
public virtual void SetUp() { conf = new FairSchedulerConfiguration(); FairScheduler scheduler = Org.Mockito.Mockito.Mock <FairScheduler>(); AllocationConfiguration allocConf = new AllocationConfiguration(conf); Org.Mockito.Mockito.When(scheduler.GetAllocationConfiguration()).ThenReturn(allocConf ); Org.Mockito.Mockito.When(scheduler.GetConf()).ThenReturn(conf); SystemClock clock = new SystemClock(); Org.Mockito.Mockito.When(scheduler.GetClock()).ThenReturn(clock); notEmptyQueues = new HashSet <FSQueue>(); queueManager = new _QueueManager_47(this, scheduler); FSQueueMetrics.ForQueue("root", null, true, conf); queueManager.Initialize(conf); }
public virtual void Setup() { Configuration conf = new Configuration(); clock = new FairSchedulerTestBase.MockClock(); scheduler = Org.Mockito.Mockito.Mock <FairScheduler>(); Org.Mockito.Mockito.When(scheduler.GetConf()).ThenReturn(new FairSchedulerConfiguration (conf)); Org.Mockito.Mockito.When(scheduler.GetClock()).ThenReturn(clock); AllocationConfiguration allocConf = new AllocationConfiguration(conf); Org.Mockito.Mockito.When(scheduler.GetAllocationConfiguration()).ThenReturn(allocConf ); queueManager = new QueueManager(scheduler); queueManager.Initialize(conf); queueMaxApps = allocConf.queueMaxApps; userMaxApps = allocConf.userMaxApps; maxAppsEnforcer = new MaxRunningAppsEnforcer(scheduler); appNum = 0; rmContext = Org.Mockito.Mockito.Mock <RMContext>(); Org.Mockito.Mockito.When(rmContext.GetEpoch()).ThenReturn(0L); }
/// <summary> /// Creates a leaf or parent queue based on what is specified in 'queueType' /// and places it in the tree. /// </summary> /// <remarks> /// Creates a leaf or parent queue based on what is specified in 'queueType' /// and places it in the tree. Creates any parents that don't already exist. /// </remarks> /// <returns> /// the created queue, if successful. null if not allowed (one of the parent /// queues in the queue name is already a leaf queue) /// </returns> private FSQueue CreateQueue(string name, FSQueueType queueType) { IList <string> newQueueNames = new AList <string>(); newQueueNames.AddItem(name); int sepIndex = name.Length; FSParentQueue parent = null; // Move up the queue tree until we reach one that exists. while (sepIndex != -1) { sepIndex = name.LastIndexOf('.', sepIndex - 1); FSQueue queue; string curName = null; curName = Sharpen.Runtime.Substring(name, 0, sepIndex); queue = queues[curName]; if (queue == null) { newQueueNames.AddItem(curName); } else { if (queue is FSParentQueue) { parent = (FSParentQueue)queue; break; } else { return(null); } } } // At this point, parent refers to the deepest existing parent of the // queue to create. // Now that we know everything worked out, make all the queues // and add them to the map. AllocationConfiguration queueConf = scheduler.GetAllocationConfiguration(); FSLeafQueue leafQueue = null; for (int i = newQueueNames.Count - 1; i >= 0; i--) { string queueName = newQueueNames[i]; if (i == 0 && queueType != FSQueueType.Parent) { leafQueue = new FSLeafQueue(name, scheduler, parent); try { leafQueue.SetPolicy(queueConf.GetDefaultSchedulingPolicy()); } catch (AllocationConfigurationException ex) { Log.Warn("Failed to set default scheduling policy " + queueConf.GetDefaultSchedulingPolicy () + " on new leaf queue.", ex); } parent.AddChildQueue(leafQueue); queues[leafQueue.GetName()] = leafQueue; leafQueues.AddItem(leafQueue); leafQueue.UpdatePreemptionVariables(); return(leafQueue); } else { FSParentQueue newParent = new FSParentQueue(queueName, scheduler, parent); try { newParent.SetPolicy(queueConf.GetDefaultSchedulingPolicy()); } catch (AllocationConfigurationException ex) { Log.Warn("Failed to set default scheduling policy " + queueConf.GetDefaultSchedulingPolicy () + " on new parent queue.", ex); } parent.AddChildQueue(newParent); queues[newParent.GetName()] = newParent; newParent.UpdatePreemptionVariables(); parent = newParent; } } return(parent); }
public virtual ResourceWeights GetWeights() { return(scheduler.GetAllocationConfiguration().GetQueueWeight(GetName())); }
protected internal override ReservationSchedulerConfiguration GetReservationSchedulerConfiguration () { return(fairScheduler.GetAllocationConfiguration()); }