Search in sources :

Example 1 with Level

use of com.alibaba.dubbo.common.status.Status.Level in project dubbo by alibaba.

the class Status method execute.

public void execute(Map<String, Object> context) throws Exception {
    //FIXME cache监控存在性能问题 汇总页面去掉
    Map<String, com.alibaba.dubbo.common.status.Status> statuses = StatusManager.getInstance().getStatusList(new String[] { "cache" });
    com.alibaba.dubbo.common.status.Status status = StatusManager.getInstance().getStatusSummary(statuses);
    Level level = status.getLevel();
    if (!com.alibaba.dubbo.common.status.Status.Level.OK.equals(level)) {
        context.put("message", level + new SimpleDateFormat(" [yyyy-MM-dd HH:mm:ss] ").format(new Date()) + filterOK(status.getMessage()));
    } else {
        context.put("message", level.toString());
    }
    PrintWriter writer = response.getWriter();
    writer.print(context.get("message").toString());
    writer.flush();
}
Also used : Date(java.util.Date) Level(com.alibaba.dubbo.common.status.Status.Level) SimpleDateFormat(java.text.SimpleDateFormat) PrintWriter(java.io.PrintWriter)

Example 2 with Level

use of com.alibaba.dubbo.common.status.Status.Level in project dubbo by alibaba.

the class StatusUtils method getSummaryStatus.

public static Status getSummaryStatus(Map<String, Status> statuses) {
    Level level = Level.OK;
    StringBuilder msg = new StringBuilder();
    for (Map.Entry<String, Status> entry : statuses.entrySet()) {
        String key = entry.getKey();
        Status status = entry.getValue();
        Level l = status.getLevel();
        if (Level.ERROR.equals(l)) {
            level = Level.ERROR;
            if (msg.length() > 0) {
                msg.append(",");
            }
            msg.append(key);
        } else if (Level.WARN.equals(l)) {
            if (!Level.ERROR.equals(level)) {
                level = Level.WARN;
            }
            if (msg.length() > 0) {
                msg.append(",");
            }
            msg.append(key);
        }
    }
    return new Status(level, msg.toString());
}
Also used : Status(com.alibaba.dubbo.common.status.Status) Level(com.alibaba.dubbo.common.status.Status.Level) Map(java.util.Map)

Example 3 with Level

use of com.alibaba.dubbo.common.status.Status.Level in project dubbo by alibaba.

the class StatusManager method getSummaryStatus.

public static Status getSummaryStatus(Map<String, Status> statuses) {
    Level level = Level.OK;
    StringBuilder msg = new StringBuilder();
    for (Map.Entry<String, Status> entry : statuses.entrySet()) {
        String key = entry.getKey();
        Status status = entry.getValue();
        Level l = status.getLevel();
        if (Level.ERROR.equals(l)) {
            level = Level.ERROR;
            if (msg.length() > 0) {
                msg.append(",");
            }
            msg.append(key);
        } else if (Level.WARN.equals(l)) {
            if (!Level.ERROR.equals(level)) {
                level = Level.WARN;
            }
            if (msg.length() > 0) {
                msg.append(",");
            }
            msg.append(key);
        }
    }
    return new Status(level, msg.toString());
}
Also used : Status(com.alibaba.dubbo.common.status.Status) Level(com.alibaba.dubbo.common.status.Status.Level) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap)

Aggregations

Level (com.alibaba.dubbo.common.status.Status.Level)3 Status (com.alibaba.dubbo.common.status.Status)2 Map (java.util.Map)2 PrintWriter (java.io.PrintWriter)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1