Skip to content

Commit

Permalink
Switch all editions and tools to use community format
Browse files Browse the repository at this point in the history
Update record format selector to select community format, except if configuration option was specified.
Adapt tests to use community format.
  • Loading branch information
MishaDemianenko committed Apr 15, 2016
1 parent 24e035c commit fe058d2
Show file tree
Hide file tree
Showing 26 changed files with 108 additions and 128 deletions.
Expand Up @@ -21,8 +21,6 @@

import org.apache.commons.lang3.StringUtils;

import java.util.Iterator;

import org.neo4j.helpers.Service;
import org.neo4j.kernel.configuration.Config;
import org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory;
Expand All @@ -43,7 +41,8 @@
* Selects record format that will be used in a database.
* Support two types of selection : config based or automatic.
* <p>
* Automatic selection is used by various tools and tests that should work for format independent (for example backup)
* Automatic selection is used by various tools and tests that should pretend being format independent (for
* example backup)
*/
public class RecordFormatSelector
{
Expand Down Expand Up @@ -124,25 +123,20 @@ public static RecordFormats selectForVersion( String storeVersion )
}

/**
* Select record formats based on available services in class path.
* In case if multiple services are available only 'first' will be considered.
* In case if no record format providers are found - default record format ({@link #DEFAULT_AUTOSELECT_FORMAT}) will
* be used.
* Select {@link #DEFAULT_AUTOSELECT_FORMAT} record format.
*
* @return - selected record format.
* @return selected record format.
*/
public static RecordFormats autoSelectFormat()
{
return autoSelectFormat( Config.empty(), NullLogService.getInstance() );
}

/**
* Select record formats based on available services in class path.
* Specific format selection can be forced by specifying format name in
* {@link GraphDatabaseFacadeFactory.Configuration#record_format} property.
* In case if multiple services are available only 'first' will be considered.
* In case if no record format providers are found - default record format ({@link #DEFAULT_AUTOSELECT_FORMAT}) will
* be used.
* Select configured record format based on available services in class path.
* Specific format can be specified by {@link GraphDatabaseFacadeFactory.Configuration#record_format} property.
* <p>
* If format is not specified {@link #DEFAULT_AUTOSELECT_FORMAT} will be used.
*
* @param config - configuration parameters
* @param logService - logging service
Expand All @@ -154,7 +148,7 @@ public static RecordFormats autoSelectFormat( Config config, LogService logServi
String recordFormat = configuredRecordFormat( config );
RecordFormats recordFormats = StringUtils.isNotEmpty( recordFormat ) ?
selectSpecificFormat( recordFormat, logService ) :
getFirstAvailableOrDefault( DEFAULT_AUTOSELECT_FORMAT );
DEFAULT_AUTOSELECT_FORMAT;
logSelectedFormat( logService, recordFormats );
return recordFormats;
}
Expand All @@ -169,12 +163,6 @@ private static RecordFormats selectSpecificFormat( String recordFormat, LogServi
return formats;
}

private static RecordFormats getFirstAvailableOrDefault( RecordFormats defaultAutoSelectFormat )
{
Iterable<RecordFormats.Factory> formatFactories = Service.load( RecordFormats.Factory.class );
Iterator<RecordFormats.Factory> factoryIterator = formatFactories.iterator();
return factoryIterator.hasNext() ? factoryIterator.next().newInstance() : defaultAutoSelectFormat;
}

private static RecordFormats loadRecordFormat( String recordFormat )
{
Expand Down
Expand Up @@ -19,18 +19,18 @@
*/
package org.neo4j.backup;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.SystemUtils;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.RelationshipType;
Expand All @@ -40,7 +40,7 @@
import org.neo4j.kernel.configuration.Config;
import org.neo4j.kernel.configuration.Settings;
import org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory;
import org.neo4j.kernel.impl.store.format.highlimit.HighLimit;
import org.neo4j.kernel.impl.store.format.lowlimit.LowLimitV3_0;
import org.neo4j.test.DbRepresentation;
import org.neo4j.test.EmbeddedDatabaseRule;
import org.neo4j.test.ProcessStreamHandler;
Expand Down Expand Up @@ -153,7 +153,7 @@ public static int runBackupToolFromOtherJvmToGetExitCode( String... args )
private Config getConfig()
{
return new Config( MapUtil.stringMap( GraphDatabaseFacadeFactory.Configuration.record_format.name(),
HighLimit.NAME ) );
LowLimitV3_0.NAME ) );
}

