Exemplo n.º 1
0
 /// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/>
 /// <exception cref="System.IO.IOException"/>
 /// <exception cref="System.Exception"/>
 public virtual void TestCallBackThrowOutException()
 {
     // test exception in callback with app calling stop() on app.onError()
     TestAMRMClientAsync.TestCallbackHandler2 callbackHandler = Org.Mockito.Mockito.Spy
                                                                    (new TestAMRMClientAsync.TestCallbackHandler2(this));
     RunCallBackThrowOutException(callbackHandler);
 }
Exemplo n.º 2
0
        /// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/>
        /// <exception cref="System.IO.IOException"/>
        /// <exception cref="System.Exception"/>
        public virtual void TestCallAMRMClientAsyncStopFromCallbackHandlerWithWaitFor()
        {
            Configuration conf = new Configuration();

            TestAMRMClientAsync.TestCallbackHandler2 callbackHandler = new TestAMRMClientAsync.TestCallbackHandler2
                                                                           (this);
            AMRMClient <AMRMClient.ContainerRequest> client = Org.Mockito.Mockito.Mock <AMRMClientImpl
                                                                                        >();
            IList <ContainerStatus> completed = Arrays.AsList(ContainerStatus.NewInstance(NewContainerId
                                                                                              (0, 0, 0, 0), ContainerState.Complete, string.Empty, 0));
            AllocateResponse response = CreateAllocateResponse(completed, new AList <Container
                                                                                     >(), null);

            Org.Mockito.Mockito.When(client.Allocate(Matchers.AnyFloat())).ThenReturn(response
                                                                                      );
            AMRMClientAsync <AMRMClient.ContainerRequest> asyncClient = AMRMClientAsync.CreateAMRMClientAsync
                                                                            (client, 20, callbackHandler);

            callbackHandler.asynClient = asyncClient;
            asyncClient.Init(conf);
            asyncClient.Start();
            Supplier <bool> checker = new _Supplier_320(callbackHandler);

            asyncClient.RegisterApplicationMaster("localhost", 1234, null);
            asyncClient.WaitFor(checker);
            NUnit.Framework.Assert.IsTrue(checker.Get());
        }
Exemplo n.º 3
0
        /// <exception cref="System.Exception"/>
        /// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/>
        /// <exception cref="System.IO.IOException"/>
        internal virtual void RunCallBackThrowOutException(TestAMRMClientAsync.TestCallbackHandler2
                                                           callbackHandler)
        {
            Configuration conf = new Configuration();
            AMRMClient <AMRMClient.ContainerRequest> client = Org.Mockito.Mockito.Mock <AMRMClientImpl
                                                                                        >();
            IList <ContainerStatus> completed = Arrays.AsList(ContainerStatus.NewInstance(NewContainerId
                                                                                              (0, 0, 0, 0), ContainerState.Complete, string.Empty, 0));
            AllocateResponse response = CreateAllocateResponse(completed, new AList <Container
                                                                                     >(), null);

            Org.Mockito.Mockito.When(client.Allocate(Matchers.AnyFloat())).ThenReturn(response
                                                                                      );
            AMRMClientAsync <AMRMClient.ContainerRequest> asyncClient = AMRMClientAsync.CreateAMRMClientAsync
                                                                            (client, 20, callbackHandler);

            callbackHandler.asynClient        = asyncClient;
            callbackHandler.throwOutException = true;
            asyncClient.Init(conf);
            asyncClient.Start();
            // call register and wait for error callback and stop
            lock (callbackHandler.notifier)
            {
                asyncClient.RegisterApplicationMaster("localhost", 1234, null);
                while (callbackHandler.notify == false)
                {
                    try
                    {
                        Sharpen.Runtime.Wait(callbackHandler.notifier);
                    }
                    catch (Exception e)
                    {
                        Sharpen.Runtime.PrintStackTrace(e);
                    }
                }
            }
            // verify error invoked
            Org.Mockito.Mockito.Verify(callbackHandler, Org.Mockito.Mockito.Times(0)).GetProgress
                ();
            Org.Mockito.Mockito.Verify(callbackHandler, Org.Mockito.Mockito.Times(1)).OnError
                (Matchers.Any <Exception>());
            // sleep to wait for a few heartbeat calls that can trigger callbacks
            Sharpen.Thread.Sleep(50);
            // verify no more invocations after the first one.
            // ie. callback thread has stopped
            Org.Mockito.Mockito.Verify(callbackHandler, Org.Mockito.Mockito.Times(0)).GetProgress
                ();
            Org.Mockito.Mockito.Verify(callbackHandler, Org.Mockito.Mockito.Times(1)).OnError
                (Matchers.Any <Exception>());
        }
Exemplo n.º 4
0
        /// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/>
        /// <exception cref="System.IO.IOException"/>
        /// <exception cref="System.Exception"/>
        public virtual void TestCallAMRMClientAsyncStopFromCallbackHandler()
        {
            Configuration conf = new Configuration();

            TestAMRMClientAsync.TestCallbackHandler2 callbackHandler = new TestAMRMClientAsync.TestCallbackHandler2
                                                                           (this);
            AMRMClient <AMRMClient.ContainerRequest> client = Org.Mockito.Mockito.Mock <AMRMClientImpl
                                                                                        >();
            IList <ContainerStatus> completed = Arrays.AsList(ContainerStatus.NewInstance(NewContainerId
                                                                                              (0, 0, 0, 0), ContainerState.Complete, string.Empty, 0));
            AllocateResponse response = CreateAllocateResponse(completed, new AList <Container
                                                                                     >(), null);

            Org.Mockito.Mockito.When(client.Allocate(Matchers.AnyFloat())).ThenReturn(response
                                                                                      );
            AMRMClientAsync <AMRMClient.ContainerRequest> asyncClient = AMRMClientAsync.CreateAMRMClientAsync
                                                                            (client, 20, callbackHandler);

            callbackHandler.asynClient = asyncClient;
            asyncClient.Init(conf);
            asyncClient.Start();
            lock (callbackHandler.notifier)
            {
                asyncClient.RegisterApplicationMaster("localhost", 1234, null);
                while (callbackHandler.notify == false)
                {
                    try
                    {
                        Sharpen.Runtime.Wait(callbackHandler.notifier);
                    }
                    catch (Exception e)
                    {
                        Sharpen.Runtime.PrintStackTrace(e);
                    }
                }
            }
        }
Exemplo n.º 5
0
 public _Supplier_320(TestAMRMClientAsync.TestCallbackHandler2 callbackHandler)
 {
     this.callbackHandler = callbackHandler;
 }