Skip to content
7 changes: 7 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1093,6 +1093,13 @@ jobs:
image: ghcr.io/balhar-jakub/api-catalog-services:${{ github.run_id }}-${{ github.run_number }}
volumes:
- /api-defs:/api-defs
api-catalog-services-2:
image: ghcr.io/balhar-jakub/api-catalog-services:${{ github.run_id }}-${{ github.run_number }}
volumes:
- /api-defs:/api-defs
env:
APIML_SERVICE_HOSTNAME: api-catalog-services-2
APIML_HEALTH_PROTECTED: false
caching-service:
image: ghcr.io/balhar-jakub/caching-service:${{ github.run_id }}-${{ github.run_number }}
discoverable-client:
Expand Down
62 changes: 62 additions & 0 deletions apiml/src/main/java/org/zowe/apiml/EurekaHealthIndicatorApiml.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright Contributors to the Zowe Project.
*/

package org.zowe.apiml;

import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.Status;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.netflix.eureka.EurekaHealthIndicator;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;

import java.util.Map;
import java.util.stream.Collectors;

/**
* This class is replacement of org.springframework.cloud.netflix.eureka.EurekaHealthIndicator, because it is using
* a different Eureka client
*/
@Primary
@Component("eurekaHealthIndicator")
public class EurekaHealthIndicatorApiml extends EurekaHealthIndicator {

private DiscoveryClient discoveryClient;

public EurekaHealthIndicatorApiml(DiscoveryClient discoveryClient) {
super(null, null, null);
this.discoveryClient = discoveryClient;
}

@Override
public String getName() {
return "eureka";
}

@Override
public Health health() {
Health.Builder builder = Health.unknown();
Status status = getStatus(builder);
return builder.status(status).withDetail("applications", getApplications()).build();
}

private Status getStatus(Health.Builder builder) {
return new Status("UP", "Eureka discovery client has not yet successfully connected to a Eureka server");
}

private Map<String, Object> getApplications() {
return discoveryClient.getServices().stream()
.collect(Collectors.toMap(
String::toLowerCase,
serviceId -> discoveryClient.getInstances(serviceId).size())
);
}

}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,22 @@
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.zowe.apiml.product.constants.CoreService;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class ApiCatalogServiceConfiguration implements ServiceConfiguration {

private String scheme;
private String url;
private String host;
private int port;
private int instances;

@Override
public String getServiceId() {
return CoreService.API_CATALOG.getServiceId();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.zowe.apiml.product.constants.CoreService;

@Data
@AllArgsConstructor
Expand All @@ -36,4 +37,9 @@ public int getPort() {
throw new IllegalStateException("Method is not implemented");
}

@Override
public String getServiceId() {
return CoreService.CACHING.getServiceId();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.zowe.apiml.product.constants.CoreService;

@Data
@AllArgsConstructor
Expand All @@ -23,4 +24,9 @@ public class CentralGatewayServiceConfiguration implements ServiceConfiguration
private String host;
private int port;

@Override
public String getServiceId() {
return "centralGateway";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.zowe.apiml.product.constants.CoreService;

/**
* Configuration parameters for DiscoverableClient
Expand All @@ -21,9 +22,16 @@
@NoArgsConstructor
@AllArgsConstructor
public class DiscoverableClientConfiguration implements ServiceConfiguration {

private String scheme;
private String applId;
private String host;
private int port;
private int instances;

@Override
public String getServiceId() {
return "discoverableclient";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.zowe.apiml.product.constants.CoreService;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class DiscoveryServiceConfiguration implements ServiceConfiguration {

private String scheme;
private String user;
private String password;
Expand All @@ -26,5 +28,11 @@ public class DiscoveryServiceConfiguration implements ServiceConfiguration {
private int port;
private int additionalPort;
private int instances;

@Override
public String getServiceId() {
return CoreService.DISCOVERY.getServiceId();
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.zowe.apiml.product.constants.CoreService;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class GatewayServiceConfiguration implements ServiceConfiguration {

private String scheme;
private String host;
private String dvipaHost;
Expand All @@ -27,4 +29,10 @@ public class GatewayServiceConfiguration implements ServiceConfiguration {
private String internalPorts;
private String servicesEndpoint;
private int bucketCapacity;

@Override
public String getServiceId() {
return CoreService.GATEWAY.getServiceId();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,22 @@

package org.zowe.apiml.util.config;

import org.apache.commons.lang3.StringUtils;

public interface ServiceConfiguration {

String getScheme();
String getHost();
int getPort();

default int getInstances() {
var host = getHost();
if (StringUtils.isBlank(host)) {
return 0;
}
return getHost().split(",").length;
}

String getServiceId();

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,21 @@
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.zowe.apiml.product.constants.CoreService;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class ZaasConfiguration implements ServiceConfiguration {

private String scheme;
private String host;
private int port;
private int instances;

@Override
public String getServiceId() {
return CoreService.ZAAS.getServiceId();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
@AllArgsConstructor
@NoArgsConstructor
public class ZosmfServiceConfiguration implements ServiceConfiguration {

private String scheme;
private String host;
private int port;
private String serviceId;
private String contextRoot;

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ gatewayServiceConfiguration:
bucketCapacity: 20
zaasConfiguration:
scheme: https
host: zaas-service
host: zaas-service,zaas-service-2
port: 10023
discoveryServiceConfiguration:
scheme: https
Expand Down
Loading