Commit 232b4f28 authored by rosemaryng's avatar rosemaryng
Browse files

[WaitingTime metric] Debug wrong waiting time implementation

parent 1b636526
......@@ -393,7 +393,7 @@ public class Queue extends InputSection {
}
try {
Parameter param = new ExponentialPar(0.5);
Parameter param = new ExponentialPar(0.2);
retrial = new Retrial(this.getNetSytem(), param);
} catch (IncorrectDistributionParameterException e) {
e.printStackTrace();
......@@ -525,6 +525,7 @@ public class Queue extends InputSection {
job = message.getJob();
JobInfo jobInfo = nodeJobsList.lookFor(job);
System.out.println("---- " + job.getId() + " time: " + getNetSytem().getTime());
if (isRetrialJob) {
retried.add(job.getId());
nodeJobsList.retryJob(jobInfo);
......@@ -591,11 +592,15 @@ public class Queue extends InputSection {
// retryFull && nodeJobsList.getJobsInPrimaryQueue().size() < size) {
if (infinite || nodeJobsList.size() <= size) {
// Queue is not full. Okay.
if (retrialFullGroup.containsKey(job.getId())) {
double waitingTime = getNetSytem().getTime() - job.getSystemEnteringTime();
if (nodeJobsList.getRetrialOrbit().containsKey(job.getId())) {
// System.out.println(job.getId() + " proceeds.");
waitingTime = getNetSytem().getTime() - nodeJobsList.getRetrialOrbit().get(job.getId()).get(0);
nodeJobsList.removeFromRetrialOrbit(job);
System.out.println("waitingTime for a retrial job: " + waitingTime);
}
// System.out.println("retrialJobsCount: " + retried.size() + " retrials Total Count: " + retrialCount + " orbit size: " + nodeJobsList.getRetrialOrbit() + " NodeJobsList: " + nodeJobsList.getInternalJobInfoList());
nodeJobsList.updateWaitingTime(job, waitingTime);
// If parent node is a fork node adds job to FJ info list
if (getOwnerNode().getSection(NodeSection.OUTPUT) instanceof Fork) {
addJobToBuffer(job, message, BufferType.FJ_LIST);
......@@ -617,11 +622,13 @@ public class Queue extends InputSection {
// forward without any delay
sendForward(jobsList.removeFirst().getJob(), 0.0);
} else { //queue is not empty (need to queue before service)
putStrategies[job.getJobClass().getId()].put(job, jobsList, this);
setRenegingEvent(job);
Job jobSent = getStrategy.get(jobsList);
sendForward(jobSent, 0.0);
}
forwardRenegingData(job, this.getNetSytem().getTime());
coolStart = false;
......@@ -650,7 +657,6 @@ public class Queue extends InputSection {
// Retry Full route
if (dropStrategies != null && dropStrategies[0].equals(FINITE_RETRIAL)) {
// System.out.println(job.getId() + " full, will be retried. Time now: " + this.getNetSytem().getTime());
System.out.println("retrialJobsCount: " + retried.size() + " retrials Total Count: " + retrialCount + " orbit size: " + nodeJobsList.getRetrialOrbit().size() + " NodeJobsList: " + nodeJobsList.getInternalJobInfoList());
sendMe(NetEvent.EVENT_RETRIAL, job, 0);
} else {
......
......@@ -89,7 +89,7 @@ public abstract class ServiceSection extends PipeSection {
* @return a token to remove sent event.
*/
protected RemoveToken sendBackward(int event, Object data, double delay) {
this.getOwnerNode().getJobInfoList().updateWaitingTime((Job) data);
// this.getOwnerNode().getJobInfoList().updateWaitingTime((Job) data);
return send(event, data, delay, NodeSection.INPUT);
}
......
......@@ -413,7 +413,10 @@ public interface JobInfoList {
* Updates the waiting time of a job -- called when a job is being served.
* @param job Reference to the job that is being sent to service section (of a queue).
*/
public void updateWaitingTime(Job job);
public void updateWaitingTime(Job job, double wt);
public void updateNumberOfBusyServers(Job job);
/**
* Sets the number of servers. This parameter is used to scale utilization.
* @param numberOfServers Number of servers.
......
......@@ -47,6 +47,8 @@ public class LinkedJobInfoList implements JobInfoList {
protected Map<Integer, List<Double>> retrialOrbit = new HashMap<>();
protected Map<Integer, List<Double>> retrialOrbitPerClass[];
//arrivals and completions
protected int jobsIn;
......@@ -77,9 +79,12 @@ public class LinkedJobInfoList implements JobInfoList {
protected double lastJobBalkingTimePerClass[];
protected double lastJobRetrialTime;
protected double lastJobRetrialTimePerClass[];
protected double lastRetrialOrbitModifyTime;
protected double lastRetrialOrbitModifyTimePerClass[];
protected double totalSojournTime;
protected double totalSojournTimePerClass[];
......@@ -88,9 +93,7 @@ public class LinkedJobInfoList implements JobInfoList {
protected double lastJobSojournTimePerClass[];
protected double lastRetrialTime;
protected double lastRetrialTimePerClass[];
protected Measure queueLength;
......@@ -140,6 +143,8 @@ public class LinkedJobInfoList implements JobInfoList {
protected Measure retrialOrbitSize;
protected Measure retrialOrbitSizePerClass[];
protected Measure busyServerNum;
protected Measure responseTimePerSink;
......@@ -149,6 +154,7 @@ public class LinkedJobInfoList implements JobInfoList {
protected InverseMeasure throughputPerSinkPerClass[];
/** The number of servers to estimate Utilization measure on multiserver environments */
protected int numberOfServers = 1;
......@@ -178,7 +184,7 @@ public class LinkedJobInfoList implements JobInfoList {
lastJobRetrialTimePerClass = new double[numberOfJobClasses];
totalSojournTimePerClass = new double[numberOfJobClasses];
lastJobSojournTimePerClass = new double[numberOfJobClasses];
lastRetrialTimePerClass = new double[numberOfJobClasses];
lastRetrialOrbitModifyTimePerClass = new double[numberOfJobClasses];
}
/**---------------------------------------------------------------------
......@@ -211,8 +217,8 @@ public class LinkedJobInfoList implements JobInfoList {
currList.add(this.getTime());
retrialOrbit.put(job.getId(), currList);
retrialOrbitPerClass[classID].put(job.getId(), currList);
lastRetrialTime = getTime();
lastRetrialTimePerClass[classID] = getTime();
lastRetrialOrbitModifyTime = getTime();
lastRetrialOrbitModifyTimePerClass[classID] = getTime();
return retrialOrbit;
}
......@@ -222,8 +228,8 @@ public class LinkedJobInfoList implements JobInfoList {
updateRetrialOrbitSize(job);
retrialOrbit.remove(id);
retrialOrbitPerClass[classID].remove(id);
lastRetrialTime = getTime();
lastRetrialTimePerClass[job.getJobClass().getId()] = getTime();
lastRetrialOrbitModifyTime = getTime();
lastRetrialOrbitModifyTimePerClass[job.getJobClass().getId()] = getTime();
}
/* (non-Javadoc)
......@@ -980,31 +986,36 @@ public class LinkedJobInfoList implements JobInfoList {
int c = jobClass.getId();
Measure m = retrialOrbitSizePerClass[c];
if (m != null) {
m.update(retrialOrbit.size(), getTime() - getLastJobRetrialTimePerClass(jobClass));
m.update(retrialOrbit.size(), getTime() - lastRetrialOrbitModifyTimePerClass[c]);
}
}
if (retrialOrbitSize != null) {
retrialOrbitSize.update(retrialOrbit.size(), getTime() - getLastJobRetrialTime());
retrialOrbitSize.update(retrialOrbit.size(), getTime() - lastRetrialOrbitModifyTime);
}
}
/* (non-Javadoc)
* @see jmt.engine.QueueNet.JobInfoList#updateWaitingTime(jmt.engine.QueueNet.JobInfo)
*/
public void updateWaitingTime(Job job) {
public void updateWaitingTime(Job job, double wt) {
if (waitingTimePerClass != null) {
JobClass jobClass = job.getJobClass();
int c = jobClass.getId();
Measure m = waitingTimePerClass[c];
if (m != null) {
m.update(getTime() - job.getServiceArrivalTime(), 1.0);
m.update(wt, 1.0);
}
}
if (waitingTime != null) {
waitingTime.update(getTime() - job.getServiceArrivalTime(), 1.0);
waitingTime.update(wt, 1.0);
}
}
@Override
public void updateNumberOfBusyServers(Job job) {
}
protected void updateResponseTimePerSink(JobInfo jobInfo) {
if (responseTimePerSinkPerClass != null) {
JobClass jobClass = jobInfo.getJob().getJobClass();
......
......@@ -119,6 +119,8 @@ public interface SimConstants {
/** Measure identifier: (total) waiting time of a job of the system (system entering time - time when job is pass to serving section) */
public static final int SYSTEM_WAITING_TIME = 37;
public static final int VARIANCE_BUSY_SERVERS = 39;
//-------------------- end SIMULATION MEASURE IDENTIFIERS -------------------------//
......@@ -154,6 +156,9 @@ public interface SimConstants {
/** Measure identifier: (total) waiting time of a job of the list (system entering time - time when job is pass to serving section) */
public static final int LIST_WAITING_TIME = 38;
public static final int LIST_VARIANCE_BUSY_SERVERS = 38;
//-------------------- end JOB LIST MEASURE IDENTIFIERS -------------------------//
/** To be used for a blocking region measure */
......
......@@ -201,6 +201,8 @@ public class DispatcherJSIMschema {
simPaused = false;
simFinished = true;
System.out.println("sim finished: " + this.net.getNodes().get(1));
// Shutdown the simulation timer, if any.
es.shutdownNow();
......
......@@ -223,6 +223,13 @@ public interface MeasureDefinition {
*/
public int[] getWaitingTimeMeasures();
/**
* Returns an array with the measureIndex of every waiting time measure
* @return an array with measures' index
*/
public int[] getNumberOfBusyServersVarianceMeasures();
/**
* Returns an array with the measureIndex of every system customer number measure
* @return an array with measures' index
......
......@@ -74,6 +74,9 @@ public interface SimulationDefinition {
/**Code for retrial orbit size measure*/
public static final String MEASURE_RS = "Retrial Orbit Size";
public static final String MEASURE_V_BS = "Variance of number of busy servers";
/**Code for system waiting time measure*/
public static final String MEASURE_S_WT = "Waiting Time";
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment