Ejemplo n.º 1
0
 public virtual void OnContainerStarted(ContainerId containerId, IDictionary <string
                                                                              , ByteBuffer> allServiceResponse)
 {
     if (this.path)
     {
         if (containerId.GetId() >= this.expectedSuccess)
         {
             this.errorMsgs.AddItem("Container " + containerId + " should throw the exception onContainerStarted"
                                    );
             return;
         }
         this.actualStartSuccess.AddAndGet(1);
         this.actualStartSuccessArray.Set(containerId.GetId(), 1);
         // move on to the following success tests
         this._enclosing.asyncClient.GetContainerStatusAsync(containerId, this._enclosing.
                                                             nodeId);
     }
     else
     {
         // move on to the following failure tests
         this._enclosing.asyncClient.StopContainerAsync(containerId, this._enclosing.nodeId
                                                        );
     }
     // Shouldn't crash the test thread
     throw new RuntimeException("Ignorable Exception");
 }
Ejemplo n.º 2
0
 public virtual void OnContainerStopped(ContainerId containerId)
 {
     if (containerId.GetId() >= this.expectedSuccess)
     {
         this.errorMsgs.AddItem("Container " + containerId + " should throw the exception onContainerStopped"
                                );
         return;
     }
     this.actualStopSuccess.AddAndGet(1);
     this.actualStopSuccessArray.Set(containerId.GetId(), 1);
     // Shouldn't crash the test thread
     throw new RuntimeException("Ignorable Exception");
 }
Ejemplo n.º 3
0
 public virtual void OnContainerStatusReceived(ContainerId containerId, ContainerStatus
                                               containerStatus)
 {
     if (containerId.GetId() >= this.expectedSuccess)
     {
         this.errorMsgs.AddItem("Container " + containerId + " should throw the exception onContainerStatusReceived"
                                );
         return;
     }
     this.actualQuerySuccess.AddAndGet(1);
     this.actualQuerySuccessArray.Set(containerId.GetId(), 1);
     // move on to the following success tests
     this._enclosing.asyncClient.StopContainerAsync(containerId, this._enclosing.nodeId
                                                    );
     // Shouldn't crash the test thread
     throw new RuntimeException("Ignorable Exception");
 }
Ejemplo n.º 4
0
 /// <exception cref="System.IO.IOException"/>
 private void TestReadHistoryData(int num, bool missingContainer, bool missingApplicationAttempt
                                  )
 {
     // read application history data
     NUnit.Framework.Assert.AreEqual(num, store.GetAllApplications().Count);
     for (int i = 1; i <= num; ++i)
     {
         ApplicationId          appId   = ApplicationId.NewInstance(0, i);
         ApplicationHistoryData appData = store.GetApplication(appId);
         NUnit.Framework.Assert.IsNotNull(appData);
         NUnit.Framework.Assert.AreEqual(appId.ToString(), appData.GetApplicationName());
         NUnit.Framework.Assert.AreEqual(appId.ToString(), appData.GetDiagnosticsInfo());
         // read application attempt history data
         NUnit.Framework.Assert.AreEqual(num, store.GetApplicationAttempts(appId).Count);
         for (int j = 1; j <= num; ++j)
         {
             ApplicationAttemptId          appAttemptId = ApplicationAttemptId.NewInstance(appId, j);
             ApplicationAttemptHistoryData attemptData  = store.GetApplicationAttempt(appAttemptId
                                                                                      );
             NUnit.Framework.Assert.IsNotNull(attemptData);
             NUnit.Framework.Assert.AreEqual(appAttemptId.ToString(), attemptData.GetHost());
             if (missingApplicationAttempt && j == num)
             {
                 NUnit.Framework.Assert.IsNull(attemptData.GetDiagnosticsInfo());
                 continue;
             }
             else
             {
                 NUnit.Framework.Assert.AreEqual(appAttemptId.ToString(), attemptData.GetDiagnosticsInfo
                                                     ());
             }
             // read container history data
             NUnit.Framework.Assert.AreEqual(num, store.GetContainers(appAttemptId).Count);
             for (int k = 1; k <= num; ++k)
             {
                 ContainerId          containerId   = ContainerId.NewContainerId(appAttemptId, k);
                 ContainerHistoryData containerData = store.GetContainer(containerId);
                 NUnit.Framework.Assert.IsNotNull(containerData);
                 NUnit.Framework.Assert.AreEqual(Priority.NewInstance(containerId.GetId()), containerData
                                                 .GetPriority());
                 if (missingContainer && k == num)
                 {
                     NUnit.Framework.Assert.IsNull(containerData.GetDiagnosticsInfo());
                 }
                 else
                 {
                     NUnit.Framework.Assert.AreEqual(containerId.ToString(), containerData.GetDiagnosticsInfo
                                                         ());
                 }
             }
             ContainerHistoryData masterContainer = store.GetAMContainer(appAttemptId);
             NUnit.Framework.Assert.IsNotNull(masterContainer);
             NUnit.Framework.Assert.AreEqual(ContainerId.NewContainerId(appAttemptId, 1), masterContainer
                                             .GetContainerId());
         }
     }
 }
