HADOOP-11875. [JDK9] Adding a second copy of Hamlet without _ as a one-character identifier.

This commit is contained in:
Akira Ajisaka 2017-07-28 08:57:34 +09:00
parent c6330f22a5
commit 38c6fa5c7a
No known key found for this signature in database
GPG Key ID: C1EDBB9CA400FD50
113 changed files with 35634 additions and 1100 deletions

View File

@ -84,11 +84,11 @@ protected AppController(App app, Configuration conf, RequestContext ctx) {
public void info() {
AppInfo info = new AppInfo(app, app.context);
info("Application Master Overview").
_("Application ID:", info.getId()).
_("Application Name:", info.getName()).
_("User:", info.getUser()).
_("Started on:", Times.format(info.getStartTime())).
_("Elasped: ", org.apache.hadoop.util.StringUtils.formatTime(
__("Application ID:", info.getId()).
__("Application Name:", info.getName()).
__("User:", info.getUser()).
__("Started on:", Times.format(info.getStartTime())).
__("Elasped: ", org.apache.hadoop.util.StringUtils.formatTime(
info.getElapsedTime() ));
render(InfoPage.class);
}

View File

@ -25,14 +25,14 @@
public class AppView extends TwoColumnLayout {
@Override protected void preHead(Page.HTML<_> html) {
@Override protected void preHead(Page.HTML<__> html) {
commonPreHead(html);
set(DATATABLES_ID, "jobs");
set(initID(DATATABLES, "jobs"), jobsTableInit());
setTableStyles(html, "jobs");
}
protected void commonPreHead(Page.HTML<_> html) {
protected void commonPreHead(Page.HTML<__> html) {
set(ACCORDION_ID, "nav");
set(initID(ACCORDION, "nav"), "{autoHeight:false, active:1}");
}

View File

@ -30,10 +30,10 @@
import org.apache.hadoop.mapreduce.v2.app.webapp.dao.ConfEntryInfo;
import org.apache.hadoop.mapreduce.v2.app.webapp.dao.ConfInfo;
import org.apache.hadoop.mapreduce.v2.util.MRApps;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TBODY;
import org.apache.hadoop.yarn.webapp.hamlet.HamletSpec.InputType;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TABLE;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TBODY;
import org.apache.hadoop.yarn.webapp.hamlet2.HamletSpec.InputType;
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
import com.google.inject.Inject;
@ -56,21 +56,21 @@ public class ConfBlock extends HtmlBlock {
String jid = $(JOB_ID);
if (jid.isEmpty()) {
html.
p()._("Sorry, can't do anything without a JobID.")._();
p().__("Sorry, can't do anything without a JobID.").__();
return;
}
JobId jobID = MRApps.toJobID(jid);
Job job = appContext.getJob(jobID);
if (job == null) {
html.
p()._("Sorry, ", jid, " not found.")._();
p().__("Sorry, ", jid, " not found.").__();
return;
}
Path confPath = job.getConfFile();
try {
ConfInfo info = new ConfInfo(job);
html.div().a("/jobhistory/downloadconf/" + jid, confPath.toString())._();
html.div().a("/jobhistory/downloadconf/" + jid, confPath.toString()).__();
TBODY<TABLE<Hamlet>> tbody = html.
// Tasks table
table("#conf").
@ -79,8 +79,8 @@ public class ConfBlock extends HtmlBlock {
th(_TH, "key").
th(_TH, "value").
th(_TH, "source chain").
_().
_().
__().
__().
tbody();
for (ConfEntryInfo entry : info.getProperties()) {
StringBuffer buffer = new StringBuffer();
@ -100,20 +100,20 @@ public class ConfBlock extends HtmlBlock {
td(entry.getName()).
td(entry.getValue()).
td(buffer.toString()).
_();
__();
}
tbody._().
tbody.__().
tfoot().
tr().
th().input("search_init").$type(InputType.text).$name("key").$value("key")._()._().
th().input("search_init").$type(InputType.text).$name("value").$value("value")._()._().
th().input("search_init").$type(InputType.text).$name("source chain").$value("source chain")._()._().
_().
_().
_();
th().input("search_init").$type(InputType.text).$name("key").$value("key").__().__().
th().input("search_init").$type(InputType.text).$name("value").$value("value").__().__().
th().input("search_init").$type(InputType.text).$name("source chain").$value("source chain").__().__().
__().
__().
__();
} catch(IOException e) {
LOG.error("Error while reading "+confPath, e);
html.p()._("Sorry got an error while reading conf file. ",confPath);
html.p().__("Sorry got an error while reading conf file. ", confPath);
}
}
}

View File

@ -34,13 +34,13 @@
import org.apache.hadoop.mapreduce.v2.app.job.Job;
import org.apache.hadoop.mapreduce.v2.app.job.Task;
import org.apache.hadoop.mapreduce.v2.util.MRApps;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.DIV;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TBODY;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TD;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.THEAD;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TR;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.DIV;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TABLE;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TBODY;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TD;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.THEAD;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TR;
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
import com.google.inject.Inject;
@ -60,12 +60,12 @@ public class CountersBlock extends HtmlBlock {
@Override protected void render(Block html) {
if (job == null) {
html.
p()._("Sorry, no counters for nonexistent", $(JOB_ID, "job"))._();
p().__("Sorry, no counters for nonexistent", $(JOB_ID, "job")).__();
return;
}
if (!$(TASK_ID).isEmpty() && task == null) {
html.
p()._("Sorry, no counters for nonexistent", $(TASK_ID, "task"))._();
p().__("Sorry, no counters for nonexistent", $(TASK_ID, "task")).__();
return;
}
@ -75,7 +75,7 @@ public class CountersBlock extends HtmlBlock {
type = $(JOB_ID, "the job");
}
html.
p()._("Sorry it looks like ",type," has no counters.")._();
p().__("Sorry it looks like ", type, " has no counters.").__();
return;
}
@ -97,7 +97,7 @@ public class CountersBlock extends HtmlBlock {
thead().
tr().
th(".group.ui-state-default", "Counter Group").
th(".ui-state-default", "Counters")._()._().
th(".ui-state-default", "Counters").__().__().
tbody();
for (CounterGroup g : total) {
CounterGroup mg = map == null ? null : map.getGroup(g.getName());
@ -109,7 +109,7 @@ public class CountersBlock extends HtmlBlock {
TR<THEAD<TABLE<TD<TR<TBODY<TABLE<DIV<Hamlet>>>>>>>> groupHeadRow = tbody.
tr().
th().$title(g.getName()).$class("ui-state-default").
_(fixGroupDisplayName(g.getDisplayName()))._().
__(fixGroupDisplayName(g.getDisplayName())).__().
td().$class(C_TABLE).
table(".dt-counters").$id(job.getID()+"."+g.getName()).
thead().
@ -120,20 +120,20 @@ public class CountersBlock extends HtmlBlock {
}
// Ditto
TBODY<TABLE<TD<TR<TBODY<TABLE<DIV<Hamlet>>>>>>> group = groupHeadRow.
th(map == null ? "Value" : "Total")._()._().
th(map == null ? "Value" : "Total").__().__().
tbody();
for (Counter counter : g) {
// Ditto
TR<TBODY<TABLE<TD<TR<TBODY<TABLE<DIV<Hamlet>>>>>>>> groupRow = group.
tr();
if (task == null && mg == null && rg == null) {
groupRow.td().$title(counter.getName())._(counter.getDisplayName()).
_();
groupRow.td().$title(counter.getName()).__(counter.getDisplayName()).
__();
} else {
groupRow.td().$title(counter.getName()).
a(url(urlBase,urlId,g.getName(),
counter.getName()), counter.getDisplayName()).
_();
__();
}
if (map != null) {
Counter mc = mg == null ? null : mg.findCounter(counter.getName());
@ -142,11 +142,11 @@ public class CountersBlock extends HtmlBlock {
td(mc == null ? "0" : String.format("%,d", mc.getValue())).
td(rc == null ? "0" : String.format("%,d", rc.getValue()));
}
groupRow.td(String.format("%,d", counter.getValue()))._();
groupRow.td(String.format("%,d", counter.getValue())).__();
}
group._()._()._()._();
group.__().__().__().__();
}
tbody._()._()._();
tbody.__().__().__();
}
private void getCounters(AppContext ctx) {

View File

@ -25,7 +25,7 @@
public class CountersPage extends AppView {
@Override protected void preHead(Page.HTML<_> html) {
@Override protected void preHead(Page.HTML<__> html) {
commonPreHead(html);
String tid = $(TASK_ID);
@ -39,7 +39,7 @@ public class CountersPage extends AppView {
"{bJQueryUI:true, sDom:'t', iDisplayLength:-1}");
}
@Override protected void postHead(Page.HTML<_> html) {
@Override protected void postHead(Page.HTML<__> html) {
html.
style("#counters, .dt-counters { table-layout: fixed }",
"#counters th { overflow: hidden; vertical-align: middle }",

View File

@ -23,7 +23,7 @@
public class InfoPage extends AppView {
@Override protected void preHead(Page.HTML<_> html) {
@Override protected void preHead(Page.HTML<__> html) {
commonPreHead(html);
setTitle("About the Application Master");
}

View File

@ -30,7 +30,6 @@
import java.util.Date;
import java.util.List;
import org.apache.hadoop.http.HttpConfig;
import org.apache.hadoop.mapreduce.v2.api.records.AMInfo;
import org.apache.hadoop.mapreduce.v2.api.records.JobId;
import org.apache.hadoop.mapreduce.v2.app.AppContext;
@ -41,9 +40,9 @@
import org.apache.hadoop.mapreduce.v2.util.MRApps.TaskAttemptStateUI;
import org.apache.hadoop.mapreduce.v2.util.MRWebAppUtil;
import org.apache.hadoop.util.StringUtils;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.DIV;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.DIV;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TABLE;
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
import org.apache.hadoop.yarn.webapp.view.InfoBlock;
@ -60,14 +59,14 @@ public class JobBlock extends HtmlBlock {
String jid = $(JOB_ID);
if (jid.isEmpty()) {
html.
p()._("Sorry, can't do anything without a JobID.")._();
p().__("Sorry, can't do anything without a JobID.").__();
return;
}
JobId jobID = MRApps.toJobID(jid);
Job job = appContext.getJob(jobID);
if (job == null) {
html.
p()._("Sorry, ", jid, " not found.")._();
p().__("Sorry, ", jid, " not found.").__();
return;
}
@ -77,15 +76,15 @@ public class JobBlock extends HtmlBlock {
JobInfo jinfo = new JobInfo(job, true);
info("Job Overview").
_("Job Name:", jinfo.getName()).
_("User Name:", jinfo.getUserName()).
_("Queue Name:", jinfo.getQueueName()).
_("State:", jinfo.getState()).
_("Uberized:", jinfo.isUberized()).
_("Started:", new Date(jinfo.getStartTime())).
_("Elapsed:", StringUtils.formatTime(jinfo.getElapsedTime()));
__("Job Name:", jinfo.getName()).
__("User Name:", jinfo.getUserName()).
__("Queue Name:", jinfo.getQueueName()).
__("State:", jinfo.getState()).
__("Uberized:", jinfo.isUberized()).
__("Started:", new Date(jinfo.getStartTime())).
__("Elapsed:", StringUtils.formatTime(jinfo.getElapsedTime()));
DIV<Hamlet> div = html.
_(InfoBlock.class).
__(InfoBlock.class).
div(_INFO_WRAP);
// MRAppMasters Table
@ -93,13 +92,13 @@ public class JobBlock extends HtmlBlock {
table.
tr().
th(amString).
_().
__().
tr().
th(_TH, "Attempt Number").
th(_TH, "Start Time").
th(_TH, "Node").
th(_TH, "Logs").
_();
__();
for (AMInfo amInfo : amInfos) {
AMAttemptInfo attempt = new AMAttemptInfo(amInfo,
jinfo.getId(), jinfo.getUserName());
@ -109,14 +108,14 @@ public class JobBlock extends HtmlBlock {
td(new Date(attempt.getStartTime()).toString()).
td().a(".nodelink", url(MRWebAppUtil.getYARNWebappScheme(),
attempt.getNodeHttpAddress()),
attempt.getNodeHttpAddress())._().
attempt.getNodeHttpAddress()).__().
td().a(".logslink", url(attempt.getLogsLink()),
"logs")._().
_();
"logs").__().
__();
}
table._();
div._();
table.__();
div.__();
html.div(_INFO_WRAP).
// Tasks table
@ -127,30 +126,30 @@ public class JobBlock extends HtmlBlock {
th(_TH, "Total").
th(_TH, "Pending").
th(_TH, "Running").
th(_TH, "Complete")._().
th(_TH, "Complete").__().
tr(_ODD).
th("Map").
td().
div(_PROGRESSBAR).
$title(join(jinfo.getMapProgressPercent(), '%')). // tooltip
div(_PROGRESSBAR_VALUE).
$style(join("width:", jinfo.getMapProgressPercent(), '%'))._()._()._().
td().a(url("tasks", jid, "m", "ALL"),String.valueOf(jinfo.getMapsTotal()))._().
td().a(url("tasks", jid, "m", "PENDING"),String.valueOf(jinfo.getMapsPending()))._().
td().a(url("tasks", jid, "m", "RUNNING"),String.valueOf(jinfo.getMapsRunning()))._().
td().a(url("tasks", jid, "m", "COMPLETED"),String.valueOf(jinfo.getMapsCompleted()))._()._().
$style(join("width:", jinfo.getMapProgressPercent(), '%')).__().__().__().
td().a(url("tasks", jid, "m", "ALL"), String.valueOf(jinfo.getMapsTotal())).__().
td().a(url("tasks", jid, "m", "PENDING"), String.valueOf(jinfo.getMapsPending())).__().
td().a(url("tasks", jid, "m", "RUNNING"), String.valueOf(jinfo.getMapsRunning())).__().
td().a(url("tasks", jid, "m", "COMPLETED"), String.valueOf(jinfo.getMapsCompleted())).__().__().
tr(_EVEN).
th("Reduce").
td().
div(_PROGRESSBAR).
$title(join(jinfo.getReduceProgressPercent(), '%')). // tooltip
div(_PROGRESSBAR_VALUE).
$style(join("width:", jinfo.getReduceProgressPercent(), '%'))._()._()._().
td().a(url("tasks", jid, "r", "ALL"),String.valueOf(jinfo.getReducesTotal()))._().
td().a(url("tasks", jid, "r", "PENDING"),String.valueOf(jinfo.getReducesPending()))._().
td().a(url("tasks", jid, "r", "RUNNING"),String.valueOf(jinfo.getReducesRunning()))._().
td().a(url("tasks", jid, "r", "COMPLETED"),String.valueOf(jinfo.getReducesCompleted()))._()._()
._().
$style(join("width:", jinfo.getReduceProgressPercent(), '%')).__().__().__().
td().a(url("tasks", jid, "r", "ALL"), String.valueOf(jinfo.getReducesTotal())).__().
td().a(url("tasks", jid, "r", "PENDING"), String.valueOf(jinfo.getReducesPending())).__().
td().a(url("tasks", jid, "r", "RUNNING"), String.valueOf(jinfo.getReducesRunning())).__().
td().a(url("tasks", jid, "r", "COMPLETED"), String.valueOf(jinfo.getReducesCompleted())).__().__()
.__().
// Attempts table
table("#job").
tr().
@ -159,45 +158,45 @@ public class JobBlock extends HtmlBlock {
th(_TH, "Running").
th(_TH, "Failed").
th(_TH, "Killed").
th(_TH, "Successful")._().
th(_TH, "Successful").__().
tr(_ODD).
th("Maps").
td().a(url("attempts", jid, "m",
TaskAttemptStateUI.NEW.toString()),
String.valueOf(jinfo.getNewMapAttempts()))._().
String.valueOf(jinfo.getNewMapAttempts())).__().
td().a(url("attempts", jid, "m",
TaskAttemptStateUI.RUNNING.toString()),
String.valueOf(jinfo.getRunningMapAttempts()))._().
String.valueOf(jinfo.getRunningMapAttempts())).__().
td().a(url("attempts", jid, "m",
TaskAttemptStateUI.FAILED.toString()),
String.valueOf(jinfo.getFailedMapAttempts()))._().
String.valueOf(jinfo.getFailedMapAttempts())).__().
td().a(url("attempts", jid, "m",
TaskAttemptStateUI.KILLED.toString()),
String.valueOf(jinfo.getKilledMapAttempts()))._().
String.valueOf(jinfo.getKilledMapAttempts())).__().
td().a(url("attempts", jid, "m",
TaskAttemptStateUI.SUCCESSFUL.toString()),
String.valueOf(jinfo.getSuccessfulMapAttempts()))._().
_().
String.valueOf(jinfo.getSuccessfulMapAttempts())).__().
__().
tr(_EVEN).
th("Reduces").
td().a(url("attempts", jid, "r",
TaskAttemptStateUI.NEW.toString()),
String.valueOf(jinfo.getNewReduceAttempts()))._().
String.valueOf(jinfo.getNewReduceAttempts())).__().
td().a(url("attempts", jid, "r",
TaskAttemptStateUI.RUNNING.toString()),
String.valueOf(jinfo.getRunningReduceAttempts()))._().
String.valueOf(jinfo.getRunningReduceAttempts())).__().
td().a(url("attempts", jid, "r",
TaskAttemptStateUI.FAILED.toString()),
String.valueOf(jinfo.getFailedReduceAttempts()))._().
String.valueOf(jinfo.getFailedReduceAttempts())).__().
td().a(url("attempts", jid, "r",
TaskAttemptStateUI.KILLED.toString()),
String.valueOf(jinfo.getKilledReduceAttempts()))._().
String.valueOf(jinfo.getKilledReduceAttempts())).__().
td().a(url("attempts", jid, "r",
TaskAttemptStateUI.SUCCESSFUL.toString()),
String.valueOf(jinfo.getSuccessfulReduceAttempts()))._().
_().
_().
_();
String.valueOf(jinfo.getSuccessfulReduceAttempts())).__().
__().
__().
__();
}
}

View File

@ -27,7 +27,6 @@
import static org.apache.hadoop.yarn.webapp.view.JQueryUI.postInitID;
import static org.apache.hadoop.yarn.webapp.view.JQueryUI.tableInit;
import org.apache.hadoop.mapreduce.v2.app.webapp.ConfBlock;
import org.apache.hadoop.yarn.webapp.SubView;
/**
@ -39,7 +38,7 @@ public class JobConfPage extends AppView {
* (non-Javadoc)
* @see org.apache.hadoop.mapreduce.v2.hs.webapp.HsView#preHead(org.apache.hadoop.yarn.webapp.hamlet.Hamlet.HTML)
*/
@Override protected void preHead(Page.HTML<_> html) {
@Override protected void preHead(Page.HTML<__> html) {
String jobID = $(JOB_ID);
set(TITLE, jobID.isEmpty() ? "Bad request: missing job ID"
: join("Configuration for MapReduce Job ", $(JOB_ID)));

View File

@ -27,7 +27,7 @@
public class JobPage extends AppView {
@Override protected void preHead(Page.HTML<_> html) {
@Override protected void preHead(Page.HTML<__> html) {
String jobID = $(JOB_ID);
set(TITLE, jobID.isEmpty() ? "Bad request: missing job ID"
: join("MapReduce Job ", $(JOB_ID)));

View File

@ -25,9 +25,9 @@
import org.apache.hadoop.mapreduce.v2.app.AppContext;
import org.apache.hadoop.mapreduce.v2.app.job.Job;
import org.apache.hadoop.mapreduce.v2.app.webapp.dao.JobInfo;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TBODY;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TABLE;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TBODY;
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
import com.google.inject.Inject;
@ -53,34 +53,34 @@ public class JobsBlock extends HtmlBlock {
th("Maps Completed").
th("Reduce Progress").
th("Reduces Total").
th("Reduces Completed")._()._().
th("Reduces Completed").__().__().
tbody();
for (Job j : appContext.getAllJobs().values()) {
JobInfo job = new JobInfo(j, false);
tbody.
tr().
td().
span().$title(String.valueOf(job.getId()))._(). // for sorting
a(url("job", job.getId()), job.getId())._().
span().$title(String.valueOf(job.getId())).__(). // for sorting
a(url("job", job.getId()), job.getId()).__().
td(job.getName()).
td(job.getState()).
td().
span().$title(job.getMapProgressPercent())._(). // for sorting
span().$title(job.getMapProgressPercent()).__(). // for sorting
div(_PROGRESSBAR).
$title(join(job.getMapProgressPercent(), '%')). // tooltip
div(_PROGRESSBAR_VALUE).
$style(join("width:", job.getMapProgressPercent(), '%'))._()._()._().
$style(join("width:", job.getMapProgressPercent(), '%')).__().__().__().
td(String.valueOf(job.getMapsTotal())).
td(String.valueOf(job.getMapsCompleted())).
td().
span().$title(job.getReduceProgressPercent())._(). // for sorting
span().$title(job.getReduceProgressPercent()).__(). // for sorting
div(_PROGRESSBAR).
$title(join(job.getReduceProgressPercent(), '%')). // tooltip
div(_PROGRESSBAR_VALUE).
$style(join("width:", job.getReduceProgressPercent(), '%'))._()._()._().
$style(join("width:", job.getReduceProgressPercent(), '%')).__().__().__().
td(String.valueOf(job.getReducesTotal())).
td(String.valueOf(job.getReducesCompleted()))._();
td(String.valueOf(job.getReducesCompleted())).__();
}
tbody._()._();
tbody.__().__();
}
}

View File

@ -25,8 +25,8 @@
import org.apache.hadoop.mapreduce.v2.api.records.AMInfo;
import org.apache.hadoop.mapreduce.v2.util.MRApps;
import org.apache.hadoop.mapreduce.v2.util.MRWebAppUtil;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.DIV;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.DIV;
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
import com.google.inject.Inject;
@ -42,13 +42,13 @@ public class NavBlock extends HtmlBlock {
div("#nav").
h3("Cluster").
ul().
li().a(url(rmweb, "cluster", "cluster"), "About")._().
li().a(url(rmweb, "cluster", "apps"), "Applications")._().
li().a(url(rmweb, "cluster", "scheduler"), "Scheduler")._()._().
li().a(url(rmweb, "cluster", "cluster"), "About").__().
li().a(url(rmweb, "cluster", "apps"), "Applications").__().
li().a(url(rmweb, "cluster", "scheduler"), "Scheduler").__().__().
h3("Application").
ul().
li().a(url("app/info"), "About")._().
li().a(url("app"), "Jobs")._()._();
li().a(url("app/info"), "About").__().
li().a(url("app"), "Jobs").__().__();
if (app.getJob() != null) {
String jobid = MRApps.toString(app.getJob().getID());
List<AMInfo> amInfos = app.getJob().getAMInfos();
@ -58,31 +58,31 @@ public class NavBlock extends HtmlBlock {
nav.
h3("Job").
ul().
li().a(url("job", jobid), "Overview")._().
li().a(url("jobcounters", jobid), "Counters")._().
li().a(url("conf", jobid), "Configuration")._().
li().a(url("tasks", jobid, "m"), "Map tasks")._().
li().a(url("tasks", jobid, "r"), "Reduce tasks")._().
li().a(url("job", jobid), "Overview").__().
li().a(url("jobcounters", jobid), "Counters").__().
li().a(url("conf", jobid), "Configuration").__().
li().a(url("tasks", jobid, "m"), "Map tasks").__().
li().a(url("tasks", jobid, "r"), "Reduce tasks").__().
li().a(".logslink", url(MRWebAppUtil.getYARNWebappScheme(),
nodeHttpAddress, "node",
"containerlogs", thisAmInfo.getContainerId().toString(),
app.getJob().getUserName()),
"AM Logs")._()._();
"AM Logs").__().__();
if (app.getTask() != null) {
String taskid = MRApps.toString(app.getTask().getID());
nav.
h3("Task").
ul().
li().a(url("task", taskid), "Task Overview")._().
li().a(url("taskcounters", taskid), "Counters")._()._();
li().a(url("task", taskid), "Task Overview").__().
li().a(url("taskcounters", taskid), "Counters").__().__();
}
}
nav.
h3("Tools").
ul().
li().a("/conf", "Configuration")._().
li().a("/logs", "Local logs")._().
li().a("/stacks", "Server stacks")._().
li().a("/jmx?qry=Hadoop:*", "Server metrics")._()._()._();
li().a("/conf", "Configuration").__().
li().a("/logs", "Local logs").__().
li().a("/stacks", "Server stacks").__().
li().a("/jmx?qry=Hadoop:*", "Server metrics").__().__().__();
}
}

View File

@ -39,11 +39,11 @@
import org.apache.hadoop.mapreduce.v2.app.job.Task;
import org.apache.hadoop.mapreduce.v2.app.job.TaskAttempt;
import org.apache.hadoop.mapreduce.v2.util.MRApps;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.DIV;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TBODY;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TR;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.DIV;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TABLE;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TBODY;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TR;
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
import com.google.inject.Inject;
@ -62,12 +62,12 @@ public class SingleCounterBlock extends HtmlBlock {
@Override protected void render(Block html) {
if (job == null) {
html.
p()._("Sorry, no counters for nonexistent", $(JOB_ID, "job"))._();
p().__("Sorry, no counters for nonexistent", $(JOB_ID, "job")).__();
return;
}
if (!$(TASK_ID).isEmpty() && task == null) {
html.
p()._("Sorry, no counters for nonexistent", $(TASK_ID, "task"))._();
p().__("Sorry, no counters for nonexistent", $(TASK_ID, "task")).__();
return;
}
@ -79,7 +79,7 @@ public class SingleCounterBlock extends HtmlBlock {
thead().
tr().
th(".ui-state-default", columnType).
th(".ui-state-default", "Value")._()._().
th(".ui-state-default", "Value").__().__().
tbody();
for (Map.Entry<String, Long> entry : values.entrySet()) {
TR<TBODY<TABLE<DIV<Hamlet>>>> row = tbody.tr();
@ -87,16 +87,16 @@ public class SingleCounterBlock extends HtmlBlock {
String val = entry.getValue().toString();
if(task != null) {
row.td(id);
row.td().br().$title(val)._()._(val)._();
row.td().br().$title(val).__().__(val).__();
} else {
row.td().a(url("singletaskcounter",entry.getKey(),
$(COUNTER_GROUP), $(COUNTER_NAME)), id)._();
row.td().br().$title(val)._().a(url("singletaskcounter",entry.getKey(),
$(COUNTER_GROUP), $(COUNTER_NAME)), val)._();
$(COUNTER_GROUP), $(COUNTER_NAME)), id).__();
row.td().br().$title(val).__().a(url("singletaskcounter", entry.getKey(),
$(COUNTER_GROUP), $(COUNTER_NAME)), val).__();
}
row._();
row.__();
}
tbody._()._()._();
tbody.__().__().__();
}
private void populateMembers(AppContext ctx) {

View File

@ -21,7 +21,6 @@
import static org.apache.hadoop.mapreduce.v2.app.webapp.AMParams.TASK_ID;
import static org.apache.hadoop.yarn.webapp.view.JQueryUI.*;
import org.apache.hadoop.mapreduce.v2.app.webapp.SingleCounterBlock;
import org.apache.hadoop.yarn.webapp.SubView;
/**
@ -33,7 +32,7 @@ public class SingleCounterPage extends AppView {
* (non-Javadoc)
* @see org.apache.hadoop.mapreduce.v2.hs.webapp.HsView#preHead(org.apache.hadoop.yarn.webapp.hamlet.Hamlet.HTML)
*/
@Override protected void preHead(Page.HTML<_> html) {
@Override protected void preHead(Page.HTML<__> html) {
commonPreHead(html);
String tid = $(TASK_ID);
String activeNav = "3";

View File

@ -38,11 +38,11 @@
import org.apache.hadoop.mapreduce.v2.util.MRWebAppUtil;
import org.apache.hadoop.util.StringUtils;
import org.apache.hadoop.yarn.webapp.SubView;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TBODY;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.THEAD;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TR;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TABLE;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TBODY;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.THEAD;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TR;
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
import com.google.inject.Inject;
@ -100,7 +100,7 @@ protected void render(Block html) {
.append(" }\n")
.append("}\n");
html.script().$type("text/javascript")._(script.toString())._();
html.script().$type("text/javascript").__(script.toString()).__();
}
TR<THEAD<TABLE<Hamlet>>> tr = html.table("#attempts").thead().tr();
@ -118,7 +118,7 @@ protected void render(Block html) {
tr.th(".actions", "Actions");
}
TBODY<TABLE<Hamlet>> tbody = tr._()._().tbody();
TBODY<TABLE<Hamlet>> tbody = tr.__().__().tbody();
// Write all the data into a JavaScript array of arrays for JQuery
// DataTables to display
StringBuilder attemptsTableData = new StringBuilder("[\n");
@ -178,9 +178,9 @@ protected void render(Block html) {
}
attemptsTableData.append("]");
html.script().$type("text/javascript").
_("var attemptsTableData=" + attemptsTableData)._();
__("var attemptsTableData=" + attemptsTableData).__();
tbody._()._();
tbody.__().__();
}
@ -197,7 +197,7 @@ protected Collection<TaskAttempt> getTaskAttempts() {
}
}
@Override protected void preHead(Page.HTML<_> html) {
@Override protected void preHead(Page.HTML<__> html) {
commonPreHead(html);
set(initID(ACCORDION, "nav"), "{autoHeight:false, active:3}");

View File

@ -30,9 +30,9 @@
import org.apache.hadoop.mapreduce.v2.app.webapp.dao.TaskInfo;
import org.apache.hadoop.mapreduce.v2.util.MRApps;
import org.apache.hadoop.util.StringUtils;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TBODY;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TABLE;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TBODY;
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
import com.google.inject.Inject;
@ -65,7 +65,7 @@ public class TasksBlock extends HtmlBlock {
th("State").
th("Start Time").
th("Finish Time").
th("Elapsed Time")._()._().
th("Elapsed Time").__().__().
tbody();
StringBuilder tasksTableData = new StringBuilder("[\n");
@ -117,8 +117,8 @@ public class TasksBlock extends HtmlBlock {
}
tasksTableData.append("]");
html.script().$type("text/javascript").
_("var tasksTableData=" + tasksTableData)._();
__("var tasksTableData=" + tasksTableData).__();
tbody._()._();
tbody.__().__();
}
}

View File

@ -24,7 +24,7 @@
public class TasksPage extends AppView {
@Override protected void preHead(Page.HTML<_> html) {
@Override protected void preHead(Page.HTML<__> html) {
commonPreHead(html);
set(DATATABLES_ID, "tasks");
set(initID(ACCORDION, "nav"), "{autoHeight:false, active:2}");

View File

@ -21,7 +21,6 @@
import static org.apache.hadoop.yarn.webapp.view.JQueryUI.ACCORDION;
import static org.apache.hadoop.yarn.webapp.view.JQueryUI.initID;
import org.apache.hadoop.mapreduce.v2.hs.JobHistoryServer;
import org.apache.hadoop.mapreduce.v2.hs.webapp.dao.HistoryInfo;
import org.apache.hadoop.yarn.util.Times;
import org.apache.hadoop.yarn.webapp.SubView;
@ -36,7 +35,7 @@ public class HsAboutPage extends HsView {
* (non-Javadoc)
* @see org.apache.hadoop.mapreduce.v2.hs.webapp.HsView#preHead(org.apache.hadoop.yarn.webapp.hamlet.Hamlet.HTML)
*/
@Override protected void preHead(Page.HTML<_> html) {
@Override protected void preHead(Page.HTML<__> html) {
commonPreHead(html);
//override the nav config from commonPReHead
set(initID(ACCORDION, "nav"), "{autoHeight:false, active:0}");
@ -49,9 +48,9 @@ public class HsAboutPage extends HsView {
@Override protected Class<? extends SubView> content() {
HistoryInfo info = new HistoryInfo();
info("History Server").
_("BuildVersion", info.getHadoopBuildVersion()
__("BuildVersion", info.getHadoopBuildVersion()
+ " on " + info.getHadoopVersionBuiltOn()).
_("History Server started on", Times.format(info.getStartedOn()));
__("History Server started on", Times.format(info.getStartedOn()));
return InfoBlock.class;
}
}

View File

@ -39,7 +39,7 @@ public class HsConfPage extends HsView {
* (non-Javadoc)
* @see org.apache.hadoop.mapreduce.v2.hs.webapp.HsView#preHead(org.apache.hadoop.yarn.webapp.hamlet.Hamlet.HTML)
*/
@Override protected void preHead(Page.HTML<_> html) {
@Override protected void preHead(Page.HTML<__> html) {
String jobID = $(JOB_ID);
set(TITLE, jobID.isEmpty() ? "Bad request: missing job ID"
: join("Configuration for MapReduce Job ", $(JOB_ID)));

View File

@ -32,7 +32,7 @@ public class HsCountersPage extends HsView {
* (non-Javadoc)
* @see org.apache.hadoop.mapreduce.v2.hs.webapp.HsView#preHead(org.apache.hadoop.yarn.webapp.hamlet.Hamlet.HTML)
*/
@Override protected void preHead(Page.HTML<_> html) {
@Override protected void preHead(Page.HTML<__> html) {
commonPreHead(html);
setActiveNavColumnForTask();
set(DATATABLES_SELECTOR, "#counters .dt-counters");
@ -44,7 +44,7 @@ public class HsCountersPage extends HsView {
* (non-Javadoc)
* @see org.apache.hadoop.yarn.webapp.view.TwoColumnLayout#postHead(org.apache.hadoop.yarn.webapp.hamlet.Hamlet.HTML)
*/
@Override protected void postHead(Page.HTML<_> html) {
@Override protected void postHead(Page.HTML<__> html) {
html.
style("#counters, .dt-counters { table-layout: fixed }",
"#counters th { overflow: hidden; vertical-align: middle }",

View File

@ -43,9 +43,9 @@
import org.apache.hadoop.util.StringUtils;
import org.apache.hadoop.yarn.util.Times;
import org.apache.hadoop.yarn.webapp.ResponseInfo;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.DIV;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.DIV;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TABLE;
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
import org.apache.hadoop.yarn.webapp.view.InfoBlock;
@ -69,38 +69,38 @@ public class HsJobBlock extends HtmlBlock {
String jid = $(JOB_ID);
if (jid.isEmpty()) {
html.
p()._("Sorry, can't do anything without a JobID.")._();
p().__("Sorry, can't do anything without a JobID.").__();
return;
}
JobId jobID = MRApps.toJobID(jid);
Job j = appContext.getJob(jobID);
if (j == null) {
html.p()._("Sorry, ", jid, " not found.")._();
html.p().__("Sorry, ", jid, " not found.").__();
return;
}
if(j instanceof UnparsedJob) {
final int taskCount = j.getTotalMaps() + j.getTotalReduces();
UnparsedJob oversizedJob = (UnparsedJob) j;
html.p()._("The job has a total of " + taskCount + " tasks. ")
._("Any job larger than " + oversizedJob.getMaxTasksAllowed() +
" will not be loaded.")._();
html.p()._("You can either use the CLI tool: 'mapred job -history'"
html.p().__("The job has a total of " + taskCount + " tasks. ")
.__("Any job larger than " + oversizedJob.getMaxTasksAllowed() +
" will not be loaded.").__();
html.p().__("You can either use the CLI tool: 'mapred job -history'"
+ " to view large jobs or adjust the property " +
JHAdminConfig.MR_HS_LOADED_JOBS_TASKS_MAX + ".")._();
JHAdminConfig.MR_HS_LOADED_JOBS_TASKS_MAX + ".").__();
return;
}
List<AMInfo> amInfos = j.getAMInfos();
JobInfo job = new JobInfo(j);
ResponseInfo infoBlock = info("Job Overview").
_("Job Name:", job.getName()).
_("User Name:", job.getUserName()).
_("Queue:", job.getQueueName()).
_("State:", job.getState()).
_("Uberized:", job.isUber()).
_("Submitted:", new Date(job.getSubmitTime())).
_("Started:", job.getStartTimeStr()).
_("Finished:", new Date(job.getFinishTime())).
_("Elapsed:", StringUtils.formatTime(
__("Job Name:", job.getName()).
__("User Name:", job.getUserName()).
__("Queue:", job.getQueueName()).
__("State:", job.getState()).
__("Uberized:", job.isUber()).
__("Submitted:", new Date(job.getSubmitTime())).
__("Started:", job.getStartTimeStr()).
__("Finished:", new Date(job.getFinishTime())).
__("Elapsed:", StringUtils.formatTime(
Times.elapsed(job.getStartTime(), job.getFinishTime(), false)));
String amString =
@ -117,19 +117,19 @@ public class HsJobBlock extends HtmlBlock {
}
if(job.getNumMaps() > 0) {
infoBlock._("Average Map Time", StringUtils.formatTime(job.getAvgMapTime()));
infoBlock.__("Average Map Time", StringUtils.formatTime(job.getAvgMapTime()));
}
if(job.getNumReduces() > 0) {
infoBlock._("Average Shuffle Time", StringUtils.formatTime(job.getAvgShuffleTime()));
infoBlock._("Average Merge Time", StringUtils.formatTime(job.getAvgMergeTime()));
infoBlock._("Average Reduce Time", StringUtils.formatTime(job.getAvgReduceTime()));
infoBlock.__("Average Shuffle Time", StringUtils.formatTime(job.getAvgShuffleTime()));
infoBlock.__("Average Merge Time", StringUtils.formatTime(job.getAvgMergeTime()));
infoBlock.__("Average Reduce Time", StringUtils.formatTime(job.getAvgReduceTime()));
}
for (ConfEntryInfo entry : job.getAcls()) {
infoBlock._("ACL "+entry.getName()+":", entry.getValue());
infoBlock.__("ACL "+entry.getName()+":", entry.getValue());
}
DIV<Hamlet> div = html.
_(InfoBlock.class).
__(InfoBlock.class).
div(_INFO_WRAP);
// MRAppMasters Table
@ -137,13 +137,13 @@ public class HsJobBlock extends HtmlBlock {
table.
tr().
th(amString).
_().
__().
tr().
th(_TH, "Attempt Number").
th(_TH, "Start Time").
th(_TH, "Node").
th(_TH, "Logs").
_();
__();
boolean odd = false;
for (AMInfo amInfo : amInfos) {
AMAttemptInfo attempt = new AMAttemptInfo(amInfo,
@ -153,13 +153,13 @@ public class HsJobBlock extends HtmlBlock {
td(new Date(attempt.getStartTime()).toString()).
td().a(".nodelink", url(MRWebAppUtil.getYARNWebappScheme(),
attempt.getNodeHttpAddress()),
attempt.getNodeHttpAddress())._().
attempt.getNodeHttpAddress()).__().
td().a(".logslink", url(attempt.getLogsLink()),
"logs")._().
_();
"logs").__().
__();
}
table._();
div._();
table.__();
div.__();
html.div(_INFO_WRAP).
@ -169,18 +169,18 @@ public class HsJobBlock extends HtmlBlock {
tr().
th(_TH, "Task Type").
th(_TH, "Total").
th(_TH, "Complete")._().
th(_TH, "Complete").__().
tr(_ODD).
th().
a(url("tasks", jid, "m"), "Map")._().
a(url("tasks", jid, "m"), "Map").__().
td(String.valueOf(String.valueOf(job.getMapsTotal()))).
td(String.valueOf(String.valueOf(job.getMapsCompleted())))._().
td(String.valueOf(String.valueOf(job.getMapsCompleted()))).__().
tr(_EVEN).
th().
a(url("tasks", jid, "r"), "Reduce")._().
a(url("tasks", jid, "r"), "Reduce").__().
td(String.valueOf(String.valueOf(job.getReducesTotal()))).
td(String.valueOf(String.valueOf(job.getReducesCompleted())))._()
._().
td(String.valueOf(String.valueOf(job.getReducesCompleted()))).__()
.__().
// Attempts table
table("#job").
@ -188,33 +188,33 @@ public class HsJobBlock extends HtmlBlock {
th(_TH, "Attempt Type").
th(_TH, "Failed").
th(_TH, "Killed").
th(_TH, "Successful")._().
th(_TH, "Successful").__().
tr(_ODD).
th("Maps").
td().a(url("attempts", jid, "m",
TaskAttemptStateUI.FAILED.toString()),
String.valueOf(job.getFailedMapAttempts()))._().
String.valueOf(job.getFailedMapAttempts())).__().
td().a(url("attempts", jid, "m",
TaskAttemptStateUI.KILLED.toString()),
String.valueOf(job.getKilledMapAttempts()))._().
String.valueOf(job.getKilledMapAttempts())).__().
td().a(url("attempts", jid, "m",
TaskAttemptStateUI.SUCCESSFUL.toString()),
String.valueOf(job.getSuccessfulMapAttempts()))._().
_().
String.valueOf(job.getSuccessfulMapAttempts())).__().
__().
tr(_EVEN).
th("Reduces").
td().a(url("attempts", jid, "r",
TaskAttemptStateUI.FAILED.toString()),
String.valueOf(job.getFailedReduceAttempts()))._().
String.valueOf(job.getFailedReduceAttempts())).__().
td().a(url("attempts", jid, "r",
TaskAttemptStateUI.KILLED.toString()),
String.valueOf(job.getKilledReduceAttempts()))._().
String.valueOf(job.getKilledReduceAttempts())).__().
td().a(url("attempts", jid, "r",
TaskAttemptStateUI.SUCCESSFUL.toString()),
String.valueOf(job.getSuccessfulReduceAttempts()))._().
_().
_().
_();
String.valueOf(job.getSuccessfulReduceAttempts())).__().
__().
__().
__();
}
static String addTaskLinks(String text) {

View File

@ -34,7 +34,7 @@ public class HsJobPage extends HsView {
* (non-Javadoc)
* @see org.apache.hadoop.mapreduce.v2.hs.webapp.HsView#preHead(org.apache.hadoop.yarn.webapp.hamlet.Hamlet.HTML)
*/
@Override protected void preHead(Page.HTML<_> html) {
@Override protected void preHead(Page.HTML<__> html) {
String jobID = $(JOB_ID);
set(TITLE, jobID.isEmpty() ? "Bad request: missing job ID"
: join("MapReduce Job ", $(JOB_ID)));

View File

@ -27,10 +27,10 @@
import org.apache.hadoop.mapreduce.v2.hs.webapp.dao.JobInfo;
import org.apache.hadoop.util.StringUtils;
import org.apache.hadoop.yarn.util.Times;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TBODY;
import org.apache.hadoop.yarn.webapp.hamlet.HamletSpec.InputType;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TABLE;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TBODY;
import org.apache.hadoop.yarn.webapp.hamlet2.HamletSpec.InputType;
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
import com.google.inject.Inject;
@ -69,7 +69,7 @@ public class HsJobsBlock extends HtmlBlock {
th("Maps Completed").
th("Reduces Total").
th("Reduces Completed").
th("Elapsed Time")._()._().
th("Elapsed Time").__().__().
tbody();
LOG.info("Getting list of all Jobs.");
// Write all the data into a JavaScript array of arrays for JQuery
@ -105,38 +105,38 @@ public class HsJobsBlock extends HtmlBlock {
}
jobsTableData.append("]");
html.script().$type("text/javascript").
_("var jobsTableData=" + jobsTableData)._();
tbody._().
__("var jobsTableData=" + jobsTableData).__();
tbody.__().
tfoot().
tr().
th().input("search_init").$type(InputType.text)
.$name("submit_time").$value("Submit Time")._()._().
.$name("submit_time").$value("Submit Time").__().__().
th().input("search_init").$type(InputType.text)
.$name("start_time").$value("Start Time")._()._().
.$name("start_time").$value("Start Time").__().__().
th().input("search_init").$type(InputType.text)
.$name("finish_time").$value("Finish Time")._()._().
.$name("finish_time").$value("Finish Time").__().__().
th().input("search_init").$type(InputType.text)
.$name("job_id").$value("Job ID")._()._().
.$name("job_id").$value("Job ID").__().__().
th().input("search_init").$type(InputType.text)
.$name("name").$value("Name")._()._().
.$name("name").$value("Name").__().__().
th().input("search_init").$type(InputType.text)
.$name("user").$value("User")._()._().
.$name("user").$value("User").__().__().
th().input("search_init").$type(InputType.text)
.$name("queue").$value("Queue")._()._().
.$name("queue").$value("Queue").__().__().
th().input("search_init").$type(InputType.text)
.$name("state").$value("State")._()._().
.$name("state").$value("State").__().__().
th().input("search_init").$type(InputType.text)
.$name("maps_total").$value("Maps Total")._()._().
.$name("maps_total").$value("Maps Total").__().__().
th().input("search_init").$type(InputType.text).
$name("maps_completed").$value("Maps Completed")._()._().
$name("maps_completed").$value("Maps Completed").__().__().
th().input("search_init").$type(InputType.text).
$name("reduces_total").$value("Reduces Total")._()._().
$name("reduces_total").$value("Reduces Total").__().__().
th().input("search_init").$type(InputType.text).
$name("reduces_completed").$value("Reduces Completed")._()._().
$name("reduces_completed").$value("Reduces Completed").__().__().
th().input("search_init").$type(InputType.text).
$name("elapsed_time").$value("Elapsed Time")._()._().
_().
_().
_();
$name("elapsed_time").$value("Elapsed Time").__().__().
__().
__().
__();
}
}

View File

@ -26,7 +26,7 @@ public class HsLogsPage extends HsView {
* (non-Javadoc)
* @see org.apache.hadoop.mapreduce.v2.hs.webapp.HsView#preHead(org.apache.hadoop.yarn.webapp.hamlet.Hamlet.HTML)
*/
@Override protected void preHead(Page.HTML<_> html) {
@Override protected void preHead(Page.HTML<__> html) {
commonPreHead(html);
setActiveNavColumnForTask();
}

View File

@ -20,8 +20,8 @@
import org.apache.hadoop.mapreduce.v2.app.webapp.App;
import org.apache.hadoop.mapreduce.v2.util.MRApps;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.DIV;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.DIV;
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
import com.google.inject.Inject;
@ -43,33 +43,33 @@ public class HsNavBlock extends HtmlBlock {
div("#nav").
h3("Application").
ul().
li().a(url("about"), "About")._().
li().a(url("app"), "Jobs")._()._();
li().a(url("about"), "About").__().
li().a(url("app"), "Jobs").__().__();
if (app.getJob() != null) {
String jobid = MRApps.toString(app.getJob().getID());
nav.
h3("Job").
ul().
li().a(url("job", jobid), "Overview")._().
li().a(url("jobcounters", jobid), "Counters")._().
li().a(url("conf", jobid), "Configuration")._().
li().a(url("tasks", jobid, "m"), "Map tasks")._().
li().a(url("tasks", jobid, "r"), "Reduce tasks")._()._();
li().a(url("job", jobid), "Overview").__().
li().a(url("jobcounters", jobid), "Counters").__().
li().a(url("conf", jobid), "Configuration").__().
li().a(url("tasks", jobid, "m"), "Map tasks").__().
li().a(url("tasks", jobid, "r"), "Reduce tasks").__().__();
if (app.getTask() != null) {
String taskid = MRApps.toString(app.getTask().getID());
nav.
h3("Task").
ul().
li().a(url("task", taskid), "Task Overview")._().
li().a(url("taskcounters", taskid), "Counters")._()._();
li().a(url("task", taskid), "Task Overview").__().
li().a(url("taskcounters", taskid), "Counters").__().__();
}
}
nav.
h3("Tools").
ul().
li().a("/conf", "Configuration")._().
li().a("/logs", "Local logs")._().
li().a("/stacks", "Server stacks")._().
li().a("/jmx?qry=Hadoop:*", "Server metrics")._()._()._();
li().a("/conf", "Configuration").__().
li().a("/logs", "Local logs").__().
li().a("/stacks", "Server stacks").__().
li().a("/jmx?qry=Hadoop:*", "Server metrics").__().__().__();
}
}

View File

@ -32,7 +32,7 @@ public class HsSingleCounterPage extends HsView {
* (non-Javadoc)
* @see org.apache.hadoop.mapreduce.v2.hs.webapp.HsView#preHead(org.apache.hadoop.yarn.webapp.hamlet.Hamlet.HTML)
*/
@Override protected void preHead(Page.HTML<_> html) {
@Override protected void preHead(Page.HTML<__> html) {
commonPreHead(html);
setActiveNavColumnForTask();
set(DATATABLES_ID, "singleCounter");

View File

@ -39,16 +39,15 @@
import org.apache.hadoop.mapreduce.v2.util.MRWebAppUtil;
import org.apache.hadoop.yarn.util.Times;
import org.apache.hadoop.yarn.webapp.SubView;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TBODY;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TFOOT;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.THEAD;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TR;
import org.apache.hadoop.yarn.webapp.hamlet.HamletSpec.InputType;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TABLE;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TBODY;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TFOOT;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.THEAD;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TR;
import org.apache.hadoop.yarn.webapp.hamlet2.HamletSpec.InputType;
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
import com.google.common.base.Joiner;
import com.google.inject.Inject;
/**
@ -110,7 +109,7 @@ protected void render(Block html) {
headRow.th("Elapsed Time").
th(".note", "Note");
TBODY<TABLE<Hamlet>> tbody = headRow._()._().tbody();
TBODY<TABLE<Hamlet>> tbody = headRow.__().__().tbody();
// Write all the data into a JavaScript array of arrays for JQuery
// DataTables to display
StringBuilder attemptsTableData = new StringBuilder("[\n");
@ -182,55 +181,55 @@ protected void render(Block html) {
}
attemptsTableData.append("]");
html.script().$type("text/javascript").
_("var attemptsTableData=" + attemptsTableData)._();
__("var attemptsTableData=" + attemptsTableData).__();
TR<TFOOT<TABLE<Hamlet>>> footRow = tbody._().tfoot().tr();
TR<TFOOT<TABLE<Hamlet>>> footRow = tbody.__().tfoot().tr();
footRow.
th().input("search_init").$type(InputType.text).
$name("attempt_name").$value("Attempt")._()._().
$name("attempt_name").$value("Attempt").__().__().
th().input("search_init").$type(InputType.text).
$name("attempt_state").$value("State")._()._().
$name("attempt_state").$value("State").__().__().
th().input("search_init").$type(InputType.text).
$name("attempt_status").$value("Status")._()._().
$name("attempt_status").$value("Status").__().__().
th().input("search_init").$type(InputType.text).
$name("attempt_node").$value("Node")._()._().
$name("attempt_node").$value("Node").__().__().
th().input("search_init").$type(InputType.text).
$name("attempt_node").$value("Logs")._()._().
$name("attempt_node").$value("Logs").__().__().
th().input("search_init").$type(InputType.text).
$name("attempt_start_time").$value("Start Time")._()._();
$name("attempt_start_time").$value("Start Time").__().__();
if(type == TaskType.REDUCE) {
footRow.
th().input("search_init").$type(InputType.text).
$name("shuffle_time").$value("Shuffle Time")._()._();
$name("shuffle_time").$value("Shuffle Time").__().__();
footRow.
th().input("search_init").$type(InputType.text).
$name("merge_time").$value("Merge Time")._()._();
$name("merge_time").$value("Merge Time").__().__();
}
footRow.
th().input("search_init").$type(InputType.text).
$name("attempt_finish").$value("Finish Time")._()._();
$name("attempt_finish").$value("Finish Time").__().__();
if(type == TaskType.REDUCE) {
footRow.
th().input("search_init").$type(InputType.text).
$name("elapsed_shuffle_time").$value("Elapsed Shuffle Time")._()._();
$name("elapsed_shuffle_time").$value("Elapsed Shuffle Time").__().__();
footRow.
th().input("search_init").$type(InputType.text).
$name("elapsed_merge_time").$value("Elapsed Merge Time")._()._();
$name("elapsed_merge_time").$value("Elapsed Merge Time").__().__();
footRow.
th().input("search_init").$type(InputType.text).
$name("elapsed_reduce_time").$value("Elapsed Reduce Time")._()._();
$name("elapsed_reduce_time").$value("Elapsed Reduce Time").__().__();
}
footRow.
th().input("search_init").$type(InputType.text).
$name("attempt_elapsed").$value("Elapsed Time")._()._().
$name("attempt_elapsed").$value("Elapsed Time").__().__().
th().input("search_init").$type(InputType.text).
$name("note").$value("Note")._()._();
$name("note").$value("Note").__().__();
footRow._()._()._();
footRow.__().__().__();
}
protected String getAttemptId(TaskId taskId, TaskAttemptInfo ta) {
@ -256,7 +255,7 @@ protected Collection<TaskAttempt> getTaskAttempts() {
* (non-Javadoc)
* @see org.apache.hadoop.mapreduce.v2.hs.webapp.HsView#preHead(org.apache.hadoop.yarn.webapp.hamlet.Hamlet.HTML)
*/
@Override protected void preHead(Page.HTML<_> html) {
@Override protected void preHead(Page.HTML<__> html) {
commonPreHead(html);
//override the nav config from commonPReHead
set(initID(ACCORDION, "nav"), "{autoHeight:false, active:2}");

View File

@ -28,14 +28,13 @@
import org.apache.hadoop.mapreduce.v2.app.webapp.dao.TaskAttemptInfo;
import org.apache.hadoop.mapreduce.v2.app.webapp.dao.TaskInfo;
import org.apache.hadoop.mapreduce.v2.util.MRApps;
import org.apache.hadoop.util.StringUtils;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TBODY;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TFOOT;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.THEAD;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TR;
import org.apache.hadoop.yarn.webapp.hamlet.HamletSpec.InputType;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TABLE;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TBODY;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TFOOT;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.THEAD;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TR;
import org.apache.hadoop.yarn.webapp.hamlet2.HamletSpec.InputType;
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
import com.google.inject.Inject;
@ -74,10 +73,10 @@ public class HsTasksBlock extends HtmlBlock {
//Create the spanning row
int attemptColSpan = type == TaskType.REDUCE ? 8 : 3;
thead.tr().
th().$colspan(5).$class("ui-state-default")._("Task")._().
th().$colspan(5).$class("ui-state-default").__("Task").__().
th().$colspan(attemptColSpan).$class("ui-state-default").
_("Successful Attempt")._().
_();
__("Successful Attempt").__().
__();
TR<THEAD<TABLE<Hamlet>>> theadRow = thead.
tr().
@ -102,7 +101,7 @@ public class HsTasksBlock extends HtmlBlock {
}
theadRow.th("Elapsed Time"); //Attempt
TBODY<TABLE<Hamlet>> tbody = theadRow._()._().tbody();
TBODY<TABLE<Hamlet>> tbody = theadRow.__().__().tbody();
// Write all the data into a JavaScript array of arrays for JQuery
// DataTables to display
@ -173,41 +172,41 @@ public class HsTasksBlock extends HtmlBlock {
}
tasksTableData.append("]");
html.script().$type("text/javascript").
_("var tasksTableData=" + tasksTableData)._();
__("var tasksTableData=" + tasksTableData).__();
TR<TFOOT<TABLE<Hamlet>>> footRow = tbody._().tfoot().tr();
TR<TFOOT<TABLE<Hamlet>>> footRow = tbody.__().tfoot().tr();
footRow.th().input("search_init").$type(InputType.text).$name("task")
.$value("ID")._()._().th().input("search_init").$type(InputType.text)
.$name("state").$value("State")._()._().th().input("search_init")
.$type(InputType.text).$name("start_time").$value("Start Time")._()._()
.$value("ID").__().__().th().input("search_init").$type(InputType.text)
.$name("state").$value("State").__().__().th().input("search_init")
.$type(InputType.text).$name("start_time").$value("Start Time").__().__()
.th().input("search_init").$type(InputType.text).$name("finish_time")
.$value("Finish Time")._()._().th().input("search_init")
.$type(InputType.text).$name("elapsed_time").$value("Elapsed Time")._()
._().th().input("search_init").$type(InputType.text)
.$name("attempt_start_time").$value("Start Time")._()._();
.$value("Finish Time").__().__().th().input("search_init")
.$type(InputType.text).$name("elapsed_time").$value("Elapsed Time").__()
.__().th().input("search_init").$type(InputType.text)
.$name("attempt_start_time").$value("Start Time").__().__();
if(type == TaskType.REDUCE) {
footRow.th().input("search_init").$type(InputType.text)
.$name("shuffle_time").$value("Shuffle Time")._()._();
.$name("shuffle_time").$value("Shuffle Time").__().__();
footRow.th().input("search_init").$type(InputType.text)
.$name("merge_time").$value("Merge Time")._()._();
.$name("merge_time").$value("Merge Time").__().__();
}
footRow.th().input("search_init").$type(InputType.text)
.$name("attempt_finish").$value("Finish Time")._()._();
.$name("attempt_finish").$value("Finish Time").__().__();
if(type == TaskType.REDUCE) {
footRow.th().input("search_init").$type(InputType.text)
.$name("elapsed_shuffle_time").$value("Elapsed Shuffle Time")._()._();
.$name("elapsed_shuffle_time").$value("Elapsed Shuffle Time").__().__();
footRow.th().input("search_init").$type(InputType.text)
.$name("elapsed_merge_time").$value("Elapsed Merge Time")._()._();
.$name("elapsed_merge_time").$value("Elapsed Merge Time").__().__();
footRow.th().input("search_init").$type(InputType.text)
.$name("elapsed_reduce_time").$value("Elapsed Reduce Time")._()._();
.$name("elapsed_reduce_time").$value("Elapsed Reduce Time").__().__();
}
footRow.th().input("search_init").$type(InputType.text)
.$name("attempt_elapsed").$value("Elapsed Time")._()._();
.$name("attempt_elapsed").$value("Elapsed Time").__().__();
footRow._()._()._();
footRow.__().__().__();
}
}

View File

@ -41,7 +41,7 @@ public class HsTasksPage extends HsView {
* (non-Javadoc)
* @see org.apache.hadoop.mapreduce.v2.hs.webapp.HsView#preHead(org.apache.hadoop.yarn.webapp.hamlet.Hamlet.HTML)
*/
@Override protected void preHead(Page.HTML<_> html) {
@Override protected void preHead(Page.HTML<__> html) {
commonPreHead(html);
set(DATATABLES_ID, "tasks");
set(DATATABLES_SELECTOR, ".dt-tasks" );

View File

@ -39,7 +39,7 @@ public class HsView extends TwoColumnLayout {
* (non-Javadoc)
* @see org.apache.hadoop.yarn.webapp.view.TwoColumnLayout#preHead(org.apache.hadoop.yarn.webapp.hamlet.Hamlet.HTML)
*/
@Override protected void preHead(Page.HTML<_> html) {
@Override protected void preHead(Page.HTML<__> html) {
commonPreHead(html);
set(DATATABLES_ID, "jobs");
set(initID(DATATABLES, "jobs"), jobsTableInit());
@ -51,7 +51,7 @@ public class HsView extends TwoColumnLayout {
* The prehead that should be common to all subclasses.
* @param html used to render.
*/
protected void commonPreHead(Page.HTML<_> html) {
protected void commonPreHead(Page.HTML<__> html) {
set(ACCORDION_ID, "nav");
set(initID(ACCORDION, "nav"), "{autoHeight:false, active:0}");
}

View File

@ -341,4 +341,26 @@
</plugin>
</plugins>
</build>
<!-- TODO: Remove this profile when hamlet was removed. -->
<profiles>
<profile>
<id>java9</id>
<activation>
<jdk>9</jdk>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<excludes>
<exclude>src/main/java/org/apache/hadoop/yarn/webapp/hamlet/**</exclude>
<exclude>src/main/test/org/apache/haodop/yarn/webapp/hamlet/**</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -75,12 +75,12 @@ public String about() {
return about;
}
public ResponseInfo _(String key, Object value) {
public ResponseInfo __(String key, Object value) {
items.add(Item.of(key, value, false));
return this;
}
public ResponseInfo _(String key, String url, Object anchor) {
public ResponseInfo __(String key, String url, Object anchor) {
if (url == null) {
items.add(Item.of(key, anchor, false));
} else {

View File

@ -41,11 +41,11 @@ public static class Hello extends Controller {
}
public static class HelloView extends HtmlPage {
@Override protected void render(Page.HTML<_> html) {
@Override protected void render(Page.HTML<__> html) {
html. // produces valid html 4.01 strict
title($("title")).
p("#hello-for-css").
_($("title"))._()._();
__($("title")).__().__();
}
}

View File

@ -60,12 +60,12 @@ public void anythingYouWant() {
public static class MyView extends HtmlPage {
// You can inject the app in views if needed.
@Override
public void render(Page.HTML<_> html) {
public void render(Page.HTML<__> html) {
html.
title("My App").
p("#content_id_for_css_styling").
_("You can have", $("anything"))._()._();
// Note, there is no _(); (to parent element) method at root level.
__("You can have", $("anything")).__().__();
// Note, there is no __(); (to parent element) method at root level.
// and IDE provides instant feedback on what level you're on in
// the auto-completion drop-downs.
}

View File

@ -29,6 +29,10 @@
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.yarn.webapp.SubView;
/**
* @deprecated Use org.apache.hadoop.yarn.webapp.hamlet2 package instead.
*/
@Deprecated
@InterfaceAudience.LimitedPrivate({"YARN", "MapReduce"})
public class Hamlet extends HamletImpl implements HamletSpec._Html {
public Hamlet(PrintWriter out, int nestLevel, boolean wasInline) {

View File

@ -43,7 +43,9 @@
/**
* Generates a specific hamlet implementation class from a spec class
* using a generic hamlet implementation class.
* @deprecated Use org.apache.hadoop.yarn.webapp.hamlet2 package instead.
*/
@Deprecated
@InterfaceAudience.LimitedPrivate({"YARN", "MapReduce"})
public class HamletGen {
static final Logger LOG = LoggerFactory.getLogger(HamletGen.class);

View File

@ -43,7 +43,9 @@
* optimized to use a thread-local element pool.
*
* Prints HTML as it builds. So the order is important.
* @deprecated Use org.apache.hadoop.yarn.webapp.hamlet2 package instead.
*/
@Deprecated
@InterfaceAudience.Private
public class HamletImpl extends HamletSpec {
private static final String INDENT_CHARS = " ";

View File

@ -43,7 +43,9 @@
* UPPERCASE, corresponding to an element definition in the DTD. $lowercase is
* used as attribute builder methods to differentiate from element builder
* methods.
* @deprecated Use org.apache.hadoop.yarn.webapp.hamlet2 package instead.
*/
@Deprecated
@InterfaceAudience.LimitedPrivate({"YARN", "MapReduce"})
public class HamletSpec {
// The enum values are lowercase for better compression,

View File

@ -15,6 +15,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Deprecated.
* Use org.apache.hadoop.yarn.webapp.hamlet2 package instead.
*/
@Deprecated
@InterfaceAudience.LimitedPrivate({"YARN", "MapReduce"})
package org.apache.hadoop.yarn.webapp.hamlet;
import org.apache.hadoop.classification.InterfaceAudience;

View File

@ -0,0 +1,449 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hadoop.yarn.webapp.hamlet2;
import com.google.common.collect.Sets;
import java.io.IOException;
import java.io.PrintWriter;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Set;
import java.util.regex.Pattern;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.GnuParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.util.StringUtils;
import org.apache.hadoop.yarn.webapp.WebAppException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Generates a specific hamlet implementation class from a spec class
* using a generic hamlet implementation class.
*/
@InterfaceAudience.LimitedPrivate({"YARN", "MapReduce"})
public class HamletGen {
static final Logger LOG = LoggerFactory.getLogger(HamletGen.class);
static final Options opts = new Options();
static {
opts.addOption("h", "help", false, "Print this help message").
addOption("s", "spec-class", true,
"The class that holds the spec interfaces. e.g. HamletSpec").
addOption("i", "impl-class", true,
"An implementation class. e.g. HamletImpl").
addOption("o", "output-class", true, "Output class name").
addOption("p", "output-package", true, "Output package name");
};
static final Pattern elementRegex = Pattern.compile("^[A-Z][A-Z0-9]*$");
int bytes = 0;
PrintWriter out;
final Set<String> endTagOptional = Sets.newHashSet();
final Set<String> inlineElements = Sets.newHashSet();
Class<?> top; // html top-level interface
String hamlet; // output class simple name;
boolean topMode;
/**
* Generate a specific Hamlet implementation from a spec.
* @param specClass holds hamlet interfaces. e.g. {@link HamletSpec}
* @param implClass a generic hamlet implementation. e.g. {@link HamletImpl}
* @param outputName name of the output class. e.g. {@link Hamlet}
* @param outputPkg package name of the output class.
* @throws IOException
*/
public void generate(Class<?> specClass, Class<?> implClass,
String outputName, String outputPkg) throws IOException {
LOG.info("Generating {} using {} and {}", new Object[]{outputName,
specClass, implClass});
out = new PrintWriter(outputName +".java", "UTF-8");
hamlet = basename(outputName);
String pkg = pkgName(outputPkg, implClass.getPackage().getName());
puts(0, "// Generated by HamletGen. Do NOT edit!\n",
"package ", pkg, ";\n",
"import java.io.PrintWriter;\n",
"import java.util.EnumSet;\n",
"import static java.util.EnumSet.*;\n",
"import static ", implClass.getName(), ".EOpt.*;\n",
"import org.apache.hadoop.yarn.webapp.SubView;");
String implClassName = implClass.getSimpleName();
if (!implClass.getPackage().getName().equals(pkg)) {
puts(0, "import ", implClass.getName(), ';');
}
puts(0, "\n",
"public class ", hamlet, " extends ", implClassName,
" implements ", specClass.getSimpleName(), "._Html {\n",
" public ", hamlet, "(PrintWriter out, int nestLevel,",
" boolean wasInline) {\n",
" super(out, nestLevel, wasInline);\n",
" }\n\n", // inline is context sensitive
" static EnumSet<EOpt> opt(boolean endTag, boolean inline, ",
"boolean pre) {\n",
" EnumSet<EOpt> opts = of(ENDTAG);\n",
" if (!endTag) opts.remove(ENDTAG);\n",
" if (inline) opts.add(INLINE);\n",
" if (pre) opts.add(PRE);\n",
" return opts;\n",
" }");
initLut(specClass);
genImpl(specClass, implClassName, 1);
LOG.info("Generating {} methods", hamlet);
genMethods(hamlet, top, 1);
puts(0, "}");
out.close();
LOG.info("Wrote {} bytes to {}.java", bytes, outputName);
}
String basename(String path) {
return path.substring(path.lastIndexOf('/') + 1);
}
String pkgName(String pkg, String defaultPkg) {
if (pkg == null || pkg.isEmpty()) return defaultPkg;
return pkg;
}
void initLut(Class<?> spec) {
endTagOptional.clear();
inlineElements.clear();
for (Class<?> cls : spec.getClasses()) {
Annotation a = cls.getAnnotation(HamletSpec.Element.class);
if (a != null && !((HamletSpec.Element) a).endTag()) {
endTagOptional.add(cls.getSimpleName());
}
if (cls.getSimpleName().equals("Inline")) {
for (Method method : cls.getMethods()) {
String retName = method.getReturnType().getSimpleName();
if (isElement(retName)) {
inlineElements.add(retName);
}
}
}
}
}
void genImpl(Class<?> spec, String implClassName, int indent) {
String specName = spec.getSimpleName();
for (Class<?> cls : spec.getClasses()) {
String className = cls.getSimpleName();
if (cls.isInterface()) {
genFactoryMethods(cls, indent);
}
if (isElement(className)) {
LOG.info("Generating class {}<T>", className);
puts(indent, "\n",
"public class ", className, "<T extends __>",
" extends EImp<T> implements ", specName, ".", className, " {\n",
" public ", className, "(String name, T parent,",
" EnumSet<EOpt> opts) {\n",
" super(name, parent, opts);\n",
" }");
genMethods(className, cls, indent + 1);
puts(indent, "}");
} else if (className.equals("_Html")) {
top = cls;
}
}
}
void genFactoryMethods(Class<?> cls, int indent) {
for (Method method : cls.getDeclaredMethods()) {
String retName = method.getReturnType().getSimpleName();
String methodName = method.getName();
if (methodName.charAt(0) == '$') continue;
if (isElement(retName) && method.getParameterTypes().length == 0) {
genFactoryMethod(retName, methodName, indent);
}
}
}
void genMethods(String className, Class<?> cls, int indent) {
topMode = (top != null && cls.equals(top));
for (Method method : cls.getMethods()) {
String retName = method.getReturnType().getSimpleName();
if (method.getName().charAt(0) == '$') {
genAttributeMethod(className, method, indent);
} else if (isElement(retName)) {
genNewElementMethod(className, method, indent);
} else {
genCurElementMethod(className, method, indent);
}
}
}
void genAttributeMethod(String className, Method method, int indent) {
String methodName = method.getName();
String attrName = methodName.substring(1).replace("__", "-");
Type[] params = method.getGenericParameterTypes();
echo(indent, "\n",
"@Override\n",
"public ", className, topMode ? " " : "<T> ", methodName, "(");
if (params.length == 0) {
puts(0, ") {");
puts(indent,
" addAttr(\"", attrName, "\", null);\n",
" return this;\n", "}");
} else if (params.length == 1) {
String typeName = getTypeName(params[0]);
puts(0, typeName, " value) {");
if (typeName.equals("EnumSet<LinkType>")) {
puts(indent,
" addRelAttr(\"", attrName, "\", value);\n",
" return this;\n", "}");
} else if (typeName.equals("EnumSet<Media>")) {
puts(indent,
" addMediaAttr(\"", attrName, "\", value);\n",
" return this;\n", "}");
} else {
puts(indent,
" addAttr(\"", attrName, "\", value);\n",
" return this;\n", "}");
}
} else {
throwUnhandled(className, method);
}
}
String getTypeName(Type type) {
if (type instanceof Class<?>) {
return ((Class<?>)type).getSimpleName();
}
ParameterizedType pt = (ParameterizedType) type;
return ((Class<?>)pt.getRawType()).getSimpleName() +"<"+
((Class<?>)pt.getActualTypeArguments()[0]).getSimpleName() +">";
}
void genFactoryMethod(String retName, String methodName, int indent) {
puts(indent, "\n",
"private <T extends __> ", retName, "<T> ", methodName,
"__(T e, boolean inline) {\n",
" return new ", retName, "<T>(\"", StringUtils.toLowerCase(retName),
"\", e, opt(", !endTagOptional.contains(retName), ", inline, ",
retName.equals("PRE"), ")); }");
}
void genNewElementMethod(String className, Method method, int indent) {
String methodName = method.getName();
String retName = method.getReturnType().getSimpleName();
Class<?>[] params = method.getParameterTypes();
echo(indent, "\n",
"@Override\n",
"public ", retName, "<", className, topMode ? "> " : "<T>> ",
methodName, "(");
if (params.length == 0) {
puts(0, ") {");
puts(indent,
topMode ? "" : " closeAttrs();\n",
" return ", StringUtils.toLowerCase(retName), "__" + "(this, ",
isInline(className, retName), ");\n", "}");
} else if (params.length == 1) {
puts(0, "String selector) {");
puts(indent,
" return setSelector(", methodName, "(), selector);\n", "}");
} else {
throwUnhandled(className, method);
}
}
boolean isInline(String container, String className) {
if ((container.equals("BODY") || container.equals(hamlet) ||
container.equals("HEAD") || container.equals("HTML")) &&
(className.equals("INS") || className.equals("DEL") ||
className.equals("SCRIPT"))) {
return false;
}
return inlineElements.contains(className);
}
void genCurElementMethod(String className, Method method, int indent) {
String methodName = method.getName();
Class<?>[] params = method.getParameterTypes();
if (topMode || params.length > 0) {
echo(indent, "\n",
"@Override\n",
"public ", className, topMode ? " " : "<T> ", methodName, "(");
}
if (params.length == 0) {
if (topMode) {
puts(0, ") {");
puts(indent, " return this;\n", "}");
}
} else if (params.length == 1) {
if (methodName.equals("base")) {
puts(0, "String href) {");
puts(indent,
" return base().$href(href).__();\n", "}");
} else if (methodName.equals("script")) {
puts(0, "String src) {");
puts(indent,
" return setScriptSrc(script(), src).__();\n", "}");
} else if (methodName.equals("style")) {
puts(0, "Object... lines) {");
puts(indent,
" return style().$type(\"text/css\").__(lines).__();\n", "}");
} else if (methodName.equals("img")) {
puts(0, "String src) {");
puts(indent,
" return ", methodName, "().$src(src).__();\n", "}");
} else if (methodName.equals("br") || methodName.equals("hr") ||
methodName.equals("col")) {
puts(0, "String selector) {");
puts(indent,
" return setSelector(", methodName, "(), selector).__();\n", "}");
} else if (methodName.equals("link")) {
puts(0, "String href) {");
puts(indent,
" return setLinkHref(", methodName, "(), href).__();\n", "}");
} else if (methodName.equals("__")) {
if (params[0].getSimpleName().equals("Class")) {
puts(0, "Class<? extends SubView> cls) {");
puts(indent,
" ", topMode ? "subView" : "_v", "(cls);\n",
" return this;\n", "}");
} else {
puts(0, "Object... lines) {");
puts(indent,
" _p(", needsEscaping(className), ", lines);\n",
" return this;\n", "}");
}
} else if (methodName.equals("_r")) {
puts(0, "Object... lines) {");
puts(indent,
" _p(false, lines);\n",
" return this;\n", "}");
} else {
puts(0, "String cdata) {");
puts(indent,
" return ", methodName, "().__(cdata).__();\n", "}");
}
} else if (params.length == 2) {
if (methodName.equals("meta")) {
puts(0, "String name, String content) {");
puts(indent,
" return meta().$name(name).$content(content).__();\n", "}");
} else if (methodName.equals("meta_http")) {
puts(0, "String header, String content) {");
puts(indent,
" return meta().$http_equiv(header).$content(content).__();\n",
"}");
} else if (methodName.equals("a")) {
puts(0, "String href, String anchorText) {");
puts(indent,
" return a().$href(href).__(anchorText).__();\n", "}");
} else if (methodName.equals("bdo")) {
puts(0, "Dir dir, String cdata) {");
puts(indent, " return bdo().$dir(dir).__(cdata).__();\n", "}");
} else if (methodName.equals("label")) {
puts(0, "String forId, String cdata) {");
puts(indent, " return label().$for(forId).__(cdata).__();\n", "}");
} else if (methodName.equals("param")) {
puts(0, "String name, String value) {");
puts(indent,
" return param().$name(name).$value(value).__();\n", "}");
} else {
puts(0, "String selector, String cdata) {");
puts(indent,
" return setSelector(", methodName,
"(), selector).__(cdata).__();\n", "}");
}
} else if (params.length == 3) {
if (methodName.equals("a")) {
puts(0, "String selector, String href, String anchorText) {");
puts(indent,
" return setSelector(a(), selector)",
".$href(href).__(anchorText).__();\n", "}");
}
} else {
throwUnhandled(className, method);
}
}
static boolean needsEscaping(String eleName) {
return !eleName.equals("SCRIPT") && !eleName.equals("STYLE");
}
static void throwUnhandled(String className, Method method) {
throw new WebAppException("Unhandled " + className + "#" + method);
}
void echo(int indent, Object... args) {
String prev = null;
for (Object o : args) {
String s = String.valueOf(o);
if (!s.isEmpty() && !s.equals("\n") &&
(prev == null || prev.endsWith("\n"))) {
indent(indent);
}
prev = s;
out.print(s);
bytes += s.length();
}
}
void indent(int indent) {
for (int i = 0; i < indent; ++i) {
out.print(" ");
bytes += 2;
}
}
void puts(int indent, Object... args) {
echo(indent, args);
out.println();
++bytes;
}
boolean isElement(String s) {
return elementRegex.matcher(s).matches();
}
public static void main(String[] args) throws Exception {
CommandLine cmd = new GnuParser().parse(opts, args);
if (cmd.hasOption("help")) {
new HelpFormatter().printHelp("Usage: hbgen [OPTIONS]", opts);
return;
}
// defaults
Class<?> specClass = HamletSpec.class;
Class<?> implClass = HamletImpl.class;
String outputClass = "HamletTmp";
String outputPackage = implClass.getPackage().getName();
if (cmd.hasOption("spec-class")) {
specClass = Class.forName(cmd.getOptionValue("spec-class"));
}
if (cmd.hasOption("impl-class")) {
implClass = Class.forName(cmd.getOptionValue("impl-class"));
}
if (cmd.hasOption("output-class")) {
outputClass = cmd.getOptionValue("output-class");
}
if (cmd.hasOption("output-package")) {
outputPackage = cmd.getOptionValue("output-package");
}
new HamletGen().generate(specClass, implClass, outputClass, outputPackage);
}
}

View File

@ -0,0 +1,385 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hadoop.yarn.webapp.hamlet2;
import com.google.common.base.Joiner;
import static com.google.common.base.Preconditions.*;
import com.google.common.base.Splitter;
import com.google.common.collect.Iterables;
import java.io.PrintWriter;
import java.util.EnumSet;
import static java.util.EnumSet.*;
import java.util.Iterator;
import static org.apache.commons.lang.StringEscapeUtils.*;
import static org.apache.hadoop.yarn.webapp.hamlet2.HamletImpl.EOpt.*;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.yarn.webapp.SubView;
import org.apache.hadoop.yarn.webapp.WebAppException;
/**
* A simple unbuffered generic hamlet implementation.
*
* Zero copy but allocation on every element, which could be
* optimized to use a thread-local element pool.
*
* Prints HTML as it builds. So the order is important.
*/
@InterfaceAudience.Private
public class HamletImpl extends HamletSpec {
private static final String INDENT_CHARS = " ";
private static final Splitter SS = Splitter.on('.').
omitEmptyStrings().trimResults();
private static final Joiner SJ = Joiner.on(' ');
private static final Joiner CJ = Joiner.on(", ");
static final int S_ID = 0;
static final int S_CLASS = 1;
int nestLevel;
int indents; // number of indent() called. mostly for testing.
private final PrintWriter out;
private final StringBuilder sb = new StringBuilder(); // not shared
private boolean wasInline = false;
/**
* Element options. (whether it needs end tag, is inline etc.)
*/
public enum EOpt {
/** needs end(close) tag */
ENDTAG,
/** The content is inline */
INLINE,
/** The content is preformatted */
PRE
};
/**
* The base class for elements
* @param <T> type of the parent (containing) element for the element
*/
public class EImp<T extends __> implements _Child {
private final String name;
private final T parent; // short cut for parent element
private final EnumSet<EOpt> opts; // element options
private boolean started = false;
private boolean attrsClosed = false;
EImp(String name, T parent, EnumSet<EOpt> opts) {
this.name = name;
this.parent = parent;
this.opts = opts;
}
@Override
public T __() {
closeAttrs();
--nestLevel;
printEndTag(name, opts);
return parent;
}
protected void _p(boolean quote, Object... args) {
closeAttrs();
for (Object s : args) {
if (!opts.contains(PRE)) {
indent(opts);
}
out.print(quote ? escapeHtml(String.valueOf(s))
: String.valueOf(s));
if (!opts.contains(INLINE) && !opts.contains(PRE)) {
out.println();
}
}
}
protected void _v(Class<? extends SubView> cls) {
closeAttrs();
subView(cls);
}
protected void closeAttrs() {
if (!attrsClosed) {
startIfNeeded();
++nestLevel;
out.print('>');
if (!opts.contains(INLINE) && !opts.contains(PRE)) {
out.println();
}
attrsClosed = true;
}
}
protected void addAttr(String name, String value) {
checkState(!attrsClosed, "attribute added after content");
startIfNeeded();
printAttr(name, value);
}
protected void addAttr(String name, Object value) {
addAttr(name, String.valueOf(value));
}
protected void addMediaAttr(String name, EnumSet<Media> media) {
// 6.13 comma-separated list
addAttr(name, CJ.join(media));
}
protected void addRelAttr(String name, EnumSet<LinkType> types) {
// 6.12 space-separated list
addAttr(name, SJ.join(types));
}
private void startIfNeeded() {
if (!started) {
printStartTag(name, opts);
started = true;
}
}
protected void _inline(boolean choice) {
if (choice) {
opts.add(INLINE);
} else {
opts.remove(INLINE);
}
}
protected void _endTag(boolean choice) {
if (choice) {
opts.add(ENDTAG);
} else {
opts.remove(ENDTAG);
}
}
protected void _pre(boolean choice) {
if (choice) {
opts.add(PRE);
} else {
opts.remove(PRE);
}
}
}
public class Generic<T extends __> extends EImp<T> implements PCData {
Generic(String name, T parent, EnumSet<EOpt> opts) {
super(name, parent, opts);
}
public Generic<T> _inline() {
super._inline(true);
return this;
}
public Generic<T> _noEndTag() {
super._endTag(false);
return this;
}
public Generic<T> _pre() {
super._pre(true);
return this;
}
public Generic<T> _attr(String name, String value) {
addAttr(name, value);
return this;
}
public Generic<Generic<T>> _elem(String name, EnumSet<EOpt> opts) {
closeAttrs();
return new Generic<Generic<T>>(name, this, opts);
}
public Generic<Generic<T>> elem(String name) {
return _elem(name, of(ENDTAG));
}
@Override
public Generic<T> __(Object... lines) {
_p(true, lines);
return this;
}
@Override
public Generic<T> _r(Object... lines) {
_p(false, lines);
return this;
}
}
public HamletImpl(PrintWriter out, int nestLevel, boolean wasInline) {
this.out = out;
this.nestLevel = nestLevel;
this.wasInline = wasInline;
}
public int nestLevel() {
return nestLevel;
}
public boolean wasInline() {
return wasInline;
}
public void setWasInline(boolean state) {
wasInline = state;
}
public PrintWriter getWriter() {
return out;
}
/**
* Create a root-level generic element.
* Mostly for testing purpose.
* @param <T> type of the parent element
* @param name of the element
* @param opts {@link EOpt element options}
* @return the element
*/
public <T extends __>
Generic<T> root(String name, EnumSet<EOpt> opts) {
return new Generic<T>(name, null, opts);
}
public <T extends __> Generic<T> root(String name) {
return root(name, of(ENDTAG));
}
protected void printStartTag(String name, EnumSet<EOpt> opts) {
indent(opts);
sb.setLength(0);
out.print(sb.append('<').append(name).toString()); // for easier mock test
}
protected void indent(EnumSet<EOpt> opts) {
if (opts.contains(INLINE) && wasInline) {
return;
}
if (wasInline) {
out.println();
}
wasInline = opts.contains(INLINE) || opts.contains(PRE);
for (int i = 0; i < nestLevel; ++i) {
out.print(INDENT_CHARS);
}
++indents;
}
protected void printEndTag(String name, EnumSet<EOpt> opts) {
if (!opts.contains(ENDTAG)) {
return;
}
if (!opts.contains(PRE)) {
indent(opts);
} else {
wasInline = opts.contains(INLINE);
}
sb.setLength(0);
out.print(sb.append("</").append(name).append('>').toString()); // ditto
if (!opts.contains(INLINE)) {
out.println();
}
}
protected void printAttr(String name, String value) {
sb.setLength(0);
sb.append(' ').append(name);
if (value != null) {
sb.append("=\"").append(escapeHtml(value)).append("\"");
}
out.print(sb.toString());
}
/**
* Sub-classes should override this to do something interesting.
* @param cls the sub-view class
*/
protected void subView(Class<? extends SubView> cls) {
indent(of(ENDTAG)); // not an inline view
sb.setLength(0);
out.print(sb.append('[').append(cls.getName()).append(']').toString());
out.println();
}
/**
* Parse selector into id and classes
* @param selector in the form of (#id)?(.class)*
* @return an two element array [id, "space-separated classes"].
* Either element could be null.
* @throws WebAppException when both are null or syntax error.
*/
public static String[] parseSelector(String selector) {
String[] result = new String[]{null, null};
Iterable<String> rs = SS.split(selector);
Iterator<String> it = rs.iterator();
if (it.hasNext()) {
String maybeId = it.next();
if (maybeId.charAt(0) == '#') {
result[S_ID] = maybeId.substring(1);
if (it.hasNext()) {
result[S_CLASS] = SJ.join(Iterables.skip(rs, 1));
}
} else {
result[S_CLASS] = SJ.join(rs);
}
return result;
}
throw new WebAppException("Error parsing selector: "+ selector);
}
/**
* Set id and/or class attributes for an element.
* @param <E> type of the element
* @param e the element
* @param selector Haml form of "(#id)?(.class)*"
* @return the element
*/
public static <E extends CoreAttrs> E setSelector(E e, String selector) {
String[] res = parseSelector(selector);
if (res[S_ID] != null) {
e.$id(res[S_ID]);
}
if (res[S_CLASS] != null) {
e.$class(res[S_CLASS]);
}
return e;
}
public static <E extends LINK> E setLinkHref(E e, String href) {
if (href.endsWith(".css")) {
e.$rel("stylesheet"); // required in html5
}
e.$href(href);
return e;
}
public static <E extends SCRIPT> E setScriptSrc(E e, String src) {
if (src.endsWith(".js")) {
e.$type("text/javascript"); // required in html4
}
e.$src(src);
return e;
}
}

View File

@ -0,0 +1,27 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* This package is the replacement for org.apache.hadoop.yarn.webapp.hamlet.
* The old package is using _ as a one-character identifier,
* which is banned from JDK9.
*/
@InterfaceAudience.LimitedPrivate({"YARN", "MapReduce"})
package org.apache.hadoop.yarn.webapp.hamlet2;
import org.apache.hadoop.classification.InterfaceAudience;

View File

@ -44,10 +44,9 @@
import org.apache.hadoop.yarn.logaggregation.AggregatedLogFormat;
import org.apache.hadoop.yarn.logaggregation.LogAggregationUtils;
import org.apache.hadoop.yarn.server.security.ApplicationACLsManager;
import org.apache.hadoop.yarn.util.ConverterUtils;
import org.apache.hadoop.yarn.util.Times;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.PRE;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.PRE;
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
import com.google.inject.Inject;
@ -84,12 +83,12 @@ protected void render(Block html) {
if (!conf.getBoolean(YarnConfiguration.LOG_AGGREGATION_ENABLED,
YarnConfiguration.DEFAULT_LOG_AGGREGATION_ENABLED)) {
html.h1()
._("Aggregation is not enabled. Try the nodemanager at " + nodeId)
._();
.__("Aggregation is not enabled. Try the nodemanager at " + nodeId)
.__();
if(nmApplicationLogUrl != null) {
html.h1()
._("Or see application log at " + nmApplicationLogUrl)
._();
.__("Or see application log at " + nmApplicationLogUrl)
.__();
}
return;
}
@ -110,18 +109,18 @@ protected void render(Block html) {
.listStatus(remoteAppDir);
} catch (FileNotFoundException fnf) {
html.h1()
._("Logs not available for " + logEntity
.__("Logs not available for " + logEntity
+ ". Aggregation may not be complete, "
+ "Check back later or try the nodemanager at " + nodeId)._();
+ "Check back later or try the nodemanager at " + nodeId).__();
if(nmApplicationLogUrl != null) {
html.h1()
._("Or see application log at " + nmApplicationLogUrl)
._();
.__("Or see application log at " + nmApplicationLogUrl)
.__();
}
return;
} catch (Exception ex) {
html.h1()
._("Error getting logs at " + nodeId)._();
.__("Error getting logs at " + nodeId).__();
return;
}
@ -168,9 +167,9 @@ protected void render(Block html) {
if (callerUGI != null && !aclsManager.checkAccess(callerUGI,
ApplicationAccessType.VIEW_APP, owner, applicationId)) {
html.h1()
._("User [" + remoteUser
.__("User [" + remoteUser
+ "] is not authorized to view the logs for " + logEntity
+ " in log file [" + thisNodeFile.getPath().getName() + "]")._();
+ " in log file [" + thisNodeFile.getPath().getName() + "]").__();
LOG.error("User [" + remoteUser
+ "] is not authorized to view the logs for " + logEntity);
continue;
@ -188,8 +187,9 @@ protected void render(Block html) {
LOG.error("Error getting logs for " + logEntity, ex);
continue;
} finally {
if (reader != null)
if (reader != null) {
reader.close();
}
}
}
if (!foundLog) {
@ -201,7 +201,7 @@ protected void render(Block html) {
}
}
} catch (IOException e) {
html.h1()._("Error getting logs for " + logEntity)._();
html.h1().__("Error getting logs for " + logEntity).__();
LOG.error("Error getting logs for " + logEntity, e);
}
}
@ -219,12 +219,12 @@ private boolean readContainerLogs(Block html,
|| desiredLogType.equals(logType)) {
long logLength = logReader.getCurrentLogLength();
if (foundLog) {
html.pre()._("\n\n")._();
html.pre().__("\n\n").__();
}
html.p()._("Log Type: " + logType)._();
html.p()._("Log Upload Time: " + Times.format(logUpLoadTime))._();
html.p()._("Log Length: " + Long.toString(logLength))._();
html.p().__("Log Type: " + logType).__();
html.p().__("Log Upload Time: " + Times.format(logUpLoadTime)).__();
html.p().__("Log Length: " + Long.toString(logLength)).__();
long start = logLimits.start < 0
? logLength + logLimits.start : logLimits.start;
@ -238,12 +238,12 @@ private boolean readContainerLogs(Block html,
long toRead = end - start;
if (toRead < logLength) {
html.p()._("Showing " + toRead + " bytes of " + logLength
html.p().__("Showing " + toRead + " bytes of " + logLength
+ " total. Click ")
.a(url("logs", $(NM_NODENAME), $(CONTAINER_ID),
$(ENTITY_STRING), $(APP_OWNER),
logType, "?start=0"), "here").
_(" for the full log.")._();
__(" for the full log.").__();
}
long totalSkipped = 0;
@ -267,12 +267,12 @@ private boolean readContainerLogs(Block html,
while (toRead > 0
&& (len = logReader.read(cbuf, 0, currentToRead)) > 0) {
pre._(new String(cbuf, 0, len));
pre.__(new String(cbuf, 0, len));
toRead = toRead - len;
currentToRead = toRead > bufferSize ? bufferSize : (int) toRead;
}
pre._();
pre.__();
foundLog = true;
}
@ -285,7 +285,7 @@ private boolean readContainerLogs(Block html,
private ContainerId verifyAndGetContainerId(Block html) {
String containerIdStr = $(CONTAINER_ID);
if (containerIdStr == null || containerIdStr.isEmpty()) {
html.h1()._("Cannot get container logs without a ContainerId")._();
html.h1().__("Cannot get container logs without a ContainerId").__();
return null;
}
ContainerId containerId = null;
@ -293,8 +293,8 @@ private ContainerId verifyAndGetContainerId(Block html) {
containerId = ContainerId.fromString(containerIdStr);
} catch (IllegalArgumentException e) {
html.h1()
._("Cannot get container logs for invalid containerId: "
+ containerIdStr)._();
.__("Cannot get container logs for invalid containerId: "
+ containerIdStr).__();
return null;
}
return containerId;
@ -303,15 +303,15 @@ private ContainerId verifyAndGetContainerId(Block html) {
private NodeId verifyAndGetNodeId(Block html) {
String nodeIdStr = $(NM_NODENAME);
if (nodeIdStr == null || nodeIdStr.isEmpty()) {
html.h1()._("Cannot get container logs without a NodeId")._();
html.h1().__("Cannot get container logs without a NodeId").__();
return null;
}
NodeId nodeId = null;
try {
nodeId = NodeId.fromString(nodeIdStr);
} catch (IllegalArgumentException e) {
html.h1()._("Cannot get container logs. Invalid nodeId: " + nodeIdStr)
._();
html.h1().__("Cannot get container logs. Invalid nodeId: " + nodeIdStr)
.__();
return null;
}
return nodeId;
@ -320,7 +320,7 @@ private NodeId verifyAndGetNodeId(Block html) {
private String verifyAndGetAppOwner(Block html) {
String appOwner = $(APP_OWNER);
if (appOwner == null || appOwner.isEmpty()) {
html.h1()._("Cannot get container logs without an app owner")._();
html.h1().__("Cannot get container logs without an app owner").__();
}
return appOwner;
}
@ -341,7 +341,7 @@ private LogLimits verifyAndGetLogLimits(Block html) {
start = Long.parseLong(startStr);
} catch (NumberFormatException e) {
isValid = false;
html.h1()._("Invalid log start value: " + startStr)._();
html.h1().__("Invalid log start value: " + startStr).__();
}
}
@ -351,7 +351,7 @@ private LogLimits verifyAndGetLogLimits(Block html) {
end = Long.parseLong(endStr);
} catch (NumberFormatException e) {
isValid = false;
html.h1()._("Invalid log end value: " + endStr)._();
html.h1().__("Invalid log end value: " + endStr).__();
}
}

View File

@ -28,7 +28,7 @@ public class AggregatedLogsNavBlock extends HtmlBlock {
protected void render(Block html) {
html
.div("#nav")
.h3()._("Logs")._() //
._();
.h3().__("Logs").__()
.__();
}
}

View File

@ -37,7 +37,7 @@ public class AggregatedLogsPage extends TwoColumnLayout {
* @see org.apache.hadoop.yarn.server.nodemanager.webapp.NMView#preHead(org.apache.hadoop.yarn.webapp.hamlet.Hamlet.HTML)
*/
@Override
protected void preHead(Page.HTML<_> html) {
protected void preHead(Page.HTML<__> html) {
String logEntity = $(ENTITY_STRING);
if (logEntity == null || logEntity.isEmpty()) {
logEntity = $(CONTAINER_ID);

View File

@ -30,24 +30,24 @@
public class ErrorPage extends HtmlPage {
@Override
protected void render(Page.HTML<_> html) {
protected void render(Page.HTML<__> html) {
set(JQueryUI.ACCORDION_ID, "msg");
String title = "Sorry, got error "+ status();
html.
title(title).
link(root_url("static","yarn.css")).
_(JQueryUI.class). // an embedded sub-view
link(root_url("static", "yarn.css")).
__(JQueryUI.class). // an embedded sub-view
style("#msg { margin: 1em auto; width: 88%; }",
"#msg h1 { padding: 0.2em 1.5em; font: bold 1.3em serif; }").
div("#msg").
h1(title).
div().
_("Please consult").
__("Please consult").
a("http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html",
"RFC 2616")._(" for meanings of the error code.")._().
"RFC 2616").__(" for meanings of the error code.").__().
h1("Error Details").
pre().
_(errorDetails())._()._()._();
__(errorDetails()).__().__().__();
}
protected String errorDetails() {

View File

@ -25,6 +25,6 @@ public class FooterBlock extends HtmlBlock {
@Override protected void render(Block html) {
html.
div("#footer.ui-widget")._();
div("#footer.ui-widget").__();
}
}

View File

@ -31,9 +31,9 @@ public class HeaderBlock extends HtmlBlock {
html.
div("#header.ui-widget").
div("#user").
_(loggedIn)._().
__(loggedIn).__().
div("#logo").
img("/static/hadoop-st.png")._().
h1($(TITLE))._();
img("/static/hadoop-st.png").__().
h1($(TITLE)).__();
}
}

View File

@ -25,7 +25,7 @@
import org.apache.hadoop.yarn.webapp.MimeType;
import org.apache.hadoop.yarn.webapp.SubView;
import org.apache.hadoop.yarn.webapp.WebAppException;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet;
@InterfaceAudience.LimitedPrivate({"YARN", "MapReduce"})
public abstract class HtmlBlock extends TextView implements SubView {

View File

@ -25,17 +25,17 @@
import org.apache.hadoop.yarn.webapp.MimeType;
import org.apache.hadoop.yarn.webapp.SubView;
import org.apache.hadoop.yarn.webapp.WebAppException;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet;
/**
* The parent class of all HTML pages. Override
* {@link #render(org.apache.hadoop.yarn.webapp.hamlet.Hamlet.HTML)}
* {@link #render(org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.HTML)}
* to actually render the page.
*/
@InterfaceAudience.LimitedPrivate({"YARN", "MapReduce"})
public abstract class HtmlPage extends TextView {
public static class _ implements Hamlet._ {
public static class __ implements Hamlet.__ {
}
public class Page extends Hamlet {
@ -50,8 +50,8 @@ protected void subView(Class<? extends SubView> cls) {
setWasInline(context().wasInline());
}
public HTML<HtmlPage._> html() {
return new HTML<HtmlPage._>("html", null, EnumSet.of(EOpt.ENDTAG));
public HTML<HtmlPage.__> html() {
return new HTML<HtmlPage.__>("html", null, EnumSet.of(EOpt.ENDTAG));
}
}
@ -91,6 +91,6 @@ public void render() {
* Render the the HTML page.
* @param html the page to render data to.
*/
protected abstract void render(Page.HTML<_> html);
protected abstract void render(Page.HTML<__> html);
}

View File

@ -26,11 +26,11 @@
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.yarn.webapp.ResponseInfo;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.DIV;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TD;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TR;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.DIV;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TABLE;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TD;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TR;
import com.google.inject.Inject;
@ -47,7 +47,7 @@ public class InfoBlock extends HtmlBlock {
div(_INFO_WRAP).
table(_INFO).
tr().
th().$class(C_TH).$colspan(2)._(info.about())._()._();
th().$class(C_TH).$colspan(2).__(info.about()).__().__();
int i = 0;
for (ResponseInfo.Item item : info) {
TR<TABLE<DIV<Hamlet>>> tr = table.
@ -62,23 +62,23 @@ public class InfoBlock extends HtmlBlock {
DIV<TD<TR<TABLE<DIV<Hamlet>>>>> singleLineDiv;
for ( String line :lines) {
singleLineDiv = td.div();
singleLineDiv._(line);
singleLineDiv._();
singleLineDiv.__(line);
singleLineDiv.__();
}
} else {
td._(value);
td.__(value);
}
td._();
td.__();
} else {
tr.td()._r(value)._();
tr.td()._r(value).__();
}
} else {
tr.
td().
a(url(item.url), value)._();
a(url(item.url), value).__();
}
tr._();
tr.__();
}
table._()._();
table.__().__();
}
}

View File

@ -26,7 +26,7 @@
import java.util.List;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.yarn.webapp.hamlet.HamletSpec.HTML;
import org.apache.hadoop.yarn.webapp.hamlet2.HamletSpec.HTML;
import com.google.common.collect.Lists;
@ -82,19 +82,19 @@ protected void render(Block html) {
initProgressBars(list);
if (!list.isEmpty()) {
html.script().$type("text/javascript")._("$(function() {")
._(list.toArray())._("});")._();
html.script().$type("text/javascript").__("$(function() {")
.__(list.toArray()).__("});").__();
}
}
public static void jsnotice(HTML html) {
html.
div("#jsnotice.ui-state-error").
_("This page will not function without javascript enabled."
+ " Please enable javascript on your browser.")._();
__("This page will not function without javascript enabled."
+ " Please enable javascript on your browser.").__();
html.
script().$type("text/javascript").
_("$('#jsnotice').hide();")._();
__("$('#jsnotice').hide();").__();
}
protected void initAccordions(List<String> list) {
@ -130,7 +130,7 @@ protected void initDataTables(List<String> list) {
// for inserting stateSaveInit
int pos = init.indexOf('{') + 1;
init = new StringBuffer(init).insert(pos, stateSaveInit).toString();
list.add(join(id,"DataTable = $('#", id, "').dataTable(", init,
list.add(join(id, "DataTable = $('#", id, "').dataTable(", init,
").fnSetFilteringDelay(188);"));
String postInit = $(postInitID(DATATABLES, id));
if(!postInit.isEmpty()) {

View File

@ -27,7 +27,7 @@ public class LipsumBlock extends HtmlBlock {
public void render(Block html) {
html.
p().
_("Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
__("Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"Vivamus eu dui in ipsum tincidunt egestas ac sed nibh.",
"Praesent quis nisl lorem, nec interdum urna.",
"Duis sagittis dignissim purus sed sollicitudin.",
@ -45,6 +45,6 @@ public void render(Block html) {
"Proin eu ante nisl, vel porttitor eros.",
"Aliquam gravida luctus augue, at scelerisque enim consectetur vel.",
"Donec interdum tempor nisl, quis laoreet enim venenatis eu.",
"Quisque elit elit, vulputate eget porta vel, laoreet ac lacus.")._();
"Quisque elit elit, vulputate eget porta vel, laoreet ac lacus.").__();
}
}

View File

@ -30,12 +30,12 @@ public class NavBlock extends HtmlBlock {
ul().
li("Item 1").
li("Item 2").
li("...")._().
li("...").__().
h3("Tools").
ul().
li().a("/conf", "Configuration")._().
li().a("/stacks", "Thread dump")._().
li().a("/logs", "Logs")._().
li().a("/jmx?qry=Hadoop:*", "Metrics")._()._()._();
li().a("/conf", "Configuration").__().
li().a("/stacks", "Thread dump").__().
li().a("/logs", "Logs").__().
li().a("/jmx?qry=Hadoop:*", "Metrics").__().__().__();
}
}

View File

@ -31,11 +31,11 @@
@InterfaceAudience.LimitedPrivate({"YARN", "MapReduce"})
public class TwoColumnCssLayout extends HtmlPage {
@Override protected void render(Page.HTML<_> html) {
@Override protected void render(Page.HTML<__> html) {
preHead(html);
html.
title($("title")).
link(root_url("static","yarn.css")).
link(root_url("static", "yarn.css")).
style(".main { min-height: 100%; height: auto !important; height: 100%;",
" margin: 0 auto -4em; border: 0; }",
".footer, .push { height: 4em; clear: both; border: 0 }",
@ -50,28 +50,28 @@ public class TwoColumnCssLayout extends HtmlPage {
" right: 100%; overflow: hidden; }",
".leftnav .nav { float: left; width: 11em; position: relative;",
" right: 12em; overflow: hidden; }").
_(JQueryUI.class);
__(JQueryUI.class);
postHead(html);
JQueryUI.jsnotice(html);
html.
div(".main.ui-widget-content").
_(header()).
__(header()).
div(".cmask.leftnav").
div(".c1right").
div(".c1wrap").
div(".content").
_(content())._()._().
__(content()).__().__().
div(".nav").
_(nav()).
div(".push")._()._()._()._()._().
__(nav()).
div(".push").__().__().__().__().__().
div(".footer.ui-widget-content").
_(footer())._()._();
__(footer()).__().__();
}
protected void preHead(Page.HTML<_> html) {
protected void preHead(Page.HTML<__> html) {
}
protected void postHead(Page.HTML<_> html) {
protected void postHead(Page.HTML<__> html) {
}
protected Class<? extends SubView> header() {

View File

@ -39,18 +39,18 @@ public class TwoColumnLayout extends HtmlPage {
* (non-Javadoc)
* @see org.apache.hadoop.yarn.webapp.view.HtmlPage#render(org.apache.hadoop.yarn.webapp.hamlet.Hamlet.HTML)
*/
@Override protected void render(Page.HTML<_> html) {
@Override protected void render(Page.HTML<__> html) {
preHead(html);
html.
title($(TITLE)).
link(root_url("static","yarn.css")).
link(root_url("static", "yarn.css")).
style("#layout { height: 100%; }",
"#layout thead td { height: 3em; }",
"#layout #navcell { width: 11em; padding: 0 1em; }",
"#layout td.content { padding-top: 0 }",
"#layout tbody { vertical-align: top; }",
"#layout tfoot td { height: 4em; }").
_(JQueryUI.class);
__(JQueryUI.class);
postHead(html);
JQueryUI.jsnotice(html);
html.
@ -58,17 +58,17 @@ public class TwoColumnLayout extends HtmlPage {
thead().
tr().
td().$colspan(2).
_(header())._()._()._().
__(header()).__().__().__().
tfoot().
tr().
td().$colspan(2).
_(footer())._()._()._().
__(footer()).__().__().__().
tbody().
tr().
td().$id("navcell").
_(nav())._().
__(nav()).__().
td().$class("content").
_(content())._()._()._()._()._();
__(content()).__().__().__().__().__();
}
/**
@ -76,14 +76,14 @@ public class TwoColumnLayout extends HtmlPage {
* involves setting page variables for Javascript and CSS rendering.
* @param html the html to use to render.
*/
protected void preHead(Page.HTML<_> html) {
protected void preHead(Page.HTML<__> html) {
}
/**
* Do what needs to be done after the header is rendered.
* @param html the html to use to render.
*/
protected void postHead(Page.HTML<_> html) {
protected void postHead(Page.HTML<__> html) {
}
/**
@ -120,7 +120,7 @@ protected Class<? extends SubView> footer() {
* @param tableId the ID of the table to set styles on.
* @param innerStyles any other styles to add to the table.
*/
protected void setTableStyles(Page.HTML<_> html, String tableId,
protected void setTableStyles(Page.HTML<__> html, String tableId,
String... innerStyles) {
List<String> styles = Lists.newArrayList();
styles.add(join('#', tableId, "_paginate span {font-weight:normal}"));

View File

@ -32,14 +32,14 @@ public class TestSubViews {
static public class MainView extends HtmlPage {
@Override
public void render(Page.HTML<_> html) {
public void render(Page.HTML<__> html) {
html.
body().
div().
_(Sub1.class)._().
__(Sub1.class).__().
div().
i("inline text").
_(Sub2.class)._()._()._();
__(Sub2.class).__().__().__();
}
}
@ -48,7 +48,7 @@ static public class Sub1 extends HtmlBlock {
public void render(Block html) {
html.
div("#sub1").
_("sub1 text")._();
__("sub1 text").__();
}
}
@ -57,7 +57,7 @@ static public class Sub2 extends HtmlBlock {
public void render(Block html) {
html.
pre().
_("sub2 text")._();
__("sub2 text").__();
}
}

View File

@ -100,7 +100,7 @@ static class DefaultController extends Controller {
static class TablesView extends HtmlPage {
@Override
public void render(Page.HTML<_> html) {
public void render(Page.HTML<__> html) {
set(DATATABLES_ID, "t1 t2 t3 t4");
set(initID(DATATABLES, "t1"), tableInit().append("}").toString());
set(initID(DATATABLES, "t2"), join("{bJQueryUI:true, sDom:'t',",
@ -110,7 +110,7 @@ public void render(Page.HTML<_> html) {
html.
title("Test DataTables").
link("/static/yarn.css").
_(JQueryUI.class).
__(JQueryUI.class).
style(".wrapper { padding: 1em }",
".wrapper h2 { margin: 0.5em 0 }",
".dataTables_wrapper { min-height: 1em }").
@ -118,33 +118,33 @@ public void render(Page.HTML<_> html) {
h2("Default table init").
table("#t1").
thead().
tr().th("Column1").th("Column2")._()._().
tr().th("Column1").th("Column2").__().__().
tbody().
tr().td("c1r1").td("c2r1")._().
tr().td("c1r2").td("c2r2")._()._()._().
tr().td("c1r1").td("c2r1").__().
tr().td("c1r2").td("c2r2").__().__().__().
h2("Nested tables").
div(_INFO_WRAP).
table("#t2").
thead().
tr().th(_TH, "Column1").th(_TH, "Column2")._()._().
tr().th(_TH, "Column1").th(_TH, "Column2").__().__().
tbody().
tr().td("r1"). // th wouldn't work as of dt 1.7.5
td().$class(C_TABLE).
table("#t3").
thead().
tr().th("SubColumn1").th("SubColumn2")._()._().
tr().th("SubColumn1").th("SubColumn2").__().__().
tbody().
tr().td("subc1r1").td("subc2r1")._().
tr().td("subc1r2").td("subc2r2")._()._()._()._()._().
tr().td("subc1r1").td("subc2r1").__().
tr().td("subc1r2").td("subc2r2").__().__().__().__().__().
tr().td("r2"). // ditto
td().$class(C_TABLE).
table("#t4").
thead().
tr().th("SubColumn1").th("SubColumn2")._()._().
tr().th("SubColumn1").th("SubColumn2").__().__().
tbody().
tr().td("subc1r1").td("subc2r1")._().
tr().td("subc1r2").td("subc2r2")._().
_()._()._()._()._()._()._()._()._();
tr().td("subc1r1").td("subc2r1").__().
tr().td("subc1r2").td("subc2r2").__().
__().__().__().__().__().__().__().__().__();
}
}
@ -358,7 +358,7 @@ public void testPortRanges() throws Exception {
assertEquals("foo", getContent(baseUrl +"test/foo").trim());
app1 = WebApps.$for("test", this).at(port).start();
assertEquals(port, app1.getListenerAddress().getPort());
app2 = WebApps.$for("test", this).at("0.0.0.0",port, true).start();
app2 = WebApps.$for("test", this).at("0.0.0.0", port, true).start();
assertTrue(app2.getListenerAddress().getPort() > port);
Configuration conf = new Configuration();
port = ServerSocketUtil.waitForPort(47000, 60);

View File

@ -24,8 +24,6 @@
import org.apache.hadoop.yarn.webapp.WebAppException;
import org.apache.hadoop.yarn.webapp.test.WebAppTests;
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
import org.apache.hadoop.yarn.webapp.view.HtmlPage;
import org.junit.Test;
import static org.mockito.Mockito.*;
@ -35,7 +33,7 @@ public static class TestBlock extends HtmlBlock {
@Override
public void render(Block html) {
html.
p("#testid")._("test note")._();
p("#testid").__("test note").__();
}
}
@ -43,16 +41,16 @@ public static class ShortBlock extends HtmlBlock {
@Override
public void render(Block html) {
html.
p()._("should throw");
p().__("should throw");
}
}
public static class ShortPage extends HtmlPage {
@Override
public void render(Page.HTML<_> html) {
public void render(Page.HTML<__> html) {
html.
title("short test").
_(ShortBlock.class);
__(ShortBlock.class);
}
}

View File

@ -25,7 +25,6 @@
import org.apache.hadoop.yarn.webapp.MimeType;
import org.apache.hadoop.yarn.webapp.WebAppException;
import org.apache.hadoop.yarn.webapp.test.WebAppTests;
import org.apache.hadoop.yarn.webapp.view.HtmlPage;
import org.junit.Test;
import static org.mockito.Mockito.*;
@ -34,19 +33,19 @@ public class TestHtmlPage {
public static class TestView extends HtmlPage {
@Override
public void render(Page.HTML<_> html) {
public void render(Page.HTML<__> html) {
html.
title("test").
p("#testid")._("test note")._()._();
p("#testid").__("test note").__().__();
}
}
public static class ShortView extends HtmlPage {
@Override
public void render(Page.HTML<_> html) {
public void render(Page.HTML<__> html) {
html.
title("short test").
p()._("should throw");
p().__("should throw");
}
}

View File

@ -45,7 +45,7 @@ public static class JavaScriptInfoBlock extends InfoBlock{
static {
resInfo = new ResponseInfo();
resInfo._("User_Name", JAVASCRIPT);
resInfo.__("User_Name", JAVASCRIPT);
}
@Override
@ -68,8 +68,8 @@ public static class MultilineInfoBlock extends InfoBlock{
static {
resInfo = new ResponseInfo();
resInfo._("Multiple_line_value", "This is one line.");
resInfo._("Multiple_line_value", "This is first line.\nThis is second line.");
resInfo.__("Multiple_line_value", "This is one line.");
resInfo.__("Multiple_line_value", "This is first line.\nThis is second line.");
}
@Override

View File

@ -22,8 +22,6 @@
import org.apache.hadoop.yarn.webapp.Controller;
import org.apache.hadoop.yarn.webapp.WebApps;
import org.apache.hadoop.yarn.webapp.test.WebAppTests;
import org.apache.hadoop.yarn.webapp.view.HtmlPage;
import org.apache.hadoop.yarn.webapp.view.TwoColumnCssLayout;
import org.junit.Test;
public class TestTwoColumnCssPage {
@ -52,10 +50,10 @@ public void textnames() {
public static class TestView extends HtmlPage {
@Override
public void render(Page.HTML<_> html) {
public void render(Page.HTML<__> html) {
html.
title($("title")).
h1($("title"))._();
h1($("title")).__();
}
}

View File

@ -34,7 +34,7 @@ protected Class<? extends SubView> content() {
}
@Override
protected void preHead(Page.HTML<_> html) {
protected void preHead(Page.HTML<__> html) {
commonPreHead(html);
String title = "Errors and Warnings in the Application History Server";
setTitle(title);

View File

@ -32,7 +32,7 @@ public class AHSLogsPage extends AHSView {
* preHead(org.apache.hadoop .yarn.webapp.hamlet.Hamlet.HTML)
*/
@Override
protected void preHead(Page.HTML<_> html) {
protected void preHead(Page.HTML<__> html) {
String logEntity = $(ENTITY_STRING);
if (logEntity == null || logEntity.isEmpty()) {
logEntity = $(CONTAINER_ID);

View File

@ -37,7 +37,7 @@ public class AHSView extends TwoColumnLayout {
static final int MAX_FAST_ROWS = 1000; // inline js array
@Override
protected void preHead(Page.HTML<_> html) {
protected void preHead(Page.HTML<__> html) {
commonPreHead(html);
set(DATATABLES_ID, "apps");
set(initID(DATATABLES, "apps"), WebPageUtils.appsTableInit(false));
@ -49,7 +49,7 @@ protected void preHead(Page.HTML<_> html) {
setTitle(sjoin(reqState, "Applications"));
}
protected void commonPreHead(Page.HTML<_> html) {
protected void commonPreHead(Page.HTML<__> html) {
set(ACCORDION_ID, "nav");
set(initID(ACCORDION, "nav"), "{autoHeight:false, active:0}");
}

View File

@ -19,9 +19,7 @@
package org.apache.hadoop.yarn.server.applicationhistoryservice.webapp;
import com.google.inject.Inject;
import org.apache.hadoop.util.VersionInfo;
import org.apache.hadoop.yarn.api.records.timeline.TimelineAbout;
import org.apache.hadoop.yarn.util.YarnVersionInfo;
import org.apache.hadoop.yarn.util.timeline.TimelineUtils;
import org.apache.hadoop.yarn.webapp.View;
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
@ -38,10 +36,10 @@ protected void render(Block html) {
TimelineAbout tsInfo = TimelineUtils.createTimelineAbout(
"Timeline Server - Generic History Service UI");
info("Timeline Server Overview").
_("Timeline Server Version:", tsInfo.getTimelineServiceBuildVersion() +
__("Timeline Server Version:", tsInfo.getTimelineServiceBuildVersion() +
" on " + tsInfo.getTimelineServiceVersionBuiltOn()).
_("Hadoop Version:", tsInfo.getHadoopBuildVersion() +
__("Hadoop Version:", tsInfo.getHadoopBuildVersion() +
" on " + tsInfo.getHadoopVersionBuiltOn());
html._(InfoBlock.class);
html.__(InfoBlock.class);
}
}

View File

@ -20,12 +20,9 @@
import org.apache.hadoop.yarn.webapp.SubView;
import org.apache.hadoop.yarn.webapp.YarnWebParams;
import static org.apache.hadoop.yarn.util.StringHelper.join;
public class AboutPage extends AHSView {
@Override protected void preHead(Page.HTML<_> html) {
@Override protected void preHead(Page.HTML<__> html) {
commonPreHead(html);
set(TITLE, "Timeline Server - Generic History Service");
}

View File

@ -29,7 +29,7 @@
public class AppAttemptPage extends AHSView {
@Override
protected void preHead(Page.HTML<_> html) {
protected void preHead(Page.HTML<__> html) {
commonPreHead(html);
String appAttemptId = $(YarnWebParams.APPLICATION_ATTEMPT_ID);

View File

@ -30,7 +30,7 @@
public class AppPage extends AHSView {
@Override
protected void preHead(Page.HTML<_> html) {
protected void preHead(Page.HTML<__> html) {
commonPreHead(html);
String appId = $(YarnWebParams.APPLICATION_ID);

View File

@ -26,7 +26,7 @@
public class ContainerPage extends AHSView {
@Override
protected void preHead(Page.HTML<_> html) {
protected void preHead(Page.HTML<__> html) {
commonPreHead(html);
String containerId = $(YarnWebParams.CONTAINER_ID);

View File

@ -23,7 +23,7 @@
import org.apache.commons.logging.impl.Log4JLogger;
import org.apache.hadoop.yarn.api.records.YarnApplicationState;
import org.apache.hadoop.yarn.util.Log4jWarningErrorMetricsAppender;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet;
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
public class NavBlock extends HtmlBlock {
@ -44,34 +44,34 @@ public void render(Block html) {
h3("Application History").
ul().
li().a(url("about"), "About").
_().
__().
li().a(url("apps"), "Applications").
ul().
li().a(url("apps",
YarnApplicationState.FINISHED.toString()),
YarnApplicationState.FINISHED.toString()).
_().
__().
li().a(url("apps",
YarnApplicationState.FAILED.toString()),
YarnApplicationState.FAILED.toString()).
_().
__().
li().a(url("apps",
YarnApplicationState.KILLED.toString()),
YarnApplicationState.KILLED.toString()).
_().
_().
_().
_();
__().
__().
__().
__();
Hamlet.UL<Hamlet.DIV<Hamlet>> tools = nav.h3("Tools").ul();
tools.li().a("/conf", "Configuration")._()
.li().a("/logs", "Local logs")._()
.li().a("/stacks", "Server stacks")._()
.li().a("/jmx?qry=Hadoop:*", "Server metrics")._();
tools.li().a("/conf", "Configuration").__()
.li().a("/logs", "Local logs").__()
.li().a("/stacks", "Server stacks").__()
.li().a("/jmx?qry=Hadoop:*", "Server metrics").__();
if (addErrorsAndWarningsLink) {
tools.li().a(url("errors-and-warnings"), "Errors/Warnings")._();
tools.li().a(url("errors-and-warnings"), "Errors/Warnings").__();
}
tools._()._();
tools.__().__();
}
}

View File

@ -36,10 +36,9 @@
import org.apache.hadoop.yarn.api.records.YarnApplicationAttemptState;
import org.apache.hadoop.yarn.server.webapp.dao.AppAttemptInfo;
import org.apache.hadoop.yarn.server.webapp.dao.ContainerInfo;
import org.apache.hadoop.yarn.util.ConverterUtils;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TBODY;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TABLE;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TBODY;
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
import org.apache.hadoop.yarn.webapp.view.InfoBlock;
import com.google.inject.Inject;
@ -94,7 +93,7 @@ public ApplicationAttemptReport run() throws Exception {
String message =
"Failed to read the application attempt " + appAttemptId + ".";
LOG.error(message, e);
html.p()._(message)._();
html.p().__(message).__();
return;
}
@ -140,14 +139,14 @@ public Collection<ContainerReport> run() throws Exception {
if (exceptionWhenGetContainerReports) {
html
.p()
._(
.__(
"Sorry, Failed to get containers for application attempt" + attemptid
+ ".")._();
+ ".").__();
return;
}
createAttemptHeadRoomTable(html);
html._(InfoBlock.class);
html.__(InfoBlock.class);
createTablesForAttemptMetrics(html);
@ -155,7 +154,7 @@ public Collection<ContainerReport> run() throws Exception {
TBODY<TABLE<Hamlet>> tbody =
html.table("#containers").thead().tr().th(".id", "Container ID")
.th(".node", "Node").th(".exitstatus", "Container Exit Status")
.th(".logs", "Logs")._()._().tbody();
.th(".logs", "Logs").__().__().tbody();
StringBuilder containersTableData = new StringBuilder("[\n");
for (ContainerReport containerReport : containers) {
@ -186,9 +185,9 @@ public Collection<ContainerReport> run() throws Exception {
}
containersTableData.append("]");
html.script().$type("text/javascript")
._("var containersTableData=" + containersTableData)._();
.__("var containersTableData=" + containersTableData).__();
tbody._()._();
tbody.__().__();
}
protected void generateOverview(ApplicationAttemptReport appAttemptReport,
@ -196,18 +195,18 @@ protected void generateOverview(ApplicationAttemptReport appAttemptReport,
String node) {
String amContainerId = appAttempt.getAmContainerId();
info("Application Attempt Overview")
._(
.__(
"Application Attempt State:",
appAttempt.getAppAttemptState() == null ? UNAVAILABLE : appAttempt
.getAppAttemptState())
._("AM Container:",
.__("AM Container:",
amContainerId == null
|| containers == null
|| !hasAMContainer(appAttemptReport.getAMContainerId(),
containers) ? null : root_url("container", amContainerId),
amContainerId == null ? "N/A" : amContainerId)
._("Node:", node)
._(
.__("Node:", node)
.__(
"Tracking URL:",
appAttempt.getTrackingUrl() == null
|| appAttempt.getTrackingUrl().equals(UNAVAILABLE) ? null
@ -219,7 +218,7 @@ protected void generateOverview(ApplicationAttemptReport appAttemptReport,
|| appAttempt.getAppAttemptState() == YarnApplicationAttemptState.FAILED
|| appAttempt.getAppAttemptState() == YarnApplicationAttemptState.KILLED
? "History" : "ApplicationMaster")
._(
.__(
"Diagnostics Info:",
appAttempt.getDiagnosticsInfo() == null ? "" : appAttempt
.getDiagnosticsInfo());

View File

@ -55,9 +55,9 @@
import org.apache.hadoop.yarn.util.Times;
import org.apache.hadoop.yarn.webapp.ResponseInfo;
import org.apache.hadoop.yarn.webapp.YarnWebParams;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TBODY;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TABLE;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TBODY;
import org.apache.hadoop.yarn.webapp.util.WebAppUtils;
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
import org.apache.hadoop.yarn.webapp.view.InfoBlock;
@ -116,7 +116,7 @@ public ApplicationReport run() throws Exception {
} catch (Exception e) {
String message = "Failed to read the application " + appID + ".";
LOG.error(message, e);
html.p()._(message)._();
html.p().__(message).__();
return;
}
@ -136,8 +136,8 @@ public ApplicationReport run() throws Exception {
// Application Kill
html.div()
.button()
.$onclick("confirmAction()").b("Kill Application")._()
._();
.$onclick("confirmAction()").b("Kill Application").__()
.__();
StringBuilder script = new StringBuilder();
script.append("function confirmAction() {")
@ -160,7 +160,7 @@ public ApplicationReport run() throws Exception {
.append(" }")
.append("}");
html.script().$type("text/javascript")._(script.toString())._();
html.script().$type("text/javascript").__(script.toString()).__();
}
String schedulerPath = WebAppUtils.getResolvedRMWebAppURLWithScheme(conf) +
@ -185,13 +185,13 @@ public Collection<ApplicationAttemptReport> run() throws Exception {
String message =
"Failed to read the attempts of the application " + appID + ".";
LOG.error(message, e);
html.p()._(message)._();
html.p().__(message).__();
return;
}
createApplicationMetricsTable(html);
html._(InfoBlock.class);
html.__(InfoBlock.class);
generateApplicationTable(html, callerUGI, attempts);
@ -207,25 +207,25 @@ public Collection<ApplicationAttemptReport> run() throws Exception {
private void generateOverviewTable(AppInfo app, String schedulerPath,
String webUiType, ApplicationReport appReport) {
ResponseInfo overviewTable = info("Application Overview")
._("User:", schedulerPath, app.getUser())
._("Name:", app.getName())
._("Application Type:", app.getType())
._("Application Tags:",
.__("User:", schedulerPath, app.getUser())
.__("Name:", app.getName())
.__("Application Type:", app.getType())
.__("Application Tags:",
app.getApplicationTags() == null ? "" : app.getApplicationTags())
._("Application Priority:", clarifyAppPriority(app.getPriority()))
._(
.__("Application Priority:", clarifyAppPriority(app.getPriority()))
.__(
"YarnApplicationState:",
app.getAppState() == null ? UNAVAILABLE : clarifyAppState(app
.getAppState()))
._("Queue:", schedulerPath, app.getQueue())
._("FinalStatus Reported by AM:",
.__("Queue:", schedulerPath, app.getQueue())
.__("FinalStatus Reported by AM:",
clairfyAppFinalStatus(app.getFinalAppStatus()))
._("Started:", Times.format(app.getStartedTime()))
._(
.__("Started:", Times.format(app.getStartedTime()))
.__(
"Elapsed:",
StringUtils.formatTime(Times.elapsed(app.getStartedTime(),
app.getFinishedTime())))
._(
.__(
"Tracking URL:",
app.getTrackingUrl() == null
|| app.getTrackingUrl().equals(UNAVAILABLE) ? null : root_url(app
@ -240,31 +240,31 @@ private void generateOverviewTable(AppInfo app, String schedulerPath,
&& webUiType.equals(YarnWebParams.RM_WEB_UI)) {
LogAggregationStatus status = getLogAggregationStatus();
if (status == null) {
overviewTable._("Log Aggregation Status:", "N/A");
overviewTable.__("Log Aggregation Status:", "N/A");
} else if (status == LogAggregationStatus.DISABLED
|| status == LogAggregationStatus.NOT_START
|| status == LogAggregationStatus.SUCCEEDED) {
overviewTable._("Log Aggregation Status:", status.name());
overviewTable.__("Log Aggregation Status:", status.name());
} else {
overviewTable._("Log Aggregation Status:",
overviewTable.__("Log Aggregation Status:",
root_url("logaggregationstatus", app.getAppId()), status.name());
}
long timeout = appReport.getApplicationTimeouts()
.get(ApplicationTimeoutType.LIFETIME).getRemainingTime();
if (timeout < 0) {
overviewTable._("Application Timeout (Remaining Time):", "Unlimited");
overviewTable.__("Application Timeout (Remaining Time):", "Unlimited");
} else {
overviewTable._("Application Timeout (Remaining Time):",
overviewTable.__("Application Timeout (Remaining Time):",
String.format("%d seconds", timeout));
}
}
overviewTable._("Diagnostics:",
overviewTable.__("Diagnostics:",
app.getDiagnosticsInfo() == null ? "" : app.getDiagnosticsInfo());
overviewTable._("Unmanaged Application:", app.isUnmanagedApp());
overviewTable._("Application Node Label expression:",
overviewTable.__("Unmanaged Application:", app.isUnmanagedApp());
overviewTable.__("Application Node Label expression:",
app.getAppNodeLabelExpression() == null ? "<Not set>"
: app.getAppNodeLabelExpression());
overviewTable._("AM container Node Label expression:",
overviewTable.__("AM container Node Label expression:",
app.getAmNodeLabelExpression() == null ? "<Not set>"
: app.getAmNodeLabelExpression());
}
@ -276,7 +276,7 @@ protected void generateApplicationTable(Block html,
TBODY<TABLE<Hamlet>> tbody =
html.table("#attempts").thead().tr().th(".id", "Attempt ID")
.th(".started", "Started").th(".node", "Node").th(".logs", "Logs")
._()._().tbody();
.__().__().tbody();
StringBuilder attemptsTableData = new StringBuilder("[\n");
for (final ApplicationAttemptReport appAttemptReport : attempts) {
@ -312,7 +312,7 @@ public ContainerReport run() throws Exception {
"Failed to read the AM container of the application attempt "
+ appAttemptReport.getApplicationAttemptId() + ".";
LOG.error(message, e);
html.p()._(message)._();
html.p().__(message).__();
return;
}
long startTime = 0L;
@ -346,9 +346,9 @@ public ContainerReport run() throws Exception {
}
attemptsTableData.append("]");
html.script().$type("text/javascript")
._("var attemptsTableData=" + attemptsTableData)._();
.__("var attemptsTableData=" + attemptsTableData).__();
tbody._()._();
tbody.__().__();
}
private String clarifyAppState(YarnApplicationState state) {

View File

@ -44,9 +44,9 @@
import org.apache.hadoop.yarn.exceptions.YarnException;
import org.apache.hadoop.yarn.server.webapp.dao.AppInfo;
import org.apache.hadoop.yarn.webapp.BadRequestException;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TBODY;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TABLE;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TBODY;
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
import com.google.inject.Inject;
@ -134,7 +134,7 @@ public void render(Block html) {
catch( Exception e) {
String message = "Failed to read the applications.";
LOG.error(message, e);
html.p()._(message)._();
html.p().__(message).__();
return;
}
renderData(html);
@ -147,7 +147,7 @@ protected void renderData(Block html) {
.th(".queue", "Queue").th(".priority", "Application Priority")
.th(".starttime", "StartTime").th(".finishtime", "FinishTime")
.th(".state", "State").th(".finalstatus", "FinalStatus")
.th(".progress", "Progress").th(".ui", "Tracking UI")._()._().tbody();
.th(".progress", "Progress").th(".ui", "Tracking UI").__().__().tbody();
StringBuilder appsTableData = new StringBuilder("[\n");
for (ApplicationReport appReport : appReports) {
@ -218,8 +218,8 @@ protected void renderData(Block html) {
}
appsTableData.append("]");
html.script().$type("text/javascript")
._("var appsTableData=" + appsTableData)._();
.__("var appsTableData=" + appsTableData).__();
tbody._()._();
tbody.__().__();
}
}

View File

@ -31,7 +31,6 @@
import org.apache.hadoop.yarn.api.records.ContainerId;
import org.apache.hadoop.yarn.api.records.ContainerReport;
import org.apache.hadoop.yarn.server.webapp.dao.ContainerInfo;
import org.apache.hadoop.yarn.util.ConverterUtils;
import org.apache.hadoop.yarn.util.Times;
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
import org.apache.hadoop.yarn.webapp.view.InfoBlock;
@ -86,7 +85,7 @@ public ContainerReport run() throws Exception {
} catch (Exception e) {
String message = "Failed to read the container " + containerid + ".";
LOG.error(message, e);
html.p()._(message)._();
html.p().__(message).__();
return;
}
@ -99,32 +98,32 @@ public ContainerReport run() throws Exception {
setTitle(join("Container ", containerid));
info("Container Overview")
._(
.__(
"Container State:",
container.getContainerState() == null ? UNAVAILABLE : container
.getContainerState())
._("Exit Status:", container.getContainerExitStatus())
._(
.__("Exit Status:", container.getContainerExitStatus())
.__(
"Node:",
container.getNodeHttpAddress() == null ? "#" : container
.getNodeHttpAddress(),
container.getNodeHttpAddress() == null ? "N/A" : container
.getNodeHttpAddress())
._("Priority:", container.getPriority())
._("Started:", Times.format(container.getStartedTime()))
._(
.__("Priority:", container.getPriority())
.__("Started:", Times.format(container.getStartedTime()))
.__(
"Elapsed:",
StringUtils.formatTime(Times.elapsed(container.getStartedTime(),
container.getFinishedTime())))
._(
.__(
"Resource:",
container.getAllocatedMB() + " Memory, "
+ container.getAllocatedVCores() + " VCores")
._("Logs:", container.getLogUrl() == null ? "#" : container.getLogUrl(),
.__("Logs:", container.getLogUrl() == null ? "#" : container.getLogUrl(),
container.getLogUrl() == null ? "N/A" : "Logs")
._("Diagnostics:", container.getDiagnosticsInfo() == null ?
.__("Diagnostics:", container.getDiagnosticsInfo() == null ?
"" : container.getDiagnosticsInfo());
html._(InfoBlock.class);
html.__(InfoBlock.class);
}
}

View File

@ -28,7 +28,7 @@
import org.apache.hadoop.yarn.security.AdminACLsManager;
import org.apache.hadoop.yarn.util.Log4jWarningErrorMetricsAppender;
import org.apache.hadoop.yarn.util.Times;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet;
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
import java.util.ArrayList;
@ -74,19 +74,19 @@ protected void render(Block html) {
}
if (!isAdmin) {
html.div().p()._("This page is for admins only.")._()._();
html.div().p().__("This page is for admins only.").__().__();
return;
}
if (log instanceof Log4JLogger) {
html._(ErrorMetrics.class);
html._(WarningMetrics.class);
html.__(ErrorMetrics.class);
html.__(WarningMetrics.class);
html.div().button().$onclick("reloadPage()").b("View data for the last ")
._().select().$id("cutoff").option().$value("60")._("1 min")._()
.option().$value("300")._("5 min")._().option().$value("900")
._("15 min")._().option().$value("3600")._("1 hour")._().option()
.$value("21600")._("6 hours")._().option().$value("43200")
._("12 hours")._().option().$value("86400")._("24 hours")._()._()._();
.__().select().$id("cutoff").option().$value("60").__("1 min").__()
.option().$value("300").__("5 min").__().option().$value("900")
.__("15 min").__().option().$value("3600").__("1 hour").__().option()
.$value("21600").__("6 hours").__().option().$value("43200")
.__("12 hours").__().option().$value("86400").__("24 hours").__().__().__();
String script = "function reloadPage() {"
+ " var timePeriod = $(\"#cutoff\").val();"
@ -97,7 +97,7 @@ protected void render(Block html) {
+ " $(element).parent().siblings('.toggle-content').fadeToggle();"
+ "}";
html.script().$type("text/javascript")._(script)._();
html.script().$type("text/javascript").__(script).__();
html.style(".toggle-content { display: none; }");
@ -110,7 +110,7 @@ protected void render(Block html) {
Hamlet.TBODY<Hamlet.TABLE<Hamlet>> errorsTable =
html.table("#messages").thead().tr().th(".message", "Message")
.th(".type", "Type").th(".count", "Count")
.th(".lasttime", "Latest Message Time")._()._().tbody();
.th(".lasttime", "Latest Message Time").__().__().tbody();
// cutoff has to be in seconds
cutoff.add((Time.now() - cutoffPeriodSeconds * 1000) / 1000);
@ -145,18 +145,18 @@ protected void render(Block html) {
}
cell.pre().a().$href("#").$onclick("toggleContent(this);")
.$style("white-space: pre")._(displayMessage)._()._().div()
.$class("toggle-content").pre()._(message)._()._()._();
.$style("white-space: pre").__(displayMessage).__().__().div()
.$class("toggle-content").pre().__(message).__().__().__();
} else {
cell.pre()._(message)._()._();
cell.pre().__(message).__().__();
}
Log4jWarningErrorMetricsAppender.Element ele = entry.getValue();
row.td(type).td(String.valueOf(ele.count))
.td(Times.format(ele.timestampSeconds * 1000))._();
.td(Times.format(ele.timestampSeconds * 1000)).__();
}
}
}
errorsTable._()._();
errorsTable.__().__();
}
}
@ -199,19 +199,19 @@ protected void render(Block html) {
html.div().$class("metrics").$style("padding-bottom: 20px");
div.h3(tableHeading).table("#metricsoverview").thead()
.$class("ui-widget-header").tr().th().$class("ui-state-default")
._("Last 1 minute")._().th().$class("ui-state-default")
._("Last 5 minutes")._().th().$class("ui-state-default")
._("Last 15 minutes")._().th().$class("ui-state-default")
._("Last 1 hour")._().th().$class("ui-state-default")
._("Last 6 hours")._().th().$class("ui-state-default")
._("Last 12 hours")._().th().$class("ui-state-default")
._("Last 24 hours")._()._()._().tbody().$class("ui-widget-content")
.__("Last 1 minute").__().th().$class("ui-state-default")
.__("Last 5 minutes").__().th().$class("ui-state-default")
.__("Last 15 minutes").__().th().$class("ui-state-default")
.__("Last 1 hour").__().th().$class("ui-state-default")
.__("Last 6 hours").__().th().$class("ui-state-default")
.__("Last 12 hours").__().th().$class("ui-state-default")
.__("Last 24 hours").__().__().__().tbody().$class("ui-widget-content")
.tr().td(String.valueOf(values.get(0)))
.td(String.valueOf(values.get(1))).td(String.valueOf(values.get(2)))
.td(String.valueOf(values.get(3))).td(String.valueOf(values.get(4)))
.td(String.valueOf(values.get(5))).td(String.valueOf(values.get(6)))
._()._()._();
div._();
.__().__().__();
div.__();
}
}
}

View File

@ -31,17 +31,17 @@
import org.apache.hadoop.yarn.server.nodemanager.webapp.dao.AppInfo;
import org.apache.hadoop.yarn.webapp.SubView;
import org.apache.hadoop.yarn.webapp.YarnWebParams;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.BODY;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TBODY;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.BODY;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TABLE;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TBODY;
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
import com.google.inject.Inject;
public class AllApplicationsPage extends NMView {
@Override protected void preHead(Page.HTML<_> html) {
@Override protected void preHead(Page.HTML<__> html) {
commonPreHead(html);
setTitle("Applications running on this node");
set(DATATABLES_ID, "applications");
@ -88,22 +88,22 @@ protected void render(Block html) {
.table("#applications")
.thead()
.tr()
.td()._("ApplicationId")._()
.td()._("ApplicationState")._()
._()
._()
.td().__("ApplicationId").__()
.td().__("ApplicationState").__()
.__()
.__()
.tbody();
for (Entry<ApplicationId, Application> entry : this.nmContext
.getApplications().entrySet()) {
AppInfo info = new AppInfo(entry.getValue());
tableBody
.tr()
.td().a(url("application", info.getId()), info.getId())._()
.td()._(info.getState())
._()
._();
.td().a(url("application", info.getId()), info.getId()).__()
.td().__(info.getState())
.__()
.__();
}
tableBody._()._()._();
tableBody.__().__().__();
}
}
}

View File

@ -31,17 +31,17 @@
import org.apache.hadoop.yarn.server.nodemanager.webapp.dao.ContainerInfo;
import org.apache.hadoop.yarn.webapp.SubView;
import org.apache.hadoop.yarn.webapp.YarnWebParams;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.BODY;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TBODY;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.BODY;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TABLE;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TBODY;
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
import com.google.inject.Inject;
public class AllContainersPage extends NMView {
@Override protected void preHead(Page.HTML<_> html) {
@Override protected void preHead(Page.HTML<__> html) {
commonPreHead(html);
setTitle("All containers running on this node");
set(DATATABLES_ID, "containers");
@ -82,24 +82,24 @@ protected void render(Block html) {
.table("#containers")
.thead()
.tr()
.td()._("ContainerId")._()
.td()._("ContainerState")._()
.td()._("logs")._()
._()
._().tbody();
.td().__("ContainerId").__()
.td().__("ContainerState").__()
.td().__("logs").__()
.__()
.__().tbody();
for (Entry<ContainerId, Container> entry : this.nmContext
.getContainers().entrySet()) {
ContainerInfo info = new ContainerInfo(this.nmContext, entry.getValue());
tableBody
.tr()
.td().a(url("container", info.getId()), info.getId())
._()
.td()._(info.getState())._()
.__()
.td().__(info.getState()).__()
.td()
.a(url(info.getShortLogLink()), "logs")._()
._();
.a(url(info.getShortLogLink()), "logs").__()
.__();
}
tableBody._()._()._();
tableBody.__().__().__();
}
}

View File

@ -30,12 +30,11 @@
import org.apache.hadoop.yarn.server.nodemanager.Context;
import org.apache.hadoop.yarn.server.nodemanager.containermanager.application.Application;
import org.apache.hadoop.yarn.server.nodemanager.webapp.dao.AppInfo;
import org.apache.hadoop.yarn.util.ConverterUtils;
import org.apache.hadoop.yarn.webapp.SubView;
import org.apache.hadoop.yarn.webapp.YarnWebParams;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.DIV;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.DIV;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TABLE;
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
import org.apache.hadoop.yarn.webapp.view.InfoBlock;
@ -43,7 +42,7 @@
public class ApplicationPage extends NMView implements YarnWebParams {
@Override protected void preHead(Page.HTML<_> html) {
@Override protected void preHead(Page.HTML<__> html) {
commonPreHead(html);
set(DATATABLES_ID, "containers");
@ -80,30 +79,30 @@ protected void render(Block html) {
try {
applicationID = ApplicationId.fromString($(APPLICATION_ID));
} catch (IllegalArgumentException e) {
html.p()._("Invalid Application Id " + $(APPLICATION_ID))._();
html.p().__("Invalid Application Id " + $(APPLICATION_ID)).__();
return;
}
DIV<Hamlet> div = html.div("#content");
Application app = this.nmContext.getApplications().get(applicationID);
if (app == null) {
div.h1("Unknown application with id " + applicationID
+ ". Application might have been completed")._();
+ ". Application might have been completed").__();
return;
}
AppInfo info = new AppInfo(app);
info("Application's information")
._("ApplicationId", info.getId())
._("ApplicationState", info.getState())
._("User", info.getUser());
TABLE<Hamlet> containersListBody = html._(InfoBlock.class)
.__("ApplicationId", info.getId())
.__("ApplicationState", info.getState())
.__("User", info.getUser());
TABLE<Hamlet> containersListBody = html.__(InfoBlock.class)
.table("#containers");
for (String containerIdStr : info.getContainers()) {
containersListBody
.tr().td()
.a(url("container", containerIdStr), containerIdStr)
._()._();
.__().__();
}
containersListBody._();
containersListBody.__();
}
}
}

View File

@ -37,12 +37,11 @@
import org.apache.hadoop.yarn.api.records.ContainerId;
import org.apache.hadoop.yarn.exceptions.YarnException;
import org.apache.hadoop.yarn.server.nodemanager.Context;
import org.apache.hadoop.yarn.util.ConverterUtils;
import org.apache.hadoop.yarn.webapp.NotFoundException;
import org.apache.hadoop.yarn.webapp.SubView;
import org.apache.hadoop.yarn.webapp.YarnWebParams;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.PRE;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.PRE;
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
import com.google.inject.Inject;
@ -51,7 +50,7 @@ public class ContainerLogsPage extends NMView {
public static final String REDIRECT_URL = "redirect.url";
@Override protected void preHead(Page.HTML<_> html) {
@Override protected void preHead(Page.HTML<__> html) {
String redirectUrl = $(REDIRECT_URL);
if (redirectUrl == null || redirectUrl.isEmpty()) {
set(TITLE, join("Logs for ", $(CONTAINER_ID)));
@ -142,10 +141,10 @@ private void printLogFile(Block html, File logFile) {
try {
long toRead = end - start;
if (toRead < logFile.length()) {
html.p()._("Showing " + toRead + " bytes. Click ")
html.p().__("Showing " + toRead + " bytes. Click ")
.a(url("containerlogs", $(CONTAINER_ID), $(APP_OWNER),
logFile.getName(), "?start=0"), "here").
_(" for full log")._();
__(" for full log").__();
}
IOUtils.skipFully(logByteStream, start);
@ -160,12 +159,12 @@ private void printLogFile(Block html, File logFile) {
while ((len = reader.read(cbuf, 0, currentToRead)) > 0
&& toRead > 0) {
pre._(new String(cbuf, 0, len));
pre.__(new String(cbuf, 0, len));
toRead = toRead - len;
currentToRead = toRead > bufferSize ? bufferSize : (int) toRead;
}
pre._();
pre.__();
reader.close();
} catch (IOException e) {
@ -199,7 +198,7 @@ private void printLogFileDirectory(Block html, List<File> containerLogsDirs) {
.a(url("containerlogs", $(CONTAINER_ID), $(APP_OWNER),
logFile.getName(), "?start=-4096"),
logFile.getName() + " : Total file length is "
+ logFile.length() + " bytes.")._();
+ logFile.length() + " bytes.").__();
}
}
}

View File

@ -25,11 +25,10 @@
import org.apache.hadoop.yarn.server.nodemanager.Context;
import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container;
import org.apache.hadoop.yarn.server.nodemanager.webapp.dao.ContainerInfo;
import org.apache.hadoop.yarn.util.ConverterUtils;
import org.apache.hadoop.yarn.webapp.SubView;
import org.apache.hadoop.yarn.webapp.YarnWebParams;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.DIV;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.DIV;
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
import org.apache.hadoop.yarn.webapp.view.InfoBlock;
@ -38,7 +37,7 @@
public class ContainerPage extends NMView implements YarnWebParams {
@Override
protected void preHead(Page.HTML<_> html) {
protected void preHead(Page.HTML<__> html) {
commonPreHead(html);
setTitle("Container " + $(CONTAINER_ID));
@ -65,7 +64,7 @@ protected void render(Block html) {
try {
containerID = ContainerId.fromString($(CONTAINER_ID));
} catch (IllegalArgumentException e) {
html.p()._("Invalid containerId " + $(CONTAINER_ID))._();
html.p().__("Invalid containerId " + $(CONTAINER_ID)).__();
return;
}
@ -73,22 +72,22 @@ protected void render(Block html) {
Container container = this.nmContext.getContainers().get(containerID);
if (container == null) {
div.h1("Unknown Container. Container might have completed, "
+ "please go back to the previous page and retry.")._();
+ "please go back to the previous page and retry.").__();
return;
}
ContainerInfo info = new ContainerInfo(this.nmContext, container);
info("Container information")
._("ContainerID", info.getId())
._("ContainerState", info.getState())
._("ExitStatus", info.getExitStatus())
._("Diagnostics", info.getDiagnostics())
._("User", info.getUser())
._("TotalMemoryNeeded", info.getMemoryNeeded())
._("TotalVCoresNeeded", info.getVCoresNeeded())
._("ExecutionType", info.getExecutionType())
._("logs", info.getShortLogLink(), "Link to logs");
html._(InfoBlock.class);
.__("ContainerID", info.getId())
.__("ContainerState", info.getState())
.__("ExitStatus", info.getExitStatus())
.__("Diagnostics", info.getDiagnostics())
.__("User", info.getUser())
.__("TotalMemoryNeeded", info.getMemoryNeeded())
.__("TotalVCoresNeeded", info.getVCoresNeeded())
.__("ExecutionType", info.getExecutionType())
.__("logs", info.getShortLogLink(), "Link to logs");
html.__(InfoBlock.class);
}
}
}

View File

@ -32,7 +32,7 @@ protected Class<? extends SubView> content() {
}
@Override
protected void preHead(HtmlPage.Page.HTML<HtmlPage._> html) {
protected void preHead(HtmlPage.Page.HTML<__> html) {
commonPreHead(html);
String title = "Errors and Warnings in the NodeManager";
setTitle(title);

View File

@ -27,11 +27,11 @@
public class NMView extends TwoColumnLayout {
@Override protected void preHead(Page.HTML<_> html) {
@Override protected void preHead(Page.HTML<__> html) {
commonPreHead(html);
}
protected void commonPreHead(Page.HTML<_> html) {
protected void commonPreHead(Page.HTML<__> html) {
set(ACCORDION_ID, "nav");
set(initID(ACCORDION, "nav"), "{autoHeight:false, active:0}");
}

View File

@ -24,7 +24,7 @@
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.yarn.util.Log4jWarningErrorMetricsAppender;
import org.apache.hadoop.yarn.webapp.YarnWebParams;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet;
import org.apache.hadoop.yarn.webapp.util.WebAppUtils;
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
@ -55,29 +55,29 @@ protected void render(Block html) {
WebAppUtils.getResolvedRMWebAppURLWithScheme(this.conf);
Hamlet.UL<Hamlet.DIV<Hamlet>> ul = html
.div("#nav")
.h3()._("ResourceManager")._()
.h3().__("ResourceManager").__()
.ul()
.li().a(RMWebAppURL, "RM Home")._()._()
.h3()._("NodeManager")._() // TODO: Problem if no header like this
.li().a(RMWebAppURL, "RM Home").__().__()
.h3().__("NodeManager").__() // TODO: Problem if no header like this
.ul()
.li()
.a(url("node"), "Node Information")._()
.a(url("node"), "Node Information").__()
.li()
.a(url("allApplications"), "List of Applications")
._()
.__()
.li()
.a(url("allContainers"), "List of Containers")._()
._()
.a(url("allContainers"), "List of Containers").__()
.__()
.h3("Tools")
.ul()
.li().a("/conf", "Configuration")._()
.li().a("/logs", "Local logs")._()
.li().a("/stacks", "Server stacks")._()
.li().a("/jmx?qry=Hadoop:*", "Server metrics")._();
.li().a("/conf", "Configuration").__()
.li().a("/logs", "Local logs").__()
.li().a("/stacks", "Server stacks").__()
.li().a("/jmx?qry=Hadoop:*", "Server metrics").__();
if (addErrorsAndWarningsLink) {
ul.li().a(url("errors-and-warnings"), "Errors/Warnings")._();
ul.li().a(url("errors-and-warnings"), "Errors/Warnings").__();
}
ul._()._();
ul.__().__();
}
}

View File

@ -28,7 +28,7 @@
import org.apache.hadoop.yarn.server.nodemanager.ResourceView;
import org.apache.hadoop.yarn.server.nodemanager.webapp.dao.NodeInfo;
import org.apache.hadoop.yarn.webapp.SubView;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.HTML;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.HTML;
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
import org.apache.hadoop.yarn.webapp.view.InfoBlock;
@ -39,7 +39,7 @@ public class NodePage extends NMView {
private static final long BYTES_IN_MB = 1024 * 1024;
@Override
protected void commonPreHead(HTML<_> html) {
protected void commonPreHead(HTML<__> html) {
super.commonPreHead(html);
set(initID(ACCORDION, "nav"), "{autoHeight:false, active:1}");
@ -65,29 +65,29 @@ public NodeBlock(Context context, ResourceView resourceView) {
protected void render(Block html) {
NodeInfo info = new NodeInfo(this.context, this.resourceView);
info("NodeManager information")
._("Total Vmem allocated for Containers",
.__("Total Vmem allocated for Containers",
StringUtils.byteDesc(info.getTotalVmemAllocated() * BYTES_IN_MB))
._("Vmem enforcement enabled",
.__("Vmem enforcement enabled",
info.isVmemCheckEnabled())
._("Total Pmem allocated for Container",
.__("Total Pmem allocated for Container",
StringUtils.byteDesc(info.getTotalPmemAllocated() * BYTES_IN_MB))
._("Pmem enforcement enabled",
.__("Pmem enforcement enabled",
info.isPmemCheckEnabled())
._("Total VCores allocated for Containers",
.__("Total VCores allocated for Containers",
String.valueOf(info.getTotalVCoresAllocated()))
._("NodeHealthyStatus",
.__("NodeHealthyStatus",
info.getHealthStatus())
._("LastNodeHealthTime", new Date(
.__("LastNodeHealthTime", new Date(
info.getLastNodeUpdateTime()))
._("NodeHealthReport",
.__("NodeHealthReport",
info.getHealthReport())
._("NodeManager started on", new Date(
.__("NodeManager started on", new Date(
info.getNMStartupTime()))
._("NodeManager Version:", info.getNMBuildVersion() +
.__("NodeManager Version:", info.getNMBuildVersion() +
" on " + info.getNMVersionBuiltOn())
._("Hadoop Version:", info.getHadoopBuildVersion() +
.__("Hadoop Version:", info.getHadoopBuildVersion() +
" on " + info.getHadoopVersionBuiltOn());
html._(InfoBlock.class);
html.__(InfoBlock.class);
}
}
}

View File

@ -37,22 +37,22 @@ public class AboutBlock extends HtmlBlock {
@Override
protected void render(Block html) {
html._(MetricsOverviewTable.class);
html.__(MetricsOverviewTable.class);
ResourceManager rm = getInstance(ResourceManager.class);
ClusterInfo cinfo = new ClusterInfo(rm);
info("Cluster overview").
_("Cluster ID:", cinfo.getClusterId()).
_("ResourceManager state:", cinfo.getState()).
_("ResourceManager HA state:", cinfo.getHAState()).
_("ResourceManager HA zookeeper connection state:",
__("Cluster ID:", cinfo.getClusterId()).
__("ResourceManager state:", cinfo.getState()).
__("ResourceManager HA state:", cinfo.getHAState()).
__("ResourceManager HA zookeeper connection state:",
cinfo.getHAZookeeperConnectionState()).
_("ResourceManager RMStateStore:", cinfo.getRMStateStore()).
_("ResourceManager started on:", Times.format(cinfo.getStartedOn())).
_("ResourceManager version:", cinfo.getRMBuildVersion() +
__("ResourceManager RMStateStore:", cinfo.getRMStateStore()).
__("ResourceManager started on:", Times.format(cinfo.getStartedOn())).
__("ResourceManager version:", cinfo.getRMBuildVersion() +
" on " + cinfo.getRMVersionBuiltOn()).
_("Hadoop version:", cinfo.getHadoopBuildVersion() +
__("Hadoop version:", cinfo.getHadoopBuildVersion() +
" on " + cinfo.getHadoopVersionBuiltOn());
html._(InfoBlock.class);
html.__(InfoBlock.class);
}
}

View File

@ -22,7 +22,7 @@
public class AboutPage extends RmView {
@Override protected void preHead(Page.HTML<_> html) {
@Override protected void preHead(Page.HTML<__> html) {
commonPreHead(html);
}

View File

@ -31,7 +31,7 @@
public class AppAttemptPage extends RmView {
@Override
protected void preHead(Page.HTML<_> html) {
protected void preHead(Page.HTML<__> html) {
commonPreHead(html);
String appAttemptId = $(YarnWebParams.APPLICATION_ATTEMPT_ID);

View File

@ -25,7 +25,7 @@
public class AppLogAggregationStatusPage extends RmView{
@Override
protected void preHead(Page.HTML<_> html) {
protected void preHead(Page.HTML<__> html) {
commonPreHead(html);
String appId = $(YarnWebParams.APPLICATION_ID);
set(

View File

@ -30,7 +30,7 @@
public class AppPage extends RmView {
@Override
protected void preHead(Page.HTML<_> html) {
protected void preHead(Page.HTML<__> html) {
commonPreHead(html);
String appId = $(YarnWebParams.APPLICATION_ID);
set(

View File

@ -18,7 +18,6 @@
package org.apache.hadoop.yarn.server.resourcemanager.webapp;
import org.apache.hadoop.yarn.server.webapp.AppsBlock;
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
/**
@ -26,7 +25,7 @@
*/
class AppsBlockWithMetrics extends HtmlBlock {
@Override public void render(Block html) {
html._(MetricsOverviewTable.class);
html._(RMAppsBlock.class);
html.__(MetricsOverviewTable.class);
html.__(RMAppsBlock.class);
}
}

View File

@ -47,12 +47,12 @@
import org.apache.hadoop.yarn.util.resource.Resources;
import org.apache.hadoop.yarn.webapp.ResponseInfo;
import org.apache.hadoop.yarn.webapp.SubView;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.DIV;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.LI;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TBODY;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.UL;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.DIV;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.LI;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TABLE;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TBODY;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.UL;
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
import org.apache.hadoop.yarn.webapp.view.InfoBlock;
@ -105,7 +105,7 @@ private void renderLeafQueueInfoWithPartition(Block html) {
info("\'" + lqinfo.getQueuePath().substring(5)
+ "\' Queue Status for Partition \'" + nodeLabelDisplay + "\'");
renderQueueCapacityInfo(ri, nodeLabel);
html._(InfoBlock.class);
html.__(InfoBlock.class);
// clear the info contents so this queue's info doesn't accumulate into
// another queue's info
ri.clear();
@ -113,10 +113,10 @@ private void renderLeafQueueInfoWithPartition(Block html) {
// second display the queue specific details :
ri =
info("\'" + lqinfo.getQueuePath().substring(5) + "\' Queue Status")
._("Queue State:", lqinfo.getQueueState());
.__("Queue State:", lqinfo.getQueueState());
renderCommonLeafQueueInfo(ri);
html._(InfoBlock.class);
html.__(InfoBlock.class);
// clear the info contents so this queue's info doesn't accumulate into
// another queue's info
ri.clear();
@ -125,10 +125,10 @@ private void renderLeafQueueInfoWithPartition(Block html) {
private void renderLeafQueueInfoWithoutParition(Block html) {
ResponseInfo ri =
info("\'" + lqinfo.getQueuePath().substring(5) + "\' Queue Status")
._("Queue State:", lqinfo.getQueueState());
.__("Queue State:", lqinfo.getQueueState());
renderQueueCapacityInfo(ri, "");
renderCommonLeafQueueInfo(ri);
html._(InfoBlock.class);
html.__(InfoBlock.class);
// clear the info contents so this queue's info doesn't accumulate into
// another queue's info
ri.clear();
@ -155,40 +155,40 @@ private void renderQueueCapacityInfo(ResponseInfo ri, String label) {
? new ResourceInfo(Resources.none())
: resourceUsages.getAmUsed();
ri.
_("Used Capacity:", percent(capacities.getUsedCapacity() / 100)).
_("Configured Capacity:", percent(capacities.getCapacity() / 100)).
_("Configured Max Capacity:", percent(capacities.getMaxCapacity() / 100)).
_("Absolute Used Capacity:", percent(capacities.getAbsoluteUsedCapacity() / 100)).
_("Absolute Configured Capacity:", percent(capacities.getAbsoluteCapacity() / 100)).
_("Absolute Configured Max Capacity:", percent(capacities.getAbsoluteMaxCapacity() / 100)).
_("Used Resources:", resourceUsages.getUsed().toString()).
_("Configured Max Application Master Limit:", StringUtils.format("%.1f",
__("Used Capacity:", percent(capacities.getUsedCapacity() / 100)).
__("Configured Capacity:", percent(capacities.getCapacity() / 100)).
__("Configured Max Capacity:", percent(capacities.getMaxCapacity() / 100)).
__("Absolute Used Capacity:", percent(capacities.getAbsoluteUsedCapacity() / 100)).
__("Absolute Configured Capacity:", percent(capacities.getAbsoluteCapacity() / 100)).
__("Absolute Configured Max Capacity:", percent(capacities.getAbsoluteMaxCapacity() / 100)).
__("Used Resources:", resourceUsages.getUsed().toString()).
__("Configured Max Application Master Limit:", StringUtils.format("%.1f",
capacities.getMaxAMLimitPercentage())).
_("Max Application Master Resources:",
__("Max Application Master Resources:",
resourceUsages.getAMLimit().toString()).
_("Used Application Master Resources:",
__("Used Application Master Resources:",
amUsed.toString()).
_("Max Application Master Resources Per User:",
__("Max Application Master Resources Per User:",
userAMResourceLimit.toString());
}
private void renderCommonLeafQueueInfo(ResponseInfo ri) {
ri.
_("Num Schedulable Applications:", Integer.toString(lqinfo.getNumActiveApplications())).
_("Num Non-Schedulable Applications:", Integer.toString(lqinfo.getNumPendingApplications())).
_("Num Containers:", Integer.toString(lqinfo.getNumContainers())).
_("Max Applications:", Integer.toString(lqinfo.getMaxApplications())).
_("Max Applications Per User:", Integer.toString(lqinfo.getMaxApplicationsPerUser())).
_("Configured Minimum User Limit Percent:", Integer.toString(lqinfo.getUserLimit()) + "%").
_("Configured User Limit Factor:", lqinfo.getUserLimitFactor()).
_("Accessible Node Labels:", StringUtils.join(",", lqinfo.getNodeLabels())).
_("Ordering Policy: ", lqinfo.getOrderingPolicyInfo()).
_("Preemption:", lqinfo.getPreemptionDisabled() ? "disabled" : "enabled").
_("Default Node Label Expression:",
__("Num Schedulable Applications:", Integer.toString(lqinfo.getNumActiveApplications())).
__("Num Non-Schedulable Applications:", Integer.toString(lqinfo.getNumPendingApplications())).
__("Num Containers:", Integer.toString(lqinfo.getNumContainers())).
__("Max Applications:", Integer.toString(lqinfo.getMaxApplications())).
__("Max Applications Per User:", Integer.toString(lqinfo.getMaxApplicationsPerUser())).
__("Configured Minimum User Limit Percent:", Integer.toString(lqinfo.getUserLimit()) + "%").
__("Configured User Limit Factor:", lqinfo.getUserLimitFactor()).
__("Accessible Node Labels:", StringUtils.join(",", lqinfo.getNodeLabels())).
__("Ordering Policy: ", lqinfo.getOrderingPolicyInfo()).
__("Preemption:", lqinfo.getPreemptionDisabled() ? "disabled" : "enabled").
__("Default Node Label Expression:",
lqinfo.getDefaultNodeLabelExpression() == null
? NodeLabel.DEFAULT_NODE_LABEL_PARTITION
: lqinfo.getDefaultNodeLabelExpression()).
_("Default Application Priority:",
__("Default Application Priority:",
Integer.toString(lqinfo.getDefaultApplicationPriority()));
}
}
@ -208,14 +208,14 @@ static class QueueUsersInfoBlock extends HtmlBlock {
protected void render(Block html) {
TBODY<TABLE<Hamlet>> tbody =
html.table("#userinfo").thead().$class("ui-widget-header").tr().th()
.$class("ui-state-default")._("User Name")._().th()
.$class("ui-state-default")._("Max Resource")._().th()
.$class("ui-state-default")._("Weight")._().th()
.$class("ui-state-default")._("Used Resource")._().th()
.$class("ui-state-default")._("Max AM Resource")._().th()
.$class("ui-state-default")._("Used AM Resource")._().th()
.$class("ui-state-default")._("Schedulable Apps")._().th()
.$class("ui-state-default")._("Non-Schedulable Apps")._()._()._()
.$class("ui-state-default").__("User Name").__().th()
.$class("ui-state-default").__("Max Resource").__().th()
.$class("ui-state-default").__("Weight").__().th()
.$class("ui-state-default").__("Used Resource").__().th()
.$class("ui-state-default").__("Max AM Resource").__().th()
.$class("ui-state-default").__("Used AM Resource").__().th()
.$class("ui-state-default").__("Schedulable Apps").__().th()
.$class("ui-state-default").__("Non-Schedulable Apps").__().__().__()
.tbody();
ArrayList<UserInfo> users = lqinfo.getUsers().getUsersList();
@ -240,11 +240,11 @@ protected void render(Block html) {
.td(resourceUsages.getAMLimit().toString())
.td(amUsed.toString())
.td(Integer.toString(userInfo.getNumActiveApplications()))
.td(Integer.toString(userInfo.getNumPendingApplications()))._();
.td(Integer.toString(userInfo.getNumPendingApplications())).__();
}
html.div().$class("usersinfo").h5("Active Users Info")._();
tbody._()._();
html.div().$class("usersinfo").h5("Active Users Info").__();
tbody.__().__();
}
}
@ -288,25 +288,25 @@ public void render(Block html) {
a(_Q).$style(width(absMaxCap * Q_MAX_WIDTH)).
$title(join("Absolute Capacity:", percent(absCap))).
span().$style(join(Q_GIVEN, ";font-size:1px;", width(absCap/absMaxCap))).
_('.')._().
__('.').__().
span().$style(join(width(absUsedCap/absMaxCap),
";font-size:1px;left:0%;", absUsedCap > absCap ? Q_OVER : Q_UNDER)).
_('.')._().
span(".q", "Queue: "+info.getQueuePath().substring(5))._().
__('.').__().
span(".q", "Queue: "+info.getQueuePath().substring(5)).__().
span().$class("qstats").$style(left(Q_STATS_POS)).
_(join(percent(used), " used"))._();
__(join(percent(used), " used")).__();
csqinfo.qinfo = info;
if (info.getQueues() == null) {
li.ul("#lq").li()._(LeafQueueInfoBlock.class)._()._();
li.ul("#lq").li()._(QueueUsersInfoBlock.class)._()._();
li.ul("#lq").li().__(LeafQueueInfoBlock.class).__().__();
li.ul("#lq").li().__(QueueUsersInfoBlock.class).__().__();
} else {
li._(QueueBlock.class);
li.__(QueueBlock.class);
}
li._();
li.__();
}
ul._();
ul.__();
}
}
@ -327,7 +327,7 @@ static class QueuesBlock extends HtmlBlock {
@Override
public void render(Block html) {
html._(MetricsOverviewTable.class);
html.__(MetricsOverviewTable.class);
UserGroupInformation callerUGI = this.getCallerUGI();
boolean isAdmin = false;
@ -347,10 +347,10 @@ public void render(Block html) {
.$style(
"border-style: solid; border-color: #000000; border-width: 1px;"
+ " cursor: hand; cursor: pointer; border-radius: 4px")
.$onclick("confirmAction()").b("Dump scheduler logs")._().select()
.$id("time").option().$value("60")._("1 min")._().option()
.$value("300")._("5 min")._().option().$value("600")._("10 min")._()
._()._();
.$onclick("confirmAction()").b("Dump scheduler logs").__().select()
.$id("time").option().$value("60").__("1 min").__().option()
.$value("300").__("5 min").__().option().$value("600").__("10 min").__()
.__().__();
StringBuilder script = new StringBuilder();
script
@ -377,36 +377,36 @@ public void render(Block html) {
.append(" console.log(data);").append(" });").append(" }")
.append("}");
html.script().$type("text/javascript")._(script.toString())._();
html.script().$type("text/javascript").__(script.toString()).__();
}
UL<DIV<DIV<Hamlet>>> ul = html.
div("#cs-wrapper.ui-widget").
div(".ui-widget-header.ui-corner-top").
_("Application Queues")._().
__("Application Queues").__().
div("#cs.ui-widget-content.ui-corner-bottom").
ul();
if (cs == null) {
ul.
li().
a(_Q).$style(width(Q_MAX_WIDTH)).
span().$style(Q_END)._("100% ")._().
span(".q", "default")._()._();
span().$style(Q_END).__("100% ").__().
span(".q", "default").__().__();
} else {
ul.
li().$style("margin-bottom: 1em").
span().$style("font-weight: bold")._("Legend:")._().
span().$style("font-weight: bold").__("Legend:").__().
span().$class("qlegend ui-corner-all").$style(Q_GIVEN).
_("Capacity")._().
__("Capacity").__().
span().$class("qlegend ui-corner-all").$style(Q_UNDER).
_("Used")._().
__("Used").__().
span().$class("qlegend ui-corner-all").$style(Q_OVER).
_("Used (over capacity)")._().
__("Used (over capacity)").__().
span().$class("qlegend ui-corner-all ui-state-default").
_("Max Capacity")._().
__("Max Capacity").__().
span().$class("qlegend ui-corner-all").$style(ACTIVE_USER).
_("Users Requesting Resources")._().
_();
__("Users Requesting Resources").__().
__();
float used = 0;
@ -433,11 +433,11 @@ public void render(Block html) {
ul.li().
a(_Q).$style(width(Q_MAX_WIDTH)).
span().$style(join(width(used), ";left:0%;",
used > 1 ? Q_OVER : Q_UNDER))._(".")._().
span(".q", "Queue: root")._().
used > 1 ? Q_OVER : Q_UNDER)).__(".").__().
span(".q", "Queue: root").__().
span().$class("qstats").$style(left(Q_STATS_POS)).
_(join(percent(used), " used"))._().
_(QueueBlock.class)._();
__(join(percent(used), " used")).__().
__(QueueBlock.class).__();
} else {
for (RMNodeLabel label : nodeLabelsInfo) {
csqinfo.qinfo = null;
@ -453,29 +453,29 @@ public void render(Block html) {
ul.li().
a(_Q).$style(width(Q_MAX_WIDTH)).
span().$style(join(width(used), ";left:0%;",
used > 1 ? Q_OVER : Q_UNDER))._(".")._().
span(".q", partitionUiTag)._().
used > 1 ? Q_OVER : Q_UNDER)).__(".").__().
span(".q", partitionUiTag).__().
span().$class("qstats").$style(left(Q_STATS_POS)).
_(join(percent(used), " used"))._()._();
__(join(percent(used), " used")).__().__();
//for the queue hierarchy under label
UL<Hamlet> underLabel = html.ul("#pq");
underLabel.li().
a(_Q).$style(width(Q_MAX_WIDTH)).
span().$style(join(width(used), ";left:0%;",
used > 1 ? Q_OVER : Q_UNDER))._(".")._().
span(".q", "Queue: root")._().
used > 1 ? Q_OVER : Q_UNDER)).__(".").__().
span(".q", "Queue: root").__().
span().$class("qstats").$style(left(Q_STATS_POS)).
_(join(percent(used), " used"))._().
_(QueueBlock.class)._()._();
__(join(percent(used), " used")).__().
__(QueueBlock.class).__().__();
}
}
}
ul._()._().
ul.__().__().
script().$type("text/javascript").
_("$('#cs').hide();")._()._().
_(RMAppsBlock.class);
html._(HealthBlock.class);
__("$('#cs').hide();").__().__().
__(RMAppsBlock.class);
html.__(HealthBlock.class);
}
}
@ -495,13 +495,13 @@ public void render(HtmlBlock.Block html) {
div.h4("Aggregate scheduler counts");
TBODY<TABLE<DIV<Hamlet>>> tbody =
div.table("#lastrun").thead().$class("ui-widget-header").tr().th()
.$class("ui-state-default")._("Total Container Allocations(count)")
._().th().$class("ui-state-default")
._("Total Container Releases(count)")._().th()
.$class("ui-state-default").__("Total Container Allocations(count)")
.__().th().$class("ui-state-default")
.__("Total Container Releases(count)").__().th()
.$class("ui-state-default")
._("Total Fulfilled Reservations(count)")._().th()
.$class("ui-state-default")._("Total Container Preemptions(count)")
._()._()._().tbody();
.__("Total Fulfilled Reservations(count)").__().th()
.$class("ui-state-default").__("Total Container Preemptions(count)")
.__().__().__().tbody();
tbody
.$class("ui-widget-content")
.tr()
@ -512,15 +512,15 @@ public void render(HtmlBlock.Block html) {
String.valueOf(cs.getRootQueueMetrics()
.getAggegatedReleasedContainers()))
.td(healthInfo.getAggregateFulFilledReservationsCount().toString())
.td(healthInfo.getAggregatePreemptionCount().toString())._()._()._();
.td(healthInfo.getAggregatePreemptionCount().toString()).__().__().__();
div.h4("Last scheduler run");
tbody =
div.table("#lastrun").thead().$class("ui-widget-header").tr().th()
.$class("ui-state-default")._("Time")._().th()
.$class("ui-state-default")._("Allocations(count - resources)")._()
.th().$class("ui-state-default")._("Reservations(count - resources)")
._().th().$class("ui-state-default")._("Releases(count - resources)")
._()._()._().tbody();
.$class("ui-state-default").__("Time").__().th()
.$class("ui-state-default").__("Allocations(count - resources)").__()
.th().$class("ui-state-default").__("Reservations(count - resources)")
.__().th().$class("ui-state-default").__("Releases(count - resources)")
.__().__().__().tbody();
tbody
.$class("ui-widget-content")
.tr()
@ -533,7 +533,7 @@ public void render(HtmlBlock.Block html) {
+ healthInfo.getResourcesReserved().toString())
.td(
healthInfo.getReleaseCount().toString() + " - "
+ healthInfo.getResourcesReleased().toString())._()._()._();
+ healthInfo.getResourcesReleased().toString()).__().__().__();
Map<String, SchedulerHealth.DetailedInformation> info = new HashMap<>();
info.put("Allocation", healthInfo.getLastAllocationDetails());
info.put("Reservation", healthInfo.getLastReservationDetails());
@ -549,10 +549,10 @@ public void render(HtmlBlock.Block html) {
div.h4("Last " + entry.getKey());
tbody =
div.table(table).thead().$class("ui-widget-header").tr().th()
.$class("ui-state-default")._("Time")._().th()
.$class("ui-state-default")._("Container Id")._().th()
.$class("ui-state-default")._("Node Id")._().th()
.$class("ui-state-default")._("Queue")._()._()._().tbody();
.$class("ui-state-default").__("Time").__().th()
.$class("ui-state-default").__("Container Id").__().th()
.$class("ui-state-default").__("Node Id").__().th()
.$class("ui-state-default").__("Queue").__().__().__().tbody();
SchedulerHealth.DetailedInformation di = entry.getValue();
if (di.getTimestamp() != 0) {
containerId = di.getContainerId().toString();
@ -561,26 +561,26 @@ public void render(HtmlBlock.Block html) {
}
tbody.$class("ui-widget-content").tr()
.td(Times.format(di.getTimestamp())).td(containerId).td(nodeId)
.td(queue)._()._()._();
.td(queue).__().__().__();
}
div._();
div.__();
}
}
@Override protected void postHead(Page.HTML<_> html) {
@Override protected void postHead(Page.HTML<__> html) {
html.
style().$type("text/css").
_("#cs { padding: 0.5em 0 1em 0; margin-bottom: 1em; position: relative }",
__("#cs { padding: 0.5em 0 1em 0; margin-bottom: 1em; position: relative }",
"#cs ul { list-style: none }",
"#cs a { font-weight: normal; margin: 2px; position: relative }",
"#cs a span { font-weight: normal; font-size: 80% }",
"#cs-wrapper .ui-widget-header { padding: 0.2em 0.5em }",
".qstats { font-weight: normal; font-size: 80%; position: absolute }",
".qlegend { font-weight: normal; padding: 0 1em; margin: 1em }",
"table.info tr th {width: 50%}")._(). // to center info table
"table.info tr th {width: 50%}").__(). // to center info table
script("/static/jt/jquery.jstree.js").
script().$type("text/javascript").
_("$(function() {",
__("$(function() {",
" $('#cs a span').addClass('ui-corner-all').css('position', 'absolute');",
" $('#cs').bind('loaded.jstree', function (e, data) {",
" var callback = { call:reopenQueryNodes }",
@ -603,8 +603,8 @@ public void render(HtmlBlock.Block html) {
" $('#apps').dataTable().fnFilter(q, 4, true);",
" });",
" $('#cs').show();",
"});")._().
_(SchedulerPageUtil.QueueBlockUtil.class);
"});").__().
__(SchedulerPageUtil.QueueBlockUtil.class);
}
@Override protected Class<? extends SubView> content() {

View File

@ -28,7 +28,7 @@
public class ContainerPage extends RmView {
@Override
protected void preHead(Page.HTML<_> html) {
protected void preHead(Page.HTML<__> html) {
commonPreHead(html);
String containerId = $(YarnWebParams.CONTAINER_ID);

View File

@ -26,9 +26,9 @@
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.FifoSchedulerInfo;
import org.apache.hadoop.yarn.server.webapp.AppsBlock;
import org.apache.hadoop.yarn.webapp.SubView;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.DIV;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.UL;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.DIV;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.UL;
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
import org.apache.hadoop.yarn.webapp.view.InfoBlock;
@ -53,16 +53,16 @@ static class QueueInfoBlock extends HtmlBlock {
@Override public void render(Block html) {
info("\'" + sinfo.getQueueName() + "\' Queue Status").
_("Queue State:" , sinfo.getState()).
_("Minimum Queue Memory Capacity:" , Long.toString(sinfo.getMinQueueMemoryCapacity())).
_("Maximum Queue Memory Capacity:" , Long.toString(sinfo.getMaxQueueMemoryCapacity())).
_("Number of Nodes:" , Integer.toString(sinfo.getNumNodes())).
_("Used Node Capacity:" , Integer.toString(sinfo.getUsedNodeCapacity())).
_("Available Node Capacity:" , Integer.toString(sinfo.getAvailNodeCapacity())).
_("Total Node Capacity:" , Integer.toString(sinfo.getTotalNodeCapacity())).
_("Number of Node Containers:" , Integer.toString(sinfo.getNumContainers()));
__("Queue State:" , sinfo.getState()).
__("Minimum Queue Memory Capacity:" , Long.toString(sinfo.getMinQueueMemoryCapacity())).
__("Maximum Queue Memory Capacity:" , Long.toString(sinfo.getMaxQueueMemoryCapacity())).
__("Number of Nodes:" , Integer.toString(sinfo.getNumNodes())).
__("Used Node Capacity:" , Integer.toString(sinfo.getUsedNodeCapacity())).
__("Available Node Capacity:" , Integer.toString(sinfo.getAvailNodeCapacity())).
__("Total Node Capacity:" , Integer.toString(sinfo.getTotalNodeCapacity())).
__("Number of Node Containers:" , Integer.toString(sinfo.getNumContainers()));
html._(InfoBlock.class);
html.__(InfoBlock.class);
}
}
@ -77,11 +77,11 @@ static class QueuesBlock extends HtmlBlock {
@Override
public void render(Block html) {
html._(MetricsOverviewTable.class);
html.__(MetricsOverviewTable.class);
UL<DIV<DIV<Hamlet>>> ul = html.
div("#cs-wrapper.ui-widget").
div(".ui-widget-header.ui-corner-top").
_("FifoScheduler Queue")._().
__("FifoScheduler Queue").__().
div("#cs.ui-widget-content.ui-corner-bottom").
ul();
@ -89,8 +89,8 @@ public void render(Block html) {
ul.
li().
a(_Q).$style(width(WIDTH_F)).
span().$style(Q_END)._("100% ")._().
span(".q", "default")._()._();
span().$style(Q_END).__("100% ").__().
span(".q", "default").__().__();
} else {
float used = sinfo.getUsedCapacity();
float set = sinfo.getCapacity();
@ -99,33 +99,33 @@ public void render(Block html) {
li().
a(_Q).$style(width(WIDTH_F)).
$title(join("used:", percent(used))).
span().$style(Q_END)._("100%")._().
span().$style(Q_END).__("100%").__().
span().$style(join(width(delta), ';', used > set ? OVER : UNDER,
';', used > set ? left(set) : left(used)))._(".")._().
span(".q", sinfo.getQueueName())._().
_(QueueInfoBlock.class)._();
';', used > set ? left(set) : left(used))).__(".").__().
span(".q", sinfo.getQueueName()).__().
__(QueueInfoBlock.class).__();
}
ul._()._().
ul.__().__().
script().$type("text/javascript").
_("$('#cs').hide();")._()._().
_(AppsBlock.class);
__("$('#cs').hide();").__().__().
__(AppsBlock.class);
}
}
@Override protected void postHead(Page.HTML<_> html) {
@Override protected void postHead(Page.HTML<__> html) {
html.
style().$type("text/css").
_("#cs { padding: 0.5em 0 1em 0; margin-bottom: 1em; position: relative }",
__("#cs { padding: 0.5em 0 1em 0; margin-bottom: 1em; position: relative }",
"#cs ul { list-style: none }",
"#cs a { font-weight: normal; margin: 2px; position: relative }",
"#cs a span { font-weight: normal; font-size: 80% }",
"#cs-wrapper .ui-widget-header { padding: 0.2em 0.5em }",
"table.info tr th {width: 50%}")._(). // to center info table
"table.info tr th {width: 50%}").__(). // to center info table
script("/static/jt/jquery.jstree.js").
script().$type("text/javascript").
_("$(function() {",
__("$(function() {",
" $('#cs a span').addClass('ui-corner-all').css('position', 'absolute');",
" $('#cs').bind('loaded.jstree', function (e, data) {",
" data.inst.open_all(); }).",
@ -142,7 +142,7 @@ public void render(Block html) {
" $('#apps').dataTable().fnFilter(q, 4);",
" });",
" $('#cs').show();",
"});")._();
"});").__();
}
@Override protected Class<? extends SubView> content() {

View File

@ -34,6 +34,6 @@ public class ErrorBlock extends HtmlBlock {
@Override
protected void render(Block html) {
html.p()._($(ERROR_MESSAGE))._();
html.p().__($(ERROR_MESSAGE)).__();
}
}

View File

@ -41,9 +41,9 @@
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler;
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppInfo;
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.FairSchedulerInfo;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TBODY;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TABLE;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.TBODY;
import org.apache.hadoop.yarn.webapp.util.WebAppUtils;
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
@ -98,7 +98,7 @@ public FairSchedulerAppsBlock(ResourceManager rm, ViewContext ctx,
th(".reservedCpu", "Reserved CPU VCores").
th(".reservedMemory", "Reserved Memory MB").
th(".progress", "Progress").
th(".ui", "Tracking UI")._()._().
th(".ui", "Tracking UI").__().__().
tbody();
Collection<YarnApplicationState> reqAppStates = null;
String reqStateString = $(APP_STATE);
@ -168,8 +168,8 @@ public FairSchedulerAppsBlock(ResourceManager rm, ViewContext ctx,
}
appsTableData.append("]");
html.script().$type("text/javascript").
_("var appsTableData=" + appsTableData)._();
__("var appsTableData=" + appsTableData).__();
tbody._()._();
tbody.__().__();
}
}

View File

@ -31,10 +31,10 @@
import org.apache.hadoop.yarn.server.webapp.WebPageUtils;
import org.apache.hadoop.yarn.webapp.ResponseInfo;
import org.apache.hadoop.yarn.webapp.SubView;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.DIV;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.LI;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.UL;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.DIV;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.LI;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.UL;
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
import org.apache.hadoop.yarn.webapp.view.InfoBlock;
@ -70,21 +70,21 @@ static class LeafQueueBlock extends HtmlBlock {
@Override
protected void render(Block html) {
ResponseInfo ri = info("\'" + qinfo.getQueueName() + "\' Queue Status").
_("Used Resources:", qinfo.getUsedResources().toString()).
_("Demand Resources:", qinfo.getDemandResources().toString()).
_("Num Active Applications:", qinfo.getNumActiveApplications()).
_("Num Pending Applications:", qinfo.getNumPendingApplications()).
_("Min Resources:", qinfo.getMinResources().toString()).
_("Max Resources:", qinfo.getMaxResources().toString()).
_("Reserved Resources:", qinfo.getReservedResources().toString());
__("Used Resources:", qinfo.getUsedResources().toString()).
__("Demand Resources:", qinfo.getDemandResources().toString()).
__("Num Active Applications:", qinfo.getNumActiveApplications()).
__("Num Pending Applications:", qinfo.getNumPendingApplications()).
__("Min Resources:", qinfo.getMinResources().toString()).
__("Max Resources:", qinfo.getMaxResources().toString()).
__("Reserved Resources:", qinfo.getReservedResources().toString());
int maxApps = qinfo.getMaxApplications();
if (maxApps < Integer.MAX_VALUE) {
ri._("Max Running Applications:", qinfo.getMaxApplications());
ri.__("Max Running Applications:", qinfo.getMaxApplications());
}
ri._(STEADY_FAIR_SHARE + ":", qinfo.getSteadyFairShare().toString());
ri._(INSTANTANEOUS_FAIR_SHARE + ":", qinfo.getFairShare().toString());
ri._("Preemptable:", qinfo.isPreemptable());
html._(InfoBlock.class);
ri.__(STEADY_FAIR_SHARE + ":", qinfo.getSteadyFairShare().toString());
ri.__(INSTANTANEOUS_FAIR_SHARE + ":", qinfo.getFairShare().toString());
ri.__("Preemptable:", qinfo.isPreemptable());
html.__(InfoBlock.class);
// clear the info contents so this queue's info doesn't accumulate into another queue's info
ri.clear();
@ -102,17 +102,17 @@ static class ParentQueueBlock extends HtmlBlock {
@Override
protected void render(Block html) {
ResponseInfo ri = info("\'" + qinfo.getQueueName() + "\' Queue Status").
_("Used Resources:", qinfo.getUsedResources().toString()).
_("Min Resources:", qinfo.getMinResources().toString()).
_("Max Resources:", qinfo.getMaxResources().toString()).
_("Reserved Resources:", qinfo.getReservedResources().toString());
__("Used Resources:", qinfo.getUsedResources().toString()).
__("Min Resources:", qinfo.getMinResources().toString()).
__("Max Resources:", qinfo.getMaxResources().toString()).
__("Reserved Resources:", qinfo.getReservedResources().toString());
int maxApps = qinfo.getMaxApplications();
if (maxApps < Integer.MAX_VALUE) {
ri._("Max Running Applications:", qinfo.getMaxApplications());
ri.__("Max Running Applications:", qinfo.getMaxApplications());
}
ri._(STEADY_FAIR_SHARE + ":", qinfo.getSteadyFairShare().toString());
ri._(INSTANTANEOUS_FAIR_SHARE + ":", qinfo.getFairShare().toString());
html._(InfoBlock.class);
ri.__(STEADY_FAIR_SHARE + ":", qinfo.getSteadyFairShare().toString());
ri.__(INSTANTANEOUS_FAIR_SHARE + ":", qinfo.getFairShare().toString());
html.__(InfoBlock.class);
// clear the info contents so this queue's info doesn't accumulate into another queue's info
ri.clear();
@ -141,28 +141,28 @@ public void render(Block html) {
$title(join(join(STEADY_FAIR_SHARE + ":", percent(steadyFairShare)),
join(" " + INSTANTANEOUS_FAIR_SHARE + ":", percent(instantaneousFairShare)))).
span().$style(join(Q_GIVEN, ";font-size:1px;", width(steadyFairShare / capacity))).
_('.')._().
__('.').__().
span().$style(join(Q_INSTANTANEOUS_FS, ";font-size:1px;",
width(instantaneousFairShare/capacity))).
_('.')._().
__('.').__().
span().$style(join(width(used/capacity),
";font-size:1px;left:0%;", used > instantaneousFairShare ? Q_OVER : Q_UNDER)).
_('.')._().
span(".q", info.getQueueName())._().
__('.').__().
span(".q", info.getQueueName()).__().
span().$class("qstats").$style(left(Q_STATS_POS)).
_(join(percent(used), " used"))._();
__(join(percent(used), " used")).__();
fsqinfo.qinfo = info;
if (info instanceof FairSchedulerLeafQueueInfo) {
li.ul("#lq").li()._(LeafQueueBlock.class)._()._();
li.ul("#lq").li().__(LeafQueueBlock.class).__().__();
} else {
li.ul("#lq").li()._(ParentQueueBlock.class)._()._();
li._(QueueBlock.class);
li.ul("#lq").li().__(ParentQueueBlock.class).__().__();
li.__(QueueBlock.class);
}
li._();
li.__();
}
ul._();
ul.__();
}
}
@ -177,19 +177,19 @@ static class QueuesBlock extends HtmlBlock {
@Override
public void render(Block html) {
html._(MetricsOverviewTable.class);
html.__(MetricsOverviewTable.class);
UL<DIV<DIV<Hamlet>>> ul = html.
div("#cs-wrapper.ui-widget").
div(".ui-widget-header.ui-corner-top").
_("Application Queues")._().
__("Application Queues").__().
div("#cs.ui-widget-content.ui-corner-bottom").
ul();
if (fs == null) {
ul.
li().
a(_Q).$style(width(Q_MAX_WIDTH)).
span().$style(Q_END)._("100% ")._().
span(".q", "default")._()._();
span().$style(Q_END).__("100% ").__().
span(".q", "default").__().__();
} else {
FairSchedulerInfo sinfo = new FairSchedulerInfo(fs);
fsqinfo.qinfo = sinfo.getRootQueueInfo();
@ -197,52 +197,52 @@ public void render(Block html) {
ul.
li().$style("margin-bottom: 1em").
span().$style("font-weight: bold")._("Legend:")._().
span().$style("font-weight: bold").__("Legend:").__().
span().$class("qlegend ui-corner-all").$style(Q_GIVEN).
$title("The steady fair shares consider all queues, " +
"both active (with running applications) and inactive.").
_(STEADY_FAIR_SHARE)._().
__(STEADY_FAIR_SHARE).__().
span().$class("qlegend ui-corner-all").$style(Q_INSTANTANEOUS_FS).
$title("The instantaneous fair shares consider only active " +
"queues (with running applications).").
_(INSTANTANEOUS_FAIR_SHARE)._().
__(INSTANTANEOUS_FAIR_SHARE).__().
span().$class("qlegend ui-corner-all").$style(Q_UNDER).
_("Used")._().
__("Used").__().
span().$class("qlegend ui-corner-all").$style(Q_OVER).
_("Used (over fair share)")._().
__("Used (over fair share)").__().
span().$class("qlegend ui-corner-all ui-state-default").
_("Max Capacity")._().
_().
__("Max Capacity").__().
__().
li().
a(_Q).$style(width(Q_MAX_WIDTH)).
span().$style(join(width(used), ";left:0%;",
used > 1 ? Q_OVER : Q_UNDER))._(".")._().
span(".q", "root")._().
used > 1 ? Q_OVER : Q_UNDER)).__(".").__().
span(".q", "root").__().
span().$class("qstats").$style(left(Q_STATS_POS)).
_(join(percent(used), " used"))._().
_(QueueBlock.class)._();
__(join(percent(used), " used")).__().
__(QueueBlock.class).__();
}
ul._()._().
ul.__().__().
script().$type("text/javascript").
_("$('#cs').hide();")._()._().
_(FairSchedulerAppsBlock.class);
__("$('#cs').hide();").__().__().
__(FairSchedulerAppsBlock.class);
}
}
@Override protected void postHead(Page.HTML<_> html) {
@Override protected void postHead(Page.HTML<__> html) {
html.
style().$type("text/css").
_("#cs { padding: 0.5em 0 1em 0; margin-bottom: 1em; position: relative }",
__("#cs { padding: 0.5em 0 1em 0; margin-bottom: 1em; position: relative }",
"#cs ul { list-style: none }",
"#cs a { font-weight: normal; margin: 2px; position: relative }",
"#cs a span { font-weight: normal; font-size: 80% }",
"#cs-wrapper .ui-widget-header { padding: 0.2em 0.5em }",
".qstats { font-weight: normal; font-size: 80%; position: absolute }",
".qlegend { font-weight: normal; padding: 0 1em; margin: 1em }",
"table.info tr th {width: 50%}")._(). // to center info table
"table.info tr th {width: 50%}").__(). // to center info table
script("/static/jt/jquery.jstree.js").
script().$type("text/javascript").
_("$(function() {",
__("$(function() {",
" $('#cs a span').addClass('ui-corner-all').css('position', 'absolute');",
" $('#cs').bind('loaded.jstree', function (e, data) {",
" var callback = { call:reopenQueryNodes }",
@ -262,8 +262,8 @@ public void render(Block html) {
" $('#apps').dataTable().fnFilter(q, 4, true);",
" });",
" $('#cs').show();",
"});")._().
_(SchedulerPageUtil.QueueBlockUtil.class);
"});").__().
__(SchedulerPageUtil.QueueBlockUtil.class);
}
@Override protected Class<? extends SubView> content() {

View File

@ -24,8 +24,8 @@
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.SchedulerInfo;
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.UserMetricsInfo;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.DIV;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.DIV;
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
import com.google.inject.Inject;
@ -61,19 +61,19 @@ protected void render(Block html) {
table("#metricsoverview").
thead().$class("ui-widget-header").
tr().
th().$class("ui-state-default")._("Apps Submitted")._().
th().$class("ui-state-default")._("Apps Pending")._().
th().$class("ui-state-default")._("Apps Running")._().
th().$class("ui-state-default")._("Apps Completed")._().
th().$class("ui-state-default")._("Containers Running")._().
th().$class("ui-state-default")._("Memory Used")._().
th().$class("ui-state-default")._("Memory Total")._().
th().$class("ui-state-default")._("Memory Reserved")._().
th().$class("ui-state-default")._("VCores Used")._().
th().$class("ui-state-default")._("VCores Total")._().
th().$class("ui-state-default")._("VCores Reserved")._().
_().
_().
th().$class("ui-state-default").__("Apps Submitted").__().
th().$class("ui-state-default").__("Apps Pending").__().
th().$class("ui-state-default").__("Apps Running").__().
th().$class("ui-state-default").__("Apps Completed").__().
th().$class("ui-state-default").__("Containers Running").__().
th().$class("ui-state-default").__("Memory Used").__().
th().$class("ui-state-default").__("Memory Total").__().
th().$class("ui-state-default").__("Memory Reserved").__().
th().$class("ui-state-default").__("VCores Used").__().
th().$class("ui-state-default").__("VCores Total").__().
th().$class("ui-state-default").__("VCores Reserved").__().
__().
__().
tbody().$class("ui-widget-content").
tr().
td(String.valueOf(clusterMetrics.getAppsSubmitted())).
@ -92,33 +92,33 @@ protected void render(Block html) {
td(String.valueOf(clusterMetrics.getAllocatedVirtualCores())).
td(String.valueOf(clusterMetrics.getTotalVirtualCores())).
td(String.valueOf(clusterMetrics.getReservedVirtualCores())).
_().
_()._();
__().
__().__();
div.h3("Cluster Nodes Metrics").
table("#nodemetricsoverview").
thead().$class("ui-widget-header").
tr().
th().$class("ui-state-default")._("Active Nodes")._().
th().$class("ui-state-default")._("Decommissioning Nodes")._().
th().$class("ui-state-default")._("Decommissioned Nodes")._().
th().$class("ui-state-default")._("Lost Nodes")._().
th().$class("ui-state-default")._("Unhealthy Nodes")._().
th().$class("ui-state-default")._("Rebooted Nodes")._().
th().$class("ui-state-default")._("Shutdown Nodes")._().
_().
_().
th().$class("ui-state-default").__("Active Nodes").__().
th().$class("ui-state-default").__("Decommissioning Nodes").__().
th().$class("ui-state-default").__("Decommissioned Nodes").__().
th().$class("ui-state-default").__("Lost Nodes").__().
th().$class("ui-state-default").__("Unhealthy Nodes").__().
th().$class("ui-state-default").__("Rebooted Nodes").__().
th().$class("ui-state-default").__("Shutdown Nodes").__().
__().
__().
tbody().$class("ui-widget-content").
tr().
td().a(url("nodes"),String.valueOf(clusterMetrics.getActiveNodes()))._().
td().a(url("nodes/decommissioning"), String.valueOf(clusterMetrics.getDecommissioningNodes()))._().
td().a(url("nodes/decommissioned"),String.valueOf(clusterMetrics.getDecommissionedNodes()))._().
td().a(url("nodes/lost"),String.valueOf(clusterMetrics.getLostNodes()))._().
td().a(url("nodes/unhealthy"),String.valueOf(clusterMetrics.getUnhealthyNodes()))._().
td().a(url("nodes/rebooted"),String.valueOf(clusterMetrics.getRebootedNodes()))._().
td().a(url("nodes/shutdown"),String.valueOf(clusterMetrics.getShutdownNodes()))._().
_().
_()._();
td().a(url("nodes"), String.valueOf(clusterMetrics.getActiveNodes())).__().
td().a(url("nodes/decommissioning"), String.valueOf(clusterMetrics.getDecommissioningNodes())).__().
td().a(url("nodes/decommissioned"), String.valueOf(clusterMetrics.getDecommissionedNodes())).__().
td().a(url("nodes/lost"), String.valueOf(clusterMetrics.getLostNodes())).__().
td().a(url("nodes/unhealthy"), String.valueOf(clusterMetrics.getUnhealthyNodes())).__().
td().a(url("nodes/rebooted"), String.valueOf(clusterMetrics.getRebootedNodes())).__().
td().a(url("nodes/shutdown"), String.valueOf(clusterMetrics.getShutdownNodes())).__().
__().
__().__();
String user = request().getRemoteUser();
if (user != null) {
@ -128,21 +128,21 @@ protected void render(Block html) {
table("#usermetricsoverview").
thead().$class("ui-widget-header").
tr().
th().$class("ui-state-default")._("Apps Submitted")._().
th().$class("ui-state-default")._("Apps Pending")._().
th().$class("ui-state-default")._("Apps Running")._().
th().$class("ui-state-default")._("Apps Completed")._().
th().$class("ui-state-default")._("Containers Running")._().
th().$class("ui-state-default")._("Containers Pending")._().
th().$class("ui-state-default")._("Containers Reserved")._().
th().$class("ui-state-default")._("Memory Used")._().
th().$class("ui-state-default")._("Memory Pending")._().
th().$class("ui-state-default")._("Memory Reserved")._().
th().$class("ui-state-default")._("VCores Used")._().
th().$class("ui-state-default")._("VCores Pending")._().
th().$class("ui-state-default")._("VCores Reserved")._().
_().
_().
th().$class("ui-state-default").__("Apps Submitted").__().
th().$class("ui-state-default").__("Apps Pending").__().
th().$class("ui-state-default").__("Apps Running").__().
th().$class("ui-state-default").__("Apps Completed").__().
th().$class("ui-state-default").__("Containers Running").__().
th().$class("ui-state-default").__("Containers Pending").__().
th().$class("ui-state-default").__("Containers Reserved").__().
th().$class("ui-state-default").__("Memory Used").__().
th().$class("ui-state-default").__("Memory Pending").__().
th().$class("ui-state-default").__("Memory Reserved").__().
th().$class("ui-state-default").__("VCores Used").__().
th().$class("ui-state-default").__("VCores Pending").__().
th().$class("ui-state-default").__("VCores Reserved").__().
__().
__().
tbody().$class("ui-widget-content").
tr().
td(String.valueOf(userMetrics.getAppsSubmitted())).
@ -163,8 +163,8 @@ protected void render(Block html) {
td(String.valueOf(userMetrics.getAllocatedVirtualCores())).
td(String.valueOf(userMetrics.getPendingVirtualCores())).
td(String.valueOf(userMetrics.getReservedVirtualCores())).
_().
_()._();
__().
__().__();
}
}
@ -175,14 +175,14 @@ protected void render(Block html) {
table("#schedulermetricsoverview").
thead().$class("ui-widget-header").
tr().
th().$class("ui-state-default")._("Scheduler Type")._().
th().$class("ui-state-default")._("Scheduling Resource Type")._().
th().$class("ui-state-default")._("Minimum Allocation")._().
th().$class("ui-state-default")._("Maximum Allocation")._().
th().$class("ui-state-default").__("Scheduler Type").__().
th().$class("ui-state-default").__("Scheduling Resource Type").__().
th().$class("ui-state-default").__("Minimum Allocation").__().
th().$class("ui-state-default").__("Maximum Allocation").__().
th().$class("ui-state-default")
._("Maximum Cluster Application Priority")._().
_().
_().
.__("Maximum Cluster Application Priority").__().
__().
__().
tbody().$class("ui-widget-content").
tr().
td(String.valueOf(schedulerInfo.getSchedulerType())).
@ -190,9 +190,9 @@ protected void render(Block html) {
td(schedulerInfo.getMinAllocation().toString()).
td(schedulerInfo.getMaxAllocation().toString()).
td(String.valueOf(schedulerInfo.getMaxClusterLevelAppPriority())).
_().
_()._();
__().
__().__();
div._();
div.__();
}
}

View File

@ -23,10 +23,10 @@
import org.apache.commons.logging.impl.Log4JLogger;
import org.apache.hadoop.yarn.api.records.YarnApplicationState;
import org.apache.hadoop.yarn.util.Log4jWarningErrorMetricsAppender;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.DIV;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.LI;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.UL;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.DIV;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.LI;
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet.UL;
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
public class NavBlock extends HtmlBlock {
@ -45,29 +45,29 @@ public class NavBlock extends HtmlBlock {
div("#nav").
h3("Cluster").
ul().
li().a(url("cluster"), "About")._().
li().a(url("nodes"), "Nodes")._().
li().a(url("nodelabels"), "Node Labels")._();
li().a(url("cluster"), "About").__().
li().a(url("nodes"), "Nodes").__().
li().a(url("nodelabels"), "Node Labels").__();
UL<LI<UL<DIV<Hamlet>>>> subAppsList = mainList.
li().a(url("apps"), "Applications").
ul();
subAppsList.li()._();
subAppsList.li().__();
for (YarnApplicationState state : YarnApplicationState.values()) {
subAppsList.
li().a(url("apps", state.toString()), state.toString())._();
li().a(url("apps", state.toString()), state.toString()).__();
}
subAppsList._()._();
subAppsList.__().__();
UL<DIV<Hamlet>> tools = mainList.
li().a(url("scheduler"), "Scheduler")._()._().
li().a(url("scheduler"), "Scheduler").__().__().
h3("Tools").ul();
tools.li().a("/conf", "Configuration")._().
li().a("/logs", "Local logs")._().
li().a("/stacks", "Server stacks")._().
li().a("/jmx?qry=Hadoop:*", "Server metrics")._();
tools.li().a("/conf", "Configuration").__().
li().a("/logs", "Local logs").__().
li().a("/stacks", "Server stacks").__().
li().a("/jmx?qry=Hadoop:*", "Server metrics").__();
if (addErrorsAndWarningsLink) {
tools.li().a(url("errors-and-warnings"), "Errors/Warnings")._();
tools.li().a(url("errors-and-warnings"), "Errors/Warnings").__();
}
tools._()._();
tools.__().__();
}
}

Some files were not shown because too many files have changed in this diff Show More