Skip to content

Commit

Permalink
Removed RecordFormats#name()
Browse files Browse the repository at this point in the history
This method was used for logging and to compare configured format with the
store format. Format class names work just fine for logging and format
comparison changed to use RecordFormats#generation();
  • Loading branch information
lutovich authored and MishaDemianenko committed Jun 3, 2016
1 parent 86eaee6 commit 5a7e9e8
Show file tree
Hide file tree
Showing 20 changed files with 43 additions and 68 deletions.
Expand Up @@ -35,23 +35,15 @@ public abstract class BaseRecordFormats implements RecordFormats
{
private final int generation;
private final Capability[] capabilities;
private final String name;
private final String storeVersion;

protected BaseRecordFormats( String name, String storeVersion, int generation, Capability... capabilities )
protected BaseRecordFormats( String storeVersion, int generation, Capability... capabilities )
{
this.name = name;
this.storeVersion = storeVersion;
this.generation = generation;
this.capabilities = capabilities;
}

@Override
public String name()
{
return name;
}

@Override
public String storeVersion()
{
Expand Down
Expand Up @@ -118,11 +118,11 @@ public static RecordFormats selectForConfig( Config config, LogProvider logProvi
String recordFormat = configuredRecordFormat( config );
if ( StringUtils.isEmpty( recordFormat ) )
{
info( logProvider, "Record format not configured, selected default: " + defaultFormat().name() );
info( logProvider, "Record format not configured, selected default: " + defaultFormat() );
return defaultFormat();
}
RecordFormats format = selectSpecificFormat( recordFormat );
info( logProvider, "Selected record format based on config: " + format.name() );
info( logProvider, "Selected record format based on config: " + format );
return format;
}

Expand Down Expand Up @@ -155,7 +155,7 @@ static RecordFormats selectForStore( File storeDir, FileSystemAbstraction fs, Pa
{
if ( format.storeVersion().equals( storeVersion ) )
{
info( logProvider, "Selected " + format.name() + " record format from store " + storeDir );
info( logProvider, "Selected " + format + " record format from store " + storeDir );
return format;
}
}
Expand Down Expand Up @@ -184,38 +184,33 @@ static RecordFormats selectForStore( File storeDir, FileSystemAbstraction fs, Pa
public static RecordFormats selectForStoreOrConfig( Config config, File storeDir, FileSystemAbstraction fs,
PageCache pageCache, LogProvider logProvider )
{
String configFormatName = configuredRecordFormat( config );
boolean formatConfigured = StringUtils.isNotEmpty( configFormatName );
RecordFormats configuredFormat = loadRecordFormat( configuredRecordFormat( config ) );
boolean formatConfigured = configuredFormat != null;

RecordFormats currentFormat = selectForStore( storeDir, fs, pageCache, NullLogProvider.getInstance() );
boolean storeWithFormatExists = currentFormat != null;

if ( formatConfigured && storeWithFormatExists )
{
if ( currentFormat.name().equals( configFormatName ) )
if ( currentFormat.generation() == configuredFormat.generation() )
{
info( logProvider, "Configured format matches format in the store. Selected: " + currentFormat.name() );
info( logProvider, "Configured format matches format in the store. Selected: " + currentFormat );
return currentFormat;
}
throw new IllegalArgumentException( String.format(
"Configured format '%s' is different from the actual format in the store '%s'",
configFormatName, currentFormat.name() ) );
configuredFormat, currentFormat ) );
}

if ( !formatConfigured && storeWithFormatExists )
{
info( logProvider, "Format not configured. Selected format from the store: " + currentFormat.name() );
info( logProvider, "Format not configured. Selected format from the store: " + currentFormat );
return currentFormat;
}

if ( formatConfigured )
{
RecordFormats configuredFormat = loadRecordFormat( configFormatName );
if ( configuredFormat == null )
{
throw new IllegalArgumentException( "Unable to load configured format '" + configFormatName + "'" );
}
info( logProvider, "Selected configured format: " + configFormatName );
info( logProvider, "Selected configured format: " + configuredFormat );
return configuredFormat;
}

Expand Down
Expand Up @@ -46,8 +46,6 @@ public Factory( String key, String... altKeys )
public abstract RecordFormats newInstance();
}

String name();

String storeVersion();

/**
Expand Down
Expand Up @@ -37,11 +37,10 @@ public class StandardV2_0 extends BaseRecordFormats
{
public static final String STORE_VERSION = StoreVersion.STANDARD_V2_0.versionString();
public static final RecordFormats RECORD_FORMATS = new StandardV2_0();
private static final String NAME = "standard_v2.0";

public StandardV2_0()
{
super( NAME, STORE_VERSION, 2, Capability.SCHEMA, Capability.LUCENE_3, Capability.VERSION_TRAILERS );
super( STORE_VERSION, 2, Capability.SCHEMA, Capability.LUCENE_3, Capability.VERSION_TRAILERS );
}

@Override
Expand Down
Expand Up @@ -37,11 +37,10 @@ public class StandardV2_1 extends BaseRecordFormats
{
public static final String STORE_VERSION = StoreVersion.STANDARD_V2_1.versionString();
public static final RecordFormats RECORD_FORMATS = new StandardV2_1();
private static final String NAME = "standard_v2.1";

public StandardV2_1()
{
super( NAME, STORE_VERSION, 3, Capability.SCHEMA, Capability.DENSE_NODES, Capability.LUCENE_3,
super( STORE_VERSION, 3, Capability.SCHEMA, Capability.DENSE_NODES, Capability.LUCENE_3,
Capability.VERSION_TRAILERS );
}

Expand Down
Expand Up @@ -37,11 +37,10 @@ public class StandardV2_2 extends BaseRecordFormats
{
public static final String STORE_VERSION = StoreVersion.STANDARD_V2_2.versionString();
public static final RecordFormats RECORD_FORMATS = new StandardV2_2();
private static final String NAME = "standard_v2.2";

public StandardV2_2()
{
super( NAME, STORE_VERSION, 4, Capability.SCHEMA, Capability.DENSE_NODES, Capability.LUCENE_3,
super( STORE_VERSION, 4, Capability.SCHEMA, Capability.DENSE_NODES, Capability.LUCENE_3,
Capability.VERSION_TRAILERS );
}

Expand Down
Expand Up @@ -37,11 +37,10 @@ public class StandardV2_3 extends BaseRecordFormats
{
public static final String STORE_VERSION = StoreVersion.STANDARD_V2_3.versionString();
public static final RecordFormats RECORD_FORMATS = new StandardV2_3();
private static final String NAME = "standard_v2.3";

public StandardV2_3()
{
super( NAME, STORE_VERSION, 5, Capability.SCHEMA, Capability.DENSE_NODES, Capability.LUCENE_3 );
super( STORE_VERSION, 5, Capability.SCHEMA, Capability.DENSE_NODES, Capability.LUCENE_3 );
}

@Override
Expand Down
Expand Up @@ -41,7 +41,7 @@ public class StandardV3_0 extends BaseRecordFormats

public StandardV3_0()
{
super( NAME, STORE_VERSION, 6, Capability.SCHEMA, Capability.DENSE_NODES, Capability.LUCENE_5 );
super( STORE_VERSION, 6, Capability.SCHEMA, Capability.DENSE_NODES, Capability.LUCENE_5 );
}

@Override
Expand Down
Expand Up @@ -96,12 +96,6 @@ public ResizableRecordFormats(int dynamicRecordHeaderSize)
this.dynamicRecordHeaderSize = dynamicRecordHeaderSize;
}

@Override
public String name()
{
return "resizable";
}

@Override
public String storeVersion()
{
Expand Down
Expand Up @@ -60,12 +60,6 @@ public PrepareTrackingRecordFormats( RecordFormats actual )
this.actual = actual;
}

@Override
public String name()
{
return actual.name();
}

@Override
public String storeVersion()
{
Expand Down
7 changes: 6 additions & 1 deletion community/neo4j/src/test/java/upgrade/StoreUpgraderTest.java
Expand Up @@ -467,11 +467,16 @@ private void makeDbNotCleanlyShutdown( boolean truncateAll ) throws IOException

private Config getTuningConfig()
{
return new Config( MapUtil.stringMap( GraphDatabaseSettings.record_format.name(), getRecordFormats().name() ) );
return new Config( MapUtil.stringMap( GraphDatabaseSettings.record_format.name(), getRecordFormatsName() ) );
}

protected RecordFormats getRecordFormats()
{
return StandardV3_0.RECORD_FORMATS;
}

protected String getRecordFormatsName()
{
return StandardV3_0.NAME;
}
}
Expand Up @@ -52,7 +52,7 @@
import org.neo4j.test.rule.TargetDirectory;

import static org.junit.Assert.assertEquals;
import static org.neo4j.test.TargetDirectory.testDirForTest;
import static org.neo4j.test.rule.TargetDirectory.testDirForTest;

@RunWith( Parameterized.class )
public class BackupEmbeddedIT
Expand Down
Expand Up @@ -143,7 +143,6 @@
import org.neo4j.kernel.impl.locking.Locks;
import org.neo4j.kernel.impl.logging.LogService;
import org.neo4j.kernel.impl.proc.Procedures;
import org.neo4j.kernel.impl.store.format.standard.StandardV3_0;
import org.neo4j.kernel.impl.store.stats.IdBasedStoreEntityCounters;
import org.neo4j.kernel.impl.transaction.TransactionHeaderInformationFactory;
import org.neo4j.kernel.impl.transaction.log.LogicalTransactionStore;
Expand Down Expand Up @@ -249,7 +248,6 @@ public EnterpriseCoreEditionModule( final PlatformModule platformModule,
DiscoveryServiceFactory discoveryServiceFactory )
{
ioLimiter = new ConfigurableIOLimiter( platformModule.config );
formats = StandardV3_0.RECORD_FORMATS;

final Dependencies dependencies = platformModule.dependencies;
final Config config = platformModule.config;
Expand Down
Expand Up @@ -112,7 +112,6 @@ public EnterpriseEdgeEditionModule( final PlatformModule platformModule,
}

ioLimiter = new ConfigurableIOLimiter( platformModule.config );
formats = StandardV3_0.RECORD_FORMATS;

org.neo4j.kernel.impl.util.Dependencies dependencies = platformModule.dependencies;
Config config = platformModule.config;
Expand Down
Expand Up @@ -54,7 +54,7 @@ public class HighLimit extends BaseRecordFormats

public HighLimit()
{
super( NAME, STORE_VERSION, 7, Capability.DENSE_NODES, Capability.SCHEMA, Capability.LUCENE_5 );
super( STORE_VERSION, 7, Capability.DENSE_NODES, Capability.SCHEMA, Capability.LUCENE_5 );
}

@Override
Expand Down
Expand Up @@ -39,7 +39,7 @@
import org.neo4j.kernel.impl.store.format.standard.StandardV3_0;
import org.neo4j.logging.LogProvider;
import org.neo4j.logging.NullLogProvider;
import org.neo4j.test.PageCacheRule;
import org.neo4j.test.rule.PageCacheRule;

import static org.hamcrest.Matchers.instanceOf;
import static org.junit.Assert.assertNull;
Expand Down Expand Up @@ -191,7 +191,7 @@ public void selectForStoreOrConfigWithDifferentlyConfiguredAndStoredFormat() thr
PageCache pageCache = getPageCache();
prepareNeoStoreFile( StandardV3_0.STORE_VERSION, pageCache );

Config config = config( HighLimit.STORE_VERSION );
Config config = config( HighLimit.NAME );

try
{
Expand Down
Expand Up @@ -46,12 +46,12 @@
import org.neo4j.kernel.impl.store.format.standard.StandardV3_0;
import org.neo4j.kernel.internal.GraphDatabaseAPI;
import org.neo4j.logging.FormattedLogProvider;
import org.neo4j.test.EmbeddedDatabaseRule;
import org.neo4j.test.SuppressOutput;
import org.neo4j.test.TargetDirectory;
import org.neo4j.test.rule.EmbeddedDatabaseRule;
import org.neo4j.test.rule.SuppressOutput;
import org.neo4j.test.rule.TargetDirectory;

import static org.junit.Assert.assertTrue;
import static org.neo4j.test.TargetDirectory.testDirForTest;
import static org.neo4j.test.rule.TargetDirectory.testDirForTest;

@RunWith( Parameterized.class )
public class ConsistencyCheckServiceRecordFormatIT
Expand Down
Expand Up @@ -42,12 +42,6 @@ private HighLimitWithSmallRecords()
{
}

@Override
public String name()
{
return NAME;
}

@Override
public String storeVersion()
{
Expand Down
Expand Up @@ -37,4 +37,10 @@ protected RecordFormats getRecordFormats()
{
return HighLimit.RECORD_FORMATS;
}

@Override
protected String getRecordFormatsName()
{
return HighLimit.NAME;
}
}
Expand Up @@ -95,12 +95,16 @@ public class StoreMigratorFrom20IT
private LabelScanStoreProvider labelScanStoreProvider;

@Parameter
public String recordFormatName;
@Parameter( 1 )
public RecordFormats recordFormat;

@Parameters( name = "{0}" )
public static List<RecordFormats> recordFormats()
public static List<Object[]> recordFormats()
{
return Arrays.asList( StandardV3_0.RECORD_FORMATS, HighLimit.RECORD_FORMATS );
return Arrays.asList(
new Object[]{StandardV3_0.NAME, StandardV3_0.RECORD_FORMATS},
new Object[]{HighLimit.NAME, HighLimit.RECORD_FORMATS} );
}

@Before
Expand Down Expand Up @@ -244,7 +248,7 @@ private StoreUpgrader upgrader( SchemaIndexMigrator indexMigrator, StoreMigrator

private Config getConfig()
{
return new Config( stringMap( GraphDatabaseSettings.record_format.name(), recordFormat.name() ),
return new Config( stringMap( GraphDatabaseSettings.record_format.name(), recordFormatName ),
GraphDatabaseSettings.class );
}
}

0 comments on commit 5a7e9e8

Please sign in to comment.