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){


       return x.sum()


def job2(x, y){

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



       return job1result + y.sum()


def job3(x, y, z){

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



       return job2result + z.sum()





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.