private DbRepresentation getDbRepresentation()
Expand Down
Expand Up @@ -60,7 +60,7 @@
import org.neo4j.kernel.impl.store.MetaDataStore.Position;
import org.neo4j.kernel.impl.store.MismatchingStoreIdException;
import org.neo4j.kernel.impl.store.StoreFactory;
import org.neo4j.kernel.impl.store.format.highlimit.HighLimit;
import org.neo4j.kernel.impl.store.format.lowlimit.LowLimitV3_0;
import org.neo4j.kernel.impl.storemigration.LogFiles;
import org.neo4j.kernel.impl.storemigration.StoreFile;
import org.neo4j.kernel.impl.transaction.CommittedTransactionRepresentation;
Expand Down Expand Up @@ -330,7 +330,7 @@ public void incrementallyBackupDatabaseShouldNotKeepGeneratedIdFiles()
// their ids should not clash with already existing
GraphDatabaseService backupBasedDatabase =
new GraphDatabaseFactory().newEmbeddedDatabaseBuilder( backupDir.getAbsoluteFile() )
.setConfig( GraphDatabaseFacadeFactory.Configuration.record_format, HighLimit.NAME )
.setConfig( GraphDatabaseFacadeFactory.Configuration.record_format, LowLimitV3_0.NAME )
.newGraphDatabase();
try
{
Expand Down Expand Up @@ -869,7 +869,7 @@ private Node findNodeByLabel( GraphDatabaseAPI graphDatabase, Label label )
private Config getConfig()
{
return new Config( MapUtil.stringMap( GraphDatabaseFacadeFactory.Configuration.record_format.name(),
HighLimit.NAME ) );
LowLimitV3_0.NAME ) );
}

private DbRepresentation getBackupDbRepresentation()
Expand Down
Expand Up @@ -27,7 +27,7 @@
import org.neo4j.graphdb.factory.GraphDatabaseSettings;
import org.neo4j.kernel.configuration.Settings;
import org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory;
import org.neo4j.kernel.impl.store.format.highlimit.HighLimit;
import org.neo4j.kernel.impl.store.format.lowlimit.LowLimitV3_0;

public class EmbeddedServer implements ServerInterface
{
Expand All @@ -38,7 +38,7 @@ public EmbeddedServer( File storeDir, String serverAddress )
GraphDatabaseBuilder graphDatabaseBuilder = new GraphDatabaseFactory().newEmbeddedDatabaseBuilder( storeDir );
graphDatabaseBuilder.setConfig( OnlineBackupSettings.online_backup_enabled, Settings.TRUE );
graphDatabaseBuilder.setConfig( OnlineBackupSettings.online_backup_server, serverAddress );
graphDatabaseBuilder.setConfig( GraphDatabaseFacadeFactory.Configuration.record_format, HighLimit.NAME );
graphDatabaseBuilder.setConfig( GraphDatabaseFacadeFactory.Configuration.record_format, LowLimitV3_0.NAME );
graphDatabaseBuilder.setConfig( GraphDatabaseSettings.pagecache_memory, "8m" );
this.db = graphDatabaseBuilder.newGraphDatabase();
}
Expand Down
Expand Up @@ -26,7 +26,6 @@
import org.junit.rules.TestName;

import java.io.File;
import java.util.Map;

