Skip to content
Snippets Groups Projects
Commit dfbfeb9c authored by Muskan Srivastava's avatar Muskan Srivastava
Browse files

changed logger

parent 3e263ba2
No related branches found
No related tags found
1 merge request!147Enabling retry for indexer to storage service calls
Pipeline #43710 failed
...@@ -20,12 +20,11 @@ import com.google.gson.JsonObject; ...@@ -20,12 +20,11 @@ import com.google.gson.JsonObject;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
import io.github.resilience4j.retry.RetryConfig; import io.github.resilience4j.retry.RetryConfig;
import lombok.Data; import lombok.Data;
import lombok.extern.java.Log; import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.opengroup.osdu.core.common.model.http.HttpResponse; import org.opengroup.osdu.core.common.model.http.HttpResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import java.time.Duration; import java.time.Duration;
...@@ -33,12 +32,15 @@ import java.time.Duration; ...@@ -33,12 +32,15 @@ import java.time.Duration;
* This class handles retry configuration logic for calls made to <prefix>/storage/v2/query/records:batch * This class handles retry configuration logic for calls made to <prefix>/storage/v2/query/records:batch
* to resolve intermittent CosmosDb Not found issue * to resolve intermittent CosmosDb Not found issue
*/ */
@Log
@Component @Component
@Data @Data
@ConfigurationProperties(prefix = "azure.urlfetchservice.retry") @ConfigurationProperties(prefix = "azure.storage.client.retry")
public class RetryPolicy { public class RetryPolicy {
@Autowired
private JaxRsDpsLog logger;
private int attempts = 3; private int attempts = 3;
private int waitDuration = 1000; private int waitDuration = 1000;
private final String RECORD_NOT_FOUND = "notFound"; private final String RECORD_NOT_FOUND = "notFound";
...@@ -71,7 +73,7 @@ public class RetryPolicy { ...@@ -71,7 +73,7 @@ public class RetryPolicy {
notFoundElement.getAsJsonArray().isJsonNull()) { notFoundElement.getAsJsonArray().isJsonNull()) {
return false; return false;
} }
log.info("Retry is set true"); logger.info("Retry is set true");
return true; return true;
} }
} }
...@@ -17,10 +17,10 @@ package org.opengroup.osdu.indexer.azure.service; ...@@ -17,10 +17,10 @@ package org.opengroup.osdu.indexer.azure.service;
import io.github.resilience4j.retry.Retry; import io.github.resilience4j.retry.Retry;
import io.github.resilience4j.retry.RetryConfig; import io.github.resilience4j.retry.RetryConfig;
import io.github.resilience4j.retry.RetryRegistry; import io.github.resilience4j.retry.RetryRegistry;
import lombok.extern.java.Log;
import org.opengroup.osdu.core.common.http.FetchServiceHttpRequest; import org.opengroup.osdu.core.common.http.FetchServiceHttpRequest;
import org.opengroup.osdu.core.common.http.IUrlFetchService; import org.opengroup.osdu.core.common.http.IUrlFetchService;
import org.opengroup.osdu.core.common.http.UrlFetchServiceImpl; import org.opengroup.osdu.core.common.http.UrlFetchServiceImpl;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.opengroup.osdu.core.common.model.http.HttpResponse; import org.opengroup.osdu.core.common.model.http.HttpResponse;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Primary;
...@@ -34,7 +34,7 @@ import java.util.function.Supplier; ...@@ -34,7 +34,7 @@ import java.util.function.Supplier;
* This class has same function as that of UrlFetchService except in the case of * This class has same function as that of UrlFetchService except in the case of
* <prefix>/storage/v2/query/records:batch call for which it enables retry * <prefix>/storage/v2/query/records:batch call for which it enables retry
*/ */
@Log
@Service @Service
@RequestScope @RequestScope
@Primary @Primary
...@@ -48,6 +48,8 @@ public class UrlFetchServiceAzureImpl implements IUrlFetchService { ...@@ -48,6 +48,8 @@ public class UrlFetchServiceAzureImpl implements IUrlFetchService {
@Autowired @Autowired
private UrlFetchServiceImpl urlFetchService; private UrlFetchServiceImpl urlFetchService;
@Autowired
private JaxRsDpsLog logger;
/** /**
* this method invokes retryFunction only for <prefix>/storage/v2/query/records:batch * this method invokes retryFunction only for <prefix>/storage/v2/query/records:batch
* calls otherwise invokes UrlFetchService.sendRequest(FetchServiceHttpRequest request) * calls otherwise invokes UrlFetchService.sendRequest(FetchServiceHttpRequest request)
...@@ -84,7 +86,7 @@ public class UrlFetchServiceAzureImpl implements IUrlFetchService { ...@@ -84,7 +86,7 @@ public class UrlFetchServiceAzureImpl implements IUrlFetchService {
try { try {
return this.urlFetchService.sendRequest(request); return this.urlFetchService.sendRequest(request);
} catch (URISyntaxException e) { } catch (URISyntaxException e) {
log.info("HttpResponse is null due to URISyntaxException. " + e.getReason()); logger.error("HttpResponse is null due to URISyntaxException. " + e.getReason());
return null; return null;
} }
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment