Java Code Examples for com.alibaba.dubbo.remoting.exchange.ExchangeServer#isBound()

The following examples show how to use com.alibaba.dubbo.remoting.exchange.ExchangeServer#isBound() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ServerStatusChecker.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
@Override
public Status check() {
    Collection<ExchangeServer> servers = DubboProtocol.getDubboProtocol().getServers();
    if (servers == null || servers.isEmpty()) {
        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());
}
 
Example 2
Source File: ServerStatusChecker.java    From dubbox with Apache License 2.0 6 votes vote down vote up
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());
}
 
Example 3
Source File: ServerStatusChecker.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
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());
}
 
Example 4
Source File: ServerStatusChecker.java    From dubbo3 with Apache License 2.0 6 votes vote down vote up
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());
}
 
Example 5
Source File: ServerStatusChecker.java    From dubbox with Apache License 2.0 6 votes vote down vote up
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());
}
 
Example 6
Source File: DubboServerStatusMetrics.java    From watcher with Apache License 2.0 6 votes vote down vote up
@Override
public Object doMonitor(Map<String, Object> params) throws Throwable {
	List<Map<String, Object>> result = Lists.newArrayList();
	Collection<ExchangeServer> servers = DubboProtocol.getDubboProtocol().getServers();
	if (servers == null || servers.size() == 0) {
		throw WatcherException.throwIt("no server found");
	}
	for (ExchangeServer server : servers) {
		Map<String, Object> serverResult = Maps.newHashMap();
		boolean isBound = server.isBound();
		serverResult.put("isBound", isBound);
		if (isBound) {
			serverResult.put("clients", server.getChannels().size());
		}
		serverResult.put("port", server.getLocalAddress().getPort());
		result.add(serverResult);
	}
	return result;
}
 
Example 7
Source File: ServerStatusChecker.java    From dubbox with Apache License 2.0 6 votes vote down vote up
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());
}
 
Example 8
Source File: DubboServerStatusHealthCheck.java    From watcher with Apache License 2.0 5 votes vote down vote up
@Override
protected Result check() throws Exception {
	Collection<ExchangeServer> servers = DubboProtocol.getDubboProtocol().getServers();
	if (servers == null || servers.size() == 0) {
		return Result.healthy("no exchangeServer found");
	}
	for (ExchangeServer server : servers) {
		if (!server.isBound()) {
			return Result.unhealthy("server is unbound");
		}
	}
	return Result.healthy();
}