Moti Asayag 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:

  org.apache.commons.lang.Validate.isTrue(numberOfMacsLong > Integer.MAX_VALUE, 
"Range too big", numberOfMacsLong);
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 ?
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 in 
case a range too big to handle was provided ?
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 <mmu...@redhat.com>
Gerrit-Reviewer: Alona Kaplan <alkap...@redhat.com>
Gerrit-Reviewer: Lior Vernia <lver...@redhat.com>
Gerrit-Reviewer: Moti Asayag <masa...@redhat.com>
Gerrit-Reviewer: Yevgeny Zaspitsky <yzasp...@redhat.com>
Gerrit-Reviewer: automat...@ovirt.org
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to