import org.neo4j.graphdb.Direction;
import org.neo4j.graphdb.DynamicRelationshipType;
Expand All @@ -40,7 +39,7 @@
import org.neo4j.kernel.configuration.Config;
import org.neo4j.kernel.configuration.Settings;
import org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory;
import org.neo4j.kernel.impl.store.format.highlimit.HighLimit;
import org.neo4j.kernel.impl.store.format.lowlimit.LowLimitV3_0;
import org.neo4j.test.DbRepresentation;
import org.neo4j.test.SuppressOutput;
import org.neo4j.test.TargetDirectory;
Expand Down Expand Up @@ -230,7 +229,7 @@ private GraphDatabaseService startGraphDatabase( File path )
newEmbeddedDatabaseBuilder( path ).
setConfig( OnlineBackupSettings.online_backup_enabled, Settings.FALSE ).
setConfig( GraphDatabaseSettings.keep_logical_logs, Settings.TRUE ).
setConfig( GraphDatabaseFacadeFactory.Configuration.record_format, HighLimit.NAME ).
setConfig( GraphDatabaseFacadeFactory.Configuration.record_format, LowLimitV3_0.NAME ).
newGraphDatabase();
}

Expand All @@ -249,12 +248,12 @@ private void shutdownServer( ServerInterface server ) throws Exception

private DbRepresentation getBackupDbRepresentation()
{
return DbRepresentation.of( backupPath, getHighLimitConfig() );
return DbRepresentation.of( backupPath, getFormatConfig() );
}

private Config getHighLimitConfig()
private Config getFormatConfig()
{
return new Config(
MapUtil.stringMap( GraphDatabaseFacadeFactory.Configuration.record_format.name(), HighLimit.NAME ) );
MapUtil.stringMap( GraphDatabaseFacadeFactory.Configuration.record_format.name(), LowLimitV3_0.NAME ) );
}
}
18 changes: 9 additions & 9 deletions enterprise/backup/src/test/java/org/neo4j/backup/TestBackup.java
Expand Up @@ -55,7 +55,7 @@
import org.neo4j.kernel.impl.store.MetaDataStore;
import org.neo4j.kernel.impl.store.MetaDataStore.Position;
import org.neo4j.kernel.impl.store.MismatchingStoreIdException;
import org.neo4j.kernel.impl.store.format.highlimit.HighLimit;
import org.neo4j.kernel.impl.store.format.lowlimit.LowLimitV3_0;
import org.neo4j.kernel.impl.store.id.IdGeneratorImpl;
import org.neo4j.kernel.impl.storemigration.StoreFile;
import org.neo4j.kernel.impl.storemigration.StoreFileType;
Expand Down Expand Up @@ -246,7 +246,7 @@ public void makeSureStoreIdIsEnforced() throws Exception
OnlineBackup backup = OnlineBackup.from( "127.0.0.1" );
backup.full( backupPath.getPath() );
assertTrue( "Should be consistent", backup.isConsistent() );
assertEquals( initialDataSetRepresentation, DbRepresentation.of( backupPath, getHighLimitConfigConfig() ) );
assertEquals( initialDataSetRepresentation, DbRepresentation.of( backupPath, getFormatConfig() ) );
shutdownServer( server );

// Create data set X+Y on server B
Expand All @@ -272,7 +272,7 @@ public void makeSureStoreIdIsEnforced() throws Exception
server = startServer( serverPath );
backup.incremental( backupPath.getPath() );
assertTrue( "Should be consistent", backup.isConsistent() );
assertEquals( furtherRepresentation, DbRepresentation.of( backupPath, getHighLimitConfigConfig() ) );
assertEquals( furtherRepresentation, DbRepresentation.of( backupPath, getFormatConfig() ) );
shutdownServer( server );
}

Expand Down Expand Up @@ -405,7 +405,7 @@ public void shouldRetainFileLocksAfterFullBackupOnLiveDatabase() throws Exceptio

GraphDatabaseService db = new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder( sourcePath )
.setConfig( OnlineBackupSettings.online_backup_enabled, Settings.TRUE )
.setConfig( GraphDatabaseFacadeFactory.Configuration.record_format, HighLimit.NAME )
.setConfig( GraphDatabaseFacadeFactory.Configuration.record_format, LowLimitV3_0.NAME )
.newGraphDatabase();
try
{
Expand Down Expand Up @@ -643,7 +643,7 @@ protected TransactionHeaderInformation createUsing( byte[] additionalHeader )
return dbFactory.newEmbeddedDatabaseBuilder( storeDir )
.setConfig( OnlineBackupSettings.online_backup_enabled, String.valueOf( withOnlineBackup ) )
.setConfig( GraphDatabaseSettings.keep_logical_logs, Settings.TRUE )
.setConfig( GraphDatabaseFacadeFactory.Configuration.record_format, HighLimit.NAME )
.setConfig( GraphDatabaseFacadeFactory.Configuration.record_format, LowLimitV3_0.NAME )
.newGraphDatabase();
}

