当前位置: 首页>>代码示例>>Java>>正文


Java Status.Level方法代码示例

本文整理汇总了Java中com.alibaba.dubbo.common.status.Status.Level方法的典型用法代码示例。如果您正苦于以下问题:Java Status.Level方法的具体用法?Java Status.Level怎么用?Java Status.Level使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.alibaba.dubbo.common.status.Status的用法示例。


在下文中一共展示了Status.Level方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: check

import com.alibaba.dubbo.common.status.Status; //导入方法依赖的package包/类
public Status check() {
    Collection<ExchangeServer> servers = DubboProtocol.getDubboProtocol().getServers();
    if (servers == null || servers.size() == 0) {
        return new Status(Status.Level.UNKNOWN);
    }
    Status.Level level = Status.Level.OK;
    StringBuilder buf = new StringBuilder();
    for (ExchangeServer server : servers) {
        if (! server.isBound()) {
            level = Status.Level.ERROR;
            buf.setLength(0);
            buf.append(server.getLocalAddress());
            break;
        }
        if (buf.length() > 0) {
            buf.append(",");
        }
        buf.append(server.getLocalAddress());
        buf.append("(clients:");
        buf.append(server.getChannels().size());
        buf.append(")");
    }
    return new Status(level, buf.toString());
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:25,代码来源:ServerStatusChecker.java

示例2: check

import com.alibaba.dubbo.common.status.Status; //导入方法依赖的package包/类
public Status check() {
    Collection<Registry> regsitries = AbstractRegistryFactory.getRegistries();
    if (regsitries == null || regsitries.size() == 0) {
        return new Status(Status.Level.UNKNOWN);
    }
    Status.Level level = Status.Level.OK;
    StringBuilder buf = new StringBuilder();
    for (Registry registry : regsitries) {
        if (buf.length() > 0) {
            buf.append(",");
        }
        buf.append(registry.getUrl().getAddress());
        if (! registry.isAvailable()) {
            level = Status.Level.ERROR;
            buf.append("(disconnected)");
        } else {
            buf.append("(connected)");
        }
    }
    return new Status(level, buf.toString());
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:22,代码来源:RegistryStatusChecker.java

示例3: check

import com.alibaba.dubbo.common.status.Status; //导入方法依赖的package包/类
public Status check() {
    Collection<Registry> regsitries = AbstractRegistryFactory.getRegistries();
    if (regsitries == null || regsitries.size() == 0) {
        return new Status(Status.Level.UNKNOWN);
    }
    Status.Level level = Status.Level.OK;
    StringBuilder buf = new StringBuilder();
    for (Registry registry : regsitries) {
        if (buf.length() > 0) {
            buf.append(",");
        }
        buf.append(registry.getUrl().getAddress());
        if (!registry.isAvailable()) {
            level = Status.Level.ERROR;
            buf.append("(disconnected)");
        } else {
            buf.append("(connected)");
        }
    }
    return new Status(level, buf.toString());
}
 
开发者ID:l1325169021,项目名称:github-test,代码行数:22,代码来源:RegistryStatusChecker.java

示例4: getLevelColor

import com.alibaba.dubbo.common.status.Status; //导入方法依赖的package包/类
private String getLevelColor(Status.Level level) {
    if (level == Status.Level.OK) {
        return "green";
    } else if (level == Status.Level.ERROR) {
        return "red";
    } else if (level == Status.Level.WARN) {
        return "yellow";
    }
    return "gray";
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:11,代码来源:StatusPageHandler.java

示例5: check

import com.alibaba.dubbo.common.status.Status; //导入方法依赖的package包/类
public Status check() {
    DataStore dataStore = ExtensionLoader.getExtensionLoader(DataStore.class).getDefaultExtension();
    Map<String, Object> executors = dataStore.get(Constants.EXECUTOR_SERVICE_COMPONENT_KEY);

    StringBuilder msg = new StringBuilder();
    Status.Level level = Status.Level.OK;
    for(Map.Entry<String, Object> entry : executors.entrySet()) {
        String port = entry.getKey();
        ExecutorService executor = (ExecutorService) entry.getValue();

        if (executor != null && executor instanceof ThreadPoolExecutor) {
            ThreadPoolExecutor tp = (ThreadPoolExecutor) executor;
            boolean ok = tp.getActiveCount() < tp.getMaximumPoolSize() - 1;
            Status.Level lvl = Status.Level.OK;
            if(!ok) {
                level = Status.Level.WARN;
                lvl = Status.Level.WARN;
            }

            if(msg.length() > 0) {
                msg.append(";");
            }
            msg.append("Pool status:" + lvl
                    + ", max:" + tp.getMaximumPoolSize()
                    + ", core:" + tp.getCorePoolSize()
                    + ", largest:" + tp.getLargestPoolSize()
                    + ", active:" + tp.getActiveCount()
                    + ", task:" + tp.getTaskCount()
                    + ", service port: " + port);
        }
    }
    return msg.length() == 0 ? new Status(Status.Level.UNKNOWN) : new Status(level, msg.toString());
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:34,代码来源:ThreadPoolStatusChecker.java

示例6: getLevelHtml

import com.alibaba.dubbo.common.status.Status; //导入方法依赖的package包/类
private String getLevelHtml(Status.Level level) {
    return "<font color=\"" + getLevelColor(level) + "\">" + level.name() + "</font>";
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:4,代码来源:StatusPageHandler.java

示例7: check

import com.alibaba.dubbo.common.status.Status; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public Status check() {
    ApplicationContext context = ServiceBean.getSpringContext();
    if (context == null) {
        return new Status(Status.Level.UNKNOWN);
    }
    Map<String, DataSource> dataSources = context.getBeansOfType(DataSource.class, false, false);
    if (dataSources == null || dataSources.size() == 0) {
        return new Status(Status.Level.UNKNOWN);
    }
    Status.Level level = Status.Level.OK;
    StringBuilder buf = new StringBuilder();
    for (Map.Entry<String, DataSource> entry : dataSources.entrySet()) {
        DataSource dataSource = entry.getValue();
        if (buf.length() > 0) {
            buf.append(", ");
        }
        buf.append(entry.getKey());
        try {
            Connection connection = dataSource.getConnection();
            try {
                DatabaseMetaData metaData = connection.getMetaData();
                ResultSet resultSet = metaData.getTypeInfo();
                try {
                    if (! resultSet.next()) {
                        level = Status.Level.ERROR;
                    }
                } finally {
                    resultSet.close();
                }
                buf.append(metaData.getURL());
                buf.append("(");
                buf.append(metaData.getDatabaseProductName());
                buf.append("-");
                buf.append(metaData.getDatabaseProductVersion());
                buf.append(")");
            } finally {
                connection.close();
            }
        } catch (Throwable e) {
            logger.warn(e.getMessage(), e);
            return new Status(level, e.getMessage());
        }
    }
    return new Status(level, buf.toString());
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:47,代码来源:DataSourceStatusChecker.java


注:本文中的com.alibaba.dubbo.common.status.Status.Level方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。