In this page you can see the three methods that implements a REJO agent:
public reactive shell(Program
handSusp, Program handResume)
{
Object[] obj;
local("step")
until( locName() + "!kill" )
par
{
loop
until(
locName() + "!susp")
loop{
gen
"step";
stop;}
handler{
call
handSusp;
stop;
wait
locName() + "!resume";
call
handResume;
}
||
control("step"){
par
{
freezable(
locName() + "!migra" )
call
body();
||
loop{
wait
locName() + "!migra", obj;
if(
migrateTo(obj) )
gen
locName() + "!kill";
else
gen
locName() + "!reload";
stop;
}
||
wait
locName() + "!reload";
run
reLoad();
}
}
}
handler
call handTermin();
}
public boolean migrateTo(Object[]
obj) if( obj.length < 2 ){ Program res = ros.unLoad( locName() + "!migra"
); try{
return true;
{
String dest="", nameRos="";
System.out.println(" Unknown
address ");
return false;
} else {
dest = (String)obj[0];
nameRos = (String)obj[1];
}
if( res == null){
System.out.println(" Empty
program ");
return false;
}
setBody( res );
setMigra(true);
MigrationServ SendingThe = (MigrationServ)lookup("//"+dest+"/MigrationServAt
"+ nameRos );
if( SendingThe.Agent(rejo) )
return false;
}catch(Exception e) {
System.out.println("\n Migration
Error of "+locName() + " To "+ dest +" "+ nameRos
+"\n");
System.out.println(" "+
e.getMessage());
e.printStackTrace();
return false;
}
}
public reactive reLoad()
{
par
{
setMigra(false);
freezable( locName() + "!migra"
){
call handWarmUp();
call body();
}
||
stop;
wait locName() + "!reload";
run reLoad();
}
}
}