maybe fix
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 1m51s
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 1m51s
This commit is contained in:
parent
aa69970ec7
commit
ad83e270b6
@ -191,27 +191,22 @@ public class MojangService {
|
||||
return endpointStatus.get();
|
||||
}
|
||||
|
||||
List<CompletableFuture<Void>> futures = new ArrayList<>();
|
||||
for (EndpointStatus endpoint : MOJANG_ENDPOINTS) {
|
||||
futures.add(CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
long start = System.currentTimeMillis();
|
||||
InetAddress address = InetAddress.getByName(endpoint.getHostname());
|
||||
if (address.isReachable((int) TimeUnit.SECONDS.toMillis(4))) { // Check if the endpoint is reachable
|
||||
endpoint.setStatus(EndpointStatus.Status.ONLINE);
|
||||
return;
|
||||
}
|
||||
// Check if the endpoint took too long to respond
|
||||
if (System.currentTimeMillis() - start > TimeUnit.SECONDS.toMillis(2)) {
|
||||
endpoint.setStatus(EndpointStatus.Status.DEGRADED);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
endpoint.setStatus(EndpointStatus.Status.OFFLINE);
|
||||
MOJANG_ENDPOINTS.parallelStream().forEach(endpoint -> {
|
||||
try {
|
||||
long start = System.currentTimeMillis();
|
||||
InetAddress address = InetAddress.getByName(endpoint.getHostname());
|
||||
if (address.isReachable((int) TimeUnit.SECONDS.toMillis(4))) { // Check if the endpoint is reachable
|
||||
endpoint.setStatus(EndpointStatus.Status.ONLINE);
|
||||
return;
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join();
|
||||
// Check if the endpoint took too long to respond
|
||||
if (System.currentTimeMillis() - start > TimeUnit.SECONDS.toMillis(2)) {
|
||||
endpoint.setStatus(EndpointStatus.Status.DEGRADED);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
endpoint.setStatus(EndpointStatus.Status.OFFLINE);
|
||||
}
|
||||
});
|
||||
|
||||
log.info("Fetched Mojang API status for {} endpoints", MOJANG_ENDPOINTS.size());
|
||||
CachedEndpointStatus status = new CachedEndpointStatus(
|
||||
|
Loading…
Reference in New Issue
Block a user