Commit 02ba22b3 authored by Marc Schiller's avatar Marc Schiller
Browse files

Changed getStatus method to ignore global overload status.

parent 78096ec9
......@@ -204,6 +204,8 @@ public class ModelBasedSegmentDatabase
private final long THRESHOLD_BANDWIDTH = 10;
private final double THRESHOLD_DROPRATE = 1;
private final double YELLOW_INDICATOR = .9;
// Other storage
private final int segment;
......@@ -248,6 +250,7 @@ public class ModelBasedSegmentDatabase
public void onHostLeavesSegment(MacAddress hostAddr) {
// Remove MAC from current users
this.hostsInSegment.remove(hostAddr);
calc();
}
......@@ -257,6 +260,7 @@ public class ModelBasedSegmentDatabase
public void onHostEntersSegment(MacAddress hostAddr) {
// Add MAC to current users
this.hostsInSegment.add(hostAddr);
calc();
}
......@@ -318,34 +322,75 @@ public class ModelBasedSegmentDatabase
}
public int getStatus(ParameterType type, Direction dir) {
this.calc();
if(this.overload) {
return 2;
}
if(type.equals(ParameterType.BANDWIDTH) && dir.equals(Direction.UPLOAD) && this.bandUp < (.9 * THRESHOLD_BANDWIDTH)) {
return 1;
if(type.equals(ParameterType.BANDWIDTH) && dir.equals(Direction.UPLOAD)) {
if(this.bandUp < THRESHOLD_BANDWIDTH) {
return 2;
}
if(this.bandUp < (YELLOW_INDICATOR * THRESHOLD_BANDWIDTH)) {
return 1;
}
return 0;
}
if(type.equals(ParameterType.BANDWIDTH) && dir.equals(Direction.DOWNLOAD) && this.bandDown < (.9 * THRESHOLD_BANDWIDTH)) {
return 1;
if(type.equals(ParameterType.BANDWIDTH) && dir.equals(Direction.DOWNLOAD)) {
if(this.bandDown < THRESHOLD_BANDWIDTH) {
return 2;
}
if(this.bandDown < (YELLOW_INDICATOR * THRESHOLD_BANDWIDTH)) {
return 1;
}
return 0;
}
if(type.equals(ParameterType.DROPRATE) && dir.equals(Direction.UPLOAD) && this.dropUp > (.9 * THRESHOLD_DROPRATE)) {
return 1;
if(type.equals(ParameterType.DROPRATE) && dir.equals(Direction.UPLOAD)) {
if(this.dropUp > THRESHOLD_DROPRATE) {
return 2;
}
if(this.dropUp > (YELLOW_INDICATOR * THRESHOLD_DROPRATE)) {
return 1;
}
return 0;
}
if(type.equals(ParameterType.DROPRATE) && dir.equals(Direction.DOWNLOAD) && this.dropDown > (.9 * THRESHOLD_DROPRATE)) {
return 1;
if(type.equals(ParameterType.DROPRATE) && dir.equals(Direction.DOWNLOAD)) {
if(this.dropDown > THRESHOLD_DROPRATE) {
return 2;
}
if(this.dropDown > (YELLOW_INDICATOR * THRESHOLD_DROPRATE)) {
return 1;
}
return 0;
}
if(type.equals(ParameterType.LATENCY) && dir.equals(Direction.UPLOAD) && this.latUp > (.9 * THRESHOLD_DROPRATE)) {
return 1;
if(type.equals(ParameterType.LATENCY) && dir.equals(Direction.UPLOAD)) {
if(this.latUp > THRESHOLD_LATENCY) {
return 2;
}
if(this.latUp > (YELLOW_INDICATOR * THRESHOLD_LATENCY)) {
return 1;
}
return 0;
}
if(type.equals(ParameterType.LATENCY) && dir.equals(Direction.DOWNLOAD) && this.latDown > (.9 * THRESHOLD_DROPRATE)) {
return 1;
if(type.equals(ParameterType.LATENCY) && dir.equals(Direction.DOWNLOAD)) {
if(this.latDown > THRESHOLD_LATENCY) {
return 2;
}
if(this.latDown > (YELLOW_INDICATOR * THRESHOLD_LATENCY)) {
return 1;
}
return 0;
}
return 0;
......
Markdown is supported
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