Пример #1
0
 /// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/>
 public virtual void MoveAllApps(string sourceQueue, string destQueue)
 {
     lock (this)
     {
         // check if destination queue is a valid leaf queue
         try
         {
             GetQueueInfo(destQueue, false, false);
         }
         catch (IOException e)
         {
             Log.Warn(e);
             throw new YarnException(e);
         }
         // check if source queue is a valid
         IList <ApplicationAttemptId> apps = GetAppsInQueue(sourceQueue);
         if (apps == null)
         {
             string errMsg = "The specified Queue: " + sourceQueue + " doesn't exist";
             Log.Warn(errMsg);
             throw new YarnException(errMsg);
         }
         // generate move events for each pending/running app
         foreach (ApplicationAttemptId app in apps)
         {
             SettableFuture <object> future = SettableFuture.Create();
             this.rmContext.GetDispatcher().GetEventHandler().Handle(new RMAppMoveEvent(app.GetApplicationId
                                                                                            (), destQueue, future));
         }
     }
 }
        public virtual void TestWriteEditsOneSlow()
        {
            EditLogOutputStream stm = CreateLogSegment();

            QJMTestUtil.WriteOp(stm, 1);
            stm.SetReadyToFlush();
            // Make the first two logs respond immediately
            FutureReturns(null).When(spyLoggers[0]).SendEdits(Matchers.AnyLong(), Matchers.Eq
                                                                  (1L), Matchers.Eq(1), Org.Mockito.Mockito.Any <byte[]>());
            FutureReturns(null).When(spyLoggers[1]).SendEdits(Matchers.AnyLong(), Matchers.Eq
                                                                  (1L), Matchers.Eq(1), Org.Mockito.Mockito.Any <byte[]>());
            // And the third log not respond
            SettableFuture <Void> slowLog = SettableFuture.Create();

            Org.Mockito.Mockito.DoReturn(slowLog).When(spyLoggers[2]).SendEdits(Matchers.AnyLong
                                                                                    (), Matchers.Eq(1L), Matchers.Eq(1), Org.Mockito.Mockito.Any <byte[]>());
            stm.Flush();
            Org.Mockito.Mockito.Verify(spyLoggers[0]).SetCommittedTxId(1L);
        }
Пример #3
0
        /// <exception cref="System.Exception"/>
        public virtual void TestQuorums()
        {
            IDictionary <string, SettableFuture <string> > futures = ImmutableMap.Of("f1", SettableFuture
                                                                                     .Create <string>(), "f2", SettableFuture.Create <string>(), "f3", SettableFuture.Create
                                                                                     <string>());
            QuorumCall <string, string> q = QuorumCall.Create(futures);

            NUnit.Framework.Assert.AreEqual(0, q.CountResponses());
            futures["f1"].Set("first future");
            q.WaitFor(1, 0, 0, 100000, "test");
            // wait for 1 response
            q.WaitFor(0, 1, 0, 100000, "test");
            // wait for 1 success
            NUnit.Framework.Assert.AreEqual(1, q.CountResponses());
            futures["f2"].SetException(new Exception("error"));
            NUnit.Framework.Assert.AreEqual(2, q.CountResponses());
            futures["f3"].Set("second future");
            q.WaitFor(3, 0, 100, 100000, "test");
            // wait for 3 responses
            q.WaitFor(0, 2, 100, 100000, "test");
            // 2 successes
            NUnit.Framework.Assert.AreEqual(3, q.CountResponses());
            NUnit.Framework.Assert.AreEqual("f1=first future,f3=second future", Joiner.On(","
                                                                                          ).WithKeyValueSeparator("=").Join(new SortedDictionary <string, string>(q.GetResults
                                                                                                                                                                      ())));
            try
            {
                q.WaitFor(0, 4, 100, 10, "test");
                NUnit.Framework.Assert.Fail("Didn't time out waiting for more responses than came back"
                                            );
            }
            catch (TimeoutException)
            {
            }
        }