Sync Integ to Master
[sdc.git] / common-app-api / src / main / java / org / openecomp / sdc / common / http / client / api / RetryHandlers.java
1 package org.openecomp.sdc.common.http.client.api;
2
3 import org.apache.http.protocol.HttpContext;
4 import org.slf4j.Logger;
5 import org.slf4j.LoggerFactory;
6
7 import java.io.IOException;
8
9 public class RetryHandlers {
10
11     private static final Logger LOGGER = LoggerFactory.getLogger(RetryHandlers.class);
12
13     private RetryHandlers(){}
14
15     public static ComparableHttpRequestRetryHandler getDefault(int numOfRetries) {
16         return (IOException exception, int executionCount, HttpContext context) -> {
17             LOGGER.debug("failed sending request with exception", exception);
18             LOGGER.debug("try request number: {}", executionCount);
19             return executionCount <= numOfRetries;
20         };
21     }
22
23
24 }