@@ -61,7 +61,7 @@ public class ImageFoundRequestHandler implements RequestHandler {
|
|||||||
//TODO отдавать любой полученный результат,даже если по таймауту падают
|
//TODO отдавать любой полученный результат,даже если по таймауту падают
|
||||||
|
|
||||||
String searchResponseYandex = null;
|
String searchResponseYandex = null;
|
||||||
// String searchResponseGoogle = null;
|
String searchResponseGoogle = null;
|
||||||
List<YandexSearchResponse.ImageResult> allYandexImages = new ArrayList<>();
|
List<YandexSearchResponse.ImageResult> allYandexImages = new ArrayList<>();
|
||||||
List<YandexSearchResponse.ImageResult> allGoogleImages = new ArrayList<>();
|
List<YandexSearchResponse.ImageResult> allGoogleImages = new ArrayList<>();
|
||||||
List<YandexSearchResponse.ImageResult> allUniqueImages;
|
List<YandexSearchResponse.ImageResult> allUniqueImages;
|
||||||
@@ -80,18 +80,18 @@ public class ImageFoundRequestHandler implements RequestHandler {
|
|||||||
log.error("Yandex search failed for file {}", fileId, e);
|
log.error("Yandex search failed for file {}", fileId, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// try {
|
try {
|
||||||
// searchResponseGoogle = searchImageService.searchReverseByPublicUrl(fileEntity, "google_lens",
|
searchResponseGoogle = searchImageService.searchReverseByPublicUrl(fileEntity, "google_lens",
|
||||||
// "exact_matches");
|
"exact_matches");
|
||||||
// log.info("searchResponseGoogle OK");
|
log.info("searchResponseGoogle OK");
|
||||||
// allGoogleImages = searchImageService.getAllImagesWithoutPagination(
|
allGoogleImages = searchImageService.getAllImagesWithoutPagination(
|
||||||
// searchResponseGoogle, "exact_matches");
|
searchResponseGoogle, "exact_matches");
|
||||||
// } catch (TimeoutException e) {
|
} catch (TimeoutException e) {
|
||||||
// log.warn("Google search timeout for file {}", fileId);
|
log.warn("Google search timeout for file {}", fileId);
|
||||||
// hasTimeout = true;
|
hasTimeout = true;
|
||||||
// } catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// log.error("Google search failed for file {}", fileId, e);
|
log.error("Google search failed for file {}", fileId, e);
|
||||||
// }
|
}
|
||||||
|
|
||||||
allUniqueImages = searchImageService.removeDuplicateUrls(allYandexImages, allGoogleImages);
|
allUniqueImages = searchImageService.removeDuplicateUrls(allYandexImages, allGoogleImages);
|
||||||
log.info("allUniqueImages OK: {} images", allUniqueImages.size());
|
log.info("allUniqueImages OK: {} images", allUniqueImages.size());
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ public class SearchImageService {
|
|||||||
.followRedirects(true)
|
.followRedirects(true)
|
||||||
.followSslRedirects(true)
|
.followSslRedirects(true)
|
||||||
.retryOnConnectionFailure(true)
|
.retryOnConnectionFailure(true)
|
||||||
|
.connectionPool(new ConnectionPool(0, 1, TimeUnit.NANOSECONDS))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
this.objectMapper = new ObjectMapper();
|
this.objectMapper = new ObjectMapper();
|
||||||
@@ -149,7 +150,7 @@ public class SearchImageService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Thread.sleep(500L * attempt); // 500ms, 1000ms, 1500ms
|
Thread.sleep(500L * attempt);
|
||||||
} catch (InterruptedException ie) {
|
} catch (InterruptedException ie) {
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
throw new IOException("Retry interrupted", ie);
|
throw new IOException("Retry interrupted", ie);
|
||||||
|
|||||||
Reference in New Issue
Block a user