use of com.ctrip.xpipe.redis.core.protocal.protocal.EofMarkType in project x-pipe by ctripcorp.
the class DefaultRdbStoreEofMarkTest method beforeDefaultRdbStoreEofMarkTest.
@Before
public void beforeDefaultRdbStoreEofMarkTest() throws IOException {
rdbFile = new File(String.format("%s/%s.rdb", getTestFileDir(), getTestName()));
rdbStore = new DefaultRdbStore(rdbFile, 0, new EofMarkType(eofMark));
}
use of com.ctrip.xpipe.redis.core.protocal.protocal.EofMarkType 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