use of com.orientechnologies.orient.core.config.OStorageSegmentConfiguration in project orientdb by orientechnologies.
the class ReadWriteDiskCacheTest method testFlushTillLSN.
public void testFlushTillLSN() throws Exception {
closeBufferAndDeleteFile();
File file = new File(storageLocal.getConfiguration().getDirectory());
if (!file.exists())
file.mkdir();
writeAheadLog = new ODiskWriteAheadLog(1024, -1, 10 * 1024, null, true, storageLocal, 10);
final OStorageSegmentConfiguration segmentConfiguration = new OStorageSegmentConfiguration(storageLocal.getConfiguration(), "readWriteDiskCacheTest.tst", 0);
segmentConfiguration.fileType = OFileClassic.NAME;
writeBuffer = new OWOWCache(false, 8 + systemOffset, new OByteBufferPool(8 + systemOffset), 10000, writeAheadLog, 100, 2 * (8 + systemOffset), 2 * (8 + systemOffset) + 4 * (8 + systemOffset), storageLocal, false, files, 10);
writeBuffer.loadRegisteredFiles();
readBuffer = new O2QCache(4 * (8 + systemOffset), 8 + systemOffset, false, 20);
long fileId = readBuffer.addFile(fileName, writeBuffer);
OLogSequenceNumber lsnToFlush = null;
for (int i = 0; i < 8; i++) {
OCacheEntry cacheEntry = readBuffer.load(fileId, i, false, writeBuffer, 1);
if (cacheEntry == null) {
cacheEntry = readBuffer.allocateNewPage(fileId, writeBuffer);
Assert.assertEquals(cacheEntry.getPageIndex(), i);
}
OCachePointer dataPointer = cacheEntry.getCachePointer();
dataPointer.acquireExclusiveLock();
OLogSequenceNumber pageLSN = writeAheadLog.log(new WriteAheadLogTest.TestRecord(30, false));
setLsn(dataPointer.getSharedBuffer(), pageLSN);
lsnToFlush = pageLSN;
cacheEntry.markDirty();
dataPointer.releaseExclusiveLock();
readBuffer.release(cacheEntry, writeBuffer);
}
Thread.sleep(1000);
Assert.assertEquals(writeAheadLog.getFlushedLsn(), lsnToFlush);
}
Aggregations