Search in sources :

Example 26 with CloudLoadBalancer

use of com.sequenceiq.cloudbreak.cloud.model.CloudLoadBalancer in project cloudbreak by hortonworks.

the class AwsLoadBalancerCommonServiceTest method createCloudLoadBalancerWithEndpointGateay.

private CloudLoadBalancer createCloudLoadBalancerWithEndpointGateay(LoadBalancerType type, List<String> instanceGroupNetworkSubnetIds, List<String> endpointGatewaySubnetIds) {
    Group group = new Group(INSTANCE_NAME, GATEWAY, List.of(), null, null, null, null, null, null, 100, null, createGroupNetwork(instanceGroupNetworkSubnetIds, endpointGatewaySubnetIds), emptyMap());
    CloudLoadBalancer cloudLoadBalancer = new CloudLoadBalancer(type);
    cloudLoadBalancer.addPortToTargetGroupMapping(new TargetGroupPortPair(PORT, PORT), Set.of(group));
    return cloudLoadBalancer;
}
Also used : AwsTargetGroup(com.sequenceiq.cloudbreak.cloud.aws.common.loadbalancer.AwsTargetGroup) Group(com.sequenceiq.cloudbreak.cloud.model.Group) CloudLoadBalancer(com.sequenceiq.cloudbreak.cloud.model.CloudLoadBalancer) TargetGroupPortPair(com.sequenceiq.cloudbreak.cloud.model.TargetGroupPortPair)

Example 27 with CloudLoadBalancer

use of com.sequenceiq.cloudbreak.cloud.model.CloudLoadBalancer in project cloudbreak by hortonworks.

the class AwsLoadBalancerCommonServiceTest method testSelectLoadBalancerSubnetIdsWhenSubnetsArePrivateAndInstanceGroupNetworkContainsSubnetForMultiAz.

@Test
public void testSelectLoadBalancerSubnetIdsWhenSubnetsArePrivateAndInstanceGroupNetworkContainsSubnetForMultiAz() {
    AwsNetworkView awsNetworkView = createNetworkView(PRIVATE_ID_1, null);
    LoadBalancerType loadBalancerType = LoadBalancerType.PRIVATE;
    CloudLoadBalancer cloudLoadBalancer = createCloudLoadBalancer(loadBalancerType, List.of(SUBNET_ID_1, SUBNET_ID_2));
    Set<String> subnetIds = underTest.selectLoadBalancerSubnetIds(loadBalancerType, awsNetworkView, cloudLoadBalancer);
    assertEquals(Set.of(SUBNET_ID_1, SUBNET_ID_2), subnetIds);
}
Also used : AwsNetworkView(com.sequenceiq.cloudbreak.cloud.aws.common.view.AwsNetworkView) CloudLoadBalancer(com.sequenceiq.cloudbreak.cloud.model.CloudLoadBalancer) LoadBalancerType(com.sequenceiq.common.api.type.LoadBalancerType) Test(org.junit.jupiter.api.Test)

Example 28 with CloudLoadBalancer

use of com.sequenceiq.cloudbreak.cloud.model.CloudLoadBalancer in project cloudbreak by hortonworks.

the class AwsLoadBalancerCommonServiceTest method testSelectLoadBalancerSubnetIdsPublicNoEndpointGateway.

@Test
public void testSelectLoadBalancerSubnetIdsPublicNoEndpointGateway() {
    AwsNetworkView awsNetworkView = createNetworkView(PUBLIC_ID_1, null);
    LoadBalancerType loadBalancerType = LoadBalancerType.PUBLIC;
    CloudLoadBalancer cloudLoadBalancer = createCloudLoadBalancer(loadBalancerType);
    Set<String> subnetIds = underTest.selectLoadBalancerSubnetIds(loadBalancerType, awsNetworkView, cloudLoadBalancer);
    assertEquals(Set.of(PUBLIC_ID_1), subnetIds);
}
Also used : AwsNetworkView(com.sequenceiq.cloudbreak.cloud.aws.common.view.AwsNetworkView) CloudLoadBalancer(com.sequenceiq.cloudbreak.cloud.model.CloudLoadBalancer) LoadBalancerType(com.sequenceiq.common.api.type.LoadBalancerType) Test(org.junit.jupiter.api.Test)

Example 29 with CloudLoadBalancer

use of com.sequenceiq.cloudbreak.cloud.model.CloudLoadBalancer in project cloudbreak by hortonworks.

the class AwsLoadBalancerCommonServiceTest method testSelectLoadBalancerSubnetIdsWhenEndpointGatewaySetAndInstanceGroupNetworkContainsSubnetForMultiAz.

