Commit a08844fc authored by Muskan Srivastava's avatar Muskan Srivastava
Browse files

resolved few comments

parent c3ca0e25
Pipeline #43017 failed with stage
in 40 seconds
// 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;
}
// 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;
......
// 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;
......
// 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());
......
// 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);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment