Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
*/
package org.zowe.apiml.apicatalog.services.cached;

import org.springframework.beans.factory.annotation.Value;
import org.zowe.apiml.apicatalog.model.APIContainer;
import org.zowe.apiml.apicatalog.model.APIService;
import org.zowe.apiml.apicatalog.model.SemanticVersion;
import org.zowe.apiml.eurekaservice.client.util.EurekaMetadataParser;
import org.zowe.apiml.message.log.ApimlLogger;
import org.zowe.apiml.product.constants.CoreService;
import org.zowe.apiml.product.gateway.GatewayClient;
import org.zowe.apiml.product.logging.annotations.InjectApimlLogger;
import org.zowe.apiml.product.routing.RoutedServices;
import org.zowe.apiml.product.routing.ServiceType;
Expand All @@ -25,8 +25,6 @@
import com.netflix.discovery.shared.Application;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
Expand Down Expand Up @@ -55,23 +53,26 @@
@Service
@CacheConfig(cacheNames = {"products"})
public class CachedProductFamilyService {
private final Map<String, APIContainer> products = new HashMap<>();

private final CachedServicesService cachedServicesService;
@InjectApimlLogger
private final ApimlLogger apimlLog = ApimlLogger.empty();

private final Integer cacheRefreshUpdateThresholdInMillis;

private final CachedServicesService cachedServicesService;
private final EurekaMetadataParser metadataParser = new EurekaMetadataParser();
private final TransformService transformService;
@InjectApimlLogger
private final ApimlLogger apimlLog = ApimlLogger.empty();

@Autowired
public CachedProductFamilyService(GatewayClient gatewayClient,
CachedServicesService cachedServicesService,
private final Map<String, APIContainer> products = new HashMap<>();


public CachedProductFamilyService(CachedServicesService cachedServicesService,
TransformService transformService,
@Value("${apiml.service-registry.cacheRefreshUpdateThresholdInMillis}")
Integer cacheRefreshUpdateThresholdInMillis) {
this.cachedServicesService = cachedServicesService;
this.transformService = transformService;
this.cacheRefreshUpdateThresholdInMillis = cacheRefreshUpdateThresholdInMillis;
this.transformService = new TransformService(gatewayClient);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ public void testCalculationOfContainerTotalsWithAllServicesUp() {

when(cachedServicesService.getService("service")).thenReturn(application);
service = new CachedProductFamilyService(
null,
cachedServicesService,
null,
cacheRefreshUpdateThresholdInMillis);

service.getContainer("demoapp", instance1);
Expand Down Expand Up @@ -224,8 +224,8 @@ public void testCalculationOfContainerTotalsWithAllServicesDown() {
when(cachedServicesService.getService("service1")).thenReturn(application1);
when(cachedServicesService.getService("service2")).thenReturn(application2);
service = new CachedProductFamilyService(
null,
cachedServicesService,
null,
cacheRefreshUpdateThresholdInMillis);

service.getContainer("demoapp", instance1);
Expand Down Expand Up @@ -254,8 +254,8 @@ public void testCalculationOfContainerTotalsWithSomeServicesDown() {
when(cachedServicesService.getService("service1")).thenReturn(application1);
when(cachedServicesService.getService("service2")).thenReturn(application2);
service = new CachedProductFamilyService(
null,
cachedServicesService,
null,
cacheRefreshUpdateThresholdInMillis);

service.getContainer("demoapp", instance1);
Expand Down