Search in sources :

Example 11 with HugeGraphComputerJob

use of com.baidu.hugegraph.computer.k8s.crd.model.HugeGraphComputerJob in project hugegraph-computer by hugegraph.

the class KubernetesDriver method submitJob.

@Override
public String submitJob(String algorithmName, Map<String, String> params) {
    HugeGraphComputerJob computerJob = new HugeGraphComputerJob();
    String jobId = KubeUtil.genJobId(algorithmName);
    String crName = KubeUtil.crName(jobId);
    ObjectMeta meta = new ObjectMetaBuilder().withNamespace(this.namespace).withName(crName).build();
    computerJob.setMetadata(meta);
    ComputerJobSpec spec = this.computerJobSpec(this.defaultSpec, params);
    Map<String, String> computerConf = this.computerConf(this.defaultConf, params);
    this.checkComputerConf(computerConf, spec);
    spec.withAlgorithmName(algorithmName).withJobId(jobId).withComputerConf(computerConf);
    if (this.enableInternalAlgorithm && this.internalAlgorithms.contains(algorithmName)) {
        spec.withImage(this.internalAlgorithmImageUrl);
    } else if (StringUtils.isNotBlank(spec.getRemoteJarUri())) {
        spec.withImage(this.frameworkImageUrl);
    } else {
        String imageUrl = this.buildImageUrl(algorithmName);
        String jarFileDir = this.conf.get(KubeDriverOptions.JAR_FILE_DIR);
        String jarFile = this.buildJarFile(jarFileDir, algorithmName);
        spec.withImage(imageUrl).withJarFile(jarFile);
    }
    computerJob.setSpec(spec);
    this.operation.createOrReplace(computerJob);
    return jobId;
}
Also used : ObjectMeta(io.fabric8.kubernetes.api.model.ObjectMeta) ComputerJobSpec(com.baidu.hugegraph.computer.k8s.crd.model.ComputerJobSpec) HugeGraphComputerJob(com.baidu.hugegraph.computer.k8s.crd.model.HugeGraphComputerJob) ObjectMetaBuilder(io.fabric8.kubernetes.api.model.ObjectMetaBuilder)

Example 12 with HugeGraphComputerJob

use of com.baidu.hugegraph.computer.k8s.crd.model.HugeGraphComputerJob in project hugegraph-computer by hugegraph.

the class KubernetesDriver method jobState.

@Override
public JobState jobState(String jobId, Map<String, String> params) {
    String crName = KubeUtil.crName(jobId);
    HugeGraphComputerJob computerJob = this.operation.withName(crName).get();
    if (computerJob == null) {
        return null;
    }
    return this.buildJobState(computerJob);
}
Also used : HugeGraphComputerJob(com.baidu.hugegraph.computer.k8s.crd.model.HugeGraphComputerJob)

Aggregations

HugeGraphComputerJob (com.baidu.hugegraph.computer.k8s.crd.model.HugeGraphComputerJob)12 Test (org.junit.Test)4 ComputerJobSpec (com.baidu.hugegraph.computer.k8s.crd.model.ComputerJobSpec)3 HashMap (java.util.HashMap)3 ComputerJobStatus (com.baidu.hugegraph.computer.k8s.crd.model.ComputerJobStatus)2 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)2 Job (io.fabric8.kubernetes.api.model.batch.v1.Job)2 DefaultJobState (com.baidu.hugegraph.computer.driver.DefaultJobState)1 JobObserver (com.baidu.hugegraph.computer.driver.JobObserver)1 CommonComponentState (com.baidu.hugegraph.computer.k8s.crd.model.CommonComponentState)1 ComponentState (com.baidu.hugegraph.computer.k8s.crd.model.ComponentState)1 ComponentStateBuilder (com.baidu.hugegraph.computer.k8s.crd.model.ComponentStateBuilder)1 JobComponentState (com.baidu.hugegraph.computer.k8s.crd.model.JobComponentState)1 ContainerPort (io.fabric8.kubernetes.api.model.ContainerPort)1 ObjectMeta (io.fabric8.kubernetes.api.model.ObjectMeta)1 ObjectMetaBuilder (io.fabric8.kubernetes.api.model.ObjectMetaBuilder)1 Pod (io.fabric8.kubernetes.api.model.Pod)1 WatcherException (io.fabric8.kubernetes.client.WatcherException)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 MutableBoolean (org.apache.commons.lang3.mutable.MutableBoolean)1