use of com.baidu.hugegraph.computer.k8s.crd.model.HugeGraphComputerJob in project hugegraph-computer by hugegraph.
the class ComputerJobDeployer method deploy.
public void deploy(ComputerJobComponent observed) {
HugeGraphComputerJob computerJob = observed.computerJob();
Set<ContainerPort> ports = this.handleConfig(computerJob.getSpec());
ComputerJobComponent desired = new ComputerJobComponent();
desired.configMap(this.desiredConfigMap(computerJob));
desired.masterJob(this.desiredMasterJob(computerJob, ports));
desired.workerJob(this.desiredWorkerJob(computerJob, ports));
this.reconcileComponent(computerJob.getMetadata().getNamespace(), desired, observed);
}
use of com.baidu.hugegraph.computer.k8s.crd.model.HugeGraphComputerJob in project hugegraph-computer by hugegraph.
the class ComputerJobController method observeComponent.
private ComputerJobComponent observeComponent(HugeGraphComputerJob computerJob) {
ComputerJobComponent observed = new ComputerJobComponent();
observed.computerJob(computerJob);
String namespace = computerJob.getMetadata().getNamespace();
String crName = computerJob.getMetadata().getName();
String masterName = KubeUtil.masterJobName(crName);
Job master = this.getResourceByName(namespace, masterName, Job.class);
observed.masterJob(master);
if (master != null) {
List<Pod> masterPods = this.getPodsByJob(master);
observed.masterPods(masterPods);
}
String workerName = KubeUtil.workerJobName(crName);
Job worker = this.getResourceByName(namespace, workerName, Job.class);
observed.workerJob(worker);
if (worker != null) {
List<Pod> workerPods = this.getPodsByJob(worker);
observed.workerPods(workerPods);
}
String configMapName = KubeUtil.configMapName(crName);
ConfigMap configMap = this.getResourceByName(namespace, configMapName, ConfigMap.class);
observed.configMap(configMap);
return observed;
}
use of com.baidu.hugegraph.computer.k8s.crd.model.HugeGraphComputerJob in project hugegraph-computer by hugegraph.
the class ComputerJobController method updateStatus.
private boolean updateStatus(ComputerJobComponent observed) {
ComputerJobStatus newStatus = this.derivedCRStatus(observed);
ComputerJobStatus oldStatus = observed.computerJob().getStatus();
if (!Objects.deepEquals(oldStatus, newStatus)) {
HugeGraphComputerJob computerJob = observed.computerJob();
computerJob.setStatus(newStatus);
this.updateStatus(computerJob);
return true;
}
return false;
}
use of com.baidu.hugegraph.computer.k8s.crd.model.HugeGraphComputerJob in project hugegraph-computer by hugegraph.
the class KubernetesDriverTest method testSubmitJob.
@Test
public void testSubmitJob() {
Map<String, String> params = new HashMap<>();
params.put(KubeSpecOptions.WORKER_INSTANCES.name(), "10");
String jobId = this.driver.submitJob("PageRank", params);
HugeGraphComputerJob computerJob = this.operation.withName(KubeUtil.crName(jobId)).get();
Assert.assertNotNull(computerJob);
Assert.assertEquals(computerJob.getSpec().getAlgorithmName(), "PageRank");
Assert.assertEquals(computerJob.getSpec().getJobId(), jobId);
}
use of com.baidu.hugegraph.computer.k8s.crd.model.HugeGraphComputerJob in project hugegraph-computer by hugegraph.
the class KubernetesDriverTest method testCancelJob.
@Test
public void testCancelJob() {
Map<String, String> params = new HashMap<>();
params.put(KubeSpecOptions.WORKER_INSTANCES.name(), "10");
String jobId = this.driver.submitJob("PageRank2", params);
String crName = KubeUtil.crName(jobId);
HugeGraphComputerJob computerJob = this.operation.withName(crName).get();
Assert.assertNotNull(computerJob);
UnitTestBase.sleep(1000L);
this.driver.cancelJob(jobId, params);
HugeGraphComputerJob canceledComputerJob = this.operation.withName(crName).get();
Assert.assertNull(canceledComputerJob);
Assert.assertNull(this.driver.jobState(jobId, params));
}
Aggregations