use of com.vmware.photon.controller.model.resources.LoadBalancerDescriptionService.LoadBalancerDescription.HealthCheckConfiguration in project photon-model by vmware.
the class LoadBalancerDescriptionService method getDocumentTemplate.
@Override
public ServiceDocument getDocumentTemplate() {
ServiceDocument td = super.getDocumentTemplate();
// enable metadata indexing
td.documentDescription.documentIndexingOptions = EnumSet.of(DocumentIndexingOption.INDEX_METADATA);
ServiceUtils.setRetentionLimit(td);
LoadBalancerDescription template = (LoadBalancerDescription) td;
template.id = UUID.randomUUID().toString();
template.name = "load-balancer";
template.endpointLink = UriUtils.buildUriPath(EndpointService.FACTORY_LINK, "my-endpoint");
template.networkName = "lb-net";
RouteConfiguration routeConfiguration = new RouteConfiguration();
routeConfiguration.protocol = Protocol.HTTP.name();
routeConfiguration.port = "80";
routeConfiguration.instanceProtocol = Protocol.HTTP.name();
routeConfiguration.instancePort = "80";
routeConfiguration.healthCheckConfiguration = new HealthCheckConfiguration();
routeConfiguration.healthCheckConfiguration.protocol = Protocol.HTTP.name();
routeConfiguration.healthCheckConfiguration.port = "80";
template.routes = Arrays.asList(routeConfiguration);
return template;
}
use of com.vmware.photon.controller.model.resources.LoadBalancerDescriptionService.LoadBalancerDescription.HealthCheckConfiguration in project photon-model by vmware.
the class AzureLoadBalancerService method buildLoadBalancingProbes.
/**
* Build Azure health probe model
*
* @param context Azure load balancer context
* @return List of ProbeInner objects
*/
private List<ProbeInner> buildLoadBalancingProbes(AzureLoadBalancerContext context) {
List<ProbeInner> loadBalancingProbes = Lists.newArrayList();
int index = 1;
for (RouteConfiguration routes : context.loadBalancerStateExpanded.routes) {
HealthCheckConfiguration healthCheckConfiguration = routes.healthCheckConfiguration;
if (healthCheckConfiguration != null) {
ProbeInner probeInner = new ProbeInner();
String healthProbeName = String.format("%s-probe-%s", context.loadBalancerStateExpanded.name, index);
probeInner.withName(healthProbeName);
probeInner.withIntervalInSeconds(healthCheckConfiguration.intervalSeconds);
probeInner.withPort(Integer.parseInt(healthCheckConfiguration.port));
boolean isHttpProtocol = StringUtils.equalsIgnoreCase(ProbeProtocol.HTTP.toString(), healthCheckConfiguration.protocol);
boolean isTcpProtocol = StringUtils.equalsIgnoreCase(ProbeProtocol.TCP.toString(), healthCheckConfiguration.protocol);
AssertUtil.assertTrue(isHttpProtocol || isTcpProtocol, String.format("Unsupported protocol %s. Only HTTP and TCP are supported.", healthCheckConfiguration.protocol));
probeInner.withProtocol(new ProbeProtocol(healthCheckConfiguration.protocol));
if (isHttpProtocol) {
probeInner.withRequestPath(healthCheckConfiguration.urlPath);
}
probeInner.withNumberOfProbes(healthCheckConfiguration.unhealthyThreshold);
loadBalancingProbes.add(probeInner);
index++;
}
}
return loadBalancingProbes;
}
use of com.vmware.photon.controller.model.resources.LoadBalancerDescriptionService.LoadBalancerDescription.HealthCheckConfiguration in project photon-model by vmware.
the class LoadBalancerServiceTest method buildValidStartState.
public static LoadBalancerState buildValidStartState() {
LoadBalancerState loadBalancerState = new LoadBalancerState();
loadBalancerState.descriptionLink = LoadBalancerDescriptionService.FACTORY_LINK + "/lb-desc";
loadBalancerState.id = UUID.randomUUID().toString();
loadBalancerState.name = "lbName";
loadBalancerState.endpointLink = EndpointService.FACTORY_LINK + "/my-endpoint";
loadBalancerState.computeLinks = new HashSet<>();
loadBalancerState.computeLinks.add(ComputeService.FACTORY_LINK + "/a-compute");
loadBalancerState.targetLinks = new HashSet<>();
loadBalancerState.targetLinks.add(ComputeService.FACTORY_LINK + "/a-compute");
loadBalancerState.targetLinks.add(NetworkInterfaceService.FACTORY_LINK + "/a-nic");
loadBalancerState.subnetLinks = new HashSet<>();
loadBalancerState.subnetLinks.add(SubnetService.FACTORY_LINK + "/a-subnet");
loadBalancerState.securityGroupLinks = new ArrayList<>();
loadBalancerState.securityGroupLinks.add(SecurityGroupService.FACTORY_LINK + "/a-sg");
loadBalancerState.regionId = "regionId";
loadBalancerState.tenantLinks = new ArrayList<>();
loadBalancerState.tenantLinks.add("tenant-linkA");
RouteConfiguration route1 = new RouteConfiguration();
route1.protocol = Protocol.HTTP.name();
route1.port = "80";
route1.instanceProtocol = Protocol.HTTP.name();
route1.instancePort = "80";
route1.healthCheckConfiguration = new HealthCheckConfiguration();
route1.healthCheckConfiguration.protocol = Protocol.HTTP.name();
route1.healthCheckConfiguration.port = "80";
RouteConfiguration route2 = new RouteConfiguration();
route2.protocol = Protocol.HTTPS.name();
route2.port = "443";
route2.instanceProtocol = Protocol.HTTP.name();
route2.instancePort = "443";
loadBalancerState.routes = Arrays.asList(route1, route2);
return loadBalancerState;
}
use of com.vmware.photon.controller.model.resources.LoadBalancerDescriptionService.LoadBalancerDescription.HealthCheckConfiguration in project photon-model by vmware.
the class AWSLoadBalancerService method buildHealthCheckRequest.
private ConfigureHealthCheckRequest buildHealthCheckRequest(AWSLoadBalancerContext context) {
HealthCheckConfiguration healthCheckConfiguration = context.loadBalancerStateExpanded.routes.stream().filter(config -> config != null && config.healthCheckConfiguration != null).map(config -> config.healthCheckConfiguration).findFirst().orElse(null);
if (healthCheckConfiguration == null) {
return null;
}
// Construct the target HTTP:80/index.html
String target = healthCheckConfiguration.protocol + ":" + healthCheckConfiguration.port + healthCheckConfiguration.urlPath;
HealthCheck healthCheck = new HealthCheck().withHealthyThreshold(healthCheckConfiguration.healthyThreshold).withInterval(healthCheckConfiguration.intervalSeconds).withTarget(target).withTimeout(healthCheckConfiguration.timeoutSeconds).withUnhealthyThreshold(healthCheckConfiguration.unhealthyThreshold);
return new ConfigureHealthCheckRequest().withLoadBalancerName(context.loadBalancerStateExpanded.name).withHealthCheck(healthCheck);
}
Aggregations