Martin Mucha has posted comments on this change.

Change subject: core: error in calculating number of available macs / trimming 
mac pool ranges
......................................................................


Patch Set 2:

(3 comments)

http://gerrit.ovirt.org/#/c/34983/2/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/macpoolmanager/Range.java
File 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/macpoolmanager/Range.java:

Line 22: 
Line 23:         long numberOfMacsLong =  (rangeEnd - rangeStart) + 1;
Line 24:         if (numberOfMacsLong > Integer.MAX_VALUE) {
Line 25:             throw new IllegalArgumentException();
Line 26:         }
> since this class resides in bll you can use apache assertion:
I don't see this as a benefit ~ clear if is hidden in not that clear (to 
everyone) method call. You're right that I should have use explaining message. 
I've added one (bigger with proper formatting) and used requested apache syntax.
Line 27: 
Line 28:         int numberOfMacs = (int) numberOfMacsLong;
Line 29: 
Line 30:         this.availableMacsCount = numberOfMacs;


Line 24:         if (numberOfMacsLong > Integer.MAX_VALUE) {
Line 25:             throw new IllegalArgumentException();
Line 26:         }
Line 27: 
Line 28:         int numberOfMacs = (int) numberOfMacsLong;
> why not change availableMacsCount's type from int to long ?
BitSet, we depend upon to store availability, can only work with int datatype, 
so there won't be (along this way) more than 2 billions of macs in bitset. If 
we want more macs in pool (which is I believe ridiculous) we have to change 
implementation.
Line 29: 
Line 30:         this.availableMacsCount = numberOfMacs;
Line 31:         this.usedMacs = new BitSet(numberOfMacs);
Line 32:     }


http://gerrit.ovirt.org/#/c/34983/2/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/network/macpoolmanager/RangeTest.java
File 
backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/network/macpoolmanager/RangeTest.java:

Line 114:     @Test
Line 115:     public void testRangeStartAndRangeStopAreInclusive() throws 
Exception {
Line 116:         assertThat(new Range(MAC_FROM_RANGE, 
MAC_FROM_RANGE).getAvailableCount(), is(1));
Line 117:     }
Line 118: 
> what about test to cover the other part ? i.e. expect IllegaStateException 
Done
Line 119:     @Test
Line 120:     public void testRangeCanContainOnlyIntSizeNumberOfElements() 
throws Exception {
Line 121:         LongRange longRange = MacAddressRangeUtils.clipRange(new 
LongRange(0, Long.MAX_VALUE));
Line 122:         Range range = new Range(longRange.getMinimumLong(), 
longRange.getMaximumLong());


-- 
To view, visit http://gerrit.ovirt.org/34983
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I4bbf719deb47c795862a03deb515283b1eae9a0e
Gerrit-PatchSet: 2
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Martin Mucha <[email protected]>
Gerrit-Reviewer: Alona Kaplan <[email protected]>
Gerrit-Reviewer: Lior Vernia <[email protected]>
Gerrit-Reviewer: Martin Mucha <[email protected]>
Gerrit-Reviewer: Moti Asayag <[email protected]>
Gerrit-Reviewer: Yevgeny Zaspitsky <[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

Reply via email to