public override void InitFilter(FilterContainer container, Configuration conf) { IDictionary <string, string> @params = new Dictionary <string, string>(); IList <string> proxies = WebAppUtils.GetProxyHostsAndPortsForAmFilter(conf); StringBuilder sb = new StringBuilder(); foreach (string proxy in proxies) { sb.Append(proxy.Split(":")[0]).Append(AmIpFilter.ProxyHostsDelimiter); } sb.Length = sb.Length - 1; @params[AmIpFilter.ProxyHosts] = sb.ToString(); string prefix = WebAppUtils.GetHttpSchemePrefix(conf); string proxyBase = GetApplicationWebProxyBase(); sb = new StringBuilder(); foreach (string proxy_1 in proxies) { sb.Append(prefix).Append(proxy_1).Append(proxyBase).Append(AmIpFilter.ProxyHostsDelimiter ); } sb.Length = sb.Length - 1; @params[AmIpFilter.ProxyUriBases] = sb.ToString(); container.AddFilter(FilterName, FilterClass, @params); }
/// <exception cref="System.Exception"/> public virtual void TestAppReportForEmptyTrackingUrl() { configuration.Set(YarnConfiguration.ProxyAddress, "localhost:9090"); // overriding num of web server threads, see HttpServer.HTTP_MAXTHREADS configuration.SetInt("hadoop.http.max.threads", 5); TestWebAppProxyServlet.WebAppProxyServerForTest proxy = new TestWebAppProxyServlet.WebAppProxyServerForTest (this); proxy.Init(configuration); proxy.Start(); int proxyPort = proxy.proxy.proxyServer.GetConnectorAddress(0).Port; TestWebAppProxyServlet.AppReportFetcherForTest appReportFetcher = proxy.proxy.appReportFetcher; try { //set AHS_ENBALED = false to simulate getting the app report from RM configuration.SetBoolean(YarnConfiguration.ApplicationHistoryEnabled, false); ApplicationId app = ApplicationId.NewInstance(0, 0); appReportFetcher.answer = 6; Uri url = new Uri("http://localhost:" + proxyPort + "/proxy/" + app.ToString()); HttpURLConnection proxyConn = (HttpURLConnection)url.OpenConnection(); proxyConn.Connect(); try { proxyConn.GetResponseCode(); } catch (ConnectException) { } // Connection Exception is expected as we have set // appReportFetcher.answer = 6, which does not set anything for // original tracking url field in the app report. string appAddressInRm = WebAppUtils.GetResolvedRMWebAppURLWithScheme(configuration ) + "/cluster" + "/app/" + app.ToString(); NUnit.Framework.Assert.IsTrue("Webapp proxy servlet should have redirected to RM" , proxyConn.GetURL().ToString().Equals(appAddressInRm)); //set AHS_ENBALED = true to simulate getting the app report from AHS configuration.SetBoolean(YarnConfiguration.ApplicationHistoryEnabled, true); proxyConn = (HttpURLConnection)url.OpenConnection(); proxyConn.Connect(); try { proxyConn.GetResponseCode(); } catch (ConnectException) { } // Connection Exception is expected as we have set // appReportFetcher.answer = 6, which does not set anything for // original tracking url field in the app report. string appAddressInAhs = WebAppUtils.GetHttpSchemePrefix(configuration) + WebAppUtils .GetAHSWebAppURLWithoutScheme(configuration) + "/applicationhistory" + "/apps/" + app.ToString(); NUnit.Framework.Assert.IsTrue("Webapp proxy servlet should have redirected to AHS" , proxyConn.GetURL().ToString().Equals(appAddressInAhs)); } finally { proxy.Close(); } }
/// <exception cref="System.Exception"/> protected override void ServiceInit(Configuration conf) { serverHttpAddress = WebAppUtils.GetHttpSchemePrefix(conf) + WebAppUtils.GetAHSWebAppURLWithoutScheme (conf); maxLoadedApplications = conf.GetLong(YarnConfiguration.ApplicationHistoryMaxApps, YarnConfiguration.DefaultApplicationHistoryMaxApps); base.ServiceInit(conf); }
protected override void GenerateApplicationTable(HtmlBlock.Block html, UserGroupInformation callerUGI, ICollection <ApplicationAttemptReport> attempts) { // Application Attempt Table Hamlet.TBODY <Hamlet.TABLE <Org.Apache.Hadoop.Yarn.Webapp.Hamlet.Hamlet> > tbody = html .Table("#attempts").Thead().Tr().Th(".id", "Attempt ID").Th(".started", "Started" ).Th(".node", "Node").Th(".logs", "Logs").Th(".blacklistednodes", "Blacklisted Nodes" ).().().Tbody(); RMApp rmApp = this.rm.GetRMContext().GetRMApps()[this.appID]; if (rmApp == null) { return; } StringBuilder attemptsTableData = new StringBuilder("[\n"); foreach (ApplicationAttemptReport appAttemptReport in attempts) { RMAppAttempt rmAppAttempt = rmApp.GetRMAppAttempt(appAttemptReport.GetApplicationAttemptId ()); if (rmAppAttempt == null) { continue; } AppAttemptInfo attemptInfo = new AppAttemptInfo(this.rm, rmAppAttempt, rmApp.GetUser (), WebAppUtils.GetHttpSchemePrefix(conf)); string blacklistedNodesCount = "N/A"; ICollection <string> nodes = RMAppAttemptBlock.GetBlacklistedNodes(rm, rmAppAttempt .GetAppAttemptId()); if (nodes != null) { blacklistedNodesCount = nodes.Count.ToString(); } string nodeLink = attemptInfo.GetNodeHttpAddress(); if (nodeLink != null) { nodeLink = WebAppUtils.GetHttpSchemePrefix(conf) + nodeLink; } string logsLink = attemptInfo.GetLogsLink(); attemptsTableData.Append("[\"<a href='").Append(Url("appattempt", rmAppAttempt.GetAppAttemptId ().ToString())).Append("'>").Append(rmAppAttempt.GetAppAttemptId().ToString()).Append ("</a>\",\"").Append(attemptInfo.GetStartTime()).Append("\",\"<a ").Append(nodeLink == null ? "#" : "href='" + nodeLink).Append("'>").Append(nodeLink == null ? "N/A" : StringEscapeUtils.EscapeJavaScript(StringEscapeUtils.EscapeHtml(nodeLink))).Append ("</a>\",\"<a ").Append(logsLink == null ? "#" : "href='" + logsLink).Append("'>" ).Append(logsLink == null ? "N/A" : "Logs").Append("</a>\",").Append("\"").Append (blacklistedNodesCount).Append("\"],\n"); } if (attemptsTableData[attemptsTableData.Length - 2] == ',') { attemptsTableData.Delete(attemptsTableData.Length - 2, attemptsTableData.Length - 1); } attemptsTableData.Append("]"); html.Script().$type("text/javascript").("var attemptsTableData=" + attemptsTableData ).(); tbody.().(); }
/// <exception cref="System.Exception"/> protected override void ServiceInit(Configuration conf) { Log.Info("ApplicationHistory Init"); historyStore = CreateApplicationHistoryStore(conf); historyStore.Init(conf); serverHttpAddress = WebAppUtils.GetHttpSchemePrefix(conf) + WebAppUtils.GetAHSWebAppURLWithoutScheme (conf); base.ServiceInit(conf); }
/// <summary>Default constructor</summary> public WebAppProxyServlet() : base() { conf = new YarnConfiguration(); this.trackingUriPlugins = conf.GetInstances <TrackingUriPlugin>(YarnConfiguration. YarnTrackingUrlGenerator); this.rmAppPageUrlBase = StringHelper.Pjoin(WebAppUtils.GetResolvedRMWebAppURLWithScheme (conf), "cluster", "app"); this.ahsAppPageUrlBase = StringHelper.Pjoin(WebAppUtils.GetHttpSchemePrefix(conf) + WebAppUtils.GetAHSWebAppURLWithoutScheme(conf), "applicationhistory", "apps"); }
public virtual string GetLogURL() { try { readLock.Lock(); StringBuilder logURL = new StringBuilder(); logURL.Append(WebAppUtils.GetHttpSchemePrefix(rmContext.GetYarnConfiguration())); logURL.Append(WebAppUtils.GetRunningLogURL(container.GetNodeHttpAddress(), ConverterUtils .ToString(containerId), user)); return(logURL.ToString()); } finally { readLock.Unlock(); } }
private void PrintAllTaskAttempts(TaskType taskType) { IDictionary <TaskID, JobHistoryParser.TaskInfo> tasks = job.GetAllTasks(); StringBuilder taskList = new StringBuilder(); taskList.Append("\n").Append(taskType); taskList.Append(" task list for ").Append(job.GetJobId()); taskList.Append("\nTaskId\t\tStartTime"); if (TaskType.Reduce.Equals(taskType)) { taskList.Append("\tShuffleFinished\tSortFinished"); } taskList.Append("\tFinishTime\tHostName\tError\tTaskLogs"); taskList.Append("\n===================================================="); System.Console.Out.WriteLine(taskList.ToString()); foreach (JobHistoryParser.TaskInfo task in tasks.Values) { foreach (JobHistoryParser.TaskAttemptInfo attempt in task.GetAllTaskAttempts().Values) { if (taskType.Equals(task.GetTaskType())) { taskList.Length = 0; taskList.Append(attempt.GetAttemptId()).Append("\t"); taskList.Append(StringUtils.GetFormattedTimeWithDiff(dateFormat, attempt.GetStartTime (), 0)).Append("\t"); if (TaskType.Reduce.Equals(taskType)) { taskList.Append(StringUtils.GetFormattedTimeWithDiff(dateFormat, attempt.GetShuffleFinishTime (), attempt.GetStartTime())); taskList.Append("\t"); taskList.Append(StringUtils.GetFormattedTimeWithDiff(dateFormat, attempt.GetSortFinishTime (), attempt.GetShuffleFinishTime())); } taskList.Append(StringUtils.GetFormattedTimeWithDiff(dateFormat, attempt.GetFinishTime (), attempt.GetStartTime())); taskList.Append("\t"); taskList.Append(attempt.GetHostname()).Append("\t"); taskList.Append(attempt.GetError()); string taskLogsUrl = GetTaskLogsUrl(WebAppUtils.GetHttpSchemePrefix(fs.GetConf()) , attempt); taskList.Append(taskLogsUrl != null ? taskLogsUrl : "n/a"); System.Console.Out.WriteLine(taskList.ToString()); } } } }
public virtual void TestSingleContainer() { ApplicationId appId = ApplicationId.NewInstance(0, 1); ApplicationAttemptId appAttemptId = ApplicationAttemptId.NewInstance(appId, 1); ContainerId containerId = ContainerId.NewContainerId(appAttemptId, 1); WebResource r = Resource(); ClientResponse response = r.Path("ws").Path("v1").Path("applicationhistory").Path ("apps").Path(appId.ToString()).Path("appattempts").Path(appAttemptId.ToString() ).Path("containers").Path(containerId.ToString()).QueryParam("user.name", Users[ round]).Accept(MediaType.ApplicationJson).Get <ClientResponse>(); if (round == 1) { NUnit.Framework.Assert.AreEqual(ClientResponse.Status.Forbidden, response.GetClientResponseStatus ()); return; } NUnit.Framework.Assert.AreEqual(MediaType.ApplicationJsonType, response.GetType() ); JSONObject json = response.GetEntity <JSONObject>(); NUnit.Framework.Assert.AreEqual("incorrect number of elements", 1, json.Length()); JSONObject container = json.GetJSONObject("container"); NUnit.Framework.Assert.AreEqual(containerId.ToString(), container.GetString("containerId" )); NUnit.Framework.Assert.AreEqual("test diagnostics info", container.GetString("diagnosticsInfo" )); NUnit.Framework.Assert.AreEqual("-1", container.GetString("allocatedMB")); NUnit.Framework.Assert.AreEqual("-1", container.GetString("allocatedVCores")); NUnit.Framework.Assert.AreEqual(NodeId.NewInstance("test host", 100).ToString(), container.GetString("assignedNodeId")); NUnit.Framework.Assert.AreEqual("-1", container.GetString("priority")); Configuration conf = new YarnConfiguration(); NUnit.Framework.Assert.AreEqual(WebAppUtils.GetHttpSchemePrefix(conf) + WebAppUtils .GetAHSWebAppURLWithoutScheme(conf) + "/applicationhistory/logs/test host:100/container_0_0001_01_000001/" + "container_0_0001_01_000001/user1", container.GetString("logUrl")); NUnit.Framework.Assert.AreEqual(ContainerState.Complete.ToString(), container.GetString ("containerState")); }
public virtual string GetNodeHttpAddress() { try { readLock.Lock(); if (container.GetNodeHttpAddress() != null) { StringBuilder httpAddress = new StringBuilder(); httpAddress.Append(WebAppUtils.GetHttpSchemePrefix(rmContext.GetYarnConfiguration ())); httpAddress.Append(container.GetNodeHttpAddress()); return(httpAddress.ToString()); } else { return(null); } } finally { readLock.Unlock(); } }
private void CreateResourceRequestsTable(HtmlBlock.Block html) { AppInfo app = new AppInfo(rm, rm.GetRMContext().GetRMApps()[this.appAttemptId.GetApplicationId ()], true, WebAppUtils.GetHttpSchemePrefix(conf)); IList <ResourceRequest> resourceRequests = app.GetResourceRequests(); if (resourceRequests == null || resourceRequests.IsEmpty()) { return; } Hamlet.DIV <Org.Apache.Hadoop.Yarn.Webapp.Hamlet.Hamlet> div = html.Div(JQueryUI.InfoWrap ); Hamlet.TABLE <Hamlet.DIV <Org.Apache.Hadoop.Yarn.Webapp.Hamlet.Hamlet> > table = div .H3("Total Outstanding Resource Requests: " + GetTotalResource(resourceRequests) ).Table("#ResourceRequests"); table.Tr().Th(JQueryUI.Th, "Priority").Th(JQueryUI.Th, "ResourceName").Th(JQueryUI .Th, "Capability").Th(JQueryUI.Th, "NumContainers").Th(JQueryUI.Th, "RelaxLocality" ).Th(JQueryUI.Th, "NodeLabelExpression").(); bool odd = false; foreach (ResourceRequest request in resourceRequests) { if (request.GetNumContainers() == 0) { continue; } table.Tr((odd = !odd) ? JQueryUI.Odd : JQueryUI.Even).Td(request.GetPriority().ToString ()).Td(request.GetResourceName()).Td(request.GetCapability().ToString()).Td(request .GetNumContainers().ToString()).Td(request.GetRelaxLocality().ToString()).Td(request .GetNodeLabelExpression() == null ? "N/A" : request.GetNodeLabelExpression()).(); } table.(); div.(); }
/// <exception cref="System.Exception"/> protected override void ServiceStart() { Configuration conf = this.GetConfig(); string bindAddress = conf.Get(YarnConfiguration.ProxyAddress); bindAddress = StringUtils.Split(bindAddress, ':')[0]; AccessControlList acl = new AccessControlList(conf.Get(YarnConfiguration.YarnAdminAcl , YarnConfiguration.DefaultYarnAdminAcl)); this.proxyServer = new HttpServer2.Builder().SetName("proxy").AddEndpoint(URI.Create (WebAppUtils.GetHttpSchemePrefix(conf) + bindAddress + ":0")).SetFindPort(true). SetConf(conf).SetACL(acl).Build(); this.proxyServer.AddServlet(ProxyUriUtils.ProxyServletName, ProxyUriUtils.ProxyPathSpec , typeof(WebAppProxyServlet)); this.appReportFetcher = new TestWebAppProxyServlet.AppReportFetcherForTest(this, conf); this.proxyServer.SetAttribute(WebAppProxy.FetcherAttribute, this.appReportFetcher ); this.proxyServer.SetAttribute(WebAppProxy.IsSecurityEnabledAttribute, true); string proxy = WebAppUtils.GetProxyHostAndPort(conf); string[] proxyParts = proxy.Split(":"); string proxyHost = proxyParts[0]; this.proxyServer.SetAttribute(WebAppProxy.ProxyHostAttribute, proxyHost); this.proxyServer.Start(); TestWebAppProxyServlet.Log.Info("Proxy server is started at port {}", this.proxyServer .GetConnectorAddress(0).Port); }
/// <exception cref="System.IO.IOException"/> protected override void DoGet(HttpServletRequest req, HttpServletResponse resp) { try { string userApprovedParamS = req.GetParameter(ProxyUriUtils.ProxyApprovalParam); bool userWasWarned = false; bool userApproved = Sharpen.Extensions.ValueOf(userApprovedParamS); bool securityEnabled = IsSecurityEnabled(); string remoteUser = req.GetRemoteUser(); string pathInfo = req.GetPathInfo(); string[] parts = pathInfo.Split("/", 3); if (parts.Length < 2) { Log.Warn("{} gave an invalid proxy path {}", remoteUser, pathInfo); NotFound(resp, "Your path appears to be formatted incorrectly."); return; } //parts[0] is empty because path info always starts with a / string appId = parts[1]; string rest = parts.Length > 2 ? parts[2] : string.Empty; ApplicationId id = Apps.ToAppID(appId); if (id == null) { Log.Warn("{} attempting to access {} that is invalid", remoteUser, appId); NotFound(resp, appId + " appears to be formatted incorrectly."); return; } if (securityEnabled) { string cookieName = GetCheckCookieName(id); Cookie[] cookies = req.GetCookies(); if (cookies != null) { foreach (Cookie c in cookies) { if (cookieName.Equals(c.GetName())) { userWasWarned = true; userApproved = userApproved || Sharpen.Extensions.ValueOf(c.GetValue()); break; } } } } bool checkUser = securityEnabled && (!userWasWarned || !userApproved); AppReportFetcher.FetchedAppReport fetchedAppReport = null; ApplicationReport applicationReport = null; try { fetchedAppReport = GetApplicationReport(id); if (fetchedAppReport != null) { if (fetchedAppReport.GetAppReportSource() != AppReportFetcher.AppReportSource.Rm && fetchedAppReport.GetAppReportSource() != AppReportFetcher.AppReportSource.Ahs) { throw new NotSupportedException("Application report not " + "fetched from RM or history server." ); } applicationReport = fetchedAppReport.GetApplicationReport(); } } catch (ApplicationNotFoundException) { applicationReport = null; } if (applicationReport == null) { Log.Warn("{} attempting to access {} that was not found", remoteUser, id); URI toFetch = ProxyUriUtils.GetUriFromTrackingPlugins(id, this.trackingUriPlugins ); if (toFetch != null) { ProxyUtils.SendRedirect(req, resp, toFetch.ToString()); return; } NotFound(resp, "Application " + appId + " could not be found " + "in RM or history server" ); return; } string original = applicationReport.GetOriginalTrackingUrl(); URI trackingUri; if (original == null || original.Equals("N/A") || original.Equals(string.Empty)) { if (fetchedAppReport.GetAppReportSource() == AppReportFetcher.AppReportSource.Rm) { // fallback to ResourceManager's app page if no tracking URI provided // and Application Report was fetched from RM Log.Debug("Original tracking url is '{}'. Redirecting to RM app page", original == null ? "NULL" : original); ProxyUtils.SendRedirect(req, resp, StringHelper.Pjoin(rmAppPageUrlBase, id.ToString ())); } else { if (fetchedAppReport.GetAppReportSource() == AppReportFetcher.AppReportSource.Ahs) { // fallback to Application History Server app page if the application // report was fetched from AHS Log.Debug("Original tracking url is '{}'. Redirecting to AHS app page", original == null ? "NULL" : original); ProxyUtils.SendRedirect(req, resp, StringHelper.Pjoin(ahsAppPageUrlBase, id.ToString ())); } } return; } else { if (ProxyUriUtils.GetSchemeFromUrl(original).IsEmpty()) { trackingUri = ProxyUriUtils.GetUriFromAMUrl(WebAppUtils.GetHttpSchemePrefix(conf) , original); } else { trackingUri = new URI(original); } } string runningUser = applicationReport.GetUser(); if (checkUser && !runningUser.Equals(remoteUser)) { Log.Info("Asking {} if they want to connect to the " + "app master GUI of {} owned by {}" , remoteUser, appId, runningUser); WarnUserPage(resp, ProxyUriUtils.GetPathAndQuery(id, rest, req.GetQueryString(), true), runningUser, id); return; } // Append the user-provided path and query parameter to the original // tracking url. IList <NameValuePair> queryPairs = URLEncodedUtils.Parse(req.GetQueryString(), null ); UriBuilder builder = UriBuilder.FromUri(trackingUri); foreach (NameValuePair pair in queryPairs) { builder.QueryParam(pair.GetName(), pair.GetValue()); } URI toFetch_1 = builder.Path(rest).Build(); Log.Info("{} is accessing unchecked {}" + " which is the app master GUI of {} owned by {}" , remoteUser, toFetch_1, appId, runningUser); switch (applicationReport.GetYarnApplicationState()) { case YarnApplicationState.Killed: case YarnApplicationState.Finished: case YarnApplicationState.Failed: { ProxyUtils.SendRedirect(req, resp, toFetch_1.ToString()); return; } default: { break; } } // fall out of the switch Cookie c_1 = null; if (userWasWarned && userApproved) { c_1 = MakeCheckCookie(id, true); } ProxyLink(req, resp, toFetch_1, c_1, GetProxyHost()); } catch (Exception e) { throw new IOException(e); } }
/// <exception cref="System.Exception"/> protected override void ServiceStart() { try { Configuration conf = GetConfig(); HttpServer2.Builder b = new HttpServer2.Builder().SetName("proxy").AddEndpoint(URI .Create(WebAppUtils.GetHttpSchemePrefix(conf) + bindAddress + ":" + port)).SetFindPort (port == 0).SetConf(GetConfig()).SetACL(acl); if (YarnConfiguration.UseHttps(conf)) { WebAppUtils.LoadSslConfiguration(b); } proxyServer = b.Build(); proxyServer.AddServlet(ProxyUriUtils.ProxyServletName, ProxyUriUtils.ProxyPathSpec , typeof(WebAppProxyServlet)); proxyServer.SetAttribute(FetcherAttribute, fetcher); proxyServer.SetAttribute(IsSecurityEnabledAttribute, isSecurityEnabled); proxyServer.SetAttribute(ProxyHostAttribute, proxyHost); proxyServer.Start(); } catch (IOException e) { Log.Error("Could not start proxy web server", e); throw; } base.ServiceStart(); }
protected override void Render(HtmlBlock.Block html) { Hamlet.TBODY <Hamlet.TABLE <Org.Apache.Hadoop.Yarn.Webapp.Hamlet.Hamlet> > tbody = html .Table("#apps").Thead().Tr().Th(".id", "ID").Th(".user", "User").Th(".name", "Name" ).Th(".type", "Application Type").Th(".queue", "Queue").Th(".fairshare", "Fair Share" ).Th(".starttime", "StartTime").Th(".finishtime", "FinishTime").Th(".state", "State" ).Th(".finalstatus", "FinalStatus").Th(".progress", "Progress").Th(".ui", "Tracking UI" ).().().Tbody(); ICollection <YarnApplicationState> reqAppStates = null; string reqStateString = $(YarnWebParams.AppState); if (reqStateString != null && !reqStateString.IsEmpty()) { string[] appStateStrings = reqStateString.Split(","); reqAppStates = new HashSet <YarnApplicationState>(appStateStrings.Length); foreach (string stateString in appStateStrings) { reqAppStates.AddItem(YarnApplicationState.ValueOf(stateString)); } } StringBuilder appsTableData = new StringBuilder("[\n"); foreach (RMApp app in apps.Values) { if (reqAppStates != null && !reqAppStates.Contains(app.CreateApplicationState())) { continue; } AppInfo appInfo = new AppInfo(rm, app, true, WebAppUtils.GetHttpSchemePrefix(conf )); string percent = string.Format("%.1f", appInfo.GetProgress()); ApplicationAttemptId attemptId = app.GetCurrentAppAttempt().GetAppAttemptId(); int fairShare = fsinfo.GetAppFairShare(attemptId); if (fairShare == FairSchedulerInfo.InvalidFairShare) { // FairScheduler#applications don't have the entry. Skip it. continue; } appsTableData.Append("[\"<a href='").Append(Url("app", appInfo.GetAppId())).Append ("'>").Append(appInfo.GetAppId()).Append("</a>\",\"").Append(StringEscapeUtils.EscapeJavaScript (StringEscapeUtils.EscapeHtml(appInfo.GetUser()))).Append("\",\"").Append(StringEscapeUtils .EscapeJavaScript(StringEscapeUtils.EscapeHtml(appInfo.GetName()))).Append("\",\"" ).Append(StringEscapeUtils.EscapeJavaScript(StringEscapeUtils.EscapeHtml(appInfo .GetApplicationType()))).Append("\",\"").Append(StringEscapeUtils.EscapeJavaScript (StringEscapeUtils.EscapeHtml(appInfo.GetQueue()))).Append("\",\"").Append(fairShare ).Append("\",\"").Append(appInfo.GetStartTime()).Append("\",\"").Append(appInfo. GetFinishTime()).Append("\",\"").Append(appInfo.GetState()).Append("\",\"").Append (appInfo.GetFinalStatus()).Append("\",\"").Append("<br title='").Append(percent) .Append("'> <div class='").Append(JQueryUI.CProgressbar).Append("' title='").Append (StringHelper.Join(percent, '%')).Append("'> ").Append("<div class='").Append(JQueryUI .CProgressbarValue).Append("' style='").Append(StringHelper.Join("width:", percent , '%')).Append("'> </div> </div>").Append("\",\"<a href='"); // Progress bar string trackingURL = !appInfo.IsTrackingUrlReady() ? "#" : appInfo.GetTrackingUrlPretty (); appsTableData.Append(trackingURL).Append("'>").Append(appInfo.GetTrackingUI()).Append ("</a>\"],\n"); } if (appsTableData[appsTableData.Length - 2] == ',') { appsTableData.Delete(appsTableData.Length - 2, appsTableData.Length - 1); } appsTableData.Append("]"); html.Script().$type("text/javascript").("var appsTableData=" + appsTableData).(); tbody.().(); }
public virtual WebApp Build(WebApp webapp) { if (webapp == null) { webapp = new _WebApp_171(); } // Defaults should be fine in usual cases webapp.SetName(name); webapp.SetWebServices(wsName); string basePath = "/" + name; webapp.SetRedirectPath(basePath); IList <string> pathList = new AList <string>(); if (basePath.Equals("/")) { webapp.AddServePathSpec("/*"); pathList.AddItem("/*"); } else { webapp.AddServePathSpec(basePath); webapp.AddServePathSpec(basePath + "/*"); pathList.AddItem(basePath + "/*"); } if (wsName != null && !wsName.Equals(basePath)) { if (wsName.Equals("/")) { webapp.AddServePathSpec("/*"); pathList.AddItem("/*"); } else { webapp.AddServePathSpec("/" + wsName); webapp.AddServePathSpec("/" + wsName + "/*"); pathList.AddItem("/" + wsName + "/*"); } } if (conf == null) { conf = new Configuration(); } try { if (application != null) { webapp.SetHostClass(application.GetType()); } else { string cls = InferHostClass(); Log.Debug("setting webapp host class to {}", cls); webapp.SetHostClass(Sharpen.Runtime.GetType(cls)); } if (devMode) { if (port > 0) { try { new Uri("http://localhost:" + port + "/__stop").GetContent(); Log.Info("stopping existing webapp instance"); Sharpen.Thread.Sleep(100); } catch (ConnectException e) { Log.Info("no existing webapp instance found: {}", e.ToString()); } catch (Exception e) { // should not be fatal Log.Warn("error stopping existing instance: {}", e.ToString()); } } else { Log.Error("dev mode does NOT work with ephemeral port!"); System.Environment.Exit(1); } } string httpScheme; if (this.httpPolicy == null) { httpScheme = WebAppUtils.GetHttpSchemePrefix(conf); } else { httpScheme = (httpPolicy == HttpConfig.Policy.HttpsOnly) ? WebAppUtils.HttpsPrefix : WebAppUtils.HttpPrefix; } HttpServer2.Builder builder = new HttpServer2.Builder().SetName(name).AddEndpoint (URI.Create(httpScheme + bindAddress + ":" + port)).SetConf(conf).SetFindPort(findPort ).SetACL(new AccessControlList(conf.Get(YarnConfiguration.YarnAdminAcl, YarnConfiguration .DefaultYarnAdminAcl))).SetPathSpec(Sharpen.Collections.ToArray(pathList, new string [0])); bool hasSpnegoConf = spnegoPrincipalKey != null && conf.Get(spnegoPrincipalKey) != null && spnegoKeytabKey != null && conf.Get(spnegoKeytabKey) != null; if (hasSpnegoConf) { builder.SetUsernameConfKey(spnegoPrincipalKey).SetKeytabConfKey(spnegoKeytabKey). SetSecurityEnabled(UserGroupInformation.IsSecurityEnabled()); } if (httpScheme.Equals(WebAppUtils.HttpsPrefix)) { WebAppUtils.LoadSslConfiguration(builder); } HttpServer2 server = builder.Build(); foreach (WebApps.Builder.ServletStruct @struct in servlets) { server.AddServlet(@struct.name, @struct.spec, @struct.clazz); } foreach (KeyValuePair <string, object> entry in attributes) { server.SetAttribute(entry.Key, entry.Value); } HttpServer2.DefineFilter(server.GetWebAppContext(), "guice", typeof(GuiceFilter). FullName, null, new string[] { "/*" }); webapp.SetConf(conf); webapp.SetHttpServer(server); } catch (TypeLoadException e) { throw new WebAppException("Error starting http server", e); } catch (IOException e) { throw new WebAppException("Error starting http server", e); } Injector injector = Guice.CreateInjector(webapp, new _AbstractModule_280(this)); Log.Info("Registered webapp guice modules"); // save a guice filter instance for webapp stop (mostly for unit tests) webapp.SetGuiceFilter(injector.GetInstance <GuiceFilter>()); if (devMode) { injector.GetInstance <Dispatcher>().SetDevMode(devMode); Log.Info("in dev mode!"); } return(webapp); }