Skip to content

Commit

Permalink
Refactor to use renamed setting and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
klaren committed Sep 5, 2017
1 parent 7697882 commit d72c3e8
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
Expand Up @@ -41,7 +41,7 @@ private LogVersionUpgradeChecker()


public static void check( LogTailScanner tailScanner, Config config ) throws UpgradeNotAllowedByConfigurationException public static void check( LogTailScanner tailScanner, Config config ) throws UpgradeNotAllowedByConfigurationException
{ {
if ( !config.get( GraphDatabaseSettings.allow_store_upgrade ) ) if ( !config.get( GraphDatabaseSettings.allow_upgrade ) )
{ {
// The user doesn't want us to upgrade the store. // The user doesn't want us to upgrade the store.
LogEntryVersion latestLogEntryVersion = tailScanner.getTailInformation().latestLogEntryVersion; LogEntryVersion latestLogEntryVersion = tailScanner.getTailInformation().latestLogEntryVersion;
Expand Down
Expand Up @@ -46,7 +46,7 @@ public class LogEntryWriter
*/ */
public LogEntryWriter( FlushableChannel channel ) public LogEntryWriter( FlushableChannel channel )
{ {
this(channel, CURRENT ); this( channel, CURRENT );
} }


/** /**
Expand Down
Expand Up @@ -66,7 +66,7 @@ public void startAsNormalWhenUpgradeIsNotAllowed() throws Exception
final GraphDatabaseService db = new TestGraphDatabaseFactory() final GraphDatabaseService db = new TestGraphDatabaseFactory()
.setFileSystem( fs.get() ) .setFileSystem( fs.get() )
.newImpermanentDatabaseBuilder( storeDirectory.graphDbDir() ) .newImpermanentDatabaseBuilder( storeDirectory.graphDbDir() )
.setConfig( GraphDatabaseSettings.allow_store_upgrade, "false" ) .setConfig( GraphDatabaseSettings.allow_upgrade, "false" )
.newGraphDatabase(); .newGraphDatabase();
db.shutdown(); db.shutdown();
} }
Expand All @@ -82,7 +82,7 @@ public void failToStartFromOlderTransactionLogsIfNotAllowed() throws Exception
final GraphDatabaseService db = new TestGraphDatabaseFactory() final GraphDatabaseService db = new TestGraphDatabaseFactory()
.setFileSystem( fs.get() ) .setFileSystem( fs.get() )
.newImpermanentDatabaseBuilder( storeDirectory.graphDbDir() ) .newImpermanentDatabaseBuilder( storeDirectory.graphDbDir() )
.setConfig( GraphDatabaseSettings.allow_store_upgrade, "false" ) .setConfig( GraphDatabaseSettings.allow_upgrade, "false" )
.newGraphDatabase(); .newGraphDatabase();
db.shutdown(); db.shutdown();
} }
Expand All @@ -96,7 +96,7 @@ public void startFromOlderTransactionLogsIfAllowed() throws Exception
final GraphDatabaseService db = new TestGraphDatabaseFactory() final GraphDatabaseService db = new TestGraphDatabaseFactory()
.setFileSystem( fs.get() ) .setFileSystem( fs.get() )
.newImpermanentDatabaseBuilder( storeDirectory.graphDbDir() ) .newImpermanentDatabaseBuilder( storeDirectory.graphDbDir() )
.setConfig( GraphDatabaseSettings.allow_store_upgrade, "true" ) .setConfig( GraphDatabaseSettings.allow_upgrade, "true" )
.newGraphDatabase(); .newGraphDatabase();
db.shutdown(); db.shutdown();
} }
Expand Down
Expand Up @@ -43,7 +43,7 @@ public void noThrowWhenLatestVersionAndUpgradeIsNotAllowed() throws Throwable
{ {
when( tailScanner.getTailInformation() ).thenReturn( new OnlyVersionTailInformation( LogEntryVersion.CURRENT ) ); when( tailScanner.getTailInformation() ).thenReturn( new OnlyVersionTailInformation( LogEntryVersion.CURRENT ) );


LogVersionUpgradeChecker.check( tailScanner, Config.defaults( GraphDatabaseSettings.allow_store_upgrade, "false") ); LogVersionUpgradeChecker.check( tailScanner, Config.defaults( GraphDatabaseSettings.allow_upgrade, "false") );
} }


@Test @Test
Expand All @@ -53,23 +53,23 @@ public void throwWhenVersionIsOlderAndUpgradeIsNotAllowed() throws Throwable


expect.expect( UpgradeNotAllowedByConfigurationException.class ); expect.expect( UpgradeNotAllowedByConfigurationException.class );


LogVersionUpgradeChecker.check( tailScanner, Config.defaults( GraphDatabaseSettings.allow_store_upgrade, "false") ); LogVersionUpgradeChecker.check( tailScanner, Config.defaults( GraphDatabaseSettings.allow_upgrade, "false") );
} }


@Test @Test
public void stillAcceptLatestVersionWhenUpgradeIsAllowed() throws Throwable public void stillAcceptLatestVersionWhenUpgradeIsAllowed() throws Throwable
{ {
when( tailScanner.getTailInformation() ).thenReturn( new OnlyVersionTailInformation( LogEntryVersion.CURRENT ) ); when( tailScanner.getTailInformation() ).thenReturn( new OnlyVersionTailInformation( LogEntryVersion.CURRENT ) );


LogVersionUpgradeChecker.check( tailScanner, Config.defaults( GraphDatabaseSettings.allow_store_upgrade, "true") ); LogVersionUpgradeChecker.check( tailScanner, Config.defaults( GraphDatabaseSettings.allow_upgrade, "true") );
} }


@Test @Test
public void acceptOlderLogsWhenUpgradeIsAllowed() throws Throwable public void acceptOlderLogsWhenUpgradeIsAllowed() throws Throwable
{ {
when( tailScanner.getTailInformation() ).thenReturn( new OnlyVersionTailInformation( LogEntryVersion.V2_3 ) ); when( tailScanner.getTailInformation() ).thenReturn( new OnlyVersionTailInformation( LogEntryVersion.V2_3 ) );


LogVersionUpgradeChecker.check( tailScanner, Config.defaults( GraphDatabaseSettings.allow_store_upgrade, "true") ); LogVersionUpgradeChecker.check( tailScanner, Config.defaults( GraphDatabaseSettings.allow_upgrade, "true") );
} }


private static class OnlyVersionTailInformation extends LogTailScanner.LogTailInformation private static class OnlyVersionTailInformation extends LogTailScanner.LogTailInformation
Expand Down
Expand Up @@ -227,7 +227,7 @@ private void startStopDatabase( File workingDirectory )
{ {
GraphDatabaseService databaseService = GraphDatabaseService databaseService =
new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder( workingDirectory ) new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder( workingDirectory )
.setConfig( GraphDatabaseSettings.allow_store_upgrade, "true" ).newGraphDatabase(); .setConfig( GraphDatabaseSettings.allow_upgrade, "true" ).newGraphDatabase();
databaseService.shutdown(); databaseService.shutdown();
} }
} }
Expand Up @@ -35,6 +35,7 @@
import org.neo4j.kernel.impl.transaction.command.Commands; import org.neo4j.kernel.impl.transaction.command.Commands;
import org.neo4j.kernel.impl.transaction.log.LogPosition; import org.neo4j.kernel.impl.transaction.log.LogPosition;
import org.neo4j.kernel.impl.transaction.log.LogTailScanner; import org.neo4j.kernel.impl.transaction.log.LogTailScanner;
import org.neo4j.kernel.impl.transaction.log.LogTailScanner.LogTailInformation;
import org.neo4j.kernel.impl.transaction.log.LogVersionBridge; import org.neo4j.kernel.impl.transaction.log.LogVersionBridge;
import org.neo4j.kernel.impl.transaction.log.LogVersionedStoreChannel; import org.neo4j.kernel.impl.transaction.log.LogVersionedStoreChannel;
import org.neo4j.kernel.impl.transaction.log.PhysicalLogFile; import org.neo4j.kernel.impl.transaction.log.PhysicalLogFile;
Expand Down Expand Up @@ -118,10 +119,9 @@ private void verifyCheckpointInLog() throws IOException
LogEntryReader<ReadableClosablePositionAwareChannel> logEntryReader = new VersionAwareLogEntryReader<>( LogEntryReader<ReadableClosablePositionAwareChannel> logEntryReader = new VersionAwareLogEntryReader<>(
new RecordStorageCommandReaderFactory(), InvalidLogEntryHandler.STRICT ); new RecordStorageCommandReaderFactory(), InvalidLogEntryHandler.STRICT );
PhysicalLogFiles logFiles = new PhysicalLogFiles( storeDir, fs ); PhysicalLogFiles logFiles = new PhysicalLogFiles( storeDir, fs );
final LogTailScanner logTailScanner = final LogTailScanner logTailScanner = new LogTailScanner( logFiles, fs, logEntryReader );
new LogTailScanner( logFiles, fs, logEntryReader );


LogTailScanner.LogTailInformation tailInformation = logTailScanner.getTailInformation(); LogTailInformation tailInformation = logTailScanner.getTailInformation();
assertNotNull( tailInformation.lastCheckPoint ); assertNotNull( tailInformation.lastCheckPoint );
assertTrue( tailInformation.commitsAfterLastCheckPoint ); assertTrue( tailInformation.commitsAfterLastCheckPoint );
} }
Expand Down

0 comments on commit d72c3e8

Please sign in to comment.