Skip to content

Commit

Permalink
Add connection timeout in HealthReporterService. Fix Nan in status page.
Browse files Browse the repository at this point in the history
  • Loading branch information
ekharkunov committed Aug 12, 2024
1 parent b4b352e commit eb8e565
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion server/html_data/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ <h3 id="statusTitle" class="panel-title">
top_block.appendTo(parent_block);
}
function handleResponse(response, rootId) {
var totalFullyOperatedPlatforms, totalUnreachablePlatforms = 0;
var totalFullyOperatedPlatforms = 0, totalUnreachablePlatforms = 0;
var parent_block_1 = $(rootId).find("#list-1");
var parent_block_2 = $(rootId).find("#list-2");
var idx = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

@Service
public class HealthReporterService {

@Value("${extender.health-reporter.connection-timeout:1500}") int connectionTimeout;
public enum OperationalStatus {
Unreachable,
NotFullyOperational,
Expand All @@ -31,7 +35,11 @@ public String collectHealthReport(boolean isRemoteBuildEnabled, Map<String, Stri
Map<String, OperationalStatus> platformOperationalStatus = new HashMap<>();
JSONObject result = new JSONObject();
JSONParser parser = new JSONParser();
final HttpClient client = HttpClientBuilder.create().build();
RequestConfig config = RequestConfig.custom()
.setConnectTimeout(connectionTimeout)
.setConnectionRequestTimeout(connectionTimeout)
.setSocketTimeout(connectionTimeout).build();
final HttpClient client = HttpClientBuilder.create().setDefaultRequestConfig(config).build();
for (Map.Entry<String, String> entry : remoteBuilderPlatformMappings.entrySet()) {
final String healthUrl = String.format("%s/health_report", entry.getValue());
final HttpGet request = new HttpGet(healthUrl);
Expand Down

0 comments on commit eb8e565

Please sign in to comment.