Skip to content

Commit

Permalink
Google Java Format
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions authored and doks5 committed Oct 26, 2023
1 parent 366c703 commit 0b914a0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,28 @@ private static DataJobContacts getContactsFromJob(DataJob job) {
return contacts;
}

public static JobDeploymentStatus toJobDeploymentStatus(
ActualDataJobDeployment deploymentStatus) {
JobDeploymentStatus jobDeploymentStatus = new JobDeploymentStatus();

jobDeploymentStatus.setDataJobName(deploymentStatus.getDataJobName());
jobDeploymentStatus.setPythonVersion(deploymentStatus.getPythonVersion());
jobDeploymentStatus.setGitCommitSha(deploymentStatus.getGitCommitSha());
jobDeploymentStatus.setEnabled(deploymentStatus.getEnabled());
jobDeploymentStatus.setLastDeployedBy(deploymentStatus.getLastDeployedBy());
jobDeploymentStatus.setLastDeployedDate(
deploymentStatus.getLastDeployedDate() == null
? null
: deploymentStatus.getLastDeployedDate().toString());
jobDeploymentStatus.setResources(getResourcesFromDeployment(deploymentStatus));
// The ActualDataJobDeployment does not have a mode attribute, which is required by the
// JobDeploymentStatus,
// so we need to set something in order to avoid errors.
jobDeploymentStatus.setMode("release");

return jobDeploymentStatus;
}

private static DataJobResources getResourcesFromDeployment(ActualDataJobDeployment deployment) {
DataJobResources resources = new DataJobResources();
var deploymentResources = deployment.getResources();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@

package com.vmware.taurus.service.graphql;

import com.vmware.taurus.controlplane.model.data.DataJobResources;
import com.vmware.taurus.datajobs.DeploymentModelConverter;
import com.vmware.taurus.datajobs.ToApiModelConverter;
import com.vmware.taurus.service.model.ActualDataJobDeployment;
import com.vmware.taurus.service.model.DataJobDeploymentResources;
import com.vmware.taurus.service.deploy.DeploymentServiceV2;
import com.vmware.taurus.service.repository.JobsRepository;
import com.vmware.taurus.service.repository.ActualJobDeploymentRepository;
import com.vmware.taurus.service.deploy.DataJobDeploymentPropertiesConfig;
Expand Down Expand Up @@ -56,8 +55,8 @@ public class GraphQLDataFetchers {
private final JobsRepository jobsRepository;
private final DeploymentService deploymentService;
private final ExecutionDataFetcher executionDataFetcher;
private final ActualJobDeploymentRepository actualJobDeploymentRepository;
private final DataJobDeploymentPropertiesConfig dataJobDeploymentPropertiesConfig;
private final DeploymentServiceV2 deploymentServiceV2;

public DataFetcher<Object> findAllAndBuildDataJobPage() {
return dataFetchingEnvironment -> {
Expand Down Expand Up @@ -242,42 +241,13 @@ private Map<String, JobDeploymentStatus> readJobDeploymentsFromK8s() {
}

private Map<String, JobDeploymentStatus> readJobDeploymentsFromDb() {
var deployments =
StreamSupport.stream(actualJobDeploymentRepository.findAll().spliterator(), false)
.collect(Collectors.toMap(ActualDataJobDeployment::getDataJobName, cronjob -> cronjob));

return deployments.entrySet().stream()
return deploymentServiceV2.findAllActualDataJobDeployments().entrySet().stream()
.collect(
Collectors.toMap(
Map.Entry::getKey, entry -> convertToJobDeploymentStatus(entry.getValue())));
Map.Entry::getKey, entry -> DeploymentModelConverter.toJobDeploymentStatus(entry.getValue())));
}

private JobDeploymentStatus convertToJobDeploymentStatus(
ActualDataJobDeployment deploymentStatus) {
JobDeploymentStatus jobDeploymentStatus = new JobDeploymentStatus();
jobDeploymentStatus.setDataJobName(deploymentStatus.getDataJobName());
jobDeploymentStatus.setPythonVersion(deploymentStatus.getPythonVersion());
jobDeploymentStatus.setGitCommitSha(deploymentStatus.getGitCommitSha());
jobDeploymentStatus.setEnabled(deploymentStatus.getEnabled());
jobDeploymentStatus.setLastDeployedBy(deploymentStatus.getLastDeployedBy());
jobDeploymentStatus.setLastDeployedDate(deploymentStatus.getLastDeployedDate().toString());
jobDeploymentStatus.setResources(getDataJobResources(deploymentStatus.getResources()));
// The ActualDataJobDeployment does not have a mode attribute, which is required by the
// JobDeploymentStatus,
// so we need to set something in order to avoid errors.
jobDeploymentStatus.setMode("release");

return jobDeploymentStatus;
}

private DataJobResources getDataJobResources(DataJobDeploymentResources deploymentResources) {
DataJobResources resources = new DataJobResources();
resources.setCpuLimit(deploymentResources.getCpuLimitCores());
resources.setCpuRequest(deploymentResources.getCpuRequestCores());
resources.setMemoryLimit(deploymentResources.getMemoryLimitMi());
resources.setMemoryRequest(deploymentResources.getMemoryRequestMi());
return resources;
}

private static DataJobPage buildResponse(int pageSize, int count, List pageList) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,7 @@ void testPopulateDeployments_readFromDB() throws Exception {
assertThat(job4.getDeployments()).hasSize(1);
assertThat(job4.getDeployments().get(0).getLastExecutionStatus())
.isEqualTo(DataJobExecution.StatusEnum.SUCCEEDED);
assertThat(job4.getDeployments().get(0).getLastExecutionTime())
.isNull();
assertThat(job4.getDeployments().get(0).getLastExecutionTime()).isNull();
assertThat(job4.getDeployments().get(0).getLastExecutionDuration()).isEqualTo(0);
assertThat(job4.getDeployments().get(0).getJobPythonVersion()).isEqualTo("3.9-secure");
}
Expand Down

0 comments on commit 0b914a0

Please sign in to comment.