use of com.epam.pipeline.entity.cluster.PipelineRunPrice in project cloud-pipeline by epam.
the class InstanceOfferManager method getPipelineRunEstimatedPrice.
public PipelineRunPrice getPipelineRunEstimatedPrice(Long runId, Long regionId) {
PipelineRun pipelineRun = pipelineRunManager.loadPipelineRun(runId);
RunInstance runInstance = pipelineRun.getInstance();
AwsRegion region = awsRegionManager.loadRegionOrGetDefault(regionId);
double pricePerHourForInstance = getPricePerHourForInstance(runInstance.getNodeType(), isSpotRequest(runInstance.getSpot()), region.getAwsRegionName());
double pricePerDisk = getPriceForDisk(runInstance.getNodeDisk(), region.getAwsRegionName());
double pricePerHour = pricePerDisk + pricePerHourForInstance;
PipelineRunPrice price = new PipelineRunPrice();
price.setInstanceDisk(runInstance.getNodeDisk());
price.setInstanceType(runInstance.getNodeType());
price.setPricePerHour(pricePerHour);
if (pipelineRun.getStatus().isFinal()) {
long duration = pipelineRun.getEndDate().getTime() - pipelineRun.getStartDate().getTime();
price.setTotalPrice(duration / ONE_HOUR * pricePerHour);
} else {
price.setTotalPrice(0);
}
return price;
}
Aggregations