本文整理汇总了Java中com.alibaba.dubbo.common.status.Status类的典型用法代码示例。如果您正苦于以下问题:Java Status类的具体用法?Java Status怎么用?Java Status使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Status类属于com.alibaba.dubbo.common.status包,在下文中一共展示了Status类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}
示例2: getSummaryStatus
import com.alibaba.dubbo.common.status.Status; //导入依赖的package包/类
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());
}
示例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());
}
示例4: getSummaryStatus
import com.alibaba.dubbo.common.status.Status; //导入依赖的package包/类
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());
}
示例5: 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());
}
示例6: 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";
}
示例7: 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());
}
示例8: check
import com.alibaba.dubbo.common.status.Status; //导入依赖的package包/类
public Status check() {
OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean();
double load;
try {
Method method = OperatingSystemMXBean.class.getMethod("getSystemLoadAverage", new Class<?>[0]);
load = (Double)method.invoke(operatingSystemMXBean, new Object[0]);
} catch (Throwable e) {
load = -1;
}
int cpu = operatingSystemMXBean.getAvailableProcessors();
return new Status(load < 0 ? Status.Level.UNKNOWN : (load < cpu ? Status.Level.OK : Status.Level.WARN), (load < 0 ? "" : "load:" + load + ",") + "cpu:" + cpu);
}
示例9: check
import com.alibaba.dubbo.common.status.Status; //导入依赖的package包/类
public Status check() {
Runtime runtime = Runtime.getRuntime();
long freeMemory = runtime.freeMemory();
long totalMemory = runtime.totalMemory();
long maxMemory = runtime.maxMemory();
boolean ok = (maxMemory - (totalMemory - freeMemory) > 2048); // 剩余空间小于2M报警
String msg = "max:" + (maxMemory / 1024 / 1024) + "M,total:"
+ (totalMemory / 1024 / 1024) + "M,used:" + ((totalMemory / 1024 / 1024) - (freeMemory / 1024 / 1024)) + "M,free:" + (freeMemory / 1024 / 1024) + "M";
return new Status(ok ? Status.Level.OK : Status.Level.WARN, msg);
}
示例10: check
import com.alibaba.dubbo.common.status.Status; //导入依赖的package包/类
public Status check() {
OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean();
double load;
try {
Method method = OperatingSystemMXBean.class.getMethod("getSystemLoadAverage", new Class<?>[0]);
load = (Double)method.invoke(operatingSystemMXBean, new Object[0]);
} catch (Throwable e) {
load = -1;
}
int cpu = operatingSystemMXBean.getAvailableProcessors();
return new Status(load < 0 ? Status.Level.UNKNOWN : (load < cpu ? Status.Level.OK : Status.Level.WARN), "Load: " + load + " / CPU: " + cpu);
}
示例11: check
import com.alibaba.dubbo.common.status.Status; //导入依赖的package包/类
public Status check() {
boolean ok;
try {
Connection connection = dataSource.getConnection();
try {
DatabaseMetaData metaData = connection.getMetaData();
ResultSet resultSet = metaData.getTypeInfo();
try {
ok = resultSet.next();
} finally {
resultSet.close();
}
if (message == null) {
message = metaData.getURL()
+ " (" + metaData.getDatabaseProductName()
+ " " + metaData.getDatabaseProductVersion()
+ ", " + getIsolation(metaData.getDefaultTransactionIsolation()) + ")";
}
if (version == 0) {
version = metaData.getDatabaseMajorVersion();
}
} finally {
connection.close();
}
} catch (Throwable e) {
logger.error(e.getMessage(), e);
ok = false;
}
return new Status(! ok ? Status.Level.ERROR : (version < 5 ? Status.Level.WARN : Status.Level.OK), message);
}