submitJob

Parent Previous Next


语法


submitJob(jobId, jobDesc, jobDef, args...)


参数


jobId 是作业的ID,是字符串类型。


jobDesc是字符串,用于描述作业。


function是要发送给远程节点的本地函数。请注意,这不是函数名,因此我们不能用单引号、双引号或反引号。


args...是函数的参数。如果函数没有参数,它可以不指定。


详情


把批处理作业提交到本地节点并且返回作业的ID。如果要把批处理作业提交到远程节点,需要用submitJob中的rpcremoteRun函数。详情请参考批处理作业


例子




def jobDemo(n){

 s = 0

 for (x in 1 : n) {

   s += sum(sin rand(1.0, 100000000)-0.5)

   print("iteration " + x + " " + s)

 }

 return s

};


>submitJob("jobDemo1","job demo", jobDemo, 100);


>getJobStatus("jobDemo1");

Node      UserID JobID    JobDesc  ReceivedTime            StartTime               EndTime ErrorMsg

--------- ------ -------- -------- ----------------------- ----------------------- ------- --------

local8848 root   jobDemo1 job demo 2017.11.15T18:30:33.796 2017.11.15T18:30:33.797



在作业的状态中,EndTime是空的。这意味着作业还在执行中。作业完成后,就能在状态中看到EndTime



>getJobStatus("jobDemo1");

Node      UserID JobID    JobDesc  ReceivedTime            StartTime               EndTime                 ErrorMsg

--------- ------ -------- -------- ----------------------- ----------------------- ----------------------- --------

local8848 root   jobDemo1 job demo 2017.11.15T18:30:33.796 2017.11.15T18:30:33.797 2017.11.15T18:32:07.716


>getJobMessage("jobDemo1");

2017-11-15 18:30:33.797633 Start the job [jobDemo1]: job demo

2017-11-15 18:30:34.948370 iteration 1 -1438.322956

2017-11-15 18:30:35.923530 iteration 2 2723.163483

2017-11-15 18:30:36.872376 iteration 3 8195.850153

2017-11-15 18:30:37.928429 iteration 4 6623.126384

2017-11-15 18:30:38.881091 iteration 5 6303.866945

.......

2017-11-15 18:32:04.915599 iteration 96 -4365.382804

2017-11-15 18:32:05.830000 iteration 97 -9324.694797

2017-11-15 18:32:06.745985 iteration 98 -7746.157029

2017-11-15 18:32:07.716094 iteration 99 -4291.91147

2017-11-15 18:32:07.716597 The job is done.


>getJobReturn("jobDemo1");

-4291.91147


>submitJob("jobDemo2",, jobDemo, 10);

jobDemo2


> (10);

Node      UserID JobID    JobDesc  ReceivedTime            StartTime               EndTime                 ErrorMsg

--------- ------ -------- -------- ----------------------- ----------------------- ----------------------- --------

local8848 root   jobDemo1 job demo 2017.11.15T18:30:33.796 2017.11.15T18:30:33.797 2017.11.15T18:32:07.716

local8848 root   jobDemo2 jobDemo  2017.11.15T18:44:51.388 2017.11.15T18:44:51.389 2017.11.15T18:44:59.817




使用rpc函数("DFS_NODE2"与本地节点在同一集群):



def jobDemo(n){

 s = 0

 for (x in 1 : n) {

   s += sum(sin rand(1.0, 100000000)-0.5)

   print("iteration " + x + " " + s)

 }

 return s

};


rpc("DFS_NODE2", submitJob, "jobDemo3", "job demo", jobDemo, 10);

Output: jobDemo3


rpc("DFS_NODE2", getJobReturn, "jobDemo3")

Output: -3426.577521



使用remoteRun函数:



conn = xdb("DFS_NODE2")  

conn.remoteRun(submitJob, "jobDemo4", "job demo", jobDemo, 10);

Output: jobDemo4


conn.remoteRun(getJobReturn, "jobDemo4")

Output: 4238.832005