use of com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OLogSequenceNumber in project orientdb by orientechnologies.
the class OLocalPaginatedStorage method copyWALToIncrementalBackup.
@Override
protected OLogSequenceNumber copyWALToIncrementalBackup(ZipOutputStream zipOutputStream, long startSegment) throws IOException {
File[] nonActiveSegments;
OLogSequenceNumber lastLSN;
long freezeId = getAtomicOperationsManager().freezeAtomicOperations(null, null);
try {
lastLSN = writeAheadLog.end();
writeAheadLog.newSegment();
nonActiveSegments = writeAheadLog.nonActiveSegments(startSegment);
} finally {
getAtomicOperationsManager().releaseAtomicOperations(freezeId);
}
for (final File nonActiveSegment : nonActiveSegments) {
final FileInputStream fileInputStream = new FileInputStream(nonActiveSegment);
try {
final BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream);
try {
final ZipEntry entry = new ZipEntry(nonActiveSegment.getName());
zipOutputStream.putNextEntry(entry);
try {
final byte[] buffer = new byte[4096];
int br = 0;
while ((br = bufferedInputStream.read(buffer)) >= 0) {
zipOutputStream.write(buffer, 0, br);
}
} finally {
zipOutputStream.closeEntry();
}
} finally {
bufferedInputStream.close();
}
} finally {
fileInputStream.close();
}
}
return lastLSN;
}
use of com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OLogSequenceNumber in project orientdb by orientechnologies.
the class ClusterPageTest method assertChangesTracking.
private void assertChangesTracking(OClusterPage localPage, ByteBuffer buffer, OByteBufferPool bufferPool) throws IOException {
ByteBuffer restoredBuffer = bufferPool.acquireDirect(true);
OCachePointer cachePointer = new OCachePointer(restoredBuffer, bufferPool, new OLogSequenceNumber(0, 0), 0, 0);
cachePointer.incrementReferrer();
OCacheEntry cacheEntry = new OCacheEntry(0, 0, cachePointer, false);
cacheEntry.acquireExclusiveLock();
try {
OClusterPage restoredPage = new OClusterPage(cacheEntry, false, null);
OWALChanges changes = localPage.getChanges();
restoredPage.restoreChanges(changes);
Assert.assertEquals(getBytes(restoredBuffer, SYSTEM_OFFSET, OClusterPage.PAGE_SIZE - SYSTEM_OFFSET), getBytes(buffer, SYSTEM_OFFSET, OClusterPage.PAGE_SIZE - SYSTEM_OFFSET));
} finally {
cacheEntry.releaseExclusiveLock();
cachePointer.decrementReferrer();
}
}
use of com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OLogSequenceNumber in project orientdb by orientechnologies.
the class ClusterPageTest method testReplaceOneRecordLowerVersion.
public void testReplaceOneRecordLowerVersion() throws Exception {
OByteBufferPool bufferPool = OByteBufferPool.instance();
ByteBuffer buffer = bufferPool.acquireDirect(true);
OCachePointer cachePointer = new OCachePointer(buffer, bufferPool, new OLogSequenceNumber(0, 0), 0, 0);
cachePointer.incrementReferrer();
OCacheEntry cacheEntry = new OCacheEntry(0, 0, cachePointer, false);
cacheEntry.acquireExclusiveLock();
ByteBuffer directBuffer = bufferPool.acquireDirect(true);
OCachePointer directCachePointer = new OCachePointer(directBuffer, bufferPool, new OLogSequenceNumber(0, 0), 0, 0);
directCachePointer.incrementReferrer();
OCacheEntry directCacheEntry = new OCacheEntry(0, 0, directCachePointer, false);
directCacheEntry.acquireExclusiveLock();
try {
OClusterPage localPage = new OClusterPage(cacheEntry, true, new OWALChangesTree());
OClusterPage directLocalPage = new OClusterPage(directCacheEntry, true, null);
replaceOneRecordLowerVersion(localPage);
replaceOneRecordLowerVersion(directLocalPage);
assertChangesTracking(localPage, directBuffer, bufferPool);
} finally {
cacheEntry.releaseExclusiveLock();
directCacheEntry.releaseExclusiveLock();
cachePointer.decrementReferrer();
directCachePointer.decrementReferrer();
}
}
use of com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OLogSequenceNumber in project orientdb by orientechnologies.
the class ClusterPageTest method testDeleteAddEqualVersion.
public void testDeleteAddEqualVersion() throws Exception {
OByteBufferPool bufferPool = OByteBufferPool.instance();
ByteBuffer buffer = bufferPool.acquireDirect(true);
OCachePointer cachePointer = new OCachePointer(buffer, bufferPool, new OLogSequenceNumber(0, 0), 0, 0);
cachePointer.incrementReferrer();
OCacheEntry cacheEntry = new OCacheEntry(0, 0, cachePointer, false);
cacheEntry.acquireExclusiveLock();
ByteBuffer directBuffer = bufferPool.acquireDirect(true);
OCachePointer directCachePointer = new OCachePointer(directBuffer, bufferPool, new OLogSequenceNumber(0, 0), 0, 0);
directCachePointer.incrementReferrer();
OCacheEntry directCacheEntry = new OCacheEntry(0, 0, directCachePointer, false);
directCacheEntry.acquireExclusiveLock();
try {
OClusterPage localPage = new OClusterPage(cacheEntry, true, new OWALChangesTree());
OClusterPage directLocalPage = new OClusterPage(directCacheEntry, true, null);
deleteAddEqualVersion(localPage);
deleteAddEqualVersion(directLocalPage);
assertChangesTracking(localPage, directBuffer, bufferPool);
} finally {
cacheEntry.releaseExclusiveLock();
directCacheEntry.releaseExclusiveLock();
cachePointer.decrementReferrer();
directCachePointer.decrementReferrer();
}
}
use of com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OLogSequenceNumber in project orientdb by orientechnologies.
the class ClusterPageTest method testDeleteAddLowerVersion.
public void testDeleteAddLowerVersion() throws Exception {
OByteBufferPool bufferPool = OByteBufferPool.instance();
ByteBuffer buffer = bufferPool.acquireDirect(true);
OCachePointer cachePointer = new OCachePointer(buffer, bufferPool, new OLogSequenceNumber(0, 0), 0, 0);
cachePointer.incrementReferrer();
OCacheEntry cacheEntry = new OCacheEntry(0, 0, cachePointer, false);
cacheEntry.acquireExclusiveLock();
ByteBuffer directBuffer = bufferPool.acquireDirect(true);
OCachePointer directCachePointer = new OCachePointer(directBuffer, bufferPool, new OLogSequenceNumber(0, 0), 0, 0);
directCachePointer.incrementReferrer();
OCacheEntry directCacheEntry = new OCacheEntry(0, 0, directCachePointer, false);
directCacheEntry.acquireExclusiveLock();
try {
OClusterPage localPage = new OClusterPage(cacheEntry, true, new OWALChangesTree());
OClusterPage directLocalPage = new OClusterPage(directCacheEntry, true, null);
deleteAddLowerVersion(localPage);
deleteAddLowerVersion(directLocalPage);
assertChangesTracking(localPage, directBuffer, bufferPool);
} finally {
cacheEntry.releaseExclusiveLock();
directCacheEntry.releaseExclusiveLock();
cachePointer.decrementReferrer();
directCachePointer.decrementReferrer();
}
}
Aggregations