Moti Asayag has posted comments on this change.

Change subject: gluster : In the task tab, size of rebalanced files is shown 
with units
......................................................................


Patch Set 19:

(5 comments)

....................................................
File 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterVolumeTaskStatusEntity.java
Line 73:                 .append(statusSummary.getFilesMoved())
Line 74:                 .append(", failed: ")
Line 75:                 .append(statusSummary.getFilesFailed())
Line 76:                 .append(", Total size moved: ")
Line 77:                 
.append((formatSize.format(sizeMoved.getValue())).toString().concat(" 
").concat(sizeMoved.getUnit().toString()));
NumberFormat.format(long number) return String, no need to call toString().

Perhaps it is simpler using StringBuilder in this context, i.e.:
 new StringBuilder(formatSize.format(sizeMoved.getValue()).appent(" 
").append(sizeMoved.getUnit()).toString()
Line 78:         return builder.toString();
Line 79:     }
Line 80: 
Line 81:     public Date getStopTime() {


....................................................
File 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/SizeConverter.java
Line 11:     public static final long BYTES_IN_KB = 1024L;
Line 12:     public static final long BYTES_IN_MB = 1024L * 1024L;
Line 13:     public static final long BYTES_IN_GB = 1024L * 1024L * 1024L;
Line 14: 
Line 15:     public static Map<Long, SizeUnit> weightToUnit = new TreeMap<Long, 
SizeUnit>(new CompareUnits());
if this is used internally, could you change its visibility to private ?
Line 16: 
Line 17:     public static enum SizeUnit {
Line 18:         BYTES(1),
Line 19:         KB(2),


Line 43:     }
Line 44: 
Line 45:     public static Size autoConvert(long size, SizeUnit inUnit) {
Line 46: 
Line 47:         for (long i = weightToUnit.size(); i >= 
inUnit.getUnitWeight(); i--) {
IIUC, the only usage of the values is to iterate from the bigger unit to lower 
unit.
So instead of implementing a reverse order here, i'd change the implementation 
of CompareUnits.unit1Weight to be reversed and i'll iterate over the elements 
in a regular fashion.

It would be be also to construct a simple list:
private static List<SizeUnit> units = new ArrayList<SizeUnit>() {{
    add(GB);
    add(MB);
    add(KB);
    add(BYTE);
}}

or any other variation of creating this list.

The reason i think a tree is not the appropriate data structure for this need 
is:
we always iterate all over its elements.

if agreed, we can drop the tree and the compareUtils and have this list instead 
which can reside inside SizeUnit
Line 48:             if (size / Math.pow(CONVERT_FACTOR, i - 1) >= 1) {
Line 49:                 return new 
SizeConverter.Size(SizeConverter.SizeUnit.getUnit(i), 
SizeConverter.convert(size,
Line 50:                         inUnit,
Line 51:                         SizeUnit.getUnit(i)).doubleValue());


Line 44: 
Line 45:     public static Size autoConvert(long size, SizeUnit inUnit) {
Line 46: 
Line 47:         for (long i = weightToUnit.size(); i >= 
inUnit.getUnitWeight(); i--) {
Line 48:             if (size / Math.pow(CONVERT_FACTOR, i - 1) >= 1) {
is 'i' were suppose to be used here or perhaps better to use 
SizeUnit.getUnit(i).getUnitWeight() ?
Line 49:                 return new 
SizeConverter.Size(SizeConverter.SizeUnit.getUnit(i), 
SizeConverter.convert(size,
Line 50:                         inUnit,
Line 51:                         SizeUnit.getUnit(i)).doubleValue());
Line 52:             }


Line 79:             this.value = value;
Line 80:         }
Line 81:     }
Line 82: 
Line 83:     static class CompareUnits implements Comparator<Long> {
Can the visibility of the CompareUtils can be reduced to private ?
Line 84: 
Line 85:         @Override
Line 86:         public int compare(Long unit1Weight, Long unit2Weight) {
Line 87:             return unit1Weight.compareTo(unit2Weight);


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

Gerrit-MessageType: comment
Gerrit-Change-Id: Iea6c90a098bfddfb616bc2b8ce58c9d0bb567f66
Gerrit-PatchSet: 19
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: anmolbabu <[email protected]>
Gerrit-Reviewer: Kanagaraj M <[email protected]>
Gerrit-Reviewer: Moti Asayag <[email protected]>
Gerrit-Reviewer: Omer Frenkel <[email protected]>
Gerrit-Reviewer: Sahina Bose <[email protected]>
Gerrit-Reviewer: Shubhendu Tripathi <[email protected]>
Gerrit-Reviewer: anmolbabu <[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