Ejemplo n.º 5
0
 public virtual void OnGetContainerStatusError(ContainerId containerId, Exception
                                               t)
 {
     if (t is RuntimeException)
     {
         this.errorMsgs.AddItem("Unexpected throwable from callback functions should be" +
                                " ignored by Container " + containerId);
     }
     if (containerId.GetId() < this.expectedSuccess)
     {
         this.errorMsgs.AddItem("Container " + containerId + " shouldn't throw the exception onGetContainerStatusError"
                                );
         return;
     }
     this.actualQueryFailure.AddAndGet(1);
     this.actualQueryFailureArray.Set(containerId.GetId() - this.expectedSuccess, 1);
     // Shouldn't crash the test thread
     throw new RuntimeException("Ignorable Exception");
 }
Ejemplo n.º 6
0
 public virtual void OnStartContainerError(ContainerId containerId, Exception t)
 {
     // If the unexpected throwable comes from success callback functions, it
     // will be handled by the error callback functions. Therefore, monitor
     // the exception here
     if (t is RuntimeException)
     {
         this.errorMsgs.AddItem("Unexpected throwable from callback functions should be" +
                                " ignored by Container " + containerId);
     }
     if (containerId.GetId() < this.expectedSuccess)
     {
         this.errorMsgs.AddItem("Container " + containerId + " shouldn't throw the exception onStartContainerError"
                                );
         return;
     }
     this.actualStartFailure.AddAndGet(1);
     this.actualStartFailureArray.Set(containerId.GetId() - this.expectedSuccess, 1);
     // move on to the following failure tests
     this._enclosing.asyncClient.GetContainerStatusAsync(containerId, this._enclosing.
                                                         nodeId);
     // Shouldn't crash the test thread
     throw new RuntimeException("Ignorable Exception");
 }
        public virtual void TestReadWriteContainerHistory()
        {
            // Out of order
            ApplicationId        appId        = ApplicationId.NewInstance(0, 1);
            ApplicationAttemptId appAttemptId = ApplicationAttemptId.NewInstance(appId, 1);
            ContainerId          containerId  = ContainerId.NewContainerId(appAttemptId, 1);

            try
            {
                WriteContainerFinishData(containerId);
                NUnit.Framework.Assert.Fail();
            }
            catch (IOException e)
            {
                NUnit.Framework.Assert.IsTrue(e.Message.Contains("is stored before the start information"
                                                                 ));
            }
            // Normal
            WriteApplicationAttemptStartData(appAttemptId);
            int numContainers = 5;

            for (int i = 1; i <= numContainers; ++i)
            {
                containerId = ContainerId.NewContainerId(appAttemptId, i);
                WriteContainerStartData(containerId);
                WriteContainerFinishData(containerId);
            }
            NUnit.Framework.Assert.AreEqual(numContainers, store.GetContainers(appAttemptId).
                                            Count);
            for (int i_1 = 1; i_1 <= numContainers; ++i_1)
            {
                containerId = ContainerId.NewContainerId(appAttemptId, i_1);
                ContainerHistoryData data = store.GetContainer(containerId);
                NUnit.Framework.Assert.IsNotNull(data);
                NUnit.Framework.Assert.AreEqual(Priority.NewInstance(containerId.GetId()), data.GetPriority
                                                    ());
                NUnit.Framework.Assert.AreEqual(containerId.ToString(), data.GetDiagnosticsInfo()
                                                );
            }
            ContainerHistoryData masterContainer = store.GetAMContainer(appAttemptId);

            NUnit.Framework.Assert.IsNotNull(masterContainer);
            NUnit.Framework.Assert.AreEqual(ContainerId.NewContainerId(appAttemptId, 1), masterContainer
                                            .GetContainerId());
            WriteApplicationAttemptFinishData(appAttemptId);
            // Write again
            containerId = ContainerId.NewContainerId(appAttemptId, 1);
            try
            {
                WriteContainerStartData(containerId);
                NUnit.Framework.Assert.Fail();
            }
            catch (IOException e)
            {
                NUnit.Framework.Assert.IsTrue(e.Message.Contains("is already stored"));
            }
            try
            {
                WriteContainerFinishData(containerId);
                NUnit.Framework.Assert.Fail();
            }
            catch (IOException e)
            {
                NUnit.Framework.Assert.IsTrue(e.Message.Contains("is already stored"));
            }
        }
 /// <exception cref="System.IO.IOException"/>
 protected internal virtual void WriteContainerStartData(ContainerId containerId)
 {
     store.ContainerStarted(ContainerStartData.NewInstance(containerId, Resource.NewInstance
                                                               (0, 0), NodeId.NewInstance("localhost", 0), Priority.NewInstance(containerId.GetId
                                                                                                                                    ()), 0));
 }