}
public void main(String[] args) throws MsgException {
- Msg.info(this.getName() +" is listenning on MBOX:WRK0"+ number);
+ Msg.info(this.getName() +" is listening on MBOX:WRK0"+ number);
while(true) {
- Task task;
+ Task task =null;
try {
task = Task.receive("MBOX:WRK0"+number);
+ if (task == null)
+ break;
} catch (MsgException e) {
Msg.debug("Received failed. I'm done. See you!");
- break;
}
Msg.info("Received \"" + task.getName() + "\". Processing it.");
- try {
- task.execute();
- } catch (MsgException e) {
- }
+ task.execute();
Msg.info(this.getName() +" executed task (" + task.getName()+")");
}
}
> [ 0.000000] (1:Master@Jacquelin) Launched 2 VMs
> [ 0.000000] (1:Master@Jacquelin) Send a first batch of work to everyone
> [ 0.000000] (1:Master@Jacquelin) Sending to WRK00
-> [ 0.000000] (2:WRK00@VM00) WRK00 is listenning on MBOX:WRK00
-> [ 0.000000] (3:WRK01@VM01) WRK01 is listenning on MBOX:WRK01
+> [ 0.000000] (2:WRK00@VM00) WRK00 is listening on MBOX:WRK00
+> [ 0.000000] (3:WRK01@VM01) WRK01 is listening on MBOX:WRK01
> [ 0.892161] (1:Master@Jacquelin) Sending to WRK01
> [ 0.892161] (2:WRK00@VM00) Received "Task00". Processing it.
> [ 0.892161] (2:WRK00@VM00) WRK00 executed task (Task00)
i++;
}
xbt_dict_cursor_free(&cursor);
- if ((peer_choosed->interested == 0) ||
- (peer_choosed->choked_upload == 0)) {
+ if (peer_choosed == NULL)
+ THROWF(unknown_error, 0, "A peer should have be selected at this point");
+ else if ((peer_choosed->interested == 0) || (peer_choosed->choked_upload == 0))
peer_choosed = NULL;
- }
+ else
+ XBT_DEBUG("Nothing to do, keep going");
j++;
} while (peer_choosed == NULL && j < MAXIMUM_PAIRS);
} else {
super(host,name,args);
}
public void main(String[] args) {
- while (true) {
+ boolean stillAlive = true;
+ while (stillAlive) {
Msg.info("I'm not dead");
try {
Process.sleep(10);
+ stillAlive = true;
} catch (HostFailureException e) {
+ stillAlive = false;
Msg.info("catch HostException: "+e.getLocalizedMessage());
- break; //Break is needed to finalize the endless loop
}
}
}