use of com.microsoft.azure.management.network.implementation.ProbeInner in project photon-model by vmware.
the class AzureLoadBalancerService method buildLoadBalancingRules.
/**
* Build Azure load balancing rule model
*
* @param context Azure load balancer context
* @return List of LoadBalancingRuleInner objects
*/
private List<LoadBalancingRuleInner> buildLoadBalancingRules(AzureLoadBalancerContext context) {
List<LoadBalancingRuleInner> loadBalancingRules = Lists.newArrayList();
int index = 1;
for (RouteConfiguration routes : context.loadBalancerStateExpanded.routes) {
ProbeInner probeInner = findMatchingProbe(context, index);
LoadBalancingRuleInner loadBalancingRule = new LoadBalancingRuleInner();
loadBalancingRule.withName(String.format("%s-lb-rule-%s", context.loadBalancerStateExpanded.name, index++));
loadBalancingRule.withBackendPort(Integer.valueOf(routes.instancePort));
loadBalancingRule.withFrontendPort(Integer.valueOf(routes.port));
loadBalancingRule.withBackendAddressPool(new SubResource().withId(context.loadBalancerAzure.backendAddressPools().get(0).id()));
// Converting HTTP and HTTPS to TCP to send to Azure as Azure only supports TCP or UCP
if (StringUtils.equalsIgnoreCase("HTTP", routes.protocol) || StringUtils.equalsIgnoreCase("HTTPS", routes.protocol)) {
routes.protocol = TransportProtocol.TCP.toString();
}
boolean isTcpProtocol = StringUtils.equalsIgnoreCase(TransportProtocol.TCP.toString(), routes.protocol);
boolean isUdpProtocol = StringUtils.equalsIgnoreCase(TransportProtocol.UDP.toString(), routes.protocol);
AssertUtil.assertTrue(isTcpProtocol || isUdpProtocol, String.format("Unsupported protocol %s. Only UDP and TCP are supported.", routes.protocol));
loadBalancingRule.withProtocol(new TransportProtocol(routes.protocol));
// TODO support more than one frontend case
loadBalancingRule.withFrontendIPConfiguration(new SubResource().withId(context.loadBalancerAzure.frontendIPConfigurations().get(0).id()));
if (probeInner != null) {
loadBalancingRule.withProbe(new SubResource().withId(probeInner.id()));
}
loadBalancingRules.add(loadBalancingRule);
}
return loadBalancingRules;
}
use of com.microsoft.azure.management.network.implementation.ProbeInner 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