From c3ca0e25337f2165d463dab1ab6e89fe951e9a8f Mon Sep 17 00:00:00 2001 From: t-muskans Date: Thu, 27 May 2021 13:41:47 +0530 Subject: [PATCH 1/6] added http client, retry configs and entitlements Factory --- pom.xml | 2 +- .../di/RetryAndTimeoutsConfiguration.java | 18 ++++++ .../EntilementsAPIConfigBean.java | 44 ++++++++++++++ .../EntitlementsFactoryAzure.java | 58 +++++++++++++++++++ .../azure/httpconfig/HttpClientAzure.java | 49 ++++++++++++++++ .../httpconfig/HttpClientHandlerAzure.java | 45 ++++++++++++++ 6 files changed, 215 insertions(+), 1 deletion(-) create mode 100644 src/main/java/org/opengroup/osdu/azure/di/RetryAndTimeoutsConfiguration.java create mode 100644 src/main/java/org/opengroup/osdu/azure/entitlements/EntilementsAPIConfigBean.java create mode 100644 src/main/java/org/opengroup/osdu/azure/entitlements/EntitlementsFactoryAzure.java create mode 100644 src/main/java/org/opengroup/osdu/azure/httpconfig/HttpClientAzure.java create mode 100644 src/main/java/org/opengroup/osdu/azure/httpconfig/HttpClientHandlerAzure.java diff --git a/pom.xml b/pom.xml index 1d122d87..2cc8a3e8 100644 --- a/pom.xml +++ b/pom.xml @@ -37,7 +37,7 @@ 2.6.3 3.4.0 1.18.16 - 0.9.0-rc13 + 0.9.0-SNAPSHOT 1.0.0-beta-3 4.2.3 2.12.0 diff --git a/src/main/java/org/opengroup/osdu/azure/di/RetryAndTimeoutsConfiguration.java b/src/main/java/org/opengroup/osdu/azure/di/RetryAndTimeoutsConfiguration.java new file mode 100644 index 00000000..accb9b5c --- /dev/null +++ b/src/main/java/org/opengroup/osdu/azure/di/RetryAndTimeoutsConfiguration.java @@ -0,0 +1,18 @@ +package org.opengroup.osdu.azure.di; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * Configuration bean for setting up retry and timeouts variables. + */ + +@Data +@ConfigurationProperties(prefix = "azure.retryAndTimeout") +public class RetryAndTimeoutsConfiguration { + + private int retryCountForServiceUnavailableStrategy = 3; + private int connectTimeoutInMillis = 60000; + private int connectionRequestTimeout = 60000; + private int socketTimeout = 60000; +} diff --git a/src/main/java/org/opengroup/osdu/azure/entitlements/EntilementsAPIConfigBean.java b/src/main/java/org/opengroup/osdu/azure/entitlements/EntilementsAPIConfigBean.java new file mode 100644 index 00000000..f8ee8b80 --- /dev/null +++ b/src/main/java/org/opengroup/osdu/azure/entitlements/EntilementsAPIConfigBean.java @@ -0,0 +1,44 @@ +package org.opengroup.osdu.azure.entitlements; + +import org.opengroup.osdu.core.common.entitlements.EntitlementsAPIConfig; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.beans.factory.config.AbstractFactoryBean; +import org.springframework.stereotype.Component; + +/** + * Creates bean of EntitlementsAPIConfig + */ +@Component +public class EntilementsAPIConfigBean extends AbstractFactoryBean { + + @Value("${AUTHORIZE_API}") + private String AUTHORIZE_API; + + @Value("${AUTHORIZE_API_KEY:}") + private String AUTHORIZE_API_KEY; + + /** + * Abstract method of AbstractBeanFactory. + * + * @return class type + */ + @Override + public Class getObjectType() { + return EntitlementsAPIConfig.class; + } + + /** + * Abstract method of AbstractBeanFactory type. + * + * @return EntitlementsAPIConfig + * @throws Exception + */ + @Override + protected EntitlementsAPIConfig createInstance() throws Exception { + return EntitlementsAPIConfig + .builder() + .rootUrl(AUTHORIZE_API) + .apiKey(AUTHORIZE_API_KEY) + .build(); + } +} diff --git a/src/main/java/org/opengroup/osdu/azure/entitlements/EntitlementsFactoryAzure.java b/src/main/java/org/opengroup/osdu/azure/entitlements/EntitlementsFactoryAzure.java new file mode 100644 index 00000000..f04e186d --- /dev/null +++ b/src/main/java/org/opengroup/osdu/azure/entitlements/EntitlementsFactoryAzure.java @@ -0,0 +1,58 @@ +package org.opengroup.osdu.azure.entitlements; + +import org.opengroup.osdu.core.common.entitlements.EntitlementsAPIConfig; +import org.opengroup.osdu.core.common.entitlements.EntitlementsService; +import org.opengroup.osdu.core.common.entitlements.IEntitlementsFactory; +import org.opengroup.osdu.core.common.entitlements.IEntitlementsService; +import org.opengroup.osdu.core.common.http.IHttpClient; +import org.opengroup.osdu.core.common.http.json.HttpResponseBodyMapper; +import org.opengroup.osdu.core.common.model.http.DpsHeaders; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Component; + +import java.util.Objects; + +/** + * Implements IEntitlementsFactory. + */ +@Component +@Primary +@ConditionalOnProperty(value = "entitlements.factory.azure.enabled", havingValue = "true", matchIfMissing = true) +public class EntitlementsFactoryAzure implements IEntitlementsFactory { + + private final EntitlementsAPIConfig config; + private final HttpResponseBodyMapper mapper; + private final IHttpClient client; + + /** + * Constructor Injection for above 3 fields. + * + * @param config EntitlementsAPIConfig + * @param mapper HttpResponseBodyMapper + * @param client IHttpClient + */ + @Autowired + public EntitlementsFactoryAzure(EntitlementsAPIConfig config, HttpResponseBodyMapper mapper, IHttpClient client) { + this.config = config; + this.mapper = mapper; + this.client = client; + } + + /** + * returns instance of EntitlementsService. + * + * @param headers DpsHeaders + * @return IEntitlementsService + */ + @Override + public IEntitlementsService create(DpsHeaders headers) { + Objects.requireNonNull(headers, "headers cannot be null"); + + return new EntitlementsService(this.config, + this.client, + headers, + this.mapper); + } +} diff --git a/src/main/java/org/opengroup/osdu/azure/httpconfig/HttpClientAzure.java b/src/main/java/org/opengroup/osdu/azure/httpconfig/HttpClientAzure.java new file mode 100644 index 00000000..182a191c --- /dev/null +++ b/src/main/java/org/opengroup/osdu/azure/httpconfig/HttpClientAzure.java @@ -0,0 +1,49 @@ +package org.opengroup.osdu.azure.httpconfig; + +import org.apache.http.HttpStatus; +import org.opengroup.osdu.core.common.http.FetchServiceHttpRequest; +import org.opengroup.osdu.core.common.http.HttpRequest; +import org.opengroup.osdu.core.common.http.IHttpClient; +import org.opengroup.osdu.core.common.http.HttpResponse; +import org.opengroup.osdu.core.common.http.UrlFetchServiceImpl; +import org.opengroup.osdu.core.common.model.http.AppException; +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Component; + +import java.net.URISyntaxException; + +/** + * Extends URlFetchService and implements IHttpClient to send requests. + */ +@Primary +@Component +public class HttpClientAzure extends UrlFetchServiceImpl implements IHttpClient { + + /** + * calls urlfetchservice's send request. + * + * @param httpRequest made by user class + * @return HttpResponse + */ + @Override + public HttpResponse send(HttpRequest httpRequest) { + org.opengroup.osdu.core.common.model.http.HttpResponse response = null; + try { + response = super.sendRequest(FetchServiceHttpRequest.builder() + .body(httpRequest.getBody()) + .httpMethod(httpRequest.getHttpMethod()) + .queryParams(httpRequest.getQueryParams()) + .url(httpRequest.getUrl()) + .headers(httpRequest.getHeaders()) + .build()); + } catch (URISyntaxException e) { + new AppException(HttpStatus.SC_BAD_REQUEST, e.getReason(), "URI Syntax is not correct"); + } + HttpResponse httpResponse = new HttpResponse(); + httpResponse.setBody(response.getBody()); + httpResponse.setResponseCode(response.getResponseCode()); + httpResponse.setContentType(response.getContentType()); + httpResponse.setRequest(httpRequest); + return httpResponse; + } +} diff --git a/src/main/java/org/opengroup/osdu/azure/httpconfig/HttpClientHandlerAzure.java b/src/main/java/org/opengroup/osdu/azure/httpconfig/HttpClientHandlerAzure.java new file mode 100644 index 00000000..665b6319 --- /dev/null +++ b/src/main/java/org/opengroup/osdu/azure/httpconfig/HttpClientHandlerAzure.java @@ -0,0 +1,45 @@ +package org.opengroup.osdu.azure.httpconfig; + +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.methods.HttpRequestBase; +import org.opengroup.osdu.azure.di.RetryAndTimeoutsConfiguration; +import org.opengroup.osdu.core.common.http.HttpClientHandler; +import org.opengroup.osdu.core.common.model.http.DpsHeaders; +import org.opengroup.osdu.core.common.model.http.HttpResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Component; + +/** + * Extends HttpClientHandler. + */ +@Primary +@Component +public class HttpClientHandlerAzure extends HttpClientHandler { + + @Autowired + private RetryAndTimeoutsConfiguration configuration; + + /** + * Constructor to set request and timeout configuration of HttpClientHandler. + */ + public HttpClientHandlerAzure() { + super.REQUEST_CONFIG = RequestConfig.custom() + .setConnectTimeout(configuration.getConnectTimeoutInMillis()) + .setConnectionRequestTimeout(configuration.getConnectTimeoutInMillis()) + .setSocketTimeout(configuration.getSocketTimeout()).build(); + + super.RETRY_COUNT = configuration.getRetryCountForServiceUnavailableStrategy(); + } + + /** + * same as the HttpClientHandler's send request. + * + * @param request HttpRequestBase + * @param requestHeaders DpsHeaders + * @return HttpResponse + */ + public HttpResponse sendRequest(HttpRequestBase request, DpsHeaders requestHeaders) { + return super.sendRequest(request, requestHeaders); + } +} -- GitLab From a08844fc6144495a922a2d27228cef14cf88fada Mon Sep 17 00:00:00 2001 From: t-muskans Date: Thu, 27 May 2021 17:51:58 +0530 Subject: [PATCH 2/6] resolved few comments --- .../di/RetryAndTimeoutsConfiguration.java | 22 ++++++++++--- .../EntilementsAPIConfigBean.java | 14 ++++++++ .../EntitlementsFactoryAzure.java | 16 ++++++++- .../azure/httpconfig/HttpClientAzure.java | 16 ++++++++- .../httpconfig/HttpClientHandlerAzure.java | 33 ++++++++++--------- 5 files changed, 79 insertions(+), 22 deletions(-) diff --git a/src/main/java/org/opengroup/osdu/azure/di/RetryAndTimeoutsConfiguration.java b/src/main/java/org/opengroup/osdu/azure/di/RetryAndTimeoutsConfiguration.java index accb9b5c..a9af886a 100644 --- a/src/main/java/org/opengroup/osdu/azure/di/RetryAndTimeoutsConfiguration.java +++ b/src/main/java/org/opengroup/osdu/azure/di/RetryAndTimeoutsConfiguration.java @@ -1,3 +1,17 @@ +// Copyright © Microsoft Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License + package org.opengroup.osdu.azure.di; import lombok.Data; @@ -8,11 +22,11 @@ import org.springframework.boot.context.properties.ConfigurationProperties; */ @Data -@ConfigurationProperties(prefix = "azure.retryAndTimeout") +@ConfigurationProperties(prefix = "azure.service.retry.config") public class RetryAndTimeoutsConfiguration { - private int retryCountForServiceUnavailableStrategy = 3; - private int connectTimeoutInMillis = 60000; - private int connectionRequestTimeout = 60000; + private int maxRetry = 3; + private int connectTimeout = 60000; + private int requestTimeout = 60000; private int socketTimeout = 60000; } diff --git a/src/main/java/org/opengroup/osdu/azure/entitlements/EntilementsAPIConfigBean.java b/src/main/java/org/opengroup/osdu/azure/entitlements/EntilementsAPIConfigBean.java index f8ee8b80..b7d4c30d 100644 --- a/src/main/java/org/opengroup/osdu/azure/entitlements/EntilementsAPIConfigBean.java +++ b/src/main/java/org/opengroup/osdu/azure/entitlements/EntilementsAPIConfigBean.java @@ -1,3 +1,17 @@ +// Copyright © Microsoft Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License + package org.opengroup.osdu.azure.entitlements; import org.opengroup.osdu.core.common.entitlements.EntitlementsAPIConfig; diff --git a/src/main/java/org/opengroup/osdu/azure/entitlements/EntitlementsFactoryAzure.java b/src/main/java/org/opengroup/osdu/azure/entitlements/EntitlementsFactoryAzure.java index f04e186d..684b7243 100644 --- a/src/main/java/org/opengroup/osdu/azure/entitlements/EntitlementsFactoryAzure.java +++ b/src/main/java/org/opengroup/osdu/azure/entitlements/EntitlementsFactoryAzure.java @@ -1,3 +1,17 @@ +// Copyright © Microsoft Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License + package org.opengroup.osdu.azure.entitlements; import org.opengroup.osdu.core.common.entitlements.EntitlementsAPIConfig; @@ -19,7 +33,7 @@ import java.util.Objects; */ @Component @Primary -@ConditionalOnProperty(value = "entitlements.factory.azure.enabled", havingValue = "true", matchIfMissing = true) +@ConditionalOnProperty(value = "azure.entitlements.factory.enabled", havingValue = "true", matchIfMissing = true) public class EntitlementsFactoryAzure implements IEntitlementsFactory { private final EntitlementsAPIConfig config; diff --git a/src/main/java/org/opengroup/osdu/azure/httpconfig/HttpClientAzure.java b/src/main/java/org/opengroup/osdu/azure/httpconfig/HttpClientAzure.java index 182a191c..7082be6d 100644 --- a/src/main/java/org/opengroup/osdu/azure/httpconfig/HttpClientAzure.java +++ b/src/main/java/org/opengroup/osdu/azure/httpconfig/HttpClientAzure.java @@ -1,3 +1,17 @@ +// Copyright © Microsoft Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License + package org.opengroup.osdu.azure.httpconfig; import org.apache.http.HttpStatus; @@ -37,7 +51,7 @@ public class HttpClientAzure extends UrlFetchServiceImpl implements IHttpClient .headers(httpRequest.getHeaders()) .build()); } catch (URISyntaxException e) { - new AppException(HttpStatus.SC_BAD_REQUEST, e.getReason(), "URI Syntax is not correct"); + throw new AppException(HttpStatus.SC_INTERNAL_SERVER_ERROR, e.getReason(), "URI Syntax is not correct",e); } HttpResponse httpResponse = new HttpResponse(); httpResponse.setBody(response.getBody()); diff --git a/src/main/java/org/opengroup/osdu/azure/httpconfig/HttpClientHandlerAzure.java b/src/main/java/org/opengroup/osdu/azure/httpconfig/HttpClientHandlerAzure.java index 665b6319..1088bbb2 100644 --- a/src/main/java/org/opengroup/osdu/azure/httpconfig/HttpClientHandlerAzure.java +++ b/src/main/java/org/opengroup/osdu/azure/httpconfig/HttpClientHandlerAzure.java @@ -1,11 +1,22 @@ +// Copyright © Microsoft Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License + package org.opengroup.osdu.azure.httpconfig; import org.apache.http.client.config.RequestConfig; -import org.apache.http.client.methods.HttpRequestBase; import org.opengroup.osdu.azure.di.RetryAndTimeoutsConfiguration; import org.opengroup.osdu.core.common.http.HttpClientHandler; -import org.opengroup.osdu.core.common.model.http.DpsHeaders; -import org.opengroup.osdu.core.common.model.http.HttpResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Component; @@ -25,21 +36,11 @@ public class HttpClientHandlerAzure extends HttpClientHandler { */ public HttpClientHandlerAzure() { super.REQUEST_CONFIG = RequestConfig.custom() - .setConnectTimeout(configuration.getConnectTimeoutInMillis()) - .setConnectionRequestTimeout(configuration.getConnectTimeoutInMillis()) + .setConnectTimeout(configuration.getConnectTimeout()) + .setConnectionRequestTimeout(configuration.getRequestTimeout()) .setSocketTimeout(configuration.getSocketTimeout()).build(); - super.RETRY_COUNT = configuration.getRetryCountForServiceUnavailableStrategy(); + super.RETRY_COUNT = configuration.getMaxRetry(); } - /** - * same as the HttpClientHandler's send request. - * - * @param request HttpRequestBase - * @param requestHeaders DpsHeaders - * @return HttpResponse - */ - public HttpResponse sendRequest(HttpRequestBase request, DpsHeaders requestHeaders) { - return super.sendRequest(request, requestHeaders); - } } -- GitLab From e13d9e6b0158b9c6aad4d30cfbcfc4986a5a9fad Mon Sep 17 00:00:00 2001 From: t-muskans Date: Thu, 3 Jun 2021 17:53:33 +0530 Subject: [PATCH 3/6] resolved comments --- ...TimeoutsConfiguration.java => HttpConfiguration.java} | 4 +++- .../azure/entitlements/EntilementsAPIConfigBean.java | 7 ++++--- .../osdu/azure/httpconfig/HttpClientHandlerAzure.java | 9 +++++---- 3 files changed, 12 insertions(+), 8 deletions(-) rename src/main/java/org/opengroup/osdu/azure/di/{RetryAndTimeoutsConfiguration.java => HttpConfiguration.java} (89%) diff --git a/src/main/java/org/opengroup/osdu/azure/di/RetryAndTimeoutsConfiguration.java b/src/main/java/org/opengroup/osdu/azure/di/HttpConfiguration.java similarity index 89% rename from src/main/java/org/opengroup/osdu/azure/di/RetryAndTimeoutsConfiguration.java rename to src/main/java/org/opengroup/osdu/azure/di/HttpConfiguration.java index a9af886a..3494876e 100644 --- a/src/main/java/org/opengroup/osdu/azure/di/RetryAndTimeoutsConfiguration.java +++ b/src/main/java/org/opengroup/osdu/azure/di/HttpConfiguration.java @@ -16,14 +16,16 @@ package org.opengroup.osdu.azure.di; import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; /** * Configuration bean for setting up retry and timeouts variables. */ @Data +@Component @ConfigurationProperties(prefix = "azure.service.retry.config") -public class RetryAndTimeoutsConfiguration { +public class HttpConfiguration { private int maxRetry = 3; private int connectTimeout = 60000; diff --git a/src/main/java/org/opengroup/osdu/azure/entitlements/EntilementsAPIConfigBean.java b/src/main/java/org/opengroup/osdu/azure/entitlements/EntilementsAPIConfigBean.java index b7d4c30d..ff0b5428 100644 --- a/src/main/java/org/opengroup/osdu/azure/entitlements/EntilementsAPIConfigBean.java +++ b/src/main/java/org/opengroup/osdu/azure/entitlements/EntilementsAPIConfigBean.java @@ -14,21 +14,22 @@ package org.opengroup.osdu.azure.entitlements; +import lombok.Data; import org.opengroup.osdu.core.common.entitlements.EntitlementsAPIConfig; -import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.config.AbstractFactoryBean; +import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; /** * Creates bean of EntitlementsAPIConfig */ +@Data @Component +@ConfigurationProperties public class EntilementsAPIConfigBean extends AbstractFactoryBean { - @Value("${AUTHORIZE_API}") private String AUTHORIZE_API; - @Value("${AUTHORIZE_API_KEY:}") private String AUTHORIZE_API_KEY; /** diff --git a/src/main/java/org/opengroup/osdu/azure/httpconfig/HttpClientHandlerAzure.java b/src/main/java/org/opengroup/osdu/azure/httpconfig/HttpClientHandlerAzure.java index 1088bbb2..e24d504c 100644 --- a/src/main/java/org/opengroup/osdu/azure/httpconfig/HttpClientHandlerAzure.java +++ b/src/main/java/org/opengroup/osdu/azure/httpconfig/HttpClientHandlerAzure.java @@ -15,7 +15,7 @@ package org.opengroup.osdu.azure.httpconfig; import org.apache.http.client.config.RequestConfig; -import org.opengroup.osdu.azure.di.RetryAndTimeoutsConfiguration; +import org.opengroup.osdu.azure.di.HttpConfiguration; import org.opengroup.osdu.core.common.http.HttpClientHandler; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Primary; @@ -28,13 +28,14 @@ import org.springframework.stereotype.Component; @Component public class HttpClientHandlerAzure extends HttpClientHandler { - @Autowired - private RetryAndTimeoutsConfiguration configuration; + private HttpConfiguration configuration; /** * Constructor to set request and timeout configuration of HttpClientHandler. */ - public HttpClientHandlerAzure() { + @Autowired + public HttpClientHandlerAzure(HttpConfiguration configuration) { + this.configuration = configuration; super.REQUEST_CONFIG = RequestConfig.custom() .setConnectTimeout(configuration.getConnectTimeout()) .setConnectionRequestTimeout(configuration.getRequestTimeout()) -- GitLab From d670e314e0f4aceb3f0615cc208f8ab1fad58b4d Mon Sep 17 00:00:00 2001 From: t-muskans Date: Mon, 7 Jun 2021 12:29:07 +0530 Subject: [PATCH 4/6] changed the version for load tests --- pom.xml | 2 +- .../osdu/azure/entitlements/EntilementsAPIConfigBean.java | 2 +- .../osdu/azure/httpconfig/HttpClientHandlerAzure.java | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 63716cb6..9ab257f2 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ org.opengroup.osdu core-lib-azure jar - 0.10.0-SNAPSHOT + 0.10.0-MS-SNAPSHOT core-lib-azure diff --git a/src/main/java/org/opengroup/osdu/azure/entitlements/EntilementsAPIConfigBean.java b/src/main/java/org/opengroup/osdu/azure/entitlements/EntilementsAPIConfigBean.java index ff0b5428..7df48210 100644 --- a/src/main/java/org/opengroup/osdu/azure/entitlements/EntilementsAPIConfigBean.java +++ b/src/main/java/org/opengroup/osdu/azure/entitlements/EntilementsAPIConfigBean.java @@ -21,7 +21,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; /** - * Creates bean of EntitlementsAPIConfig + * Creates bean of EntitlementsAPIConfig. */ @Data @Component diff --git a/src/main/java/org/opengroup/osdu/azure/httpconfig/HttpClientHandlerAzure.java b/src/main/java/org/opengroup/osdu/azure/httpconfig/HttpClientHandlerAzure.java index e24d504c..6a7b6dc2 100644 --- a/src/main/java/org/opengroup/osdu/azure/httpconfig/HttpClientHandlerAzure.java +++ b/src/main/java/org/opengroup/osdu/azure/httpconfig/HttpClientHandlerAzure.java @@ -31,7 +31,9 @@ public class HttpClientHandlerAzure extends HttpClientHandler { private HttpConfiguration configuration; /** - * Constructor to set request and timeout configuration of HttpClientHandler. + * Constuctor injection for HttpConfiguration. + * + * @param configuration of type HttpConfiguration */ @Autowired public HttpClientHandlerAzure(HttpConfiguration configuration) { -- GitLab From 409c850d2709a4a4cb0ccdc82e2d0a512c778c8d Mon Sep 17 00:00:00 2001 From: t-muskans Date: Mon, 7 Jun 2021 20:26:27 +0530 Subject: [PATCH 5/6] resolved checkstyle issues --- ...on.java => RetryAndTimeoutConfiguration.java} | 2 +- .../entitlements/EntilementsAPIConfigBean.java | 8 ++++---- .../entitlements/EntitlementsFactoryAzure.java | 16 ++++++++-------- .../osdu/azure/httpconfig/HttpClientAzure.java | 4 ++-- .../azure/httpconfig/HttpClientHandlerAzure.java | 12 ++++++------ 5 files changed, 21 insertions(+), 21 deletions(-) rename src/main/java/org/opengroup/osdu/azure/di/{HttpConfiguration.java => RetryAndTimeoutConfiguration.java} (93%) diff --git a/src/main/java/org/opengroup/osdu/azure/di/HttpConfiguration.java b/src/main/java/org/opengroup/osdu/azure/di/RetryAndTimeoutConfiguration.java similarity index 93% rename from src/main/java/org/opengroup/osdu/azure/di/HttpConfiguration.java rename to src/main/java/org/opengroup/osdu/azure/di/RetryAndTimeoutConfiguration.java index 3494876e..c519c660 100644 --- a/src/main/java/org/opengroup/osdu/azure/di/HttpConfiguration.java +++ b/src/main/java/org/opengroup/osdu/azure/di/RetryAndTimeoutConfiguration.java @@ -25,7 +25,7 @@ import org.springframework.stereotype.Component; @Data @Component @ConfigurationProperties(prefix = "azure.service.retry.config") -public class HttpConfiguration { +public class RetryAndTimeoutConfiguration { private int maxRetry = 3; private int connectTimeout = 60000; diff --git a/src/main/java/org/opengroup/osdu/azure/entitlements/EntilementsAPIConfigBean.java b/src/main/java/org/opengroup/osdu/azure/entitlements/EntilementsAPIConfigBean.java index 7df48210..cd139977 100644 --- a/src/main/java/org/opengroup/osdu/azure/entitlements/EntilementsAPIConfigBean.java +++ b/src/main/java/org/opengroup/osdu/azure/entitlements/EntilementsAPIConfigBean.java @@ -28,9 +28,9 @@ import org.springframework.stereotype.Component; @ConfigurationProperties public class EntilementsAPIConfigBean extends AbstractFactoryBean { - private String AUTHORIZE_API; + private String authorizeAPI; - private String AUTHORIZE_API_KEY; + private String authorizeAPIKey; /** * Abstract method of AbstractBeanFactory. @@ -52,8 +52,8 @@ public class EntilementsAPIConfigBean extends AbstractFactoryBean Date: Thu, 10 Jun 2021 09:11:10 +0530 Subject: [PATCH 6/6] reverted back version and updated Readme --- README.md | 8 ++++++++ pom.xml | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 68cd076c..cd753fb1 100644 --- a/README.md +++ b/README.md @@ -87,3 +87,11 @@ Enabled transaction logger and slf4jlogger | --- | --- | --- | | `azure.blobStore.required` | `true` | - | | `azure.storage.account-name` | ex `testStorage` | storage account name | + +# Default retry and timeout values for service-to-service communication +| name | default value | +| --- | --- | +| `maxRetry` | `3` | +| `connectTimeout` | `60000` | +| `requestTimeout` | `60000` | +| `socketTimeout` | `60000` | diff --git a/pom.xml b/pom.xml index 9ab257f2..63716cb6 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ org.opengroup.osdu core-lib-azure jar - 0.10.0-MS-SNAPSHOT + 0.10.0-SNAPSHOT core-lib-azure -- GitLab