Search in sources :

Example 1 with JobTerminator

use of edu.iu.dsc.tws.rsched.schedulers.k8s.master.JobTerminator in project twister2 by DSC-SPIDAL.

the class KubernetesLauncher method startJobMasterOnClient.

/**
 * start the JobMaster locally on submitting client
 * this is a blocking call
 * it finishes after the job has completed
 */
private boolean startJobMasterOnClient(JobAPI.Job job) {
    // get Dashboard IP address from dashboard service name
    String dashAddress = JobMasterContext.dashboardHost(config);
    // get the IP address for the service name by querying Kubernetes master
    if (dashAddress.endsWith("svc.cluster.local")) {
        String dashIP = getDashboardIP(dashAddress);
        String dashURL = "http://" + dashIP;
        if (dashIP == null) {
            LOG.warning("Could not get Dashboard server IP address from dashboard service name: " + dashAddress + " will not connect to Dashboard. *****");
            dashURL = null;
        }
        config = JobMasterContext.updateDashboardHost(config, dashURL);
        LOG.info("Dashboard server HTTP URL: " + dashURL);
    }
    String hostAdress = RequestObjectBuilder.getJobMasterIP();
    JobMasterAPI.NodeInfo nodeInfo = NodeInfoUtils.createNodeInfo(hostAdress, null, null);
    K8sScaler k8sScaler = new K8sScaler(config, job, controller);
    JobMasterAPI.JobMasterState initialState = JobMasterAPI.JobMasterState.JM_STARTED;
    JobTerminator jobTerminator = new JobTerminator(config, controller);
    JobMaster jobMaster = new JobMaster(config, hostAdress, jobTerminator, job, nodeInfo, k8sScaler, initialState);
    jobMaster.addShutdownHook(true);
    // jobMaster.startJobMasterThreaded();
    try {
        jobMaster.startJobMasterBlocking();
    } catch (Twister2Exception e) {
        LOG.log(Level.SEVERE, e.getMessage(), e);
        return false;
    }
    return true;
}
Also used : K8sScaler(edu.iu.dsc.tws.rsched.schedulers.k8s.driver.K8sScaler) JobMaster(edu.iu.dsc.tws.master.server.JobMaster) Twister2Exception(edu.iu.dsc.tws.api.exceptions.Twister2Exception) JobMasterAPI(edu.iu.dsc.tws.proto.jobmaster.JobMasterAPI) JobTerminator(edu.iu.dsc.tws.rsched.schedulers.k8s.master.JobTerminator)

Aggregations

Twister2Exception (edu.iu.dsc.tws.api.exceptions.Twister2Exception)1 JobMaster (edu.iu.dsc.tws.master.server.JobMaster)1 JobMasterAPI (edu.iu.dsc.tws.proto.jobmaster.JobMasterAPI)1 K8sScaler (edu.iu.dsc.tws.rsched.schedulers.k8s.driver.K8sScaler)1 JobTerminator (edu.iu.dsc.tws.rsched.schedulers.k8s.master.JobTerminator)1