}
}
}
- this.hostname = host.getName();
+ this.hostname = getHost().getName();
}
/**
* Retrieves the peer list from the tracker
// is my successor the successor?
if (isInInterval(fTask.requestId, this.id + 1, fingers[0])) {
//Msg.info("Send the request to " + fTask.answerTo + " with answer " + fingers[0]);
- FindSuccessorAnswerTask answer = new FindSuccessorAnswerTask(host.getName(), mailbox, fingers[0]);
+ FindSuccessorAnswerTask answer = new FindSuccessorAnswerTask(getHost().getName(), mailbox, fingers[0]);
answer.dsend(fTask.answerTo);
}
else {
else if (task instanceof GetPredecessorTask) {
GetPredecessorTask gTask = (GetPredecessorTask)(task);
Msg.debug("Receiving a 'Get Predecessor' request from " + gTask.issuerHostName);
- GetPredecessorAnswerTask answer = new GetPredecessorAnswerTask(host.getName(), mailbox, predId);
+ GetPredecessorAnswerTask answer = new GetPredecessorAnswerTask(getHost().getName(), mailbox, predId);
answer.dsend(gTask.answerTo);
}
else if (task instanceof NotifyTask) {
boolean stop = false;
Msg.debug("Sending a 'Get Predecessor' request to " + askTo);
String mailboxTo = Integer.toString(askTo);
- GetPredecessorTask sendTask = new GetPredecessorTask(host.getName(), this.mailbox);
+ GetPredecessorTask sendTask = new GetPredecessorTask(getHost().getName(), this.mailbox);
try {
sendTask.send(mailboxTo, Common.TIMEOUT);
try {
int successor = -1;
boolean stop = false;
String mailbox = Integer.toString(askTo);
- Task sendTask = new FindSuccessorTask(host.getName(), this.mailbox, id);
+ Task sendTask = new FindSuccessorTask(getHost().getName(), this.mailbox, id);
Msg.debug("Sending a 'Find Successor' request to " + mailbox + " for id " + id);
try {
sendTask.send(mailbox, Common.TIMEOUT);
*/
void remoteNotify(int notifyId, int predecessorCandidateId) {
Msg.debug("Sending a 'Notify' request to " + notifyId);
- Task sentTask = new NotifyTask(host.getName(), this.mailbox, predecessorCandidateId);
+ Task sentTask = new NotifyTask(getHost().getName(), this.mailbox, predecessorCandidateId);
sentTask.dsend(Integer.toString(notifyId));
}
/**
vm.start();
vms.add(vm);
Slave slave = new Slave(vm,i);
- Msg.info("Put Worker "+slave.msgName()+ " on "+vm.getName());
+ Msg.info("Put Worker "+slave.getName()+ " on "+vm.getName());
slave.start();
}
this.number = number;
}
public void main(String[] args) throws MsgException {
- Msg.info(this.msgName() +" is listenning on MBOX:WRK0"+ number);
+ Msg.info(this.getName() +" is listenning on MBOX:WRK0"+ number);
while(true) {
Task task;
try {
} catch (MsgException e) {
}
- Msg.info(this.msgName() +" executed task (" + task.getName()+")");
+ Msg.info(this.getName() +" executed task (" + task.getName()+")");
}
public void main(String[] args) throws MsgException {
// Retrieve all mount points of current host
- Storage[] storages = host.getMountedStorage();
+ Storage[] storages = getHost().getMountedStorage();
for (int i = 0; i < storages.length; i++) {
// For each disk mounted on host
super(host,name,args);
}
public void request(double CStime) throws MsgException {
- RequestTask req = new RequestTask(this.name);
+ RequestTask req = new RequestTask(getName());
Msg.info("Send a request to the coordinator");
req.send("coordinator");
Msg.info("Wait for a grant from the coordinator");
- Task.receive(this.name); // FIXME: ensure that this is a grant
+ Task.receive(getName()); // FIXME: ensure that this is a grant
Task compute = new Task("CS", CStime, 0);
compute.execute();
ReleaseTask release = new ReleaseTask();
public void main(String[] args) throws MsgException {
Msg.info("hello!");
- Trace.hostPushState (host.getName(), "PM_STATE", "waitingPing");
+ Trace.hostPushState (getHost().getName(), "PM_STATE", "waitingPing");
double communicationTime=0;
double time = Msg.getClock();
Msg.info(" --- bw "+ commSizeBw/communicationTime + " ----");
/* Send the pong */
- Trace.hostPushState (host.getName(), "PM_STATE", "sendingPong");
+ Trace.hostPushState (getHost().getName(), "PM_STATE", "sendingPong");
double computeDuration = 0;
PingPongTask pong = new PingPongTask("no name",computeDuration,commSizeLat);
pong.setTime(time);
pong.send(ping.getSource().getName());
/* Pop the two states */
- Trace.hostPopState (host.getName(), "PM_STATE");
- Trace.hostPopState (host.getName(), "PM_STATE");
+ Trace.hostPopState (getHost().getName(), "PM_STATE");
+ Trace.hostPopState (getHost().getName(), "PM_STATE");
Msg.info("goodbye!");
}
public void main(String[] args) throws MsgException {
Msg.info("hello !");
- Trace.hostPushState (host.getName(), "PM_STATE", "sendingPing");
+ Trace.hostPushState (getHost().getName(), "PM_STATE", "sendingPing");
int hostCount = args.length;
Msg.info("host count: " + hostCount);
ping.setTime(time);
ping.send(mailboxes[pos]);
- Trace.hostPushState (host.getName(), "PM_STATE", "waitingPong");
+ Trace.hostPushState (getHost().getName(), "PM_STATE", "waitingPong");
pong = (PingPongTask)Task.receive(getHost().getName());
double timeGot = Msg.getClock();
double timeSent = ping.getTime();
Msg.info(" --- bw "+ commSizeBw/communicationTime + " ----");
/* Pop the last state (going back to sending ping) */
- Trace.hostPopState (host.getName(), "PM_STATE");
+ Trace.hostPopState (getHost().getName(), "PM_STATE");
}
/* Pop the sendingPong state */
- Trace.hostPopState (host.getName(), "PM_STATE");
+ Trace.hostPopState (getHost().getName(), "PM_STATE");
Msg.info("goodbye!");
}
}
* It is compute automatically during the creation of the object.
* The native functions use this identifier to synchronize the process.
*/
- public long id;
+ private long id;
- /**
- * Start time of the process
- */
- public double startTime = 0;
- /**
+ /** Time at which the process should be created */
+ protected double startTime = 0;
+ /** Time at which th
* Kill time of the process
+ *
+ * Set at creation, and used internally by SimGrid
*/
- public double killTime = -1;
+ private double killTime = -1;
- /**
- * The name of the process.
- */
- protected String name;
- /**
- * The PID of the process
- */
- protected int pid = -1;
- /**
- * The PPID of the process
- */
- protected int ppid = -1;
- /**
- * The host of the process
- */
- protected Host host = null;
+ private String name;
+
+ private int pid = -1;
+ private int ppid = -1;
+ private Host host = null;
/** The arguments of the method function of the process. */
public Vector<String> args;
*/
public static native int killAll(int resetPID);
- /**
- * This method kill a process.
+ /** Simply kills the receiving process.
*
+ * SimGrid sometimes have issues when you kill processes that are currently communicating and such. We are working on it to fix the issues.
*/
public native void kill();
- /**
- * Suspends the process by suspending the task on which it was
- * waiting for the completion.
- */
+
+ /** Suspends the process. See {@link #resume()} to resume it afterward */
public native void suspend();
- /**
- * Suspends the process by suspending the task on which it was
- * waiting for the completion.
- * DEPRECATED: use suspend instead.
- */
- @Deprecated
- public void pause() {
- suspend();
- }
- /**
- * Sets the "auto-restart" flag of the process.
- */
- public native void setAutoRestart(boolean autoRestart);
- /**
- * Restarts the process from the beginning
- */
- public native void restart();
- /**
- * Resumes a suspended process by resuming the task on which it was
- * waiting for the completion.
- */
+ /** Resume a process that was suspended by {@link #suspend()}. */
public native void resume();
- /**
- * Tests if a process is suspended.
+ /** Tests if a process is suspended.
*
- * @return The method returns true if the process is suspended.
- * Otherwise the method returns false.
+ * @see {@link #suspend()} and {@link #resume()}
*/
public native boolean isSuspended();
+
+ /**
+ * Specify whether the process should restart when its host restarts after a failure
+ *
+ * A process naturally stops when its host stops. It starts again only if autoRestart is set to true.
+ * Otherwise, it just disappears when the host stops.
+ */
+ public native void setAutoRestart(boolean autoRestart);
+ /** Restarts the process from the beginning */
+ public native void restart();
/**
* Returns the name of the process
*/
- public String msgName() {
+ public String getName() {
return this.name;
}
/**
* @param seconds The time the current process must sleep.
*/
public native void waitFor(double seconds) throws HostFailureException;
- /**
- *
- */
- public void showArgs() {
- Msg.info("[" + this.name + "/" + this.getHost().getName() + "] argc=" +
- this.args.size());
- for (int i = 0; i < this.args.size(); i++)
- Msg.info("[" + this.msgName() + "/" + this.getHost().getName() +
- "] args[" + i + "]=" + this.args.get(i));
- }
/**
* This method actually creates and run the process.
* It is a noop if the process is already launched.
/**
* Class initializer, to initialize various JNI stuff
*/
- public static native void nativeInit();
+ private static native void nativeInit();
static {
Msg.nativeInit();
nativeInit();