use of org.apache.dubbo.common.status.Status in project dubbo by alibaba.
the class ThreadPoolStatusCheckerTest method statusUnknownTest.
@Test
public void statusUnknownTest() {
Status status = threadPoolStatusChecker.check();
Assertions.assertEquals(status.getLevel(), Status.Level.UNKNOWN);
}
use of org.apache.dubbo.common.status.Status in project dubbo by alibaba.
the class ThreadPoolStatusCheckerTest method statusOkTest.
@Test
public void statusOkTest() {
int activeCount = 1;
int maximumPoolSize = 3;
String portKey = "8888";
mockThreadPoolExecutor(activeCount, maximumPoolSize, portKey);
Status status = threadPoolStatusChecker.check();
Assertions.assertEquals(status.getLevel(), Status.Level.OK);
Assertions.assertEquals(status.getMessage(), "Pool status:OK, max:" + maximumPoolSize + ", core:0, largest:0, active:" + activeCount + ", task:0, service port: " + portKey);
destroy(portKey);
}
use of org.apache.dubbo.common.status.Status in project dubbo by alibaba.
the class ServerStatusChecker method check.
@Override
public Status check() {
List<ProtocolServer> 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 (ProtocolServer protocolServer : servers) {
RemotingServer server = protocolServer.getRemotingServer();
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());
}
use of org.apache.dubbo.common.status.Status in project dubbo by alibaba.
the class StatusUtilsTest method testGetSummaryStatus2.
@Test
public void testGetSummaryStatus2() throws Exception {
Status status1 = new Status(Status.Level.WARN);
Status status2 = new Status(Status.Level.OK);
Map<String, Status> statuses = new HashMap<String, Status>();
statuses.put("status1", status1);
statuses.put("status2", status2);
Status status = StatusUtils.getSummaryStatus(statuses);
assertThat(status.getLevel(), is(Status.Level.WARN));
assertThat(status.getMessage(), containsString("status1"));
assertThat(status.getMessage(), not(containsString("status2")));
}
use of org.apache.dubbo.common.status.Status in project dubbo by alibaba.
the class SpringStatusCheckerTest method testWithoutLifeCycleRunning.
@Test
public void testWithoutLifeCycleRunning() {
SpringExtensionFactory.clearContexts();
ApplicationLifeCycle applicationLifeCycle = mock(ApplicationLifeCycle.class);
new ServiceBean<Object>().setApplicationContext(applicationLifeCycle);
given(applicationLifeCycle.isRunning()).willReturn(false);
Status status = springStatusChecker.check();
assertThat(status.getLevel(), is(Status.Level.ERROR));
}
Aggregations