Skip to content

Commit

Permalink
Remove upgrade and migration for 2.0, 2.1, 2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
burqen committed May 17, 2017
1 parent 425277b commit f780250
Show file tree
Hide file tree
Showing 25 changed files with 148 additions and 1,606 deletions.
Expand Up @@ -40,8 +40,7 @@
import org.neo4j.kernel.impl.store.MetaDataStore;
import org.neo4j.kernel.impl.store.format.RecordFormatSelector;
import org.neo4j.kernel.impl.store.format.RecordFormats;
import org.neo4j.kernel.impl.store.format.standard.StandardV2_2;
import org.neo4j.kernel.internal.Version;
import org.neo4j.kernel.impl.store.format.standard.StandardV2_3;
import org.neo4j.test.rule.PageCacheRule;
import org.neo4j.test.rule.TestDirectory;
import org.neo4j.test.rule.fs.DefaultFileSystemRule;
Expand Down Expand Up @@ -148,17 +147,17 @@ public void readsLatestStoreVersionCorrectly() throws Exception
@Test
public void readsOlderStoreVersionCorrectly() throws Exception
{
prepareNeoStoreFile( StandardV2_2.RECORD_FORMATS.storeVersion() );
prepareNeoStoreFile( StandardV2_3.RECORD_FORMATS.storeVersion() );

execute( databaseDirectory.toString() );

verify( out, times( 3 ) ).accept( outCaptor.capture() );

assertEquals(
Arrays.asList(
"Store format version: v0.A.5",
"Store format introduced in: 2.2.0",
"Store format superseded in: 2.3.0" ),
"Store format version: v0.A.6",
"Store format introduced in: 2.3.0",
"Store format superseded in: 3.0.0" ),
outCaptor.getAllValues() );
}

Expand Down
Expand Up @@ -26,8 +26,8 @@
import java.io.UncheckedIOException;
import java.nio.file.NoSuchFileException;
import java.util.function.Consumer;
import java.util.Optional;
import java.util.function.IntFunction;
import java.util.stream.Collectors;

import org.neo4j.cursor.RawCursor;
import org.neo4j.graphdb.ResourceIterator;
Expand All @@ -49,7 +49,6 @@
import org.neo4j.storageengine.api.schema.LabelScanReader;

import static org.neo4j.helpers.Format.duration;
import static org.neo4j.helpers.collection.Iterables.single;
import static org.neo4j.helpers.collection.Iterators.asResourceIterator;
import static org.neo4j.helpers.collection.Iterators.iterator;
import static org.neo4j.helpers.collection.MapUtil.map;
Expand Down Expand Up @@ -325,18 +324,17 @@ public boolean hasStore() throws IOException
{
try
{
storeFileHandle();
return true;
return storeFileHandle().isPresent();
}
catch ( NoSuchFileException e )
{
return false;
}
}

private FileHandle storeFileHandle() throws IOException
private Optional<FileHandle> storeFileHandle() throws IOException
{
return single( pageCache.streamFilesRecursive( storeFile ).collect( Collectors.toList() ) );
return pageCache.streamFilesRecursive( storeFile ).findFirst();
}

