use of com.sequenceiq.common.api.type.LoadBalancerType in project cloudbreak by hortonworks.
the class AwsMetadataCollector method collectLoadBalancer.
@Override
public List<CloudLoadBalancerMetadata> collectLoadBalancer(AuthenticatedContext ac, List<LoadBalancerType> loadBalancerTypes, List<CloudResource> resources) {
LOGGER.debug("Collect AWS load balancer metadata, for cluster {}", ac.getCloudContext().getName());
List<CloudLoadBalancerMetadata> cloudLoadBalancerMetadata = new ArrayList<>();
for (LoadBalancerType type : loadBalancerTypes) {
AwsLoadBalancerScheme scheme = loadBalancerTypeConverter.convert(type);
String loadBalancerName = AwsLoadBalancer.getLoadBalancerName(scheme);
LOGGER.debug("Attempting to collect metadata for load balancer {}, type {}", loadBalancerName, type);
try {
LoadBalancer loadBalancer = cloudFormationStackUtil.getLoadBalancerByLogicalId(ac, loadBalancerName);
LOGGER.debug("Parsing all listener and target group information for load balancer {}", loadBalancerName);
Map<String, Object> parameters = awsLoadBalancerMetadataCollector.getParameters(ac, loadBalancer, scheme);
CloudLoadBalancerMetadata loadBalancerMetadata = new CloudLoadBalancerMetadata.Builder().withType(type).withCloudDns(loadBalancer.getDNSName()).withHostedZoneId(loadBalancer.getCanonicalHostedZoneId()).withName(loadBalancerName).withParameters(parameters).build();
cloudLoadBalancerMetadata.add(loadBalancerMetadata);
LOGGER.debug("Saved metadata for load balancer {}: DNS {}, zone id {}", loadBalancerName, loadBalancer.getDNSName(), loadBalancer.getCanonicalHostedZoneId());
} catch (RuntimeException e) {
LOGGER.debug("Unable to find metadata for load balancer " + loadBalancerName, e);
}
}
return cloudLoadBalancerMetadata;
}
use of com.sequenceiq.common.api.type.LoadBalancerType in project cloudbreak by hortonworks.
the class AwsLoadBalancerCommonServiceTest method testSelectLoadBalancerSubnetIdsOnlyEndpointGatewaySet.
@Test
public void testSelectLoadBalancerSubnetIdsOnlyEndpointGatewaySet() {
AwsNetworkView awsNetworkView = createNetworkView(null, PUBLIC_ID_1);
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.common.api.type.LoadBalancerType in project cloudbreak by hortonworks.
the class AwsLoadBalancerCommonServiceTest method testSelectLoadBalancerSubnetIdsPublicEndpointGatway.
@Test
public void testSelectLoadBalancerSubnetIdsPublicEndpointGatway() {
AwsNetworkView awsNetworkView = createNetworkView(PRIVATE_ID_1, PUBLIC_ID_1);
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.common.api.type.LoadBalancerType in project cloudbreak by hortonworks.
the class AwsLoadBalancerCommonServiceTest method testSelectLoadBalancerSubnetIdsPrivate.
@Test
public void testSelectLoadBalancerSubnetIdsPrivate() {
AwsNetworkView awsNetworkView = createNetworkView(PRIVATE_ID_1, null);
LoadBalancerType loadBalancerType = LoadBalancerType.PRIVATE;
CloudLoadBalancer cloudLoadBalancer = createCloudLoadBalancer(loadBalancerType);
Set<String> subnetIds = underTest.selectLoadBalancerSubnetIds(loadBalancerType, awsNetworkView, cloudLoadBalancer);
assertEquals(Set.of(PRIVATE_ID_1), subnetIds);
}
use of com.sequenceiq.common.api.type.LoadBalancerType in project cloudbreak by hortonworks.
the class AwsNativeMetadataCollectorTest method collectLoadBalancerMetadataWhenWhenRuntimeExceptionOccurs.
@Test
void collectLoadBalancerMetadataWhenWhenRuntimeExceptionOccurs() {
List<LoadBalancerType> loadBalancerTypes = List.of();
CloudResource cloudResource = getCloudResource("secondCrn", "secondInstanceName", null, ELASTIC_LOAD_BALANCER);
List<CloudResource> cloudResources = List.of(cloudResource);
when(awsClient.createElasticLoadBalancingClient(any(), any())).thenReturn(loadBalancingClient);
RuntimeException runtimeException = new RuntimeException("Something really bad happened...");
when(loadBalancingClient.describeLoadBalancers(any())).thenThrow(runtimeException);
CloudConnectorException cloudConnectorException = assertThrows(CloudConnectorException.class, () -> underTest.collectLoadBalancer(authenticatedContext, loadBalancerTypes, cloudResources));
assertThat(cloudConnectorException).hasMessage("Metadata collection of load balancers failed");
assertThat(cloudConnectorException).hasCauseReference(runtimeException);
verify(loadBalancingClient, times(1)).describeLoadBalancers(any());
}
Aggregations