use of com.microsoft.azure.management.network.ProbeProtocol 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;
}
Aggregations