use of com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OLogSequenceNumber in project orientdb by orientechnologies.
the class OSBTreeBonsaiLeafBucketTest method testSetRightSibling.
public void testSetRightSibling() 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();
OSBTreeBonsaiBucket<Long, OIdentifiable> treeBucket = new OSBTreeBonsaiBucket<Long, OIdentifiable>(cacheEntry, 0, true, OLongSerializer.INSTANCE, OLinkSerializer.INSTANCE, null, null);
final OBonsaiBucketPointer p = new OBonsaiBucketPointer(123, 8192 * 2);
treeBucket.setRightSibling(p);
Assert.assertEquals(treeBucket.getRightSibling(), p);
cacheEntry.releaseExclusiveLock();
cachePointer.decrementReferrer();
}
use of com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OLogSequenceNumber in project orientdb by orientechnologies.
the class ODistributedStorage method executeRecordOperationInLock.
private Object executeRecordOperationInLock(final boolean iUnlockAtTheEnd, final ORecordId rid, final OCallable<Object, OCallable<Void, ODistributedRequestId>> callback) throws Exception {
final ORecordId rid2Lock;
if (!rid.isPersistent())
// CREATE A COPY TO MAINTAIN THE LOCK ON THE CLUSTER AVOIDING THE RID IS TRANSFORMED IN PERSISTENT. THIS ALLOWS TO HAVE
// PARALLEL TX BECAUSE NEW RID LOCKS THE ENTIRE CLUSTER.
rid2Lock = new ORecordId(rid.getClusterId(), -1l);
else
rid2Lock = rid;
ODistributedRequestId requestId = null;
final OLogSequenceNumber lastLSN = wrapped.getLSN();
final AtomicBoolean lockReleased = new AtomicBoolean(false);
try {
requestId = acquireRecordLock(rid2Lock);
final ODistributedRequestId finalReqId = requestId;
final OCallable<Void, ODistributedRequestId> unlockCallback = new OCallable<Void, ODistributedRequestId>() {
@Override
public Void call(final ODistributedRequestId requestId) {
// UNLOCK AS SOON AS THE REQUEST IS SENT
if (lockReleased.compareAndSet(false, true)) {
releaseRecordLock(rid2Lock, finalReqId);
lockReleased.set(true);
}
return null;
}
};
return OScenarioThreadLocal.executeAsDistributed(new Callable() {
@Override
public Object call() throws Exception {
return callback.call(unlockCallback);
}
});
} finally {
if (iUnlockAtTheEnd) {
if (lockReleased.compareAndSet(false, true)) {
releaseRecordLock(rid2Lock, requestId);
}
}
final OLogSequenceNumber currentLSN = wrapped.getLSN();
if (!lastLSN.equals(currentLSN))
// SAVE LAST LSN
try {
localDistributedDatabase.getSyncConfiguration().setLastLSN(getDistributedManager().getLocalNodeName(), ((OLocalPaginatedStorage) getUnderlying()).getLSN(), true);
} catch (IOException e) {
ODistributedServerLog.debug(this, dManager != null ? dManager.getLocalNodeName() : "?", null, ODistributedServerLog.DIRECTION.NONE, "Error on updating local LSN configuration for database '%s'", wrapped.getName());
}
}
}
use of com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OLogSequenceNumber in project orientdb by orientechnologies.
the class NonDurableTxTest method testWalNotGrowingWhileWalDisabledInTx.
@Test
public void testWalNotGrowingWhileWalDisabledInTx() {
db.newInstance().field("some-unrelated-key", "some-unrelated-value").save();
wal.flush();
final OLogSequenceNumber startLsn = wal.getFlushedLsn();
db.begin();
db.getTransaction().setUsingLog(false);
db.newInstance().field("tx-key", "tx-value").save();
db.commit();
wal.flush();
final OLogSequenceNumber endLsn = wal.getFlushedLsn();
Assert.assertEquals(startLsn, endLsn);
}
use of com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OLogSequenceNumber in project orientdb by orientechnologies.
the class LRUListTest method testAddOneRemoveLRU.
@Test
public void testAddOneRemoveLRU() {
final OByteBufferPool bufferPool = new OByteBufferPool(1);
ByteBuffer buffer = bufferPool.acquireDirect(true);
OCachePointer cachePointerOne = new OCachePointer(buffer, bufferPool, new OLogSequenceNumber(0, 0), 0, 0);
lruList.putToMRU(new OCacheEntry(1, 10, cachePointerOne, false));
lruList.removeLRU();
Assert.assertEquals(lruList.size(), 0);
Iterator<OCacheEntry> entryIterator = lruList.iterator();
Assert.assertFalse(entryIterator.hasNext());
}
use of com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OLogSequenceNumber in project orientdb by orientechnologies.
the class LRUListTest method testSingleAdd.
@Test
public void testSingleAdd() {
final OByteBufferPool bufferPool = new OByteBufferPool(1);
final ByteBuffer buffer = bufferPool.acquireDirect(true);
OCachePointer cachePointer = new OCachePointer(buffer, bufferPool, new OLogSequenceNumber(0, 0), 0, 0);
lruList.putToMRU(new OCacheEntry(1, 10, cachePointer, false));
Iterator<OCacheEntry> entryIterator = lruList.iterator();
Assert.assertTrue(entryIterator.hasNext());
Assert.assertEquals(entryIterator.next(), new OCacheEntry(1, 10, cachePointer, false));
}
Aggregations