@Test
public void testSelectLoadBalancerSubnetIdsWhenEndpointGatewaySetAndInstanceGroupNetworkContainsSubnetForMultiAz() {
    AwsNetworkView awsNetworkView = createNetworkView(null, PUBLIC_ID_1);
    LoadBalancerType loadBalancerType = LoadBalancerType.PUBLIC;
    CloudLoadBalancer cloudLoadBalancer = createCloudLoadBalancerWithEndpointGateay(loadBalancerType, List.of(SUBNET_ID_1, SUBNET_ID_2), List.of(PUBLIC_SUBNET_ID_1, PUBLIC_SUBNET_ID_2));
    Set<String> subnetIds = underTest.selectLoadBalancerSubnetIds(loadBalancerType, awsNetworkView, cloudLoadBalancer);
    assertEquals(Set.of(PUBLIC_ID_1, PUBLIC_SUBNET_ID_1, PUBLIC_SUBNET_ID_2), subnetIds);
}
Also used : AwsNetworkView(com.sequenceiq.cloudbreak.cloud.aws.common.view.AwsNetworkView) CloudLoadBalancer(com.sequenceiq.cloudbreak.cloud.model.CloudLoadBalancer) LoadBalancerType(com.sequenceiq.common.api.type.LoadBalancerType) Test(org.junit.jupiter.api.Test)

Example 30 with CloudLoadBalancer

use of com.sequenceiq.cloudbreak.cloud.model.CloudLoadBalancer in project cloudbreak by hortonworks.

the class LoadBalancerResourceService method buildResources.

public List<CloudResourceStatus> buildResources(ResourceBuilderContext context, AuthenticatedContext auth, CloudStack stack) throws Exception {
    CloudContext cloudContext = auth.getCloudContext();
    List<CloudResourceStatus> results = new ArrayList<>();
    for (LoadBalancerResourceBuilder<ResourceBuilderContext> builder : resourceBuilders.loadBalancer(cloudContext.getVariant())) {
        for (CloudLoadBalancer loadBalancer : stack.getLoadBalancers()) {
            PollGroup pollGroup = InMemoryStateStore.getStack(auth.getCloudContext().getId());
            if (CANCELLED.equals(pollGroup)) {
                break;
            }
            try {
                List<CloudResource> buildableResources = builder.create(context, auth, loadBalancer);
                createResource(auth, buildableResources);
                LOGGER.debug("Building resources [{}], with {} for {}", buildableResources.stream().map(CloudResource::getName).collect(Collectors.joining(",")), builder.getClass().getName(), context.getName());
                List<CloudResource> resources = builder.build(context, auth, buildableResources, loadBalancer, stack);
                updateResource(auth, resources);
                PollTask<List<CloudResourceStatus>> task = statusCheckFactory.newPollResourceTask(builder, auth, resources, context, true);
                List<CloudResourceStatus> pollerResult = syncPollingScheduler.schedule(task);
                context.addLoadBalancerResources(loadBalancer.getType(), resources);
                results.addAll(pollerResult);
            } catch (ResourceNotNeededException e) {
                LOGGER.debug("Skipping resource creation: {}", e.getMessage());
            }
        }
    }
    return results;
}
Also used : CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) ArrayList(java.util.ArrayList) PollGroup(com.sequenceiq.cloudbreak.cloud.scheduler.PollGroup) ResourceNotNeededException(com.sequenceiq.cloudbreak.cloud.template.ResourceNotNeededException) CloudLoadBalancer(com.sequenceiq.cloudbreak.cloud.model.CloudLoadBalancer) CloudResourceStatus(com.sequenceiq.cloudbreak.cloud.model.CloudResourceStatus) ResourceBuilderContext(com.sequenceiq.cloudbreak.cloud.template.context.ResourceBuilderContext) ArrayList(java.util.ArrayList) List(java.util.List) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource)

Aggregations

CloudLoadBalancer (com.sequenceiq.cloudbreak.cloud.model.CloudLoadBalancer)47 TargetGroupPortPair (com.sequenceiq.cloudbreak.cloud.model.TargetGroupPortPair)27 Group (com.sequenceiq.cloudbreak.cloud.model.Group)24 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)21 ArrayList (java.util.ArrayList)21 Test (org.junit.jupiter.api.Test)20 List (java.util.List)15 AwsNetworkView (com.sequenceiq.cloudbreak.cloud.aws.common.view.AwsNetworkView)13 LoadBalancerType (com.sequenceiq.common.api.type.LoadBalancerType)13 HashMap (java.util.HashMap)13 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)13 CloudContext (com.sequenceiq.cloudbreak.cloud.context.CloudContext)12 Set (java.util.Set)12 InstanceAuthentication (com.sequenceiq.cloudbreak.cloud.model.InstanceAuthentication)11 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)11 CloudResource (com.sequenceiq.cloudbreak.cloud.model.CloudResource)10 GroupNetwork (com.sequenceiq.cloudbreak.cloud.model.GroupNetwork)10 Network (com.sequenceiq.cloudbreak.cloud.model.Network)10 Map (java.util.Map)10 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)9