public class JobMaster
extends java.lang.Object
It can be started in two different modes: Threaded and Blocking
If the user calls: startJobMasterThreaded() It starts as a Thread and the call to this method returns
If the user calls: startJobMasterBlocking() It uses the calling thread and this call does not return unless the JobMaster completes
JobMaster to Dashboard messaging JobMaster reports to Dashboard server when dashboard address is provided in the config If dashboard host address is not provided, it does not try to connect to dashboard server
Modifier and Type | Class and Description |
---|---|
class |
JobMaster.ServerConnectHandler |
Modifier and Type | Field and Description |
---|---|
static int |
JOB_MASTER_ID
an id to be used when comminicating with workers and the client
|
Constructor and Description |
---|
JobMaster(Config config,
java.lang.String jmAddress,
IJobTerminator jobTerminator,
JobAPI.Job job,
JobMasterAPI.NodeInfo nodeInfo,
IScalerPerCluster clusterScaler,
JobMasterAPI.JobMasterState initialState)
JobMaster constructor to create a job master, the port of job master is read from config
file
|
JobMaster(Config config,
java.lang.String jmAddress,
int port,
IJobTerminator jobTerminator,
JobAPI.Job job,
JobMasterAPI.NodeInfo nodeInfo,
IScalerPerCluster clusterScaler,
JobMasterAPI.JobMasterState initialState)
JobMaster constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addShutdownHook(boolean clearK8sJobResourcesOnKill)
A job can be terminated in two ways:
a) workers end a job: workers either successfully complete or fail
all workers complete their work and send COMPLETED messages to the Job Master.
|
void |
endJob(JobAPI.JobState finalState1)
this method finishes the job
It is executed when the worker completed message received from all workers
|
IDriver |
getDriver() |
JMWorkerHandler |
getWorkerHandler() |
ZKMasterController |
getZkMasterController() |
void |
jmFailed()
this method is called when JobMaster fails because of some uncaught exception
ıt is called by the JobMasterStarter program
It closes all threads started by JM
It marks its state at ZK persistent storage as FAILED
|
java.lang.Thread |
startDriverThread()
start Driver in a Thread
|
void |
startJobMasterBlocking()
start the Job Master in a blocking call
|
java.lang.Thread |
startJobMasterThreaded()
start the Job Master in a Thread
|
public static final int JOB_MASTER_ID
public JobMaster(Config config, java.lang.String jmAddress, int port, IJobTerminator jobTerminator, JobAPI.Job job, JobMasterAPI.NodeInfo nodeInfo, IScalerPerCluster clusterScaler, JobMasterAPI.JobMasterState initialState)
config
- configurationjmAddress
- master hostport
- the port numberjobTerminator
- terminatorjob
- the job in proto formatnodeInfo
- node info of masterpublic JobMaster(Config config, java.lang.String jmAddress, IJobTerminator jobTerminator, JobAPI.Job job, JobMasterAPI.NodeInfo nodeInfo, IScalerPerCluster clusterScaler, JobMasterAPI.JobMasterState initialState)
config
- configurationjmAddress
- master hostjobTerminator
- terminatorjob
- the job in proto formatnodeInfo
- node info of masterpublic java.lang.Thread startJobMasterThreaded() throws Twister2Exception
Twister2Exception
public void startJobMasterBlocking() throws Twister2Exception
Twister2Exception
public java.lang.Thread startDriverThread()
public ZKMasterController getZkMasterController()
public JMWorkerHandler getWorkerHandler()
public void jmFailed()
public void endJob(JobAPI.JobState finalState1)
public void addShutdownHook(boolean clearK8sJobResourcesOnKill)
In this case, it can either clear job resources on k8s or does not based on the parameter that is provided when the shut down hook is registered. If the job master runs in the client, it should clear k8s resources, because the job is ended by killing JM process. when the job master runs in the cluster, it should not clear resources. The resources should be cleared by the twister2 client.
public IDriver getDriver()