wait 5s berfore retrying WikiData request after GOAWAY, configurable with http_retry_wait

pull/818/head
Peter Hanecak 2024-02-16 10:33:43 +01:00
rodzic 1b0d5526a7
commit 8377e61e82
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 8DFCA0FEBE229DE2
2 zmienionych plików z 10 dodań i 0 usunięć

Wyświetl plik

@ -41,6 +41,7 @@ public record PlanetilerConfig(
String httpUserAgent,
Duration httpTimeout,
int httpRetries,
long httpRetryWait,
long downloadChunkSizeMB,
int downloadThreads,
double downloadMaxBandwidth,
@ -166,6 +167,7 @@ public record PlanetilerConfig(
"Planetiler downloader (https://github.com/onthegomap/planetiler)"),
arguments.getDuration("http_timeout", "Timeout to use when downloading files over HTTP", "30s"),
arguments.getInteger("http_retries", "Retries to use when downloading files over HTTP", 1),
arguments.getLong("http_retry_wait", "How long (in milliseconds) to wait before retrying HTTP request", 5_000),
arguments.getLong("download_chunk_size_mb", "Size of file chunks to download in parallel in megabytes", 100),
arguments.getInteger("download_threads", "Number of parallel threads to use when downloading each file", 1),
Parse.bandwidth(arguments.getString("download_max_bandwidth",

Wyświetl plik

@ -317,6 +317,14 @@ public class Wikidata {
LOGGER.error("sparql query failed, exhausted retries: " + e);
throw e;
}
if (e.getMessage() != null && e.getMessage().contains("GOAWAY")) {
try {
LOGGER.debug("GOAWAY received, waiting {} ms to give server some room", config.httpRetryWait());
Thread.sleep(config.httpRetryWait());
} catch (InterruptedException e2) {
Thread.currentThread().interrupt();
}
}
}
}