You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dlab.apache.org by bh...@apache.org on 2019/11/12 10:16:51 UTC
[incubator-dlab] 03/04: Code review
This is an automated email from the ASF dual-hosted git repository.
bhliva pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git
commit adcaa4b3b29913114f598361f0190f6726534c26
Author: Oleh Fuks <ol...@gmail.com>
AuthorDate: Mon Nov 11 17:09:41 2019 +0200
Code review
---
.../azure/AzureBillableResourcesService.java | 29 ++++++++++++----------
1 file changed, 16 insertions(+), 13 deletions(-)
diff --git a/services/billing-azure/src/main/java/com/epam/dlab/billing/azure/AzureBillableResourcesService.java b/services/billing-azure/src/main/java/com/epam/dlab/billing/azure/AzureBillableResourcesService.java
index fa3a518..ae9ff1c 100644
--- a/services/billing-azure/src/main/java/com/epam/dlab/billing/azure/AzureBillableResourcesService.java
+++ b/services/billing-azure/src/main/java/com/epam/dlab/billing/azure/AzureBillableResourcesService.java
@@ -159,25 +159,28 @@ public class AzureBillableResourcesService {
}
private Set<AzureDlabBillableResource> getEdgeAndStorageAccount() {
- Set<AzureDlabBillableResource> billableResources = new HashSet<>();
-
Map<String, List<Document>> projectEndpoints = StreamSupport.stream(mongoDbBillingClient.getDatabase()
.getCollection("Projects").find().spliterator(), false)
.collect(Collectors.toMap(key -> key.getString("name").toLowerCase(),
value -> (List<Document>) value.get("endpoints")));
- projectEndpoints.forEach((key, value) -> value.forEach(endpoint -> {
- try {
- billableResources.addAll(getEdgeAndStorageAccount(key, objectMapper.readValue(
- objectMapper.writeValueAsString(endpoint.get("edgeInfo")),
- new com.fasterxml.jackson.core.type.TypeReference<EdgeInfoAzure>() {
- })));
- } catch (IOException ex) {
- log.error("Error during preparation of billable resources", ex);
- }
- }));
+ Set<AzureDlabBillableResource> edgeInfo = projectEndpoints.entrySet()
+ .stream()
+ .flatMap(e -> e.getValue().stream().map(endpoint -> {
+ try {
+ return getEdgeAndStorageAccount(e.getKey(), objectMapper.readValue(objectMapper.writeValueAsString(endpoint.get("edgeInfo")),
+ new com.fasterxml.jackson.core.type.TypeReference<EdgeInfoAzure>() {
+ }));
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ return null;
+ }))
+ .filter(Objects::nonNull)
+ .flatMap(Set::stream)
+ .collect(Collectors.toSet());
- return billableResources;
+ return new HashSet<>(edgeInfo);
}
private Set<AzureDlabBillableResource> getEdgeAndStorageAccount(String projectName, EdgeInfoAzure edgeInfoAzure) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@dlab.apache.org
For additional commands, e-mail: commits-help@dlab.apache.org