Search in sources :

Example 1 with Log4jWarningErrorMetricsAppender

use of org.apache.hadoop.yarn.util.Log4jWarningErrorMetricsAppender in project hadoop by apache.

the class NavBlock method render.

@Override
protected void render(Block html) {
    boolean addErrorsAndWarningsLink = false;
    Log log = LogFactory.getLog(NMErrorsAndWarningsPage.class);
    if (log instanceof Log4JLogger) {
        Log4jWarningErrorMetricsAppender appender = Log4jWarningErrorMetricsAppender.findAppender();
        if (appender != null) {
            addErrorsAndWarningsLink = true;
        }
    }
    String RMWebAppURL = WebAppUtils.getResolvedRMWebAppURLWithScheme(this.conf);
    Hamlet.UL<Hamlet.DIV<Hamlet>> ul = html.div("#nav").h3()._("ResourceManager")._().ul().li().a(RMWebAppURL, "RM Home")._()._().h3()._("NodeManager")._().ul().li().a(url("node"), "Node Information")._().li().a(url("allApplications"), "List of Applications")._().li().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")._();
    if (addErrorsAndWarningsLink) {
        ul.li().a(url("errors-and-warnings"), "Errors/Warnings")._();
    }
    ul._()._();
}
Also used : Hamlet(org.apache.hadoop.yarn.webapp.hamlet.Hamlet) Log(org.apache.commons.logging.Log) Log4JLogger(org.apache.commons.logging.impl.Log4JLogger) Log4jWarningErrorMetricsAppender(org.apache.hadoop.yarn.util.Log4jWarningErrorMetricsAppender)

Example 2 with Log4jWarningErrorMetricsAppender

use of org.apache.hadoop.yarn.util.Log4jWarningErrorMetricsAppender in project hadoop by apache.

the class NavBlock method render.

@Override
public void render(Block html) {
    boolean addErrorsAndWarningsLink = false;
    Log log = LogFactory.getLog(NavBlock.class);
    if (log instanceof Log4JLogger) {
        Log4jWarningErrorMetricsAppender appender = Log4jWarningErrorMetricsAppender.findAppender();
        if (appender != null) {
            addErrorsAndWarningsLink = true;
        }
    }
    Hamlet.DIV<Hamlet> nav = html.div("#nav").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")._();
    if (addErrorsAndWarningsLink) {
        tools.li().a(url("errors-and-warnings"), "Errors/Warnings")._();
    }
    tools._()._();
}
Also used : Hamlet(org.apache.hadoop.yarn.webapp.hamlet.Hamlet) Log(org.apache.commons.logging.Log) Log4JLogger(org.apache.commons.logging.impl.Log4JLogger) Log4jWarningErrorMetricsAppender(org.apache.hadoop.yarn.util.Log4jWarningErrorMetricsAppender)

Example 3 with Log4jWarningErrorMetricsAppender

use of org.apache.hadoop.yarn.util.Log4jWarningErrorMetricsAppender in project hadoop by apache.

the class NavBlock method render.

@Override
public void render(Block html) {
    boolean addErrorsAndWarningsLink = false;
    Log log = LogFactory.getLog(NavBlock.class);
    if (log instanceof Log4JLogger) {
        Log4jWarningErrorMetricsAppender appender = Log4jWarningErrorMetricsAppender.findAppender();
        if (appender != null) {
            addErrorsAndWarningsLink = true;
        }
    }
    UL<DIV<Hamlet>> mainList = html.div("#nav").h3("Cluster").ul().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()._();
    for (YarnApplicationState state : YarnApplicationState.values()) {
        subAppsList.li().a(url("apps", state.toString()), state.toString())._();
    }
    subAppsList._()._();
    UL<DIV<Hamlet>> tools = mainList.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")._();
    if (addErrorsAndWarningsLink) {
        tools.li().a(url("errors-and-warnings"), "Errors/Warnings")._();
    }
    tools._()._();
}
Also used : DIV(org.apache.hadoop.yarn.webapp.hamlet.Hamlet.DIV) Log(org.apache.commons.logging.Log) Log4JLogger(org.apache.commons.logging.impl.Log4JLogger) Log4jWarningErrorMetricsAppender(org.apache.hadoop.yarn.util.Log4jWarningErrorMetricsAppender) YarnApplicationState(org.apache.hadoop.yarn.api.records.YarnApplicationState) LI(org.apache.hadoop.yarn.webapp.hamlet.Hamlet.LI)

Example 4 with Log4jWarningErrorMetricsAppender

use of org.apache.hadoop.yarn.util.Log4jWarningErrorMetricsAppender in project hadoop by apache.

