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

Commit

Permalink
Merge pull request #176 from corindwyer/minor-improvement
Browse files Browse the repository at this point in the history
Minor Improvements
  • Loading branch information
corindwyer authored Mar 17, 2018
2 parents 76902c7 + 82ca808 commit e462045
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -89,7 +90,6 @@ public double getFitness() {
}

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

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

double getUsedCount() {
if(resName==null)
public int getUsedCount() {
if(resName == null) {
return -1;
}
return usedSubResources;
}

Expand Down Expand Up @@ -223,6 +221,10 @@ public String getName() {
return name;
}

public List<PreferentialNamedConsumableResource> getUsageBy() {
return Collections.unmodifiableList(usageBy);
}

// boolean hasAvailability(TaskRequest request) {
// for(PreferentialNamedConsumableResource r: usageBy) {
// if(r.hasAvailability(request))
Expand Down Expand Up @@ -298,7 +300,7 @@ int getNumSubResources() {
List<Double> getUsedCounts() {
List<Double> counts = new ArrayList<>(usageBy.size());
for(PreferentialNamedConsumableResource r: usageBy)
counts.add(r.getUsedCount());
counts.add((double) r.getUsedCount());
return counts;
}
}

0 comments on commit e462045

Please sign in to comment.