use of org.sonar.server.health.Health in project sonarqube by SonarSource.
the class StandaloneSystemInfoWriter method writeHealth.
private void writeHealth(JsonWriter json) {
Health health = healthChecker.checkNode();
writeHealth(health, json);
}
use of org.sonar.server.health.Health in project sonarqube by SonarSource.
the class HealthActionSupport method toResponse.
private static System.HealthResponse toResponse(ClusterHealth check) {
System.HealthResponse.Builder responseBuilder = System.HealthResponse.newBuilder();
System.Node.Builder nodeBuilder = System.Node.newBuilder();
System.Cause.Builder causeBuilder = System.Cause.newBuilder();
Health health = check.getHealth();
responseBuilder.setHealth(System.Health.valueOf(health.getStatus().name()));
health.getCauses().forEach(str -> responseBuilder.addCauses(toCause(str, causeBuilder)));
System.Nodes.Builder nodesBuilder = System.Nodes.newBuilder();
check.getNodes().stream().sorted(NODE_HEALTH_COMPARATOR).map(node -> toNode(node, nodeBuilder, causeBuilder)).forEach(nodesBuilder::addNodes);
responseBuilder.setNodes(nodesBuilder.build());
return responseBuilder.build();
}
use of org.sonar.server.health.Health in project sonarqube by SonarSource.
the class SafeModeHealthActionTest method request_returns_status_and_causes_from_HealthChecker_checkNode_method.
@Test
public void request_returns_status_and_causes_from_HealthChecker_checkNode_method() {
authenticateWithPasscode();
Health.Status randomStatus = Health.Status.values()[new Random().nextInt(Health.Status.values().length)];
Health.Builder builder = newHealthCheckBuilder().setStatus(randomStatus);
IntStream.range(0, new Random().nextInt(5)).mapToObj(i -> RandomStringUtils.randomAlphanumeric(3)).forEach(builder::addCause);
Health health = builder.build();
when(healthChecker.checkNode()).thenReturn(health);
TestRequest request = underTest.newRequest();
System.HealthResponse healthResponse = request.executeProtobuf(System.HealthResponse.class);
assertThat(healthResponse.getHealth().name()).isEqualTo(randomStatus.name());
assertThat(health.getCauses()).isEqualTo(health.getCauses());
}
use of org.sonar.server.health.Health in project sonarqube by SonarSource.
the class ClusterSystemInfoWriterTest method before.
@Before
public void before() throws InterruptedException {
when(globalInfoLoader.load()).thenReturn(Collections.singletonList(createSection("globalInfo")));
when(appNodesInfoLoader.load()).thenReturn(Collections.singletonList(createNodeInfo("appNodes")));
when(searchNodesInfoLoader.load()).thenReturn(Collections.singletonList(createNodeInfo("searchNodes")));
Health health = Health.newHealthCheckBuilder().setStatus(Health.Status.GREEN).build();
when(healthChecker.checkCluster()).thenReturn(new ClusterHealth(health, Collections.emptySet()));
}
use of org.sonar.server.health.Health in project sonarqube by SonarSource.
the class HealthActionSupport method checkNodeHealth.
System.HealthResponse checkNodeHealth() {
Health check = healthChecker.checkNode();
System.HealthResponse.Builder responseBuilder = System.HealthResponse.newBuilder().setHealth(System.Health.valueOf(check.getStatus().name()));
System.Cause.Builder causeBuilder = System.Cause.newBuilder();
check.getCauses().forEach(str -> responseBuilder.addCauses(causeBuilder.clear().setMessage(str).build()));
return responseBuilder.build();
}
Aggregations