Skip to content

Commit

Permalink
Merge 2.3 into 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
MishaDemianenko committed Jun 7, 2016
2 parents 8968b37 + e7eff94 commit e2533bc
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,7 @@ public void start() throws IOException
catch ( Throwable e )
{
// Something unexpected happened during startup
msgLog.warn( "Exception occurred while setting up store modules. Attempting to close things down.",
e, true );
msgLog.warn( "Exception occurred while setting up store modules. Attempting to close things down.", e );
try
{
// Close the neostore, so that locks are released properly
Expand All @@ -494,7 +493,7 @@ public void start() throws IOException
}
catch ( Exception closeException )
{
msgLog.error( "Couldn't close neostore after startup failure" );
msgLog.error( "Couldn't close neostore after startup failure", closeException );
}
throw Exceptions.launderedException( e );
}
Expand All @@ -506,8 +505,7 @@ public void start() throws IOException
catch ( Throwable e )
{
// Something unexpected happened during startup
msgLog.warn( "Exception occurred while starting the datasource. Attempting to close things down.",
e, true );
msgLog.warn( "Exception occurred while starting the datasource. Attempting to close things down.", e );
try
{
life.shutdown();
Expand All @@ -516,7 +514,7 @@ public void start() throws IOException
}
catch ( Exception closeException )
{
msgLog.error( "Couldn't close neostore after startup failure" );
msgLog.error( "Couldn't close neostore after startup failure", closeException );
}
throw Exceptions.launderedException( e );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,23 @@
import org.junit.Rule;
import org.junit.Test;

import java.io.File;
import java.io.IOException;

import org.neo4j.graphdb.DependencyResolver;
import org.neo4j.graphdb.factory.GraphDatabaseSettings;
import org.neo4j.helpers.Exceptions;
import org.neo4j.io.pagecache.IOLimiter;
import org.neo4j.io.pagecache.PageCache;
import org.neo4j.kernel.NeoStoreDataSource.Diagnostics;
import org.neo4j.kernel.configuration.Config;
import org.neo4j.kernel.impl.core.DatabasePanicEventGenerator;
import org.neo4j.kernel.impl.logging.NullLogService;
import org.neo4j.kernel.impl.logging.SimpleLogService;
import org.neo4j.kernel.impl.store.NeoStores;
import org.neo4j.kernel.impl.store.StoreFactory;
import org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory;
import org.neo4j.kernel.impl.store.id.IdGeneratorFactory;
import org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles;
import org.neo4j.kernel.impl.transaction.log.entry.LogEntryVersion;
import org.neo4j.kernel.impl.transaction.log.entry.LogHeader;
Expand All @@ -41,13 +51,22 @@
import org.neo4j.test.PageCacheRule;
import org.neo4j.test.TargetDirectory;

import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyBoolean;
import static org.mockito.Matchers.anyLong;
import static org.mockito.Mockito.RETURNS_MOCKS;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.neo4j.helpers.collection.MapUtil.stringMap;
import static org.neo4j.logging.AssertableLogProvider.inLog;

public class NeoStoreDataSourceTest
{
Expand Down Expand Up @@ -196,6 +215,36 @@ public void shouldLogCorrectTransactionLogDiagnosticsForTransactionsInSecondOlde
logProvider.assertContainsMessageContaining( "version " + (logVersion + 1) );
}

@Test
public void logModuleSetUpError() throws Exception
{
Config config = new Config( stringMap(), GraphDatabaseSettings.class );
IdGeneratorFactory idGeneratorFactory = mock( IdGeneratorFactory.class );
Throwable openStoresError = new RuntimeException( "Can't set up modules" );
doThrow( openStoresError ).when( idGeneratorFactory ).create( any( File.class ), anyLong(), anyBoolean() );

AssertableLogProvider logProvider = new AssertableLogProvider();
SimpleLogService logService = new SimpleLogService( logProvider, logProvider );
PageCache pageCache = pageCacheRule.getPageCache( fs.get() );

NeoStoreDataSource dataSource = dsRule.getDataSource( dir.graphDbDir(), fs.get(), idGeneratorFactory,
pageCache, config.getParams(), mock( DatabaseHealth.class ), logService );

try
{
dataSource.start();
fail( "Exception expected" );
}
catch ( Exception e )
{
assertEquals( openStoresError, e );
}

logProvider.assertAtLeastOnce( inLog( NeoStoreDataSource.class ).warn(
equalTo( "Exception occurred while setting up store modules. Attempting to close things down." ),
equalTo( openStoresError ) ) );
}

private NeoStoreDataSource neoStoreDataSourceWithLogFilesContainingLowestTxId( PhysicalLogFiles files )
{
DependencyResolver resolver = mock( DependencyResolver.class );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@
import org.neo4j.kernel.impl.core.StartupStatisticsProvider;
import org.neo4j.kernel.impl.factory.CommunityCommitProcessFactory;
import org.neo4j.kernel.impl.locking.Locks;
import org.neo4j.kernel.impl.logging.LogService;
import org.neo4j.kernel.impl.logging.NullLogService;
import org.neo4j.kernel.impl.proc.Procedures;
import org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory;
import org.neo4j.kernel.impl.store.id.IdGeneratorFactory;
import org.neo4j.kernel.impl.transaction.TransactionHeaderInformationFactory;
import org.neo4j.kernel.impl.transaction.TransactionMonitor;
import org.neo4j.kernel.impl.transaction.log.PhysicalLogFile;
Expand All @@ -69,6 +71,15 @@ public class NeoStoreDataSourceRule extends ExternalResource

public NeoStoreDataSource getDataSource( File storeDir, FileSystemAbstraction fs,
PageCache pageCache, Map<String,String> additionalConfig, DatabaseHealth databaseHealth )
{
DefaultIdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory( fs );
NullLogService logService = NullLogService.getInstance();
return getDataSource( storeDir, fs, idGeneratorFactory, pageCache, additionalConfig, databaseHealth, logService );
}

public NeoStoreDataSource getDataSource( File storeDir, FileSystemAbstraction fs, IdGeneratorFactory
idGeneratorFactory, PageCache pageCache, Map<String,String> additionalConfig,
DatabaseHealth databaseHealth, LogService logService )
{
if ( dataSource != null )
{
Expand All @@ -82,8 +93,8 @@ public NeoStoreDataSource getDataSource( File storeDir, FileSystemAbstraction fs

JobScheduler jobScheduler = mock( JobScheduler.class, RETURNS_MOCKS );
Monitors monitors = new Monitors();
dataSource = new NeoStoreDataSource( storeDir, config, new DefaultIdGeneratorFactory( fs ),
NullLogService.getInstance(), mock( JobScheduler.class, RETURNS_MOCKS ), mock( TokenNameLookup.class ),
dataSource = new NeoStoreDataSource( storeDir, config, idGeneratorFactory,
logService, mock( JobScheduler.class, RETURNS_MOCKS ), mock( TokenNameLookup.class ),
dependencyResolverForNoIndexProvider(), mock( PropertyKeyTokenHolder.class ),
mock( LabelTokenHolder.class ), mock( RelationshipTypeTokenHolder.class ), locks,
mock( SchemaWriteGuard.class ), mock( TransactionEventHandlers.class ), IndexingService.NO_MONITOR,
Expand Down

0 comments on commit e2533bc

Please sign in to comment.