use of com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage in project orientdb by orientechnologies.
the class OLocalHashTableWALTest method restoreDataFromWAL.
private void restoreDataFromWAL() throws IOException {
OWriteAheadLog log = ((OAbstractPaginatedStorage) databaseDocumentTx.getStorage()).getWALInstance();
OLogSequenceNumber lsn = log.begin();
List<OWALRecord> atomicUnit = new ArrayList<OWALRecord>();
List<OWALRecord> batch = new ArrayList<OWALRecord>();
boolean atomicChangeIsProcessed = false;
while (lsn != null) {
OWALRecord walRecord = log.read(lsn);
batch.add(walRecord);
if (batch.size() >= 1000) {
atomicChangeIsProcessed = restoreDataFromBatch(atomicChangeIsProcessed, atomicUnit, batch);
batch = new ArrayList<OWALRecord>();
}
lsn = log.next(lsn);
}
if (batch.size() > 0) {
restoreDataFromBatch(atomicChangeIsProcessed, atomicUnit, batch);
batch = null;
}
Assert.assertTrue(atomicUnit.isEmpty());
OWriteCache writeCache = ((OAbstractPaginatedStorage) expectedDatabaseDocumentTx.getStorage()).getWriteCache();
writeCache.flush();
}
use of com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage in project orientdb by orientechnologies.
the class OLocalHashTableWALTest method restoreDataFromBatch.
private boolean restoreDataFromBatch(boolean atomicChangeIsProcessed, List<OWALRecord> atomicUnit, List<OWALRecord> records) throws IOException {
final OReadCache expectedReadCache = ((OAbstractPaginatedStorage) expectedDatabaseDocumentTx.getStorage()).getReadCache();
final OWriteCache expectedWriteCache = ((OAbstractPaginatedStorage) expectedDatabaseDocumentTx.getStorage()).getWriteCache();
for (OWALRecord walRecord : records) {
if (walRecord instanceof OOperationUnitBodyRecord)
atomicUnit.add(walRecord);
if (!atomicChangeIsProcessed && walRecord instanceof OAtomicUnitStartRecord) {
atomicChangeIsProcessed = true;
} else if (walRecord instanceof OAtomicUnitEndRecord) {
atomicChangeIsProcessed = false;
for (OWALRecord restoreRecord : atomicUnit) {
if (restoreRecord instanceof OAtomicUnitStartRecord || restoreRecord instanceof OAtomicUnitEndRecord || restoreRecord instanceof ONonTxOperationPerformedWALRecord || restoreRecord instanceof OFullCheckpointStartRecord || restoreRecord instanceof OCheckpointEndRecord)
continue;
if (restoreRecord instanceof OUpdatePageRecord) {
final OUpdatePageRecord updatePageRecord = (OUpdatePageRecord) restoreRecord;
final long fileId = updatePageRecord.getFileId();
final long pageIndex = updatePageRecord.getPageIndex();
OCacheEntry cacheEntry = expectedReadCache.load(fileId, pageIndex, true, expectedWriteCache, 1);
if (cacheEntry == null)
do {
cacheEntry = expectedReadCache.allocateNewPage(fileId, expectedWriteCache);
} while (cacheEntry.getPageIndex() != pageIndex);
cacheEntry.acquireExclusiveLock();
try {
ODurablePage durablePage = new ODurablePage(cacheEntry, null);
durablePage.restoreChanges(updatePageRecord.getChanges());
durablePage.setLsn(updatePageRecord.getLsn());
} finally {
cacheEntry.releaseExclusiveLock();
expectedReadCache.release(cacheEntry, expectedWriteCache);
}
} else if (restoreRecord instanceof OFileCreatedWALRecord) {
final OFileCreatedWALRecord fileCreatedCreatedRecord = (OFileCreatedWALRecord) restoreRecord;
String fileName = fileCreatedCreatedRecord.getFileName().replace("actualLocalHashTable", "expectedLocalHashTable");
if (!expectedWriteCache.exists(fileName))
expectedReadCache.addFile(fileName, fileCreatedCreatedRecord.getFileId(), expectedWriteCache);
}
}
atomicUnit.clear();
} else {
Assert.assertTrue(walRecord instanceof OUpdatePageRecord || walRecord instanceof OFileCreatedWALRecord || walRecord instanceof ONonTxOperationPerformedWALRecord || walRecord instanceof OFullCheckpointStartRecord || walRecord instanceof OCheckpointEndRecord || walRecord instanceof OFuzzyCheckpointStartRecord || walRecord instanceof OFuzzyCheckpointEndRecord);
}
}
return atomicChangeIsProcessed;
}
use of com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage in project orientdb by orientechnologies.
the class OSBTreeBonsaiLocalTest method beforeClass.
@BeforeClass
public void beforeClass() {
String buildDirectory = System.getProperty("buildDirectory");
if (buildDirectory == null)
buildDirectory = "./target";
databaseDocumentTx = new ODatabaseDocumentTx("plocal:" + buildDirectory + "/localSBTreeBonsaiTest");
if (databaseDocumentTx.exists()) {
databaseDocumentTx.open("admin", "admin");
databaseDocumentTx.drop();
}
databaseDocumentTx.create();
sbTree = new OSBTreeBonsaiLocal<Integer, OIdentifiable>("actualSBTreeBonsaiLocalTest", ".irs", (OAbstractPaginatedStorage) databaseDocumentTx.getStorage());
sbTree.create(OIntegerSerializer.INSTANCE, OLinkSerializer.INSTANCE);
}
use of com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage in project orientdb by orientechnologies.
the class LocalPaginatedClusterTest method beforeClass.
@BeforeClass
public void beforeClass() throws IOException {
System.out.println("Start LocalPaginatedClusterTest");
buildDirectory = System.getProperty("buildDirectory");
if (buildDirectory == null || buildDirectory.isEmpty())
buildDirectory = ".";
buildDirectory += "/localPaginatedClusterTest";
databaseDocumentTx = new ODatabaseDocumentTx("plocal:" + buildDirectory + File.separator + LocalPaginatedClusterTest.class.getSimpleName());
if (databaseDocumentTx.exists()) {
databaseDocumentTx.open("admin", "admin");
databaseDocumentTx.drop();
}
databaseDocumentTx.create();
OAbstractPaginatedStorage storage = (OAbstractPaginatedStorage) databaseDocumentTx.getStorage();
paginatedCluster = new OPaginatedCluster("paginatedClusterTest", storage);
paginatedCluster.configure(storage, 5, "paginatedClusterTest", buildDirectory, -1);
paginatedCluster.create(-1);
}
use of com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage in project orientdb by orientechnologies.
the class NonDurableTxTest method before.
@Before
public void before() {
String buildDirectory = System.getProperty("buildDirectory");
if (buildDirectory == null)
buildDirectory = ".";
db = new ODatabaseDocumentTx("plocal:" + buildDirectory + File.separator + NonDurableTxTest.class.getSimpleName());
if (db.exists()) {
db.open("admin", "admin");
db.drop();
}
db.create();
final OAbstractPaginatedStorage storage = (OAbstractPaginatedStorage) db.getStorage();
atomicOperationsManager = storage.getAtomicOperationsManager();
wal = storage.getWALInstance();
}
Aggregations