use of com.sequenceiq.cloudbreak.cloud.model.RegionCoordinateSpecifications in project cloudbreak by hortonworks.
the class AzureRegionProvider method readEnabledRegions.
private Map<Region, Coordinate> readEnabledRegions() {
String displayNames = resourceDefinition();
Map<Region, Coordinate> regionCoordinates = new HashMap<>();
try {
RegionCoordinateSpecifications regionCoordinateSpecifications = JsonUtil.readValue(displayNames, RegionCoordinateSpecifications.class);
for (RegionCoordinateSpecification regionCoordinateSpecification : regionCoordinateSpecifications.getItems()) {
regionCoordinates.put(region(regionCoordinateSpecification.getName()), coordinate(regionCoordinateSpecification.getLongitude(), regionCoordinateSpecification.getLatitude(), findByLabelOrName(regionCoordinateSpecification.getName()).label(), findByLabelOrName(regionCoordinateSpecification.getName()).name(), regionCoordinateSpecification.isK8sSupported(), regionCoordinateSpecification.getEntitlements()));
}
} catch (IOException ignored) {
LOGGER.error("Failed to read enabled Azure regions from file.");
return regionCoordinates;
}
return regionCoordinates;
}
use of com.sequenceiq.cloudbreak.cloud.model.RegionCoordinateSpecifications in project cloudbreak by hortonworks.
the class AwsPlatformResources method readRegionDisplayNames.
private Map<Region, DisplayName> readRegionDisplayNames(String displayNames) {
Map<Region, DisplayName> regionDisplayNames = new HashMap<>();
try {
RegionCoordinateSpecifications regionCoordinateSpecifications = JsonUtil.readValue(displayNames, RegionCoordinateSpecifications.class);
for (RegionCoordinateSpecification regionCoordinateSpecification : regionCoordinateSpecifications.getItems()) {
Region region = region(regionCoordinateSpecification.getName());
if (!enabledRegions.contains(region)) {
continue;
}
regionDisplayNames.put(region, displayName(regionCoordinateSpecification.getDisplayName()));
}
} catch (IOException ignored) {
return regionDisplayNames;
}
return regionDisplayNames;
}
use of com.sequenceiq.cloudbreak.cloud.model.RegionCoordinateSpecifications in project cloudbreak by hortonworks.
the class AwsPlatformResources method readRegionCoordinates.
private Map<Region, Coordinate> readRegionCoordinates(String displayNames) {
Map<Region, Coordinate> regionCoordinates = new HashMap<>();
try {
RegionCoordinateSpecifications regionCoordinateSpecifications = JsonUtil.readValue(displayNames, RegionCoordinateSpecifications.class);
for (RegionCoordinateSpecification regionCoordinateSpecification : regionCoordinateSpecifications.getItems()) {
Region region = region(regionCoordinateSpecification.getName());
if (!enabledRegions.contains(region)) {
continue;
}
Optional<Entry<Region, DisplayName>> regionEntry = regionDisplayNames.entrySet().stream().filter(e -> e.getKey().getRegionName().equalsIgnoreCase(regionCoordinateSpecification.getName())).findFirst();
regionCoordinates.put(region, coordinate(regionCoordinateSpecification.getLongitude(), regionCoordinateSpecification.getLatitude(), regionCoordinateSpecification.getDisplayName(), regionEntry.isPresent() ? regionEntry.get().getKey().value() : regionCoordinateSpecification.getDisplayName(), regionCoordinateSpecification.isK8sSupported(), regionCoordinateSpecification.getEntitlements()));
}
} catch (IOException ignored) {
return regionCoordinates;
}
return regionCoordinates;
}
use of com.sequenceiq.cloudbreak.cloud.model.RegionCoordinateSpecifications in project cloudbreak by hortonworks.
the class AzureRegionProviderTest method assertCoordinates.
private void assertCoordinates(CloudRegions actual) throws IOException {
RegionCoordinateSpecifications regionCoordinateSpecifications = getRegionsFromFile();
Assert.assertTrue(actual.getCoordinates().values().stream().allMatch(coordinate -> regionCoordinateSpecifications.getItems().stream().anyMatch(region -> region.getLatitude().equals(coordinate.getLatitude().toString()) && region.getLongitude().equals(coordinate.getLongitude().toString()))));
}
use of com.sequenceiq.cloudbreak.cloud.model.RegionCoordinateSpecifications in project cloudbreak by hortonworks.
the class AwsPlatformResources method readEnabledRegionsAndAvailabilityZones.
private void readEnabledRegionsAndAvailabilityZones() {
try {
String fileName = resourceDefinition(ENABLED_AVAILABILITY_ZONES_FILE);
RegionsSpecification regionCoordinateSpecifications = JsonUtil.readValue(fileName, RegionsSpecification.class);
enabledRegions = regionCoordinateSpecifications.getItems().stream().map(RegionSpecification::getName).map(Region::region).collect(Collectors.toSet());
enabledAvailabilityZones = regionCoordinateSpecifications.getItems().stream().flatMap(region -> region.getZones().stream()).map(AvailabilityZone::availabilityZone).collect(Collectors.toSet());
} catch (IOException e) {
LOGGER.error("Failed to read enabled AWS regions and availability zones from file.", e);
enabledRegions = new HashSet<>();
enabledAvailabilityZones = new HashSet<>();
}
}
Aggregations