Commit 53426196 authored by rosemaryng's avatar rosemaryng
Browse files

[Retry Full] Implemented retrial rate update and initialise methods

parent ebbd400b
......@@ -61,6 +61,9 @@ public class GlobalJobInfoList {
private double lastJobBalkTime;
private double[] lastJobBalkTimePerClass;
private double lastJobRetrialTime;
private double[] lastJobRetrialTimePerClass;
private double lastModifyNumber;
private double[] lastModifyNumberPerClass;
......@@ -73,9 +76,6 @@ public class GlobalJobInfoList {
private Measure responseTime;
private Measure[] responseTimePerClass;
private Measure retrialNum;
private Measure[] retrialNumPerClass;
private InverseMeasure dropRate;
private InverseMeasure[] dropRatePerClass;
......@@ -85,6 +85,9 @@ public class GlobalJobInfoList {
private InverseMeasure balkingRate;
private InverseMeasure[] balkingRatePerClass;
private InverseMeasure retrialRate;
private InverseMeasure[] retrialRatePerClass;
private InverseMeasure throughput;
private InverseMeasure[] throughputPerClass;
......@@ -130,6 +133,8 @@ public class GlobalJobInfoList {
lastJobRenegeTimePerClass = new double[classNum];
lastJobBalkTime = 0.0;
lastJobBalkTimePerClass = new double[classNum];
lastJobRetrialTime = 0.0;
lastJobRetrialTimePerClass = new double[classNum];
lastModifyNumber = 0.0;
lastModifyNumberPerClass = new double[classNum];
jobs = 0;
......@@ -143,6 +148,8 @@ public class GlobalJobInfoList {
dropRatePerClass = null;
renegingRate = null;
renegingRatePerClass = null;
retrialRate = null;
retrialRatePerClass = null;
throughput = null;
throughputPerClass = null;
systemPower = null;
......@@ -259,6 +266,22 @@ public class GlobalJobInfoList {
lastJobBalkTimePerClass[job.getJobClass().getId()] = lastJobBalkTime = getTime();
}
/**
* This method must be called each time a job balks from a queue
* @param job identifier of reneged job
*/
public void retryJob(Job job) {
updateJobNumber(job);
updateRetrialRate(job);
// Updates jobs number and balking rate data structures
jobs--;
jobsPerClass[job.getJobClass().getId()]--;
lastModifyNumberPerClass[job.getJobClass().getId()] = lastModifyNumber = getTime();
lastJobBalkTimePerClass[job.getJobClass().getId()] = lastJobBalkTime = getTime();
}
/**
* This method MUST be called each time a job is produced by a transition
* @param job identifier of produced job
......@@ -404,14 +427,14 @@ public class GlobalJobInfoList {
* @param jobClass specified job class. If null measure will be job independent.
* @param Measure reference to a Measure object.
*/
public void analyzeRetrialNumber(JobClass jobClass, Measure Measure) {
public void analyzeRetrialRate(JobClass jobClass, Measure Measure) {
if (jobClass != null) {
if (jobNumPerClass == null) {
jobNumPerClass = new Measure[classNum];
if (retrialRatePerClass == null) {
retrialRatePerClass = new InverseMeasure[classNum];
}
jobNumPerClass[jobClass.getId()] = Measure;
retrialRatePerClass[jobClass.getId()] = (InverseMeasure) Measure;
} else {
jobNum = Measure;
retrialRate = (InverseMeasure) Measure;
}
}
......@@ -521,6 +544,24 @@ public class GlobalJobInfoList {
}
}
/**
* Updates System Retrial Rate measures.
* @param job current job
*/
private void updateRetrialRate(Job job) {
if (retrialRatePerClass != null) {
int index = job.getJobClass().getId();
Measure m = retrialRatePerClass[index];
if (m != null) {
m.update(getTime() - lastJobRetrialTimePerClass[index], 1.0);
}
}
if (retrialRate != null) {
retrialRate.update(getTime() - lastJobRetrialTime, 1.0);
}
}
/**
* Updates System Power measures.
* @param job current job.
......
......@@ -370,6 +370,12 @@ public interface JobInfoList {
*/
public abstract void balkJob(JobInfo jobInfo);
/**
* add a job info from the list when a job is retried.
* @param jobInfo Reference to the job info to be added.
*/
public abstract void retryJob(JobInfo jobInfo);
/**
* Adds a new job info to the list when a job is produced.
* @param jobInfo Reference to the job info to be added.
......
......@@ -72,6 +72,10 @@ public class LinkedJobInfoList implements JobInfoList {
protected double lastJobBalkingTimePerClass[];
protected double lastJobRetrialTime;
protected double lastJobRetrialTimePerClass[];
protected double totalSojournTime;
protected double totalSojournTimePerClass[];
......@@ -288,6 +292,20 @@ public class LinkedJobInfoList implements JobInfoList {
return lastJobBalkingTimePerClass[jobClass.getId()];
}
/* (non-Javadoc)
* @see jmt.engine.QueueNet.JobInfoList#getLastJobDropTime()
*/
public double getLastJobRetrialTime() {
return lastJobRetrialTime;
}
/* (non-Javadoc)
* @see jmt.engine.QueueNet.JobInfoList#getLastJobDropTimePerClass(jmt.engine.QueueNet.JobClass)
*/
public double getLastJobRetrialTimePerClass(JobClass jobClass) {
return lastJobRetrialTimePerClass[jobClass.getId()];
}
/* (non-Javadoc)
* @see jmt.engine.QueueNet.JobInfoList#getLastModifyTime()
*/
......@@ -709,7 +727,14 @@ public class LinkedJobInfoList implements JobInfoList {
@Override
public void analyzeRetrialRate(JobClass jobClass, InverseMeasure measurement) {
if (jobClass != null) {
if (retrialRatePerClass == null) {
retrialRatePerClass = new InverseMeasure[numberOfJobClasses];
}
retrialRatePerClass[jobClass.getId()] = measurement;
} else {
retrialRate = measurement;
}
}
/* (non-Javadoc)
......@@ -864,9 +889,7 @@ public class LinkedJobInfoList implements JobInfoList {
}
protected void updateBalkingRate(JobInfo jobInfo) {
// System.out.println("update balking rate in LinkedJobInfoList " + balkingRatePerClass);
if (balkingRatePerClass != null) {
System.out.println("did we ever get in");
JobClass jobClass = jobInfo.getJob().getJobClass();
int c = jobClass.getId();
Measure m = balkingRatePerClass[c];
......@@ -875,12 +898,24 @@ public class LinkedJobInfoList implements JobInfoList {
}
}
if (balkingRate != null) {
System.out.println("did we ever get in");
balkingRate.update(getTime() - getLastJobBalkingTime(), 1.0);
}
}
protected void updateRetrialRate(JobInfo jobInfo) {
if (retrialRatePerClass != null) {
JobClass jobClass = jobInfo.getJob().getJobClass();
int c = jobClass.getId();
Measure m = retrialRatePerClass[c];
if (m != null) {
m.update(getTime() - getLastJobRetrialTimePerClass(jobClass), 1.0);
}
}
if (retrialRate != null) {
balkingRate.update(getTime() - getLastJobRetrialTime(), 1.0);
}
}
protected void updateResponseTimePerSink(JobInfo jobInfo) {
if (responseTimePerSinkPerClass != null) {
JobClass jobClass = jobInfo.getJob().getJobClass();
......@@ -975,6 +1010,19 @@ public class LinkedJobInfoList implements JobInfoList {
lastJobBalkingTimePerClass[c] = getTime();
}
/* (non-Javadoc)
* @see jmt.engine.QueueNet.JobInfoList#dropJob(jmt.engine.QueueNet.JobInfo)
*/
public void retryJob(JobInfo jobInfo) {
int c = jobInfo.getJob().getJobClass().getId();
updateRetrialRate(jobInfo);
if (findJob(jobInfo.getJob()) == null) {
list.add(jobInfo);
}
lastJobBalkingTime = getTime();
lastJobBalkingTimePerClass[c] = getTime();
}
/* (non-Javadoc)
* @see jmt.engine.QueueNet.JobInfoList#produceJob(jmt.engine.QueueNet.JobInfo)
*/
......
......@@ -574,7 +574,7 @@ public class Simulation {
network.getJobInfoList().analyzeSystemPower(jClass, ms.getMeasure());
break;
case SimConstants.SYSTEM_RETRIAL_RATE:
network.getJobInfoList().analyzeRetrialNumber(jClass, ms.getMeasure());
network.getJobInfoList().analyzeRetrialRate(jClass, ms.getMeasure());
}
}
}
......
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