in services/self-service/src/main/java/com/epam/datalab/backendapi/util/BillingUtils.java [149:216]
public static Stream<BillingReportLine> exploratoryBillingDataStream(UserInstanceDTO userInstance, Integer maxSparkInstanceCount) {
final Stream<BillingReportLine> computationalStream = userInstance.getResources()
.stream()
.filter(cr -> cr.getComputationalId() != null)
.flatMap(cr -> {
final String computationalId = getDatalabIdForComputeResources(cr);
return Stream.concat(Stream.of(
withUserProjectEndpoint(userInstance)
.resourceName(cr.getComputationalName())
.datalabId(computationalId)
.resourceType(COMPUTATIONAL)
.shape(getComputationalShape(cr))
.exploratoryName(userInstance.getExploratoryName())
.build(),
withUserProjectEndpoint(userInstance)
.resourceName(cr.getComputationalName())
.datalabId(String.format(VOLUME_PRIMARY_FORMAT, computationalId))
.resourceType(VOLUME)
.build(),
withUserProjectEndpoint(userInstance)
.resourceName(cr.getComputationalName())
.datalabId(String.format(VOLUME_SECONDARY_FORMAT, computationalId))
.resourceType(VOLUME)
.build(),
withUserProjectEndpoint(userInstance)
.resourceName(cr.getComputationalName())
.datalabId(String.format(VOLUME_PRIMARY_COMPUTATIONAL_FORMAT, computationalId, "m"))
.resourceType(VOLUME)
.build(),
withUserProjectEndpoint(userInstance)
.resourceName(cr.getComputationalName())
.datalabId(String.format(VOLUME_SECONDARY_COMPUTATIONAL_FORMAT, computationalId, "m"))
.resourceType(VOLUME)
.build(),
withUserProjectEndpoint(userInstance)
.resourceName(cr.getComputationalName())
.datalabId(String.format(DATA_ENGINE_BUCKET_FORMAT, computationalId))
.resourceType(BUCKET)
.build()
),
getSlaveVolumes(userInstance, cr, maxSparkInstanceCount)
);
});
final String exploratoryName = userInstance.getExploratoryName();
final String exploratoryId = userInstance.getExploratoryId().toLowerCase();
final String primaryVolumeId = String.format(VOLUME_PRIMARY_FORMAT, exploratoryId);
final String secondaryVolumeId = String.format(VOLUME_SECONDARY_FORMAT, exploratoryId);
final Stream<BillingReportLine> exploratoryStream = Stream.of(
withUserProjectEndpoint(userInstance)
.resourceName(exploratoryName)
.datalabId(exploratoryId)
.resourceType(EXPLORATORY)
.shape(userInstance.getShape())
.build(),
withUserProjectEndpoint(userInstance)
.resourceName(exploratoryName)
.datalabId(primaryVolumeId)
.resourceType(VOLUME)
.build(),
withUserProjectEndpoint(userInstance)
.resourceName(exploratoryName)
.datalabId(secondaryVolumeId)
.resourceType(VOLUME)
.build());
return Stream.concat(computationalStream, exploratoryStream);
}