Search in sources :

Example 36 with LogPosition

use of org.neo4j.kernel.impl.transaction.log.LogPosition in project neo4j by neo4j.

the class LogPositionMarkerTest method shouldReturnTheMarkedPosition.

@Test
public void shouldReturnTheMarkedPosition() {
    // given
    final LogPositionMarker marker = new LogPositionMarker();
    // when
    marker.mark(1, 2);
    final LogPosition logPosition = marker.newPosition();
    // given
    assertEquals(new LogPosition(1, 2), logPosition);
}
Also used : LogPositionMarker(org.neo4j.kernel.impl.transaction.log.LogPositionMarker) LogPosition(org.neo4j.kernel.impl.transaction.log.LogPosition) Test(org.junit.Test)

Example 37 with LogPosition

use of org.neo4j.kernel.impl.transaction.log.LogPosition in project neo4j by neo4j.

the class LogPositionMarkerTest method shouldReturnUnspecifiedIfNothingHasBeenMarked.

@Test
public void shouldReturnUnspecifiedIfNothingHasBeenMarked() {
    // given
    final LogPositionMarker marker = new LogPositionMarker();
    // when
    final LogPosition logPosition = marker.newPosition();
    // given
    assertEquals(LogPosition.UNSPECIFIED, logPosition);
}
Also used : LogPositionMarker(org.neo4j.kernel.impl.transaction.log.LogPositionMarker) LogPosition(org.neo4j.kernel.impl.transaction.log.LogPosition) Test(org.junit.Test)

Example 38 with LogPosition

use of org.neo4j.kernel.impl.transaction.log.LogPosition in project neo4j by neo4j.

the class LogVersionLocatorTest method shouldFindLogPosition.

@Test
public void shouldFindLogPosition() throws NoSuchTransactionException {
    // given
    final long txId = 42L;
    final PhysicalLogicalTransactionStore.LogVersionLocator locator = new PhysicalLogicalTransactionStore.LogVersionLocator(txId);
    final LogPosition position = new LogPosition(1, 128);
    // when
    final boolean result = locator.visit(position, firstTxIdInLog, lastTxIdInLog);
    // then
    assertFalse(result);
    assertEquals(position, locator.getLogPosition());
}
Also used : PhysicalLogicalTransactionStore(org.neo4j.kernel.impl.transaction.log.PhysicalLogicalTransactionStore) LogPosition(org.neo4j.kernel.impl.transaction.log.LogPosition) Test(org.junit.Test)

Example 39 with LogPosition

use of org.neo4j.kernel.impl.transaction.log.LogPosition in project neo4j by neo4j.

the class LogVersionLocatorTest method shouldNotFindLogPosition.

@Test
public void shouldNotFindLogPosition() throws NoSuchTransactionException {
    // given
    final long txId = 1L;
    final PhysicalLogicalTransactionStore.LogVersionLocator locator = new PhysicalLogicalTransactionStore.LogVersionLocator(txId);
    final LogPosition position = new LogPosition(1, 128);
    // when
    final boolean result = locator.visit(position, firstTxIdInLog, lastTxIdInLog);
    // then
    assertTrue(result);
    try {
        locator.getLogPosition();
        fail("should have thrown");
    } catch (NoSuchTransactionException e) {
        assertEquals("Unable to find transaction " + txId + " in any of my logical logs: " + "Couldn't find any log containing " + txId, e.getMessage());
    }
}
Also used : PhysicalLogicalTransactionStore(org.neo4j.kernel.impl.transaction.log.PhysicalLogicalTransactionStore) NoSuchTransactionException(org.neo4j.kernel.impl.transaction.log.NoSuchTransactionException) LogPosition(org.neo4j.kernel.impl.transaction.log.LogPosition) Test(org.junit.Test)

Example 40 with LogPosition

use of org.neo4j.kernel.impl.transaction.log.LogPosition in project neo4j by neo4j.

the class TransactionMetadataCacheTest method shouldReturnTheTxValueTIfInTheCached.

@Test
public void shouldReturnTheTxValueTIfInTheCached() {
    // given
    final TransactionMetadataCache cache = new TransactionMetadataCache(2);
    final LogPosition position = new LogPosition(3, 4);
    final int txId = 42;
    final int masterId = 0;
    final int authorId = 1;
    final int checksum = 2;
    final long timestamp = System.currentTimeMillis();
    // when
    cache.cacheTransactionMetadata(txId, position, masterId, authorId, checksum, timestamp);
    final TransactionMetadataCache.TransactionMetadata metadata = cache.getTransactionMetadata(txId);
    // then
    assertEquals(new TransactionMetadataCache.TransactionMetadata(masterId, authorId, position, checksum, timestamp), metadata);
}
Also used : TransactionMetadataCache(org.neo4j.kernel.impl.transaction.log.TransactionMetadataCache) LogPosition(org.neo4j.kernel.impl.transaction.log.LogPosition) Test(org.junit.Test)

Aggregations

LogPosition (org.neo4j.kernel.impl.transaction.log.LogPosition)42 Test (org.junit.Test)26 File (java.io.File)11 PhysicalLogFile (org.neo4j.kernel.impl.transaction.log.PhysicalLogFile)9 PhysicalLogFiles (org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles)9 IOException (java.io.IOException)6 LogPositionMarker (org.neo4j.kernel.impl.transaction.log.LogPositionMarker)6 ReadableClosablePositionAwareChannel (org.neo4j.kernel.impl.transaction.log.ReadableClosablePositionAwareChannel)5 TransactionMetadataCache (org.neo4j.kernel.impl.transaction.log.TransactionMetadataCache)5 VersionAwareLogEntryReader (org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader)5 InMemoryClosableChannel (org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel)4 LogHeaderCache (org.neo4j.kernel.impl.transaction.log.LogHeaderCache)4 CheckPoint (org.neo4j.kernel.impl.transaction.log.entry.CheckPoint)4 LogEntry (org.neo4j.kernel.impl.transaction.log.entry.LogEntry)4 LogEntryWriter (org.neo4j.kernel.impl.transaction.log.entry.LogEntryWriter)4 LifeSupport (org.neo4j.kernel.lifecycle.LifeSupport)4 LatestCheckPoint (org.neo4j.kernel.recovery.LatestCheckPointFinder.LatestCheckPoint)4 LogFile (org.neo4j.kernel.impl.transaction.log.LogFile)3 PhysicalLogicalTransactionStore (org.neo4j.kernel.impl.transaction.log.PhysicalLogicalTransactionStore)3 HashMap (java.util.HashMap)2