/**
Expand Down Expand Up @@ -389,7 +387,11 @@ private void dropStrict() throws IOException
index.close();
index = null;
}
storeFileHandle().delete();
Optional<FileHandle> fileHandle = storeFileHandle();
if ( fileHandle.isPresent() )
{
fileHandle.get().delete();
}
}

/**
Expand Down
Expand Up @@ -29,7 +29,6 @@
import org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider;
import org.neo4j.kernel.impl.logging.LogService;
import org.neo4j.kernel.impl.store.format.RecordFormats;
import org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck;
import org.neo4j.kernel.impl.storemigration.monitoring.MigrationProgressMonitor;
import org.neo4j.kernel.impl.storemigration.participant.LegacyIndexMigrator;
import org.neo4j.kernel.impl.storemigration.participant.StoreMigrator;
Expand Down Expand Up @@ -82,15 +81,15 @@ public void migrate( File storeDir )
{
LogProvider logProvider = logService.getInternalLogProvider();
UpgradableDatabase upgradableDatabase =
new UpgradableDatabase( fs, new StoreVersionCheck( pageCache ), new LegacyStoreVersionCheck( fs ),
new UpgradableDatabase( fs, new StoreVersionCheck( pageCache ),
format );
StoreUpgrader storeUpgrader = new StoreUpgrader( upgradableDatabase, progressMonitor, config, fs, pageCache,
logProvider );

StoreMigrationParticipant schemaMigrator = schemaIndexProvider.storeMigrationParticipant( fs, pageCache,
labelScanStoreProvider );
LegacyIndexMigrator legacyIndexMigrator = new LegacyIndexMigrator( fs, indexProviders, logProvider );
StoreMigrator storeMigrator = new StoreMigrator( fs, pageCache, config, logService, schemaIndexProvider );
StoreMigrator storeMigrator = new StoreMigrator( fs, pageCache, config, logService );

storeUpgrader.addParticipant( schemaMigrator );
storeUpgrader.addParticipant( legacyIndexMigrator );
Expand Down
Expand Up @@ -24,8 +24,6 @@

import org.neo4j.io.fs.FileSystemAbstraction;
import org.neo4j.kernel.impl.store.MetaDataStore;
import org.neo4j.kernel.impl.store.StoreFile;
import org.neo4j.kernel.impl.store.format.Capability;
import org.neo4j.kernel.impl.store.format.FormatFamily;
import org.neo4j.kernel.impl.store.format.RecordFormatSelector;
import org.neo4j.kernel.impl.store.format.RecordFormats;
Expand All @@ -36,7 +34,6 @@
import org.neo4j.kernel.impl.storemigration.StoreUpgrader.UpgradingStoreVersionNotFoundException;
import org.neo4j.kernel.impl.storemigration.StoreVersionCheck.Result;
import org.neo4j.kernel.impl.storemigration.StoreVersionCheck.Result.Outcome;
import org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck;
import org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles;
import org.neo4j.kernel.impl.transaction.log.ReadableClosablePositionAwareChannel;
import org.neo4j.kernel.impl.transaction.log.entry.LogEntryReader;
Expand All @@ -52,15 +49,13 @@ public class UpgradableDatabase
{
private final FileSystemAbstraction fs;
private final StoreVersionCheck storeVersionCheck;
private final LegacyStoreVersionCheck legacyStoreVersionCheck;
private final RecordFormats format;

public UpgradableDatabase( FileSystemAbstraction fs,
StoreVersionCheck storeVersionCheck, LegacyStoreVersionCheck legacyStoreVersionCheck, RecordFormats format )
StoreVersionCheck storeVersionCheck, RecordFormats format )
{
this.fs = fs;
this.storeVersionCheck = storeVersionCheck;
this.legacyStoreVersionCheck = legacyStoreVersionCheck;
this.format = format;
}

Expand Down Expand Up @@ -109,9 +104,7 @@ public RecordFormats checkUpgradeable( File storeDirectory )
}
else
{
result = fromFormat.hasCapability( Capability.VERSION_TRAILERS )
? checkCleanShutDownByVersionTrailer( storeDirectory, fromFormat )
: checkCleanShutDownByCheckPoint( storeDirectory );
result = checkCleanShutDownByCheckPoint( storeDirectory );
if ( result.outcome.isSuccessful() )
{
return fromFormat;
Expand Down Expand Up @@ -164,28 +157,12 @@ private Result checkCleanShutDownByCheckPoint( File storeDirectory )
return new Result( Result.Outcome.storeNotCleanlyShutDown, null, null );
}

private Result checkCleanShutDownByVersionTrailer( File storeDirectory, RecordFormats fromFormat )
{
Result result = null;
for ( StoreFile store : StoreFile.legacyStoreFilesForVersion( fromFormat.storeVersion() ) )
{
String expectedVersion = store.forVersion( fromFormat.storeVersion() );
File storeFile = new File( storeDirectory, store.storeFileName() );
result = legacyStoreVersionCheck.hasVersion( storeFile, expectedVersion, store.isOptional() );
if ( !result.outcome.isSuccessful() )
{
break;
}
}
return result;
}

private String getPathToStoreFile( File storeDirectory, Result result )
{
return new File( storeDirectory, result.storeFilename ).getAbsolutePath();
}

public boolean hasCurrentVersion( File storeDir )
boolean hasCurrentVersion( File storeDir )
{
File neoStore = new File( storeDir, MetaDataStore.DEFAULT_NAME );
Result result = storeVersionCheck.hasVersion( neoStore, format.storeVersion() );
Expand Down

This file was deleted.

0 comments on commit f780250

Please sign in to comment.