Beispiel #1
0
 public virtual void TestEnums()
 {
     foreach (YarnApplicationState applicationState in YarnApplicationState.Values())
     {
         TypeConverter.FromYarn(applicationState, FinalApplicationStatus.Failed);
     }
     // ad hoc test of NEW_SAVING, which is newly added
     NUnit.Framework.Assert.AreEqual(JobStatus.State.Prep, TypeConverter.FromYarn(YarnApplicationState
                                                                                  .NewSaving, FinalApplicationStatus.Failed));
     foreach (TaskType taskType in TaskType.Values())
     {
         TypeConverter.FromYarn(taskType);
     }
     foreach (JobState jobState in JobState.Values())
     {
         TypeConverter.FromYarn(jobState);
     }
     foreach (QueueState queueState in QueueState.Values())
     {
         TypeConverter.FromYarn(queueState);
     }
     foreach (TaskState taskState in TaskState.Values())
     {
         TypeConverter.FromYarn(taskState);
     }
 }
Beispiel #2
0
        private string GetAllValidApplicationStates()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("The valid application state can be" + " one of the following: ");
            sb.Append(AllstatesOption + ",");
            foreach (YarnApplicationState appState in YarnApplicationState.Values())
            {
                sb.Append(appState + ",");
            }
            string output = sb.ToString();

            return(Sharpen.Runtime.Substring(output, 0, output.Length - 1));
        }
Beispiel #3
0
 protected override void Render(HtmlBlock.Block html)
 {
     Hamlet.UL <Hamlet.DIV <Org.Apache.Hadoop.Yarn.Webapp.Hamlet.Hamlet> > mainList = html
                                                                                      .Div("#nav").H3("Cluster").Ul().Li().A(Url("cluster"), "About").().Li().A(Url("nodes"
                                                                                                                                                                    ), "Nodes").().Li().A(Url("nodelabels"), "Node Labels").();
     Hamlet.UL <Hamlet.LI <Hamlet.UL <Hamlet.DIV <Org.Apache.Hadoop.Yarn.Webapp.Hamlet.Hamlet
                                                  > > > > subAppsList = mainList.Li().A(Url("apps"), "Applications").Ul();
     subAppsList.Li().();
     foreach (YarnApplicationState state in YarnApplicationState.Values())
     {
         subAppsList.Li().A(Url("apps", state.ToString()), state.ToString()).();
     }
     subAppsList.().();
     mainList.Li().A(Url("scheduler"), "Scheduler").().().H3("Tools").Ul().Li().A("/conf"
                                                                                  , "Configuration").().Li().A("/logs", "Local logs").().Li().A("/stacks", "Server stacks"
                                                                                                                                                ).().Li().A("/jmx?qry=Hadoop:*", "Server metrics").().().();
 }
        public override void SetApplicationStates(ICollection <string> applicationStates)
        {
            EnumSet <YarnApplicationState> appStates = null;

            foreach (YarnApplicationState state in YarnApplicationState.Values())
            {
                if (applicationStates.Contains(StringUtils.ToLowerCase(state.ToString())))
                {
                    if (appStates == null)
                    {
                        appStates = EnumSet.Of(state);
                    }
                    else
                    {
                        appStates.AddItem(state);
                    }
                }
            }
            SetApplicationStates(appStates);
        }
Beispiel #5
0
        /// <summary>
        /// Lists the applications matching the given application Types And application
        /// States present in the Resource Manager
        /// </summary>
        /// <param name="appTypes"/>
        /// <param name="appStates"/>
        /// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/>
        /// <exception cref="System.IO.IOException"/>
        private void ListApplications(ICollection <string> appTypes, EnumSet <YarnApplicationState
                                                                              > appStates)
        {
            PrintWriter writer = new PrintWriter(new OutputStreamWriter(sysout, Sharpen.Extensions.GetEncoding
                                                                            ("UTF-8")));

            if (allAppStates)
            {
                foreach (YarnApplicationState appState in YarnApplicationState.Values())
                {
                    appStates.AddItem(appState);
                }
            }
            else
            {
                if (appStates.IsEmpty())
                {
                    appStates.AddItem(YarnApplicationState.Running);
                    appStates.AddItem(YarnApplicationState.Accepted);
                    appStates.AddItem(YarnApplicationState.Submitted);
                }
            }
            IList <ApplicationReport> appsReport = client.GetApplications(appTypes, appStates);

            writer.WriteLine("Total number of applications (application-types: " + appTypes +
                             " and states: " + appStates + ")" + ":" + appsReport.Count);
            writer.Printf(ApplicationsPattern, "Application-Id", "Application-Name", "Application-Type"
                          , "User", "Queue", "State", "Final-State", "Progress", "Tracking-URL");
            foreach (ApplicationReport appReport in appsReport)
            {
                DecimalFormat formatter = new DecimalFormat("###.##%");
                string        progress  = formatter.Format(appReport.GetProgress());
                writer.Printf(ApplicationsPattern, appReport.GetApplicationId(), appReport.GetName
                                  (), appReport.GetApplicationType(), appReport.GetUser(), appReport.GetQueue(), appReport
                              .GetYarnApplicationState(), appReport.GetFinalApplicationStatus(), progress, appReport
                              .GetOriginalTrackingUrl());
            }
            writer.Flush();
        }
Beispiel #6
0
        protected internal static ICollection <string> ParseQueries(ICollection <string> queries
                                                                    , bool isState)
        {
            ICollection <string> @params = new HashSet <string>();

            if (!queries.IsEmpty())
            {
                foreach (string query in queries)
                {
                    if (query != null && !query.Trim().IsEmpty())
                    {
                        string[] paramStrs = query.Split(",");
                        foreach (string paramStr in paramStrs)
                        {
                            if (paramStr != null && !paramStr.Trim().IsEmpty())
                            {
                                if (isState)
                                {
                                    try
                                    {
                                        // enum string is in the uppercase
                                        YarnApplicationState.ValueOf(StringUtils.ToUpperCase(paramStr.Trim()));
                                    }
                                    catch (RuntimeException)
                                    {
                                        YarnApplicationState[] stateArray = YarnApplicationState.Values();
                                        string allAppStates = Arrays.ToString(stateArray);
                                        throw new BadRequestException("Invalid application-state " + paramStr.Trim() + " specified. It should be one of "
                                                                      + allAppStates);
                                    }
                                }
                                @params.AddItem(StringUtils.ToLowerCase(paramStr.Trim()));
                            }
                        }
                    }
                }
            }
            return(@params);
        }
Beispiel #7
0
        public static RMApp NewApplication(int i)
        {
            ApplicationAttemptId appAttemptId = ApplicationAttemptId.NewInstance(NewAppID(i),
                                                                                 0);
            Container masterContainer = Org.Apache.Hadoop.Yarn.Util.Records.NewRecord <Container
                                                                                       >();
            ContainerId containerId = ContainerId.NewContainerId(appAttemptId, 0);

            masterContainer.SetId(containerId);
            masterContainer.SetNodeHttpAddress("node:port");
            string user   = NewUserName();
            string name   = NewAppName();
            string queue  = NewQueue();
            long   start  = 123456 + i * 1000;
            long   finish = 234567 + i * 1000;
            string type   = YarnConfiguration.DefaultApplicationType;

            YarnApplicationState[] allStates = YarnApplicationState.Values();
            YarnApplicationState   state     = allStates[i % allStates.Length];
            int maxAppAttempts = i % 1000;

            return(new _ApplicationBase_211(appAttemptId, user, name, type, queue, start, finish
                                            , state, maxAppAttempts));
        }