use of com.ctrip.xpipe.api.utils.FileSize in project x-pipe by ctripcorp.
the class DefaultRdbStore method createControllableFile.
private ControllableFile createControllableFile() throws IOException {
if (eofType instanceof LenEofType) {
return new DefaultControllableFile(file);
} else if (eofType instanceof EofMarkType) {
return new SizeControllableFile(file, new FileSize() {
@Override
public long getSize(LongSupplier realSizeProvider) {
long realSize = 0;
synchronized (truncateLock) {
// truncate may make size wrong
realSize = realSizeProvider.getAsLong();
}
if (status.get() == Status.Writing) {
long ret = realSize - ((EofMarkType) eofType).getTag().length();
logger.debug("[getSize][writing]{}, {}", DefaultRdbStore.this, ret);
return ret < 0 ? 0 : ret;
}
return realSize;
}
});
} else {
throw new IllegalStateException("unknown eoftype:" + eofType.getClass() + "," + eofType);
}
}
Aggregations