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

Commit

Permalink
add support for new two level resource set
Browse files Browse the repository at this point in the history
  • Loading branch information
spodila committed Apr 15, 2016
1 parent 009ba26 commit 7c901dd
Show file tree
Hide file tree
Showing 17 changed files with 1,213 additions and 54 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ constraint plugins that are built in to Fenzo include:
- Host attribute value constraint
- selects a host for a task only if it has a specific attribute value
- Unique host attribute constraint
- ensures co-tasks are placed on hosts that have unique values for a given attribute or host name
- ensures co-tasks are placed on hosts that have unique values for a given attribute or host attrName
- for example: one co-task per AWS EC2 availability zone, or one co-task per unique host
- Balanced host attribute constraint
- ensure co-tasks are placed on hosts such that there are an equal number of tasks on hosts with unique value
Expand Down
24 changes: 16 additions & 8 deletions fenzo-core/src/main/java/com/netflix/fenzo/AssignableVMs.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicInteger;

class AssignableVMs {

Expand Down Expand Up @@ -113,9 +114,9 @@ void unAssignTask(String taskId, String host) {
logger.warn("No VM for host " + host + " to unassign task " + taskId);
}

int addLeases(List<VirtualMachineLease> leases) {
private int addLeases(List<VirtualMachineLease> leases) {
for(AssignableVirtualMachine avm: virtualMachinesMap.values())
avm.resetResources();
avm.resetResources();
int rejected=0;
for(VirtualMachineLease l: leases) {
String host = l.hostname();
Expand Down Expand Up @@ -206,9 +207,10 @@ private void expireAnyUnknownLeaseIds() {
}
}

List<AssignableVirtualMachine> prepareAndGetOrderedVMs() {
List<AssignableVirtualMachine> prepareAndGetOrderedVMs(List<VirtualMachineLease> newLeases, AtomicInteger rejectedCount) {
expireAnyUnknownLeaseIds();
removeExpiredLeases();
rejectedCount.addAndGet(addLeases(newLeases));
List<AssignableVirtualMachine> vms = new ArrayList<>();
taskTracker.clearAssignedTasks();
vmRejectLimiter.reset();
Expand Down Expand Up @@ -307,28 +309,34 @@ AssignmentFailure getFailedMaxResource(String attrValue, TaskRequest task) {
switch (res) {
case CPU:
if(maxResources.get(VMResource.CPU) < task.getCPUs()) {
failure = new AssignmentFailure(VMResource.CPU, task.getCPUs(), 0.0, maxResources.get(VMResource.CPU));
failure = new AssignmentFailure(
VMResource.CPU, task.getCPUs(), 0.0, maxResources.get(VMResource.CPU), "");
}
break;
case Memory:
if(maxResources.get(VMResource.Memory) < task.getMemory())
failure = new AssignmentFailure(VMResource.Memory, task.getMemory(), 0.0, maxResources.get(VMResource.Memory));
failure = new AssignmentFailure(
VMResource.Memory, task.getMemory(), 0.0, maxResources.get(VMResource.Memory), "");
break;
case Disk:
if(maxResources.get(VMResource.Disk) < task.getDisk())
failure = new AssignmentFailure(VMResource.Disk, task.getDisk(), 0.0, maxResources.get(VMResource.Disk));
failure = new AssignmentFailure(
VMResource.Disk, task.getDisk(), 0.0, maxResources.get(VMResource.Disk), "");
break;
case Ports:
if(maxResources.get(VMResource.Ports) < task.getPorts())
failure = new AssignmentFailure(VMResource.Ports, task.getPorts(), 0.0, maxResources.get(VMResource.Ports));
failure = new AssignmentFailure(
VMResource.Ports, task.getPorts(), 0.0, maxResources.get(VMResource.Ports), "");
break;
case Network:
if(maxResources.get(VMResource.Network) < task.getNetworkMbps())
failure = new AssignmentFailure(VMResource.Network, task.getNetworkMbps(), 0.0, maxResources.get(VMResource.Network));
failure = new AssignmentFailure(
VMResource.Network, task.getNetworkMbps(), 0.0, maxResources.get(VMResource.Network), "");
break;
case VirtualMachine:
case Fitness:
case ResAllocs:
case ResourceSet:
break;
default:
logger.error("Unknown resource type: " + res);
Expand Down
Loading

0 comments on commit 7c901dd

Please sign in to comment.