Search in sources :

Example 1 with ProbeProtocol

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;
}
Also used : ProbeProtocol(com.microsoft.azure.management.network.ProbeProtocol) HealthCheckConfiguration(com.vmware.photon.controller.model.resources.LoadBalancerDescriptionService.LoadBalancerDescription.HealthCheckConfiguration) ProbeInner(com.microsoft.azure.management.network.implementation.ProbeInner) RouteConfiguration(com.vmware.photon.controller.model.resources.LoadBalancerDescriptionService.LoadBalancerDescription.RouteConfiguration)

Aggregations

ProbeProtocol (com.microsoft.azure.management.network.ProbeProtocol)1 ProbeInner (com.microsoft.azure.management.network.implementation.ProbeInner)1 HealthCheckConfiguration (com.vmware.photon.controller.model.resources.LoadBalancerDescriptionService.LoadBalancerDescription.HealthCheckConfiguration)1 RouteConfiguration (com.vmware.photon.controller.model.resources.LoadBalancerDescriptionService.LoadBalancerDescription.RouteConfiguration)1