Skip to content

Commit

Permalink
+ fixed ranges update size estimation issue fix
Browse files Browse the repository at this point in the history
+ issue #1012 final fix
+ missing summary metrics output newline
  • Loading branch information
Andrey Kurilov committed Jun 28, 2017
1 parent 4638729 commit 58f078a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ public final long getEnd() {
return end;
}

/**
Note that this method may return -1 if begin and end are set (size is not -1 actually)
@return the size of the range having no position
*/
public final long getSize() {
return size;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,18 @@ private static long estimateTransferSize(
if(randomRangesCount > 0) {
return itemSize * randomRangesCount / getRangeCount(itemSize);
} else if(fixedRanges != null && !fixedRanges.isEmpty()) {
return fixedRanges
.stream()
.mapToLong(ByteRange::getSize)
.filter(size -> size > 0)
.sum();
long sizeSum = 0;
long rangeSize;
for(final ByteRange byteRange : fixedRanges) {
rangeSize = byteRange.getSize();
if(rangeSize == -1) {
rangeSize = byteRange.getEnd() - byteRange.getBeg() + 1;
}
if(rangeSize > 0) {
sizeSum += rangeSize;
}
}
return sizeSum;
} else {
return itemSize;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public final void formatTo(final StringBuilder buffer) {
.append(snapshot.getDurationMax()).append("); lat[us]=(")
.append((long) snapshot.getLatencyMean()).append('/')
.append(snapshot.getLatencyMin()).append('/')
.append(snapshot.getLatencyMax()).append(')');
.append(snapshot.getLatencyMax()).append(')')
.append(System.lineSeparator());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,18 @@ public void reset()
}
case UPDATE:
if(randomRangesCount == 0 && (fixedRanges == null || fixedRanges.isEmpty())) {
fixedRanges = new ArrayList<>(1);
try {
contentSize = item.size();
} catch(IOException e) {
throw new AssertionError();
fixedRanges.add(new ByteRange(0L, item.size() - 1, -1));
} catch(final Exception e) {
throw new AssertionError(e);
}
} else {
if(randomRangesCount > 0) {
markRandomRanges(randomRangesCount);
}
contentSize = getMarkedRangesSize();
}
contentSize = getMarkedRangesSize();
break;
default:
contentSize = 0;
Expand Down

0 comments on commit 58f078a

Please sign in to comment.