Search in sources :

Example 51 with PhysicalLogFiles

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

the class PhysicalLogFilesTest method shouldGetTheFileNameForAGivenVersion.

@Test
public void shouldGetTheFileNameForAGivenVersion() {
    // given
    final PhysicalLogFiles files = new PhysicalLogFiles(tmpDirectory, filename, fs);
    final int version = 12;
    // when
    final File versionFileName = files.getLogFileForVersion(version);
    // then
    final File expected = new File(tmpDirectory, filename + DEFAULT_VERSION_SUFFIX + version);
    assertEquals(expected, versionFileName);
}
Also used : File(java.io.File) PhysicalLogFiles(org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles) Test(org.junit.Test)

Example 52 with PhysicalLogFiles

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

the class PhysicalLogFilesTest method shouldVisitEachLofFile.

@Test
public void shouldVisitEachLofFile() {
    // given
    PhysicalLogFiles files = new PhysicalLogFiles(tmpDirectory, filename, fs);
    final File[] filesOnDisk = new File[] { new File(tmpDirectory, filename + DEFAULT_VERSION_SUFFIX + "1"), new File(tmpDirectory, "crap" + DEFAULT_VERSION_SUFFIX + "2"), new File(tmpDirectory, filename + DEFAULT_VERSION_SUFFIX + "3"), new File(tmpDirectory, filename) };
    when(fs.listFiles(tmpDirectory)).thenReturn(filesOnDisk);
    // when
    final List<File> seenFiles = new ArrayList<>();
    final List<Long> seenVersions = new ArrayList<>();
    files.accept(new PhysicalLogFiles.LogVersionVisitor() {

        @Override
        public void visit(File file, long logVersion) {
            seenFiles.add(file);
            seenVersions.add(logVersion);
        }
    });
    // then
    assertEquals(Arrays.asList(new File(tmpDirectory, filename + DEFAULT_VERSION_SUFFIX + "1"), new File(tmpDirectory, filename + DEFAULT_VERSION_SUFFIX + "3")), seenFiles);
    assertEquals(Arrays.asList(1L, 3L), seenVersions);
}
Also used : ArrayList(java.util.ArrayList) File(java.io.File) PhysicalLogFiles(org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles) Test(org.junit.Test)

Aggregations

PhysicalLogFiles (org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles)52 File (java.io.File)37 Test (org.junit.Test)29 PhysicalLogFile (org.neo4j.kernel.impl.transaction.log.PhysicalLogFile)28 Command (org.neo4j.kernel.impl.transaction.command.Command)15 IOException (java.io.IOException)14 LogEntryWriter (org.neo4j.kernel.impl.transaction.log.entry.LogEntryWriter)12 LogPosition (org.neo4j.kernel.impl.transaction.log.LogPosition)11 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)9 ReadableClosablePositionAwareChannel (org.neo4j.kernel.impl.transaction.log.ReadableClosablePositionAwareChannel)8 VersionAwareLogEntryReader (org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader)8 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)7 LatestCheckPointFinder (org.neo4j.kernel.recovery.LatestCheckPointFinder)7 LogFile (org.neo4j.kernel.impl.transaction.log.LogFile)6 TransactionLogWriter (org.neo4j.kernel.impl.transaction.log.TransactionLogWriter)6 Function (java.util.function.Function)5 Assert.assertEquals (org.junit.Assert.assertEquals)5 Assert.assertTrue (org.junit.Assert.assertTrue)5 Rule (org.junit.Rule)5 StoreChannel (org.neo4j.io.fs.StoreChannel)5