Skip to content
This repository was archived by the owner on Mar 31, 2023. It is now read-only.

Commit e462045

Browse files
authored
Merge pull request #176 from corindwyer/minor-improvement
Minor Improvements
2 parents 76902c7 + 82ca808 commit e462045

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

fenzo-core/src/main/java/com/netflix/fenzo/PreferentialNamedConsumableResourceSet.java

+9-7
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.fasterxml.jackson.annotation.JsonProperty;
2222

2323
import java.util.ArrayList;
24+
import java.util.Collections;
2425
import java.util.HashMap;
2526
import java.util.List;
2627
import java.util.Map;
@@ -89,7 +90,6 @@ public double getFitness() {
8990
}
9091

9192
public static class PreferentialNamedConsumableResource {
92-
private final double maxFitness;
9393
private final String hostname;
9494
private final int index;
9595
private final String attrName;
@@ -104,9 +104,6 @@ public static class PreferentialNamedConsumableResource {
104104
this.attrName = attrName;
105105
this.limit = limit;
106106
usageBy = new HashMap<>();
107-
// we add 1.0 to max fitness possible since we add 1.0 for the situation when there is already a task
108-
// assigned with the same resValue even though it uses 0.0 subResources, versus, there are no assignments yet.
109-
maxFitness = limit + 1.0;
110107
}
111108

112109
public int getIndex() {
@@ -125,9 +122,10 @@ public Map<String, TaskRequest.NamedResourceSetRequest> getUsageBy() {
125122
return usageBy;
126123
}
127124

128-
double getUsedCount() {
129-
if(resName==null)
125+
public int getUsedCount() {
126+
if(resName == null) {
130127
return -1;
128+
}
131129
return usedSubResources;
132130
}
133131

@@ -223,6 +221,10 @@ public String getName() {
223221
return name;
224222
}
225223

224+
public List<PreferentialNamedConsumableResource> getUsageBy() {
225+
return Collections.unmodifiableList(usageBy);
226+
}
227+
226228
// boolean hasAvailability(TaskRequest request) {
227229
// for(PreferentialNamedConsumableResource r: usageBy) {
228230
// if(r.hasAvailability(request))
@@ -298,7 +300,7 @@ int getNumSubResources() {
298300
List<Double> getUsedCounts() {
299301
List<Double> counts = new ArrayList<>(usageBy.size());
300302
for(PreferentialNamedConsumableResource r: usageBy)
301-
counts.add(r.getUsedCount());
303+
counts.add((double) r.getUsedCount());
302304
return counts;
303305
}
304306
}

0 commit comments

Comments
 (0)