Commit 790bcceb authored by rosemaryng's avatar rosemaryng
Browse files

[Retry Full] Implemented actual primary queue size

parent e5f8d698
......@@ -494,13 +494,14 @@ public class Queue extends InputSection {
//If the queue is infinite, the job is put into the queue and an ack is sent
job = message.getJob();
boolean retrial = dropStrategies[0].equals(FINITE_RETRIAL);
if (retrialFullGroup.containsKey(job.getId())) {
// System.out.println(job.getId() + " " + "originally entered at: " + job.getSystemEnteringTime() +
// " re-entered at: " + retrialFullGroup.get(job.getId())
// + "retrialFullGroup size: " + retrialFullGroup.size());
System.out.println(job.getId() + " retried, current queue size: " + nodeJobsList.getJobsInPrimaryQueue().size());
} else {
System.out.println(job.getId() + "current queue size: " + nodeJobsList.getJobsInPrimaryQueue().size());
}
System.out.println(job.getId() + " current queue size: " + nodeJobsList.size());
// System.out.println("this job is: " + nodeJobsList.lookFor(job).toString() + " time: " + this.getNetSytem().getTime());
// System.out.println("jobs waiting to be retried: " + retrialFullGroup);
......@@ -547,9 +548,10 @@ public class Queue extends InputSection {
// Check if there is still capacity.
// <= size because the arriving job has not been inserted in Queue
// job list but has been inserted in NetNode job list !!
if (infinite || nodeJobsList.size() <= size) {
if (infinite || !retrial && nodeJobsList.size() <= size ||
retrial && nodeJobsList.getJobsInPrimaryQueue().size() <= size) {
// Queue is not full. Okay.
System.out.println(nodeJobsList.size());
System.out.println("current nodeJobsList size: " + nodeJobsList.size());
if (retrialFullGroup.containsKey(job.getId())) {
System.out.println(job.getId() + " proceeds.");
}
......@@ -593,6 +595,7 @@ public class Queue extends InputSection {
}
// sends an ACK backward
send(NetEvent.EVENT_ACK, job, 0.0, message.getSourceSection(), message.getSource());
nodeJobsList.addJobToPrimaryQueue(new JobInfo(job));
} else {
// System.out.println("queue is full, " + job.getId() + " added to retrial");
// Queue is full. Now we use an additional queue or drop.
......@@ -616,8 +619,7 @@ public class Queue extends InputSection {
Exponential exponential = new Exponential();
RandomEngine randEngine = job.getNetSystem().getEngine();
exponential.setRandomEngine(randEngine);
randomDelay = exponential.nextRand(new ExponentialPar(2));
// System.out.println("RandomDelay: " + randomDelay);
randomDelay = exponential.nextRand(new ExponentialPar(0.3));
// retrial.generateImpatience(retrialDelay);
} catch (IncorrectDistributionParameterException e) {
e.printStackTrace();
......
......@@ -57,4 +57,10 @@ public class JobInfo {
return job.getNetSystem();
}
// For debugging purpose
@Override
public String toString() {
return "JobID " + job.getId() +
", enteringTime = " + enteringTime + ", original entering time = " + job.getSystemEnteringTime() + ", service time = " + job.getServiceTime();
}
}
......@@ -18,6 +18,7 @@
package jmt.engine.QueueNet;
import java.util.List;
import java.util.Map;
import jmt.engine.dataAnalysis.InverseMeasure;
import jmt.engine.dataAnalysis.Measure;
......@@ -373,6 +374,10 @@ public interface JobInfoList {
*/
public void setNumberOfServers(int numberOfServers);
public abstract void setNetSystem(NetSystem netSystem);
public abstract void setNetSystem(NetSystem netSystem);
public Map<Integer, JobInfo> getJobsInPrimaryQueue();
public Map<Integer, JobInfo> addJobToPrimaryQueue(JobInfo jobInfo);
}
......@@ -18,9 +18,7 @@
package jmt.engine.QueueNet;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.*;
import jmt.engine.dataAnalysis.InverseMeasure;
import jmt.engine.dataAnalysis.Measure;
......@@ -126,6 +124,18 @@ public class LinkedJobInfoList implements JobInfoList {
protected InverseMeasure throughputPerSinkPerClass[];
//Retrial group
protected Map<Integer, JobInfo> jobsInPrimaryQueue;
public Map<Integer, JobInfo> getJobsInPrimaryQueue() {
return jobsInPrimaryQueue;
}
public Map<Integer, JobInfo> addJobToPrimaryQueue(JobInfo jobInfo) {
jobsInPrimaryQueue.put(jobInfo.getJob().getId(), jobInfo);
return jobsInPrimaryQueue;
}
/** The number of servers to estimate Utilization measure on multiserver environments */
protected int numberOfServers = 1;
......@@ -151,6 +161,8 @@ public class LinkedJobInfoList implements JobInfoList {
lastJobBalkingTimePerClass = new double[numberOfJobClasses];
totalSojournTimePerClass = new double[numberOfJobClasses];
lastJobSojournTimePerClass = new double[numberOfJobClasses];
jobsInPrimaryQueue = new HashMap<>();
}
/**---------------------------------------------------------------------
......@@ -534,6 +546,7 @@ public class LinkedJobInfoList implements JobInfoList {
list.remove(what);
break;
}
jobsInPrimaryQueue.remove(what.getJob().getId());
}
/**---------------------------------------------------------------------
......
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