Search in sources :

Example 6 with HealthCheckConfiguration

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;
}
Also used : HealthCheckConfiguration(com.vmware.photon.controller.model.resources.LoadBalancerDescriptionService.LoadBalancerDescription.HealthCheckConfiguration) RouteConfiguration(com.vmware.photon.controller.model.resources.LoadBalancerDescriptionService.LoadBalancerDescription.RouteConfiguration) ServiceDocument(com.vmware.xenon.common.ServiceDocument)

Example 7 with HealthCheckConfiguration

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;
}
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)

Example 8 with HealthCheckConfiguration

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;
}
Also used : HealthCheckConfiguration(com.vmware.photon.controller.model.resources.LoadBalancerDescriptionService.LoadBalancerDescription.HealthCheckConfiguration) RouteConfiguration(com.vmware.photon.controller.model.resources.LoadBalancerDescriptionService.LoadBalancerDescription.RouteConfiguration) LoadBalancerState(com.vmware.photon.controller.model.resources.LoadBalancerService.LoadBalancerState)

Example 9 with HealthCheckConfiguration

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);
}
Also used : CreateLoadBalancerResult(com.amazonaws.services.elasticloadbalancing.model.CreateLoadBalancerResult) Protocol(com.vmware.photon.controller.model.resources.SecurityGroupService.Protocol) AuthCredentialsServiceState(com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState) RegisterInstancesWithLoadBalancerRequest(com.amazonaws.services.elasticloadbalancing.model.RegisterInstancesWithLoadBalancerRequest) ServiceTypeCluster(com.vmware.photon.controller.model.util.ClusterUtil.ServiceTypeCluster) CreateLoadBalancerRequest(com.amazonaws.services.elasticloadbalancing.model.CreateLoadBalancerRequest) AWSClientManagerFactory.returnClientManager(com.vmware.photon.controller.model.adapters.awsadapter.util.AWSClientManagerFactory.returnClientManager) LoadBalancerState(com.vmware.photon.controller.model.resources.LoadBalancerService.LoadBalancerState) SubnetState(com.vmware.photon.controller.model.resources.SubnetService.SubnetState) URI(java.net.URI) AWSClientManager(com.vmware.photon.controller.model.adapters.awsadapter.util.AWSClientManager) HealthCheckConfiguration(com.vmware.photon.controller.model.resources.LoadBalancerDescriptionService.LoadBalancerDescription.HealthCheckConfiguration) StatelessService(com.vmware.xenon.common.StatelessService) DeleteLoadBalancerRequest(com.amazonaws.services.elasticloadbalancing.model.DeleteLoadBalancerRequest) Instance(com.amazonaws.services.elasticloadbalancing.model.Instance) Collection(java.util.Collection) TaskManager(com.vmware.photon.controller.model.adapters.util.TaskManager) Collectors(java.util.stream.Collectors) AmazonElasticLoadBalancingAsyncClient(com.amazonaws.services.elasticloadbalancing.AmazonElasticLoadBalancingAsyncClient) List(java.util.List) DeferredResult(com.vmware.xenon.common.DeferredResult) UriUtils(com.vmware.xenon.common.UriUtils) DeregisterInstancesFromLoadBalancerResult(com.amazonaws.services.elasticloadbalancing.model.DeregisterInstancesFromLoadBalancerResult) AWSDeferredResultAsyncHandler(com.vmware.photon.controller.model.adapters.awsadapter.util.AWSDeferredResultAsyncHandler) FACTORY_LINK(com.vmware.photon.controller.model.resources.SecurityGroupService.FACTORY_LINK) SecurityGroupInstanceRequest(com.vmware.photon.controller.model.adapterapi.SecurityGroupInstanceRequest) ConfigureHealthCheckResult(com.amazonaws.services.elasticloadbalancing.model.ConfigureHealthCheckResult) ComputeProperties(com.vmware.photon.controller.model.ComputeProperties) ConfigureHealthCheckRequest(com.amazonaws.services.elasticloadbalancing.model.ConfigureHealthCheckRequest) NETWORK_STATE_ID_PROP_NAME(com.vmware.photon.controller.model.tasks.ProvisionSecurityGroupTaskService.NETWORK_STATE_ID_PROP_NAME) HashMap(java.util.HashMap) DescribeLoadBalancersRequest(com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersRequest) RegisterInstancesWithLoadBalancerResult(com.amazonaws.services.elasticloadbalancing.model.RegisterInstancesWithLoadBalancerResult) HealthCheck(com.amazonaws.services.elasticloadbalancing.model.HealthCheck) ArrayList(java.util.ArrayList) SecurityGroupState(com.vmware.photon.controller.model.resources.SecurityGroupService.SecurityGroupState) Rule(com.vmware.photon.controller.model.resources.SecurityGroupService.SecurityGroupState.Rule) HashSet(java.util.HashSet) LoadBalancerDescription(com.vmware.photon.controller.model.resources.LoadBalancerDescriptionService.LoadBalancerDescription) Listener(com.amazonaws.services.elasticloadbalancing.model.Listener) InstanceRequestType(com.vmware.photon.controller.model.adapterapi.SecurityGroupInstanceRequest.InstanceRequestType) ResourceState(com.vmware.photon.controller.model.resources.ResourceState) DeregisterInstancesFromLoadBalancerRequest(com.amazonaws.services.elasticloadbalancing.model.DeregisterInstancesFromLoadBalancerRequest) LoadBalancerStateExpanded(com.vmware.photon.controller.model.resources.LoadBalancerService.LoadBalancerStateExpanded) Operation(com.vmware.xenon.common.Operation) DeleteLoadBalancerResult(com.amazonaws.services.elasticloadbalancing.model.DeleteLoadBalancerResult) ClusterUtil(com.vmware.photon.controller.model.util.ClusterUtil) DescribeLoadBalancersResult(com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersResult) LoadBalancerInstanceRequest(com.vmware.photon.controller.model.adapterapi.LoadBalancerInstanceRequest) AWSClientManagerFactory(com.vmware.photon.controller.model.adapters.awsadapter.util.AWSClientManagerFactory) NetworkState(com.vmware.photon.controller.model.resources.NetworkService.NetworkState) Collections(java.util.Collections) PhotonModelUriUtils.createInventoryUri(com.vmware.photon.controller.model.util.PhotonModelUriUtils.createInventoryUri) HealthCheckConfiguration(com.vmware.photon.controller.model.resources.LoadBalancerDescriptionService.LoadBalancerDescription.HealthCheckConfiguration) HealthCheck(com.amazonaws.services.elasticloadbalancing.model.HealthCheck) ConfigureHealthCheckRequest(com.amazonaws.services.elasticloadbalancing.model.ConfigureHealthCheckRequest)

Aggregations

HealthCheckConfiguration (com.vmware.photon.controller.model.resources.LoadBalancerDescriptionService.LoadBalancerDescription.HealthCheckConfiguration)9 RouteConfiguration (com.vmware.photon.controller.model.resources.LoadBalancerDescriptionService.LoadBalancerDescription.RouteConfiguration)7 LoadBalancerState (com.vmware.photon.controller.model.resources.LoadBalancerService.LoadBalancerState)3 LoadBalancerDescription (com.vmware.photon.controller.model.resources.LoadBalancerDescriptionService.LoadBalancerDescription)2 AmazonElasticLoadBalancingAsyncClient (com.amazonaws.services.elasticloadbalancing.AmazonElasticLoadBalancingAsyncClient)1 ConfigureHealthCheckRequest (com.amazonaws.services.elasticloadbalancing.model.ConfigureHealthCheckRequest)1 ConfigureHealthCheckResult (com.amazonaws.services.elasticloadbalancing.model.ConfigureHealthCheckResult)1 CreateLoadBalancerRequest (com.amazonaws.services.elasticloadbalancing.model.CreateLoadBalancerRequest)1 CreateLoadBalancerResult (com.amazonaws.services.elasticloadbalancing.model.CreateLoadBalancerResult)1 DeleteLoadBalancerRequest (com.amazonaws.services.elasticloadbalancing.model.DeleteLoadBalancerRequest)1 DeleteLoadBalancerResult (com.amazonaws.services.elasticloadbalancing.model.DeleteLoadBalancerResult)1 DeregisterInstancesFromLoadBalancerRequest (com.amazonaws.services.elasticloadbalancing.model.DeregisterInstancesFromLoadBalancerRequest)1 DeregisterInstancesFromLoadBalancerResult (com.amazonaws.services.elasticloadbalancing.model.DeregisterInstancesFromLoadBalancerResult)1 DescribeLoadBalancersRequest (com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersRequest)1 DescribeLoadBalancersResult (com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersResult)1 HealthCheck (com.amazonaws.services.elasticloadbalancing.model.HealthCheck)1 Instance (com.amazonaws.services.elasticloadbalancing.model.Instance)1 Listener (com.amazonaws.services.elasticloadbalancing.model.Listener)1 RegisterInstancesWithLoadBalancerRequest (com.amazonaws.services.elasticloadbalancing.model.RegisterInstancesWithLoadBalancerRequest)1 RegisterInstancesWithLoadBalancerResult (com.amazonaws.services.elasticloadbalancing.model.RegisterInstancesWithLoadBalancerResult)1