This is an automated email from the ASF dual-hosted git repository.
dyankiv pushed a commit to branch DATALAB-3082
in repository https://gitbox.apache.org/repos/asf/incubator-datalab.git
The following commit(s) were added to refs/heads/DATALAB-3082 by this push:
new 7cac38307 change datalab_id for hdinsight billing
7cac38307 is described below
commit 7cac3830787a67cb272b027b10c106dccbc4baec
Author: Denys Yankiv <[email protected]>
AuthorDate: Tue Nov 1 17:23:56 2022 +0200
change datalab_id for hdinsight billing
---
.../epam/datalab/backendapi/util/BillingUtils.java | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git
a/services/self-service/src/main/java/com/epam/datalab/backendapi/util/BillingUtils.java
b/services/self-service/src/main/java/com/epam/datalab/backendapi/util/BillingUtils.java
index 7eb19ba55..c2ec21a1c 100644
---
a/services/self-service/src/main/java/com/epam/datalab/backendapi/util/BillingUtils.java
+++
b/services/self-service/src/main/java/com/epam/datalab/backendapi/util/BillingUtils.java
@@ -151,7 +151,7 @@ public class BillingUtils {
.stream()
.filter(cr -> cr.getComputationalId() != null)
.flatMap(cr -> {
- final String computationalId =
cr.getComputationalId().toLowerCase();
+ final String computationalId =
getDatalabIdForComputeResources(cr);
return Stream.concat(Stream.of(
withUserProjectEndpoint(userInstance)
.resourceName(cr.getComputationalName())
@@ -227,12 +227,23 @@ public class BillingUtils {
);
}
+ /**
+ For HDInsight computational_id begins with random id
+ which differs from datalab_id tag
+ */
+ private static String
getDatalabIdForComputeResources(UserComputationalResource cr){
+ if(cr.getTemplateName().equals("HDInsight cluster")){
+ return cr.getComputationalId().toLowerCase().substring(7);
+ }
+ return cr.getComputationalId().toLowerCase();
+ }
+
private static Stream<BillingReportLine> getSlaveVolumes(UserInstanceDTO
userInstance, UserComputationalResource cr, Integer maxSparkInstanceCount) {
List<BillingReportLine> list = new ArrayList<>();
for (int i = 1; i <= maxSparkInstanceCount; i++) {
-
list.add(withUserProjectEndpoint(userInstance).resourceName(cr.getComputationalName()).datalabId(String.format(VOLUME_PRIMARY_COMPUTATIONAL_FORMAT,
cr.getComputationalId().toLowerCase(), "s" + i))
+
list.add(withUserProjectEndpoint(userInstance).resourceName(cr.getComputationalName()).datalabId(String.format(VOLUME_PRIMARY_COMPUTATIONAL_FORMAT,
getDatalabIdForComputeResources(cr), "s" + i))
.resourceType(VOLUME).build());
-
list.add(withUserProjectEndpoint(userInstance).resourceName(cr.getComputationalName()).datalabId(String.format(VOLUME_SECONDARY_COMPUTATIONAL_FORMAT,
cr.getComputationalId().toLowerCase(), "s" + i))
+
list.add(withUserProjectEndpoint(userInstance).resourceName(cr.getComputationalName()).datalabId(String.format(VOLUME_SECONDARY_COMPUTATIONAL_FORMAT,
getDatalabIdForComputeResources(cr), "s" + i))
.resourceType(VOLUME).build());
}
return list.stream();
@@ -319,7 +330,7 @@ public class BillingUtils {
*/
public static String getHeader(boolean isReportHeaderCompletable) {
if (!isReportHeaderCompletable) {
- return
CSVFormatter.formatLine(Arrays.asList(BillingUtils.BILLING_FILTERED_REPORT_HEADERS),
CSVFormatter.SEPARATOR);
+ return CSVFormatter.formatLine(Arrays.asList(BillingUtils.m),
CSVFormatter.SEPARATOR);
}
return
CSVFormatter.formatLine(Arrays.asList(BillingUtils.COMPLETE_REPORT_REPORT_HEADERS),
CSVFormatter.SEPARATOR);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]