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