the class ErrorsAndWarningsBlock method render.

@Override
protected void render(Block html) {
    Log log = LogFactory.getLog(ErrorsAndWarningsBlock.class);
    boolean isAdmin = false;
    UserGroupInformation callerUGI = this.getCallerUGI();
    if (adminAclsManager.areACLsEnabled()) {
        if (callerUGI != null && adminAclsManager.isAdmin(callerUGI)) {
            isAdmin = true;
        }
    } else {
        isAdmin = true;
    }
    if (!isAdmin) {
        html.div().p()._("This page is for admins only.")._()._();
        return;
    }
    if (log instanceof Log4JLogger) {
        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")._()._()._();
        String script = "function reloadPage() {" + " var timePeriod = $(\"#cutoff\").val();" + " document.location.href = '/cluster/errors-and-warnings?cutoff=' + timePeriod" + "}";
        script = script + "; function toggleContent(element) {" + "  $(element).parent().siblings('.toggle-content').fadeToggle();" + "}";
        html.script().$type("text/javascript")._(script)._();
        html.style(".toggle-content { display: none; }");
        Log4jWarningErrorMetricsAppender appender = Log4jWarningErrorMetricsAppender.findAppender();
        if (appender == null) {
            return;
        }
        List<Long> cutoff = new ArrayList<>();
        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();
        // cutoff has to be in seconds
        cutoff.add((Time.now() - cutoffPeriodSeconds * 1000) / 1000);
        List<Map<String, Log4jWarningErrorMetricsAppender.Element>> errorsData = appender.getErrorMessagesAndCounts(cutoff);
        List<Map<String, Log4jWarningErrorMetricsAppender.Element>> warningsData = appender.getWarningMessagesAndCounts(cutoff);
        Map<String, List<Map<String, Log4jWarningErrorMetricsAppender.Element>>> sources = new HashMap<>();
        sources.put("Error", errorsData);
        sources.put("Warning", warningsData);
        int maxDisplayLength = 80;
        for (Map.Entry<String, List<Map<String, Log4jWarningErrorMetricsAppender.Element>>> source : sources.entrySet()) {
            String type = source.getKey();
            List<Map<String, Log4jWarningErrorMetricsAppender.Element>> data = source.getValue();
            if (data.size() > 0) {
                Map<String, Log4jWarningErrorMetricsAppender.Element> map = data.get(0);
                for (Map.Entry<String, Log4jWarningErrorMetricsAppender.Element> entry : map.entrySet()) {
                    String message = entry.getKey();
                    Hamlet.TR<Hamlet.TBODY<Hamlet.TABLE<Hamlet>>> row = errorsTable.tr();
                    Hamlet.TD<Hamlet.TR<Hamlet.TBODY<Hamlet.TABLE<Hamlet>>>> cell = row.td();
                    if (message.length() > maxDisplayLength || message.contains("\n")) {
                        String displayMessage = entry.getKey().split("\n")[0];
                        if (displayMessage.length() > maxDisplayLength) {
                            displayMessage = displayMessage.substring(0, maxDisplayLength);
                        }
                        cell.pre().a().$href("#").$onclick("toggleContent(this);").$style("white-space: pre")._(displayMessage)._()._().div().$class("toggle-content").pre()._(message)._()._()._();
                    } else {
                        cell.pre()._(message)._()._();
                    }
                    Log4jWarningErrorMetricsAppender.Element ele = entry.getValue();
                    row.td(type).td(String.valueOf(ele.count)).td(Times.format(ele.timestampSeconds * 1000))._();
                }
            }
        }
        errorsTable._()._();
    }
}
Also used : Hamlet(org.apache.hadoop.yarn.webapp.hamlet.Hamlet) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation) Log(org.apache.commons.logging.Log) Log4JLogger(org.apache.commons.logging.impl.Log4JLogger) Log4jWarningErrorMetricsAppender(org.apache.hadoop.yarn.util.Log4jWarningErrorMetricsAppender) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

Log (org.apache.commons.logging.Log)4 Log4JLogger (org.apache.commons.logging.impl.Log4JLogger)4 Log4jWarningErrorMetricsAppender (org.apache.hadoop.yarn.util.Log4jWarningErrorMetricsAppender)4 Hamlet (org.apache.hadoop.yarn.webapp.hamlet.Hamlet)3 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)1 YarnApplicationState (org.apache.hadoop.yarn.api.records.YarnApplicationState)1 DIV (org.apache.hadoop.yarn.webapp.hamlet.Hamlet.DIV)1 LI (org.apache.hadoop.yarn.webapp.hamlet.Hamlet.LI)1