Kobi Ianko has posted comments on this change. Change subject: core: Set HotSetNumberOfCpusCommand as Quota consume ......................................................................
Patch Set 2: (3 comments) http://gerrit.ovirt.org/#/c/27356/2/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HotSetNumberOfCpusCommand.java File backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HotSetNumberOfCpusCommand.java: Line 110: List<QuotaConsumptionParameter> list = new ArrayList<>(); Line 111: Line 112: // Calculate the change in CPU consumption, result above Zero means we add CPUs to Line 113: // the VM Line 114: // result bellow Zero means we subtracted CPUs from the VM > /s/negative, /s/positive negative - we removed vCpu(s) positive - we added a vCpu(s) zero - the command will not be called Line 115: int cpuToConsume = Line 116: getParameters().getVm().getNumOfCpus() - getVm().getNumOfCpus(); Line 117: Line 118: if (cpuToConsume > 0) { Line 120: list.add(new QuotaVdsGroupConsumptionParameter(getVm().getQuotaId(), Line 121: null, Line 122: QuotaConsumptionParameter.QuotaAction.CONSUME, Line 123: getVm().getVdsGroupId(), Line 124: getVm().getCpuPerSocket() * cpuToConsume, > what about count cores as threads, I'm not sure we're handling that in quot we aren't handling it in runVmCommand, so I guess it's ok Line 125: 0)); Line 126: Line 127: } else if (cpuToConsume < 0) { Line 128: // Release CPU quota Line 129: list.add(new QuotaVdsGroupConsumptionParameter(getVm().getQuotaId(), Line 130: null, Line 131: QuotaConsumptionParameter.QuotaAction.RELEASE, Line 132: getVm().getVdsGroupId(), Line 133: getVm().getCpuPerSocket() * Math.abs(cpuToConsume), > you can multiply by -1, the number is negative. prefer it this way, looks easier to others to understand (IMO) Math.abs is not that cpu consuming (IF + *-1): public static int abs(int a) { return (a < 0) ? -a : a; } Line 134: 0)); Line 135: } Line 136: return list; Line 137: } -- To view, visit http://gerrit.ovirt.org/27356 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I6d1db7c2f7cbc4ae94e540b26e15dbcf7246bde0 Gerrit-PatchSet: 2 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Kobi Ianko <[email protected]> Gerrit-Reviewer: Gilad Chaplik <[email protected]> Gerrit-Reviewer: Kobi Ianko <[email protected]> Gerrit-Reviewer: [email protected] Gerrit-Reviewer: oVirt Jenkins CI Server Gerrit-HasComments: Yes _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
