Skip to content

Commit

Permalink
v0.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Kurilov committed Dec 4, 2017
1 parent 232f1a8 commit d3dc4f2
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 37 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ apply plugin: "maven"
apply plugin: "signing"

group = "com.github.emc-mongoose"
version = "0.1.3"
version = "0.1.4"

tasks.withType(JavaCompile) {
sourceCompatibility = JavaVersion.VERSION_1_8
Expand All @@ -34,7 +34,7 @@ ext {
depVersion = [
commonsJava: "[1.3.0,)",
log4j: "2.8.2",
mongoose: "[3.6.0,)",
mongoose: "3.+",
]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.ReadableByteChannel;
Expand Down Expand Up @@ -380,15 +381,16 @@ private void invokeReadAndVerify(
final int nextRangeIdx = ioTask.getCurrRangeIdx() + 1;
final long nextRangeOffset = getRangeOffset(nextRangeIdx);
if(currRange != null) {
final int n = currRange.readAndVerify(
srcChannel,
DirectMemUtil.getThreadLocalReusableBuff(
nextRangeOffset - countBytesDone
)
final ByteBuffer inBuff = DirectMemUtil.getThreadLocalReusableBuff(
nextRangeOffset - countBytesDone
);
final int n = srcChannel.read(inBuff);
if(n < 0) {
throw new DataSizeException(contentSize, countBytesDone);
} else {
inBuff.flip();
currRange.verify(inBuff);
currRange.position(currRange.position() + n);
countBytesDone += n;
if(countBytesDone == nextRangeOffset) {
ioTask.setCurrRangeIdx(nextRangeIdx);
Expand All @@ -398,16 +400,18 @@ private void invokeReadAndVerify(
throw new AssertionError("Null data range");
}
} else {
final int n = fileItem.readAndVerify(
srcChannel,
DirectMemUtil.getThreadLocalReusableBuff(
contentSize - countBytesDone
)
final ByteBuffer inBuff = DirectMemUtil.getThreadLocalReusableBuff(
contentSize - countBytesDone
);
final int n = srcChannel.read(inBuff);
if(n < 0) {
throw new DataSizeException(contentSize, countBytesDone);
} else {
inBuff.flip();
fileItem.verify(inBuff);
fileItem.position(fileItem.position() + n);
countBytesDone += n;
}
countBytesDone += n;
}
} catch(final DataCorruptionException e) {
ioTask.setStatus(Status.RESP_FAIL_CORRUPT);
Expand Down Expand Up @@ -464,16 +468,21 @@ private void invokeReadAndVerifyRandomRanges(
final long currRangeSize = range2read.size();
final long currPos = getRangeOffset(currRangeIdx) + countBytesDone;
srcChannel.position(currPos);

try {
countBytesDone += range2read.readAndVerify(
srcChannel,
DirectMemUtil.getThreadLocalReusableBuff(currRangeSize - countBytesDone)
);
} catch(final DataCorruptionException e) {
throw new DataCorruptionException(
currPos + e.getOffset() - countBytesDone, e.expected, e.actual
);
final ByteBuffer inBuff = DirectMemUtil.getThreadLocalReusableBuff(currRangeSize - countBytesDone);
final int n = srcChannel.read(inBuff);
if(n < 0) {
throw new DataSizeException(rangesSizeSum, countBytesDone);
} else {
inBuff.flip();
try {
range2read.verify(inBuff);
range2read.position(range2read.position() + n);
countBytesDone += n;
} catch(final DataCorruptionException e) {
throw new DataCorruptionException(
currPos + e.getOffset() - countBytesDone, e.expected, e.actual
);
}
}

if(Loggers.MSG.isTraceEnabled()) {
Expand Down Expand Up @@ -549,20 +558,23 @@ private void invokeReadAndVerifyFixedRanges(
currRange.position(currOffset - cellOffset);
srcChannel.position(currOffset);

try {
rangeBytesDone += currRange.readAndVerify(
srcChannel,
DirectMemUtil.getThreadLocalReusableBuff(
Math.min(
fixedRangeSize - countBytesDone,
currRange.size() - currRange.position()
)
)
);
} catch(final DataCorruptionException e) {
throw new DataCorruptionException(
currOffset + e.getOffset() - countBytesDone, e.expected, e.actual
);
final ByteBuffer inBuff = DirectMemUtil.getThreadLocalReusableBuff(
Math.min(fixedRangeSize - countBytesDone, currRange.size() - currRange.position())
);
final int m = srcChannel.read(inBuff);
if(m < 0) {

} else {
inBuff.flip();
try {
currRange.verify(inBuff);
currRange.position(currRange.position() + m);
rangeBytesDone += m;
} catch(final DataCorruptionException e) {
throw new DataCorruptionException(
currOffset + e.getOffset() - countBytesDone, e.expected, e.actual
);
}
}

if(rangeBytesDone == fixedRangeSize) {
Expand Down

0 comments on commit d3dc4f2

Please sign in to comment.