Skip to content
Snippets Groups Projects
Commit 066b0f49 authored by Dmitrii Novikov (EPAM)'s avatar Dmitrii Novikov (EPAM) Committed by Rostislav Dublin (EPAM)
Browse files

Added new version info endpoint (GONRG-2681)

parent 6ef4a43a
No related branches found
No related tags found
1 merge request!169Added new version info endpoint (GONRG-2681)
Showing
with 484 additions and 49 deletions
......@@ -242,9 +242,9 @@ The following software have components provided under the terms of this license:
- Google APIs Client Library for Java (from https://repo1.maven.org/maven2/com/google/api-client/google-api-client)
- Google App Engine extensions to the Google HTTP Client Library for Java. (from https://repo1.maven.org/maven2/com/google/http-client/google-http-client-appengine)
- Google App Engine extensions to the Google HTTP Client Library for Java. (from https://repo1.maven.org/maven2/com/google/http-client/google-http-client-appengine)
- Google Cloud Core (from https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-clients/google-cloud-core)
- Google Cloud Core HTTP (from https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-clients/google-cloud-core-http)
- Google Cloud Core HTTP (from https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-clients/google-cloud-core-http)
- Google Cloud Core (from https://github.com/googleapis/java-core)
- Google Cloud Core HTTP (from https://github.com/googleapis/java-core)
- Google Cloud Core HTTP (from https://github.com/googleapis/java-core)
- Google Cloud Core gRPC (from https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-clients/google-cloud-core-grpc)
- Google Cloud Core gRPC (from https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-clients/google-cloud-core-grpc)
- Google Cloud Datastore (from https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-clients/google-cloud-datastore)
......@@ -260,8 +260,8 @@ The following software have components provided under the terms of this license:
- Google HTTP Client Library for Java (from https://repo1.maven.org/maven2/com/google/http-client/google-http-client)
- Google OAuth Client Library for Java (from https://repo1.maven.org/maven2/com/google/oauth-client/google-oauth-client)
- Google OAuth Client Library for Java (from https://repo1.maven.org/maven2/com/google/oauth-client/google-oauth-client)
- Gson (from http://code.google.com/p/google-gson/)
- Gson (from http://code.google.com/p/google-gson/)
- Gson (from https://repo1.maven.org/maven2/com/google/code/gson/gson)
- Gson (from https://repo1.maven.org/maven2/com/google/code/gson/gson)
- Guava InternalFutureFailureAccess and InternalFutures (from https://repo1.maven.org/maven2/com/google/guava/failureaccess)
- Guava: Google Core Libraries for Java (from https://repo1.maven.org/maven2/com/google/guava/guava)
- Guava: Google Core Libraries for Java (from https://repo1.maven.org/maven2/com/google/guava/guava)
......@@ -304,7 +304,7 @@ The following software have components provided under the terms of this license:
- Jackson-annotations (from http://github.com/FasterXML/jackson)
- Jackson-annotations (from http://github.com/FasterXML/jackson)
- Jackson-core (from http://wiki.fasterxml.com/JacksonHome)
- Jackson-dataformat-XML (from http://wiki.fasterxml.com/JacksonExtensionXmlDataBinding)
- Jackson-dataformat-XML (from https://github.com/FasterXML/jackson-dataformat-xml)
- Jackson-dataformat-YAML (from https://github.com/FasterXML/jackson-dataformats-text)
- Jackson-dataformat-YAML (from https://github.com/FasterXML/jackson-dataformats-text)
- Jackson-datatype-Joda (from http://wiki.fasterxml.com/JacksonModuleJoda)
......@@ -433,8 +433,6 @@ The following software have components provided under the terms of this license:
- OAuth2 for Spring Security (from https://repo1.maven.org/maven2/org/springframework/security/oauth/spring-security-oauth2)
- OAuth2 for Spring Security (from https://repo1.maven.org/maven2/org/springframework/security/oauth/spring-security-oauth2)
- Objenesis (from http://objenesis.org)
- OkHttp (from https://repo1.maven.org/maven2/com/squareup/okhttp3/okhttp)
- OkHttp (from https://repo1.maven.org/maven2/com/squareup/okhttp3/okhttp)
- Okio (from https://github.com/square/okio/)
- Okio (from https://github.com/square/okio/)
- OpenCensus (from https://github.com/census-instrumentation/opencensus-java)
......@@ -456,30 +454,28 @@ The following software have components provided under the terms of this license:
- Protocol Buffer extensions to the Google HTTP Client Library for Java. (from https://repo1.maven.org/maven2/com/google/http-client/google-http-client-protobuf)
- Proton-J (from https://repo1.maven.org/maven2/org/apache/qpid/proton-j)
- QpidJMS Client (from )
- RabbitMQ Java Client (from http://www.rabbitmq.com)
- RabbitMQ Java Client (from https://www.rabbitmq.com)
- Reactor Netty with all modules (from https://github.com/reactor/reactor-netty)
- Retrofit (from https://github.com/square/retrofit)
- Servlet Specification 2.5 API (from http://jetty.mortbay.org)
- SnakeYAML (from http://www.snakeyaml.org)
- Spatial4J (from http://www.locationtech.org/projects/locationtech.spatial4j)
- Spring AMQP Core (from http://www.springsource.org/spring-amqp)
- Spring AMQP Core (from https://github.com/spring-projects/spring-amqp)
- Spring AOP (from https://github.com/spring-projects/spring-framework)
- Spring Beans (from https://github.com/spring-projects/spring-framework)
- Spring Boot (from http://projects.spring.io/spring-boot/)
- Spring Boot AMQP Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-amqp)
- Spring Boot Actuator (from http://projects.spring.io/spring-boot/)
- Spring Boot Actuator AutoConfigure (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-actuator-autoconfigure)
- Spring Boot Actuator Starter (from http://projects.spring.io/spring-boot/)
- Spring Boot AutoConfigure (from http://projects.spring.io/spring-boot/)
- Spring Boot Configuration Processor (from http://projects.spring.io/spring-boot/)
- Spring Boot Data MongoDB Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-data-mongodb)
- Spring Boot Dependencies (from https://projects.spring.io/spring-boot/#)
- Spring Boot Logging Starter (from http://projects.spring.io/spring-boot/)
- Spring Boot Reactor Netty Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-reactor-netty)
- Spring Boot Security Starter (from http://projects.spring.io/spring-boot/)
- Spring Boot Starter (from http://projects.spring.io/spring-boot/)
- Spring Boot Test (from http://projects.spring.io/spring-boot/)
- Spring Boot Test Auto-Configure (from http://projects.spring.io/spring-boot/)
- Spring Boot Test Starter (from http://projects.spring.io/spring-boot/)
- Spring Boot Validation Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-validation)
- Spring Boot WebFlux Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-webflux)
- Spring Commons Logging Bridge (from https://github.com/spring-projects/spring-framework)
......@@ -493,7 +489,7 @@ The following software have components provided under the terms of this license:
- Spring Messaging (from https://github.com/spring-projects/spring-framework)
- Spring Plugin - Metadata Extension (from https://repo1.maven.org/maven2/org/springframework/plugin/spring-plugin-metadata)
- Spring Plugin Core (from https://repo1.maven.org/maven2/org/springframework/plugin/spring-plugin-core)
- Spring RabbitMQ Support (from http://www.springsource.org/spring-amqp)
- Spring RabbitMQ Support (from https://github.com/spring-projects/spring-amqp)
- Spring Retry (from http://www.springsource.org)
- Spring Security JWT Library (from http://github.com/spring-projects/spring-security-oauth)
- Spring Security JWT Library (from http://github.com/spring-projects/spring-security-oauth)
......@@ -593,6 +589,8 @@ The following software have components provided under the terms of this license:
- mockito-core (from https://github.com/mockito/mockito)
- nio-multipart-parser (from )
- nio-stream-storage (from https://github.com/synchronoss/nio-stream-storage)
- okhttp (from https://square.github.io/okhttp/)
- okhttp (from https://square.github.io/okhttp/)
- okhttp-urlconnection (from https://github.com/square/okhttp)
- okhttp-urlconnection (from https://github.com/square/okhttp)
- org.conscrypt:conscrypt-openjdk-uber (from https://conscrypt.org/)
......@@ -618,21 +616,23 @@ The following software have components provided under the terms of this license:
- rxjava (from https://github.com/ReactiveX/RxJava)
- server (from https://github.com/elastic/elasticsearch)
- server (from https://github.com/elastic/elasticsearch)
- spring-boot-dependencies (from https://spring.io/projects/spring-boot)
- spring-boot-starter-amqp (from https://spring.io/projects/spring-boot)
- spring-boot-starter-jersey (from https://spring.io/projects/spring-boot)
- spring-boot-starter-json (from https://spring.io/projects/spring-boot)
- spring-boot-starter-log4j2 (from https://spring.io/projects/spring-boot)
- spring-boot-starter-security (from https://spring.io/projects/spring-boot)
- spring-boot-starter-test (from https://spring.io/projects/spring-boot)
- spring-boot-starter-tomcat (from https://spring.io/projects/spring-boot)
- spring-boot-starter-web (from https://spring.io/projects/spring-boot)
- spring-security-config (from http://spring.io/spring-security)
- spring-security-core (from http://spring.io/spring-security)
- spring-security-config (from https://spring.io/projects/spring-security)
- spring-security-core (from https://spring.io/projects/spring-security)
- spring-security-oauth2-client (from http://spring.io/spring-security)
- spring-security-oauth2-core (from http://spring.io/spring-security)
- spring-security-oauth2-jose (from http://spring.io/spring-security)
- spring-security-oauth2-jose (from http://spring.io/spring-security)
- spring-security-oauth2-resource-server (from http://spring.io/spring-security)
- spring-security-test (from http://spring.io/spring-security)
- spring-security-web (from http://spring.io/spring-security)
- spring-security-test (from https://spring.io/projects/spring-security)
- spring-security-web (from https://spring.io/projects/spring-security)
- springfox-core (from https://github.com/springfox/springfox)
- springfox-schema (from https://github.com/springfox/springfox)
- springfox-spi (from https://github.com/springfox/springfox)
......@@ -655,12 +655,12 @@ BSD-2-Clause
========================================================================
The following software have components provided under the terms of this license:
- API Common (from https://github.com/googleapis)
- API Common (from https://github.com/googleapis/api-common-java)
- Apache Commons CLI (from http://commons.apache.org/proper/commons-cli/)
- GAX (Google Api eXtensions) (from https://github.com/googleapis)
- GAX (Google Api eXtensions) (from https://github.com/googleapis)
- GAX (Google Api eXtensions) (from https://github.com/googleapis)
- GAX (Google Api eXtensions) (from https://github.com/googleapis)
- GAX (Google Api eXtensions) for Java (from https://github.com/googleapis/gax-java)
- GAX (Google Api eXtensions) for Java (from https://github.com/googleapis/gax-java)
- GAX (Google Api eXtensions) for Java (from https://github.com/googleapis/gax-java)
- GAX (Google Api eXtensions) for Java (from https://github.com/googleapis/gax-java)
- Lucene Common Analyzers (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-analyzers-common)
......@@ -680,8 +680,8 @@ BSD-3-Clause
========================================================================
The following software have components provided under the terms of this license:
- API Common (from https://github.com/googleapis)
- API Common (from https://github.com/googleapis)
- API Common (from https://github.com/googleapis/api-common-java)
- API Common (from https://github.com/googleapis/api-common-java)
- ASM Analysis (from )
- ASM Commons (from https://repo1.maven.org/maven2/org/ow2/asm/asm-commons)
- ASM Core (from https://repo1.maven.org/maven2/org/ow2/asm/asm)
......@@ -691,8 +691,8 @@ The following software have components provided under the terms of this license:
- Apache Commons Codec (from https://commons.apache.org/proper/commons-codec/)
- GAX (Google Api eXtensions) (from https://github.com/googleapis)
- GAX (Google Api eXtensions) (from https://github.com/googleapis)
- GAX (Google Api eXtensions) (from https://github.com/googleapis)
- GAX (Google Api eXtensions) (from https://github.com/googleapis)
- GAX (Google Api eXtensions) for Java (from https://github.com/googleapis/gax-java)
- GAX (Google Api eXtensions) for Java (from https://github.com/googleapis/gax-java)
- GAX (Google Api eXtensions) for Java (from https://github.com/googleapis/gax-java)
- GAX (Google Api eXtensions) for Java (from https://github.com/googleapis/gax-java)
- Google APIs Client Library for Java (from https://repo1.maven.org/maven2/com/google/api-client/google-api-client)
......@@ -865,7 +865,7 @@ The following software have components provided under the terms of this license:
- JavaBeans Activation Framework (from )
- Mojo's Maven plugin for Cobertura (from http://mojo.codehaus.org/cobertura-maven-plugin/)
- OSGi resource locator (from )
- RabbitMQ Java Client (from http://www.rabbitmq.com)
- RabbitMQ Java Client (from https://www.rabbitmq.com)
- Run Level Service (from https://repo1.maven.org/maven2/org/glassfish/hk2/hk2-runlevel)
- ServiceLocator Default Implementation (from https://repo1.maven.org/maven2/org/glassfish/hk2/hk2-locator)
- aopalliance-repackaged (from https://repo1.maven.org/maven2/org/glassfish/hk2/external/aopalliance-repackaged)
......@@ -905,7 +905,7 @@ The following software have components provided under the terms of this license:
- Java Servlet API (from http://servlet-spec.java.net)
- JavaBeans Activation Framework (from )
- OSGi resource locator (from )
- RabbitMQ Java Client (from http://www.rabbitmq.com)
- RabbitMQ Java Client (from https://www.rabbitmq.com)
- ServiceLocator Default Implementation (from https://repo1.maven.org/maven2/org/glassfish/hk2/hk2-locator)
- aopalliance-repackaged (from https://repo1.maven.org/maven2/org/glassfish/hk2/external/aopalliance-repackaged)
- javax.annotation-api (from http://jcp.org/en/jsr/detail?id=250)
......@@ -992,7 +992,7 @@ The following software have components provided under the terms of this license:
- Apache Log4j API (from https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-api)
- Apache Log4j Core (from https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-core)
- RabbitMQ Java Client (from http://www.rabbitmq.com)
- RabbitMQ Java Client (from https://www.rabbitmq.com)
========================================================================
MIT
......@@ -1057,7 +1057,7 @@ The following software have components provided under the terms of this license:
- msal4j (from https://github.com/AzureAD/microsoft-authentication-library-for-java)
- msal4j-persistence-extension (from https://github.com/AzureAD/microsoft-authentication-extensions-for-java)
- server (from https://github.com/elastic/elasticsearch)
- spring-security-core (from http://spring.io/spring-security)
- spring-security-core (from https://spring.io/projects/spring-security)
========================================================================
MPL-1.1
......@@ -1067,7 +1067,7 @@ The following software have components provided under the terms of this license:
- Cobertura (from http://cobertura.sourceforge.net)
- Javassist (from http://www.javassist.org/)
- Javassist (from http://www.javassist.org/)
- RabbitMQ Java Client (from http://www.rabbitmq.com)
- RabbitMQ Java Client (from https://www.rabbitmq.com)
========================================================================
MPL-2.0
......@@ -1076,8 +1076,8 @@ The following software have components provided under the terms of this license:
- Javassist (from http://www.javassist.org/)
- Javassist (from http://www.javassist.org/)
- OkHttp (from https://repo1.maven.org/maven2/com/squareup/okhttp3/okhttp)
- RabbitMQ Java Client (from http://www.rabbitmq.com)
- RabbitMQ Java Client (from https://www.rabbitmq.com)
- okhttp (from https://square.github.io/okhttp/)
========================================================================
MS-RL
......@@ -1185,7 +1185,7 @@ The following software have components provided under the terms of this license:
- Microsoft Azure SDK for SQL API of Azure Cosmos DB Service (from https://github.com/Azure/azure-sdk-for-java)
- Microsoft Azure client library for Blob Storage (from https://github.com/Azure/azure-sdk-for-java)
- Project Lombok (from http://projectlombok.org)
- RabbitMQ Java Client (from http://www.rabbitmq.com)
- RabbitMQ Java Client (from https://www.rabbitmq.com)
- Spring Security JWT Library (from http://github.com/spring-projects/spring-security-oauth)
- Spring Security JWT Library (from http://github.com/spring-projects/spring-security-oauth)
- Spring Web (from https://github.com/spring-projects/spring-framework)
......
......@@ -9,6 +9,4 @@ running the `os-indexer` Azure implementation
## GCP Implementation
All documentation for the GCP implementation of `os-indexer` lives [here](./provider/indexer-gcp/README.md)
All documentation for the GCP implementation of `os-indexer` lives [here](./provider/indexer-gcp/README.md)
\ No newline at end of file
......@@ -6,6 +6,7 @@
- [Reindex <a name="reindex"></a>](#reindex)
- [Schema Service adoption <a name="schema-service-adoption"></a>](#schema-service-adoption)
- [R3 Schema Support <a name="r3-schema-support"></a>](#r3-schema-support)
- [Version info endpoint](#version-info-endpoint)
##Introduction <a name="introduction"></a>
......@@ -185,3 +186,38 @@ data-partition-id: opendes
```
[Back to table of contents](#TOC)
## Version info endpoint
For deployment available public `/info` endpoint, which provides build and git related information.
#### Example response:
```json
{
"groupId": "org.opengroup.osdu",
"artifactId": "storage-gcp",
"version": "0.10.0-SNAPSHOT",
"buildTime": "2021-07-09T14:29:51.584Z",
"branch": "feature/GONRG-2681_Build_info",
"commitId": "7777",
"commitMessage": "Added copyright to version info properties file",
"connectedOuterServices": [
{
"name": "elasticSearch",
"version":"..."
},
{
"name": "postgresSql",
"version":"..."
},
{
"name": "redis",
"version":"..."
}
]
}
```
This endpoint takes information from files, generated by `spring-boot-maven-plugin`,
`git-commit-id-plugin` plugins. Need to specify paths for generated files to matching
properties:
- `version.info.buildPropertiesPath`
- `version.info.gitPropertiesPath`
[Back to table of contents](#TOC)
\ No newline at end of file
......@@ -16,7 +16,7 @@
<properties>
<commons-beanutils.version>1.9.4</commons-beanutils.version>
<osdu.oscorecommon.version>0.10.0</osdu.oscorecommon.version>
<os-core-common.version>0.11.0-SNAPSHOT</os-core-common.version>
</properties>
<dependencies>
......@@ -34,7 +34,7 @@
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-core-common</artifactId>
<version>${osdu.oscorecommon.version}</version>
<version>${os-core-common.version}</version>
</dependency>
<!-- spring boot dependencies -->
......
/*
* Copyright 2021 Google LLC
* Copyright 2021 EPAM Systems, Inc
*
* 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
*
* https://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.indexer.api;
import java.io.IOException;
import org.opengroup.osdu.core.common.info.VersionInfoBuilder;
import org.opengroup.osdu.core.common.model.info.VersionInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping
public class InfoApi {
@Autowired
private VersionInfoBuilder versionInfoBuilder;
@GetMapping(value = "/info", produces = MediaType.APPLICATION_JSON_VALUE)
public VersionInfo info() throws IOException {
return versionInfoBuilder.buildVersionInfo();
}
}
\ No newline at end of file
......@@ -14,11 +14,15 @@
package org.opengroup.osdu.indexer.service;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.apache.http.HttpStatus;
import org.opengroup.osdu.core.common.model.search.ClusterSettings;
import org.opengroup.osdu.core.common.model.tenant.TenantInfo;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.opengroup.osdu.core.common.multitenancy.ITenantInfoService;
import org.opengroup.osdu.core.common.provider.interfaces.IElasticRepository;
import org.opengroup.osdu.core.common.provider.interfaces.IElasticCredentialsCache;
import org.opengroup.osdu.core.common.model.indexer.IElasticSettingService;
......@@ -31,7 +35,8 @@ public class ElasticSettingServiceImpl implements IElasticSettingService {
@Inject
private TenantInfo tenantInfo;
@Inject
private javax.inject.Provider<ITenantInfoService> tenantInfoServiceProvider;
@Inject
private IElasticRepository elasticRepository;
@Inject
......@@ -43,18 +48,33 @@ public class ElasticSettingServiceImpl implements IElasticSettingService {
@Override
public ClusterSettings getElasticClusterInformation() {
return getClusterSettingsByTenantInfo(tenantInfo);
}
@Override
public Map<String, ClusterSettings> getAllClustersSettings() {
List<TenantInfo> tenantInfos = tenantInfoServiceProvider.get().getAllTenantInfos();
return tenantInfos.stream()
.collect(Collectors.toMap(TenantInfo::getDataPartitionId,
this::getClusterSettingsByTenantInfo));
}
private ClusterSettings getClusterSettingsByTenantInfo(TenantInfo tenantInfo) {
String cacheKey = String.format("%s-%s", configurationProperties.getGaeService(),
tenantInfo.getName());
String cacheKey = String.format("%s-%s", configurationProperties.getGaeService(), tenantInfo.getName());
ClusterSettings clusterInfo = (ClusterSettings) this.elasticCredentialCache.get(cacheKey);
if (clusterInfo != null) {
return clusterInfo;
}
log.warning(String.format("elastic-credential cache missed for tenant: %s", tenantInfo.getName()));
log.warning(String.format("elastic-credential cache missed for tenant: %s",
tenantInfo.getName()));
clusterInfo = this.elasticRepository.getElasticClusterSettings(tenantInfo);
if (clusterInfo == null) {
throw new AppException(HttpStatus.SC_NOT_FOUND, "Tenant not found", "No information about the given tenant was found");
throw new AppException(HttpStatus.SC_NOT_FOUND, "Tenant not found",
"No information about the given tenant was found");
}
this.elasticCredentialCache.put(cacheKey, clusterInfo);
......
/*
* Copyright 2021 Google LLC
* Copyright 2021 EPAM Systems, Inc
*
* 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
*
* https://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.indexer.util;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.opengroup.osdu.core.common.cache.RedisCache;
import org.opengroup.osdu.core.common.info.ConnectedOuterServicesBuilder;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.opengroup.osdu.core.common.model.indexer.IElasticSettingService;
import org.opengroup.osdu.core.common.model.info.ConnectedOuterService;
import org.opengroup.osdu.core.common.model.search.ClusterSettings;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.stereotype.Component;
import org.springframework.web.context.annotation.RequestScope;
@Component
@ConditionalOnMissingBean(type = "ConnectedOuterServicesBuilder")
@Slf4j
@RequestScope
public class CloudConnectedOuterServicesBuilder implements ConnectedOuterServicesBuilder {
private static final String NAME_PREFIX = "ElasticSearch-";
private static final String REDIS_PREFIX = "Redis-";
private static final String NOT_AVAILABLE = "N/A";
private final List<RedisCache> redisCaches;
private final ElasticClientHandler elasticClient;
private final IElasticSettingService elasticSettingService;
public CloudConnectedOuterServicesBuilder(
List<RedisCache> redisCaches,
ElasticClientHandler elasticClient,
IElasticSettingService elasticSettingService) {
this.redisCaches = redisCaches;
this.elasticClient = elasticClient;
this.elasticSettingService = elasticSettingService;
}
@Override
public List<ConnectedOuterService> buildConnectedOuterServices() {
return Stream.concat(redisCaches.stream().map(this::fetchRedisInfo),
fetchElasticInfos().stream())
.collect(Collectors.toList());
}
private ConnectedOuterService fetchRedisInfo(RedisCache cache) {
String redisVersion = StringUtils.substringBetween(cache.info(), ":", "\r");
return ConnectedOuterService.builder()
.name(REDIS_PREFIX + StringUtils.substringAfterLast(cache.getClass().getName(), "."))
.version(redisVersion)
.build();
}
private List<ConnectedOuterService> fetchElasticInfos() {
try {
return elasticSettingService.getAllClustersSettings()
.entrySet().stream()
.map(entry -> fetchElasticInfo(entry.getKey(), entry.getValue()))
.collect(Collectors.toList());
} catch (AppException e) {
log.error("Can't fetch cluster settings", e.getOriginalException());
return Collections.singletonList(ConnectedOuterService.builder()
.name(NAME_PREFIX + NOT_AVAILABLE)
.version(NOT_AVAILABLE)
.build());
}
}
private ConnectedOuterService fetchElasticInfo(String partitionId, ClusterSettings settings) {
try (RestHighLevelClient client = elasticClient.createRestClient(settings)) {
return ConnectedOuterService.builder()
.name(NAME_PREFIX + partitionId)
.version(client.info(RequestOptions.DEFAULT).getVersion().getNumber())
.build();
} catch (AppException e) {
log.error("Can't create elastic client", e.getOriginalException());
return ConnectedOuterService.builder()
.name(NAME_PREFIX + partitionId)
.version(NOT_AVAILABLE)
.build();
} catch (IOException e) {
log.error("Can't fetch elastic info.", e);
return ConnectedOuterService.builder()
.name(NAME_PREFIX + partitionId)
.version(NOT_AVAILABLE)
.build();
}
}
}
\ No newline at end of file
......@@ -19,7 +19,7 @@
<java.version>1.8</java.version>
<springfox-version>2.7.0</springfox-version>
<spring-cloud.version>Greenwich.SR2</spring-cloud.version>
<os-core-common.version>0.10.0</os-core-common.version>
<os-core-common.version>0.11.0-SNAPSHOT</os-core-common.version>
<snakeyaml.version>1.26</snakeyaml.version>
<hibernate-validator.version>6.1.5.Final</hibernate-validator.version>
<jackson.version>2.11.4</jackson.version>
......@@ -174,5 +174,45 @@
</profile>
</profiles>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>build-info</id>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>4.0.5</version>
<executions>
<execution>
<goals>
<goal>revision</goal>
</goals>
</execution>
</executions>
<configuration>
<verbose>true</verbose>
<dateFormat>yyyy-MM-dd'T'HH:mm:ssZ</dateFormat>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<generateGitPropertiesFilename>
${project.build.outputDirectory}/git.properties
</generateGitPropertiesFilename>
</configuration>
</plugin>
</plugins>
</build>
</project>
package org.opengroup.osdu.indexer.aws.di;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.core.common.model.tenant.TenantInfo;
import org.opengroup.osdu.core.common.multitenancy.ITenantInfoService;
import org.opengroup.osdu.core.common.provider.interfaces.ITenantFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.context.annotation.RequestScope;
@RequestScope
@Component
public class TenantInfoService implements ITenantInfoService {
@Inject
private ITenantFactory tenantFactory;
@Inject
private DpsHeaders headers;
@Override
public TenantInfo getTenantInfo() {
return tenantFactory.getTenantInfo(headers.getPartitionId());
}
@Override
public List<TenantInfo> getAllTenantInfos() {
return new ArrayList<>(tenantFactory.listTenantInfo());
}
}
\ No newline at end of file
......@@ -184,6 +184,12 @@
<groupId>org.opengroup.osdu</groupId>
<artifactId>core-lib-azure</artifactId>
<version>${osdu.corelibazure.version}</version>
<exclusions>
<exclusion>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-core-common</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
......
......@@ -14,6 +14,8 @@
package org.opengroup.osdu.indexer.azure.di;
import java.util.ArrayList;
import java.util.List;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.core.common.model.tenant.TenantInfo;
import org.opengroup.osdu.core.common.multitenancy.ITenantInfoService;
......@@ -36,4 +38,9 @@ public class TenantInfoService implements ITenantInfoService {
public TenantInfo getTenantInfo() {
return tenantFactory.getTenantInfo(headers.getPartitionId());
}
@Override
public List<TenantInfo> getAllTenantInfos() {
return new ArrayList<>(tenantFactory.listTenantInfo());
}
}
......@@ -44,6 +44,7 @@ public class AADSecurityConfig extends WebSecurityConfigurerAdapter {
"/swagger-resources/**",
"/configuration/security",
"/swagger",
"/info",
"/swagger-ui.html",
"/webjars/**").permitAll()
.anyRequest().authenticated()
......
package org.opengroup.osdu.indexer.di;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.core.common.model.tenant.TenantInfo;
import org.opengroup.osdu.core.common.multitenancy.ITenantInfoService;
import org.opengroup.osdu.core.common.provider.interfaces.ITenantFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.context.annotation.RequestScope;
@RequestScope
@Component
public class TenantInfoService implements ITenantInfoService {
@Inject
private ITenantFactory tenantFactory;
@Inject
private DpsHeaders headers;
@Override
public TenantInfo getTenantInfo() {
return tenantFactory.getTenantInfo(headers.getPartitionId());
}
@Override
public List<TenantInfo> getAllTenantInfos() {
return new ArrayList<>(tenantFactory.listTenantInfo());
}
}
\ No newline at end of file
/*
* Copyright 2021 Google LLC
* Copyright 2021 EPAM Systems, Inc
*
* 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
*
* https://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.indexer.persistence;
import com.google.api.gax.retrying.RetrySettings;
import com.google.cloud.TransportOptions;
import com.google.cloud.datastore.Datastore;
import com.google.cloud.datastore.DatastoreOptions;
import com.google.cloud.http.HttpTransportOptions;
import java.util.HashMap;
import java.util.Map;
import javax.inject.Inject;
import org.opengroup.osdu.core.common.model.tenant.TenantInfo;
import org.opengroup.osdu.core.gcp.multitenancy.credentials.DatastoreCredential;
import org.opengroup.osdu.indexer.cache.DatastoreCredentialCache;
import org.springframework.stereotype.Component;
import org.threeten.bp.Duration;
@Component("indexerDatastoreFactory")
public class DatastoreFactory {
@Inject
private DatastoreCredentialCache cache;
private static Map<String, Datastore> datastoreClients = new HashMap<>();
private static final RetrySettings RETRY_SETTINGS = RetrySettings.newBuilder()
.setMaxAttempts(6)
.setInitialRetryDelay(Duration.ofSeconds(10))
.setMaxRetryDelay(Duration.ofSeconds(32))
.setRetryDelayMultiplier(2.0)
.setTotalTimeout(Duration.ofSeconds(50))
.setInitialRpcTimeout(Duration.ofSeconds(50))
.setRpcTimeoutMultiplier(1.0)
.setMaxRpcTimeout(Duration.ofSeconds(50))
.build();
private static final TransportOptions TRANSPORT_OPTIONS = HttpTransportOptions.newBuilder()
.setReadTimeout(30000)
.build();
public Datastore getDatastoreInstance(TenantInfo tenantInfo) {
if (datastoreClients.get(tenantInfo.getName()) == null) {
Datastore googleDatastore = DatastoreOptions.newBuilder()
.setCredentials(new DatastoreCredential(tenantInfo))
.setRetrySettings(RETRY_SETTINGS)
.setTransportOptions(TRANSPORT_OPTIONS)
.setNamespace(tenantInfo.getName())
.setProjectId(tenantInfo.getProjectId())
.build().getService();
datastoreClients.put(tenantInfo.getName(), googleDatastore);
}
return datastoreClients.get(tenantInfo.getName());
}
}
......@@ -26,7 +26,6 @@ import org.opengroup.osdu.core.common.model.tenant.TenantInfo;
import org.opengroup.osdu.core.common.provider.interfaces.IElasticRepository;
import org.opengroup.osdu.core.common.provider.interfaces.IKmsClient;
import org.opengroup.osdu.core.common.search.Preconditions;
import org.opengroup.osdu.core.gcp.multitenancy.DatastoreFactory;
import org.opengroup.osdu.indexer.config.IndexerConfigurationProperties;
import org.springframework.stereotype.Component;
......@@ -52,7 +51,7 @@ public class ElasticRepositoryDatastore implements IElasticRepository {
@Override
public ClusterSettings getElasticClusterSettings(TenantInfo tenantInfo) {
Datastore googleDatastore = this.datastoreFactory.getDatastore(tenantInfo);
Datastore googleDatastore = this.datastoreFactory.getDatastoreInstance(tenantInfo);
Key key = googleDatastore.newKeyFactory().setKind(properties.getElasticDatastoreKind()).newKey(properties.getElasticDatastoreId());
Entity datastoreEntity = googleDatastore.get(key);
......
......@@ -40,6 +40,7 @@ public class GSuiteSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers("/api-docs")
.antMatchers("/info")
.antMatchers("/swagger");
}
......
......@@ -3,6 +3,8 @@
package org.opengroup.osdu.indexer.ibm.di;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
......@@ -25,4 +27,9 @@ public class TenantInfoService implements ITenantInfoService {
public TenantInfo getTenantInfo() {
return tenantFactory.getTenantInfo(headers.getPartitionId());
}
@Override
public List<TenantInfo> getAllTenantInfos() {
return new ArrayList<>(tenantFactory.listTenantInfo());
}
}
......@@ -26,6 +26,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
"/swagger-resources/**",
"/configuration/security",
"/swagger",
"/info",
"/swagger-ui.html",
"/webjars/**").permitAll()
.anyRequest().anonymous();
......
......@@ -66,6 +66,4 @@ ELASTIC_DATASTORE_ID=indexer-service
ELASTIC_HOST=elasticsearch.com
ELASTIC_PORT=443
ELASTIC_USER_PASSWORD=REPLACE_ME:REPLACE_ME
ELASTIC_USER_PASSWORD=REPLACE_ME:REPLACE_ME
\ No newline at end of file
package org.opengroup.osdu.indexer.di;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.core.common.model.tenant.TenantInfo;
import org.opengroup.osdu.core.common.multitenancy.ITenantInfoService;
import org.opengroup.osdu.core.common.provider.interfaces.ITenantFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.context.annotation.RequestScope;
@RequestScope
@Component
public class TenantInfoService implements ITenantInfoService {
@Inject
private ITenantFactory tenantFactory;
@Inject
private DpsHeaders headers;
@Override
public TenantInfo getTenantInfo() {
return tenantFactory.getTenantInfo(headers.getPartitionId());
}
@Override
public List<TenantInfo> getAllTenantInfos() {
return new ArrayList<>(tenantFactory.listTenantInfo());
}
}
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