public static QueueInfo FromYarn(QueueInfo queueInfo, Configuration conf) { QueueInfo toReturn = new QueueInfo(queueInfo.GetQueueName(), "Capacity: " + queueInfo .GetCapacity() * 100 + ", MaximumCapacity: " + (queueInfo.GetMaximumCapacity() < 0 ? "UNDEFINED" : queueInfo.GetMaximumCapacity() * 100) + ", CurrentCapacity: " + queueInfo.GetCurrentCapacity() * 100, FromYarn(queueInfo.GetQueueState()), TypeConverter .FromYarnApps(queueInfo.GetApplications(), conf)); IList <QueueInfo> childQueues = new AList <QueueInfo>(); foreach (QueueInfo childQueue in queueInfo.GetChildQueues()) { childQueues.AddItem(FromYarn(childQueue, conf)); } toReturn.SetQueueChildren(childQueues); return(toReturn); }
public virtual void TestFromYarnQueue() { //Define child queue QueueInfo child = Org.Mockito.Mockito.Mock <QueueInfo>(); Org.Mockito.Mockito.When(child.GetQueueState()).ThenReturn(QueueState.Running); //Define parent queue QueueInfo queueInfo = Org.Mockito.Mockito.Mock <QueueInfo>(); IList <QueueInfo> children = new AList <QueueInfo>(); children.AddItem(child); //Add one child Org.Mockito.Mockito.When(queueInfo.GetChildQueues()).ThenReturn(children); Org.Mockito.Mockito.When(queueInfo.GetQueueState()).ThenReturn(QueueState.Running ); //Call the function we're testing QueueInfo returned = TypeConverter.FromYarn(queueInfo, new Configuration()); //Verify that the converted queue has the 1 child we had added NUnit.Framework.Assert.AreEqual("QueueInfo children weren't properly converted", returned.GetQueueChildren().Count, 1); }