Example 7. Remote run



When we send a local function to execute on remote nodes, we don't need to worry about all the dependent function definitions or the data that are needed. They are automatically sent over to the remote nodes.


In this example we have 3 function definitions: job1, job2, and job3. Job3 calls job2, and job2 calls job1.



def job1(x){

       sleep(5000)

       return x.sum()

}

def job2(x, y){

       job1_ID = submitJob("job1_ID","",job1{x})

       sleep(4000)

       job1result=getJobReturn(job1_ID,true)

       return job1result + y.sum()

}

def job3(x, y, z){

       job2_ID = submitJob("job2_ID","",job2{x,y})

       sleep(3000)

       job2result=getJobReturn(job2_ID,true)

       return job2result + z.sum()

}


x=[1,2]

y=[1,2,3]

z=[1,2,3,4]

job3_ID = rpc("174-node1", submitJob{"job3_ID", "remote run", job3{x,y,z}})

rpc("174-node1", getJobReturn{job3_ID,true});



In the second-to-last line where we use function rpc to execute remote run, the following information are automatically sent over to the remote nodes:

Download source code here.