This is an automated email from the ASF dual-hosted git repository.
ofuks pushed a commit to branch DLAB-1571
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git
The following commit(s) were added to refs/heads/DLAB-1571 by this push:
new eae5b35 Remote billing
eae5b35 is described below
commit eae5b354d38f3c8e21f4d7c547986e0d80fb958f
Author: Oleh Fuks <[email protected]>
AuthorDate: Thu Mar 26 17:37:30 2020 +0200
Remote billing
---
.../dlab/backendapi/service/impl/BillingServiceImplNew.java | 7 +++++--
.../main/java/com/epam/dlab/backendapi/util/BillingUtils.java | 11 ++++++++---
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git
a/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/BillingServiceImplNew.java
b/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/BillingServiceImplNew.java
index 0f26d32..d922461 100644
---
a/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/BillingServiceImplNew.java
+++
b/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/BillingServiceImplNew.java
@@ -138,8 +138,11 @@ public class BillingServiceImplNew implements
BillingServiceNew {
.entrySet()
.stream()
.flatMap(e -> projectEdges(serviceBaseName, e.getKey(),
e.getValue()));
+ final Stream<BillingReportLine> billableSharedEndpoints =
endpointService.getEndpoints()
+ .stream()
+ .flatMap(endpoint ->
BillingUtils.sharedEndpointBillingDataStream(endpoint.getName(),
serviceBaseName));
- final Map<String, BillingReportLine> billableResources =
Stream.of(billableUserInstances, billableEdges, ssnBillingDataStream)
+ final Map<String, BillingReportLine> billableResources =
Stream.of(billableUserInstances, billableEdges, ssnBillingDataStream,
billableSharedEndpoints)
.flatMap(s -> s)
.collect(Collectors.toMap(BillingReportLine::getDlabId, b ->
b));
log.debug("Billable resources are: {}", billableResources);
@@ -217,7 +220,7 @@ public class BillingServiceImplNew implements
BillingServiceNew {
return s.get();
} catch (InterruptedException | ExecutionException e) {
log.error("Cannot retrieve billing information {}",
e.getMessage(), e);
- throw new DlabException("Cannot retrieve billing information");
+ return Collections.emptyList();
}
}
diff --git
a/services/self-service/src/main/java/com/epam/dlab/backendapi/util/BillingUtils.java
b/services/self-service/src/main/java/com/epam/dlab/backendapi/util/BillingUtils.java
index 33b83fd..d8e230a 100644
---
a/services/self-service/src/main/java/com/epam/dlab/backendapi/util/BillingUtils.java
+++
b/services/self-service/src/main/java/com/epam/dlab/backendapi/util/BillingUtils.java
@@ -61,13 +61,11 @@ public class BillingUtils {
final String userEdgeId = String.format(EDGE_FORMAT, sbn,
project.toLowerCase(), endpoint);
final String edgeVolumeId = String.format(EDGE_VOLUME_FORMAT, sbn,
project.toLowerCase(), endpoint);
final String endpointBucketId =
String.format(PROJECT_ENDPOINT_BUCKET_FORMAT, sbn, project.toLowerCase(),
endpoint);
- final String projectEndpointBucketId =
String.format(ENDPOINT_SHARED_BUCKET_FORMAT, sbn, endpoint);
return Stream.of(
BillingReportLine.builder().resourceName("EDGE
node").user(SHARED_RESOURCE).project(project).dlabId(userEdgeId).resourceType(BillingResourceType.EDGE).status(UserInstanceStatus.of(status)).build(),
BillingReportLine.builder().resourceName("EDGE
volume").user(SHARED_RESOURCE).project(project).dlabId(edgeVolumeId).resourceType(BillingResourceType.VOLUME).build(),
- BillingReportLine.builder().resourceName("Project endpoint
shared
bucket").user(SHARED_RESOURCE).project(project).dlabId(endpointBucketId).resourceType(BillingResourceType.BUCKET).build(),
- BillingReportLine.builder().resourceName("Endpoint shared
bucket").user(SHARED_RESOURCE).project(SHARED_RESOURCE).dlabId(projectEndpointBucketId).resourceType(BillingResourceType.BUCKET).build()
+ BillingReportLine.builder().resourceName("Project endpoint
shared
bucket").user(SHARED_RESOURCE).project(project).dlabId(endpointBucketId).resourceType(BillingResourceType.BUCKET).build()
);
}
@@ -79,6 +77,13 @@ public class BillingUtils {
);
}
+ public static Stream<BillingReportLine>
sharedEndpointBillingDataStream(String endpoint, String sbn) {
+ final String projectEndpointBucketId =
String.format(ENDPOINT_SHARED_BUCKET_FORMAT, sbn, endpoint.toLowerCase());
+ return Stream.of(
+ BillingReportLine.builder().resourceName("Endpoint shared
bucket").user(SHARED_RESOURCE).project(SHARED_RESOURCE).dlabId(projectEndpointBucketId).resourceType(BillingResourceType.BUCKET).build()
+ );
+ }
+
public static Stream<BillingReportLine>
exploratoryBillingDataStream(UserInstanceDTO userInstance, Integer
maxSparkInstanceCount) {
final Stream<BillingReportLine> computationalStream =
userInstance.getResources()
.stream()
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]