Beispiel #1
0
        private void VerifyClientConnection()
        {
            int numRetries = 3;

            while (numRetries-- > 0)
            {
                Configuration conf   = new YarnConfiguration(this.conf);
                YarnClient    client = YarnClient.CreateYarnClient();
                client.Init(conf);
                client.Start();
                try
                {
                    client.GetApplications();
                    return;
                }
                catch (Exception e)
                {
                    Log.Error(e);
                }
                finally
                {
                    client.Stop();
                }
            }
            NUnit.Framework.Assert.Fail("Client couldn't connect to the Active RM");
        }
        protected internal virtual void VerifyClientConnection()
        {
            int numRetries = 3;

            while (numRetries-- > 0)
            {
                Configuration conf   = new YarnConfiguration(this.conf);
                YarnClient    client = CreateAndStartYarnClient(conf);
                try
                {
                    Sharpen.Thread.Sleep(100);
                    client.GetApplications();
                    return;
                }
                catch (Exception e)
                {
                    Log.Error(e.Message);
                }
                finally
                {
                    client.Stop();
                }
            }
            NUnit.Framework.Assert.Fail("Client couldn't connect to the Active RM");
        }
Beispiel #3
0
 public virtual void ShutDown()
 {
     if (client != null)
     {
         client.Stop();
     }
 }
Beispiel #4
0
 /// <exception cref="System.IO.IOException"/>
 /// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/>
 public virtual bool Run()
 {
     Log.Info("Starting Client");
     // Connect to ResourceManager
     rmClient.Start();
     try
     {
         // Create launch context for app master
         Log.Info("Setting up application submission context for ASM");
         ApplicationSubmissionContext appContext = rmClient.CreateApplication().GetApplicationSubmissionContext
                                                       ();
         ApplicationId appId = appContext.GetApplicationId();
         // set the application name
         appContext.SetApplicationName(appName);
         // Set the priority for the application master
         Priority pri = Org.Apache.Hadoop.Yarn.Util.Records.NewRecord <Priority>();
         pri.SetPriority(amPriority);
         appContext.SetPriority(pri);
         // Set the queue to which this application is to be submitted in the RM
         appContext.SetQueue(amQueue);
         // Set up the container launch context for the application master
         ContainerLaunchContext amContainer = Org.Apache.Hadoop.Yarn.Util.Records.NewRecord
                                              <ContainerLaunchContext>();
         appContext.SetAMContainerSpec(amContainer);
         // unmanaged AM
         appContext.SetUnmanagedAM(true);
         Log.Info("Setting unmanaged AM");
         // Submit the application to the applications manager
         Log.Info("Submitting application to ASM");
         rmClient.SubmitApplication(appContext);
         ApplicationReport appReport = MonitorApplication(appId, EnumSet.Of(YarnApplicationState
                                                                            .Accepted, YarnApplicationState.Killed, YarnApplicationState.Failed, YarnApplicationState
                                                                            .Finished));
         if (appReport.GetYarnApplicationState() == YarnApplicationState.Accepted)
         {
             // Monitor the application attempt to wait for launch state
             ApplicationAttemptReport attemptReport = MonitorCurrentAppAttempt(appId, YarnApplicationAttemptState
                                                                               .Launched);
             ApplicationAttemptId attemptId = attemptReport.GetApplicationAttemptId();
             Log.Info("Launching AM with application attempt id " + attemptId);
             // launch AM
             LaunchAM(attemptId);
             // Monitor the application for end state
             appReport = MonitorApplication(appId, EnumSet.Of(YarnApplicationState.Killed, YarnApplicationState
                                                              .Failed, YarnApplicationState.Finished));
         }
         YarnApplicationState   appState  = appReport.GetYarnApplicationState();
         FinalApplicationStatus appStatus = appReport.GetFinalApplicationStatus();
         Log.Info("App ended with state: " + appReport.GetYarnApplicationState() + " and status: "
                  + appStatus);
         bool success;
         if (YarnApplicationState.Finished == appState && FinalApplicationStatus.Succeeded
             == appStatus)
         {
             Log.Info("Application has completed successfully.");
             success = true;
         }
         else
         {
             Log.Info("Application did finished unsuccessfully." + " YarnState=" + appState.ToString
                          () + ", FinalStatus=" + appStatus.ToString());
             success = false;
         }
         return(success);
     }
     finally
     {
         rmClient.Stop();
     }
 }
Beispiel #5
0
 /// <exception cref="System.Exception"/>
 protected override void ServiceStop()
 {
     client.Stop();
     base.ServiceStop();
 }