Skip to content
Snippets Groups Projects
Commit 49878aa1 authored by Ashwani Pandey's avatar Ashwani Pandey Committed by Shrikant Garg
Browse files

info api implementation for adding outerservice version in response

parent 679de669
No related branches found
No related tags found
1 merge request!424info api implementation for adding outerservice version in response
......@@ -6,13 +6,20 @@ package org.opengroup.osdu.indexer.service;
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.multitenancy.ITenantInfoService;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.opengroup.osdu.core.common.provider.interfaces.IElasticRepository;
import org.opengroup.osdu.indexer.config.IndexerConfigurationProperties;
import org.opengroup.osdu.core.common.provider.interfaces.IElasticCredentialsCache;
import org.opengroup.osdu.core.common.model.indexer.IElasticSettingService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.inject.Inject;
@Service
......@@ -27,6 +34,10 @@ public class ElasticSettingServiceIBMImpl implements IElasticSettingService {
private IElasticCredentialsCache elasticCredentialCache;
@Inject
private JaxRsDpsLog logger;
@Inject
private javax.inject.Provider<ITenantInfoService> tenantInfoServiceProvider;
@Inject
private IndexerConfigurationProperties configurationProperties;
@Override
public ClusterSettings getElasticClusterInformation() {
......@@ -47,4 +58,34 @@ public class ElasticSettingServiceIBMImpl implements IElasticSettingService {
this.elasticCredentialCache.put(cacheKey, clusterInfo);
return clusterInfo;
}
@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());
ClusterSettings clusterInfo = (ClusterSettings) this.elasticCredentialCache.get(cacheKey);
if (clusterInfo != null) {
return clusterInfo;
}
logger.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");
}
this.elasticCredentialCache.put(cacheKey, clusterInfo);
return clusterInfo;
}
}
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