use of com.sequenceiq.cloudbreak.domain.stack.loadbalancer.TargetGroupConfigDbWrapper in project cloudbreak by hortonworks.
the class LoadBalancerToLoadBalancerResponseConverter method convertTargetGroup.
public List<TargetGroupResponse> convertTargetGroup(TargetGroup targetGroup) {
Set<InstanceGroup> instanceGroups = instanceGroupService.findByTargetGroupId(targetGroup.getId());
Set<String> instanceIds = getInstanceMetadataForGroups(instanceGroups).stream().map(InstanceMetaData::getInstanceId).collect(Collectors.toSet());
TargetGroupConfigDbWrapper targetGroupConfig = targetGroup.getProviderConfig();
Set<TargetGroupPortPair> portPairs = loadBalancerConfigService.getTargetGroupPortPairs(targetGroup);
return portPairs.stream().map(portPair -> mapPortPairToTargetGroup(instanceIds, targetGroupConfig, portPair)).collect(Collectors.toList());
}
use of com.sequenceiq.cloudbreak.domain.stack.loadbalancer.TargetGroupConfigDbWrapper in project cloudbreak by hortonworks.
the class LoadBalancerConfigConverter method buildAzureConfig.
private TargetGroupConfigDbWrapper buildAzureConfig(AzureLoadBalancerMetadataView azureMetadata, TargetGroup targetGroup) {
Set<Integer> trafficPorts = getTrafficPorts(targetGroup);
TargetGroupConfigDbWrapper targetGroupConfigDbWrapper = new TargetGroupConfigDbWrapper();
AzureTargetGroupConfigDb azureTargetGroupConfigDb = new AzureTargetGroupConfigDb();
for (Integer port : trafficPorts) {
String availabilitySetName = azureMetadata.getAvailabilitySetByPort(port);
List<String> availabilitySetNames = List.of(StringUtils.isEmpty(availabilitySetName) ? MISSING_CLOUD_RESOURCE : availabilitySetName);
azureTargetGroupConfigDb.addPortAvailabilitySetMapping(port, availabilitySetNames);
}
targetGroupConfigDbWrapper.setAzureConfig(azureTargetGroupConfigDb);
return targetGroupConfigDbWrapper;
}
use of com.sequenceiq.cloudbreak.domain.stack.loadbalancer.TargetGroupConfigDbWrapper in project cloudbreak by hortonworks.
the class LoadBalancerConfigConverter method buildAwsConfig.
private TargetGroupConfigDbWrapper buildAwsConfig(AwsLoadBalancerMetadataView awsMetadata, TargetGroup targetGroup) {
Set<Integer> trafficPorts = getTrafficPorts(targetGroup);
TargetGroupConfigDbWrapper targetGroupConfigDbWrapper = new TargetGroupConfigDbWrapper();
AwsTargetGroupConfigDb awsTargetGroupConfigDb = new AwsTargetGroupConfigDb();
for (Integer port : trafficPorts) {
AwsTargetGroupArnsDb targetGroupArns = new AwsTargetGroupArnsDb();
String listenerArn = awsMetadata.getListenerArnByPort(port);
String targetGroupArn = awsMetadata.getTargetGroupArnByPort(port);
targetGroupArns.setListenerArn(StringUtils.isEmpty(listenerArn) ? MISSING_CLOUD_RESOURCE : listenerArn);
targetGroupArns.setTargetGroupArn(StringUtils.isEmpty(targetGroupArn) ? MISSING_CLOUD_RESOURCE : targetGroupArn);
awsTargetGroupConfigDb.addPortArnMapping(port, targetGroupArns);
}
targetGroupConfigDbWrapper.setAwsConfig(awsTargetGroupConfigDb);
return targetGroupConfigDbWrapper;
}
use of com.sequenceiq.cloudbreak.domain.stack.loadbalancer.TargetGroupConfigDbWrapper in project cloudbreak by hortonworks.
the class LoadBalancerToLoadBalancerResponseConverterTest method createAwsTargetGroups.
private Set<TargetGroup> createAwsTargetGroups() {
AwsTargetGroupArnsDb awsTargetGroupArnsDb = new AwsTargetGroupArnsDb();
awsTargetGroupArnsDb.setListenerArn(LISTENER_ARN);
awsTargetGroupArnsDb.setTargetGroupArn(TG_ARN);
AwsTargetGroupConfigDb awsTargetGroupConfigDb = new AwsTargetGroupConfigDb();
awsTargetGroupConfigDb.setPortArnMapping(Map.of(PORT, awsTargetGroupArnsDb));
TargetGroupConfigDbWrapper targetGroupConfigDbWrapper = new TargetGroupConfigDbWrapper();
targetGroupConfigDbWrapper.setAwsConfig(awsTargetGroupConfigDb);
TargetGroup targetGroup = new TargetGroup();
targetGroup.setProviderConfig(targetGroupConfigDbWrapper);
return Set.of(targetGroup);
}
use of com.sequenceiq.cloudbreak.domain.stack.loadbalancer.TargetGroupConfigDbWrapper in project cloudbreak by hortonworks.
the class LoadBalancerConfigConverterTest method testConvertAwsTargetGroupExtraPortsInMetadata.
@Test
public void testConvertAwsTargetGroupExtraPortsInMetadata() {
CloudLoadBalancerMetadata cloudLoadBalancerMetadata = new CloudLoadBalancerMetadata.Builder().withParameters(createAwsParams(3)).build();
TargetGroup targetGroup = new TargetGroup();
targetGroup.setType(TargetGroupType.KNOX);
TargetGroupPortPair portPair1 = new TargetGroupPortPair(PORT1, PORT1);
TargetGroupPortPair portPair2 = new TargetGroupPortPair(PORT2, PORT2);
when(loadBalancerConfigService.getTargetGroupPortPairs(eq(targetGroup))).thenReturn(Set.of(portPair1, portPair2));
TargetGroupConfigDbWrapper targetGroupConfigDbWrapper = underTest.convertTargetGroup(AWS, cloudLoadBalancerMetadata, targetGroup);
assertNotNull(targetGroupConfigDbWrapper.getAwsConfig());
AwsTargetGroupConfigDb awsTargetGroupConfigDb = targetGroupConfigDbWrapper.getAwsConfig();
assertEquals(2, awsTargetGroupConfigDb.getPortArnMapping().size());
assertEquals(Set.of(PORT1, PORT2), awsTargetGroupConfigDb.getPortArnMapping().keySet());
}
Aggregations