Expand Down Expand Up @@ -679,18 +679,18 @@ private GraphDatabaseService getEmbeddedTestDataBaseService()
{
return new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder( serverPath )
.setConfig( OnlineBackupSettings.online_backup_enabled, Settings.TRUE )
.setConfig( GraphDatabaseFacadeFactory.Configuration.record_format, HighLimit.NAME )
.setConfig( GraphDatabaseFacadeFactory.Configuration.record_format, LowLimitV3_0.NAME )
.newGraphDatabase();
}

private Config getHighLimitConfigConfig()
private Config getFormatConfig()
{
return new Config(
MapUtil.stringMap( GraphDatabaseFacadeFactory.Configuration.record_format.name(), HighLimit.NAME ) );
MapUtil.stringMap( GraphDatabaseFacadeFactory.Configuration.record_format.name(), LowLimitV3_0.NAME ) );
}

private DbRepresentation getDbRepresentation()
{
return DbRepresentation.of( backupPath, getHighLimitConfigConfig() );
return DbRepresentation.of( backupPath, getFormatConfig() );
}
}
Expand Up @@ -29,7 +29,7 @@
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.kernel.configuration.Settings;
import org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory;
import org.neo4j.kernel.impl.store.format.highlimit.HighLimit;
import org.neo4j.kernel.impl.store.format.lowlimit.LowLimitV3_0;
import org.neo4j.test.SuppressOutput;
import org.neo4j.test.TestGraphDatabaseFactory;

Expand All @@ -55,7 +55,7 @@ public void before() throws Exception
public void testOnByDefault() throws Exception
{
GraphDatabaseService db = new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder( SOURCE_DIR )
.setConfig( GraphDatabaseFacadeFactory.Configuration.record_format, HighLimit.NAME )
.setConfig( GraphDatabaseFacadeFactory.Configuration.record_format, LowLimitV3_0.NAME )
.newGraphDatabase();
OnlineBackup.from( HOST_ADDRESS ).full( BACKUP_DIR );
db.shutdown();
Expand All @@ -66,7 +66,7 @@ public void testOffByConfig() throws Exception
{
GraphDatabaseService db = new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder( SOURCE_DIR )
.setConfig( OnlineBackupSettings.online_backup_enabled, Settings.FALSE )
.setConfig( GraphDatabaseFacadeFactory.Configuration.record_format, HighLimit.NAME )
.setConfig( GraphDatabaseFacadeFactory.Configuration.record_format, LowLimitV3_0.NAME )
.newGraphDatabase();
try
{
Expand All @@ -84,7 +84,7 @@ public void testEnableDefaultsInConfig() throws Exception
{
GraphDatabaseService db = new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder( SOURCE_DIR )
.setConfig( OnlineBackupSettings.online_backup_enabled, Settings.TRUE )
.setConfig( GraphDatabaseFacadeFactory.Configuration.record_format, HighLimit.NAME )
.setConfig( GraphDatabaseFacadeFactory.Configuration.record_format, LowLimitV3_0.NAME )
.newGraphDatabase();

OnlineBackup.from( HOST_ADDRESS ).full( BACKUP_DIR );
Expand All @@ -98,7 +98,7 @@ public void testEnableCustomPortInConfig() throws Exception
GraphDatabaseService db = new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder( SOURCE_DIR )
.setConfig( OnlineBackupSettings.online_backup_enabled, Settings.TRUE )
.setConfig( OnlineBackupSettings.online_backup_server, ":"+customPort )
.setConfig( GraphDatabaseFacadeFactory.Configuration.record_format, HighLimit.NAME )
.setConfig( GraphDatabaseFacadeFactory.Configuration.record_format, LowLimitV3_0.NAME )
.newGraphDatabase();
try
{
Expand Down
Expand Up @@ -43,7 +43,6 @@
import org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageEngine;
import org.neo4j.kernel.impl.store.MetaDataStore;
import org.neo4j.kernel.impl.store.StoreId;
import org.neo4j.kernel.impl.store.format.highlimit.HighLimit;
import org.neo4j.kernel.impl.store.format.lowlimit.LowLimitV3_0;
import org.neo4j.kernel.impl.transaction.log.LogicalTransactionStore;
import org.neo4j.kernel.impl.transaction.log.TransactionIdStore;
Expand Down Expand Up @@ -301,7 +300,7 @@ public void shouldResetNeoStoreLastTransactionOffsetForNonForensicCopy() throws

private GraphDatabaseService startDatabase( File storeDir )
{
return startDatabase( storeDir, HighLimit.NAME );
return startDatabase( storeDir, LowLimitV3_0.NAME );
}

private GraphDatabaseService startDatabase( File storeDir, String recordFormatName )
Expand Down
Expand Up @@ -135,7 +135,7 @@
import org.neo4j.kernel.impl.locking.Locks;
import org.neo4j.kernel.impl.logging.LogService;
import org.neo4j.kernel.impl.store.StoreId;
import org.neo4j.kernel.impl.store.format.highlimit.HighLimit;
import org.neo4j.kernel.impl.store.format.lowlimit.LowLimitV3_0;
import org.neo4j.kernel.impl.store.id.IdGeneratorFactory;
import org.neo4j.kernel.impl.store.stats.IdBasedStoreEntityCounters;
import org.neo4j.kernel.impl.transaction.TransactionHeaderInformationFactory;
Expand Down Expand Up @@ -176,7 +176,7 @@ public HighlyAvailableEditionModule( final PlatformModule platformModule )
{
ioLimiter = new ConfigurableIOLimiter( platformModule.config );

formats = HighLimit.RECORD_FORMATS;
formats = LowLimitV3_0.RECORD_FORMATS;

final LifeSupport life = platformModule.life;
life.add( platformModule.dataSourceManager );
Expand Down
4 changes: 2 additions & 2 deletions enterprise/ha/src/test/java/org/neo4j/ha/BackupHaIT.java
Expand Up @@ -34,7 +34,7 @@
import org.neo4j.kernel.configuration.Settings;
import org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory;
import org.neo4j.kernel.impl.ha.ClusterManager.ManagedCluster;
import org.neo4j.kernel.impl.store.format.highlimit.HighLimit;
import org.neo4j.kernel.impl.store.format.lowlimit.LowLimitV3_0;
import org.neo4j.test.DbRepresentation;
import org.neo4j.test.SuppressOutput;
import org.neo4j.test.ha.ClusterRule;
Expand Down Expand Up @@ -130,6 +130,6 @@ private String[] backupArguments( String from, String to, String clusterName )
private Config getConfig()
{
return new Config( MapUtil.stringMap( GraphDatabaseFacadeFactory.Configuration.record_format.name(),
HighLimit.NAME ) );
LowLimitV3_0.NAME ) );
}
}
Expand Up @@ -47,7 +47,7 @@
import org.neo4j.kernel.impl.ha.ClusterManager.ManagedCluster;
import org.neo4j.kernel.impl.ha.ClusterManager.RepairKit;
import org.neo4j.kernel.impl.logging.StoreLogService;
import org.neo4j.kernel.impl.store.format.highlimit.HighLimit;
import org.neo4j.kernel.impl.store.format.lowlimit.LowLimitV3_0;
import org.neo4j.kernel.impl.util.Listener;
import org.neo4j.kernel.impl.util.StoreUtil;
import org.neo4j.kernel.lifecycle.LifeRule;
Expand Down Expand Up @@ -333,7 +333,7 @@ private GraphDatabaseService startGraphDatabaseService( File storeDir )
{
return new TestGraphDatabaseFactory()
.newEmbeddedDatabaseBuilder( storeDir )
.setConfig( GraphDatabaseFacadeFactory.Configuration.record_format, HighLimit.NAME )
.setConfig( GraphDatabaseFacadeFactory.Configuration.record_format, LowLimitV3_0.NAME )
.newGraphDatabase();
}
}

0 comments on commit fe058d2

Please sign in to comment.